babylon.module.d.ts 6.3 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537115538115539115540115541115542115543115544115545115546115547115548115549115550115551115552115553115554115555115556115557115558115559115560115561115562115563115564115565115566115567115568115569115570115571115572115573115574115575115576115577115578115579115580115581115582115583115584115585115586115587115588115589115590115591115592115593115594115595115596115597115598115599115600115601115602115603115604115605115606115607115608115609115610115611115612115613115614115615115616115617115618115619115620115621115622115623115624115625115626115627115628115629115630115631115632115633115634115635115636115637115638115639115640115641115642115643115644115645115646115647115648115649115650115651115652115653115654115655115656115657115658115659115660115661115662115663115664115665115666115667115668115669115670115671115672115673115674115675115676115677115678115679115680115681115682115683115684115685115686115687115688115689115690115691115692115693115694115695115696115697115698115699115700115701115702115703115704115705115706115707115708115709115710115711115712115713115714115715115716115717115718115719115720115721115722115723115724115725115726115727115728115729115730115731115732115733115734115735115736115737115738115739115740115741115742115743115744115745115746115747115748115749115750115751115752115753115754115755115756115757115758115759115760115761115762115763115764115765115766115767115768115769115770115771115772115773115774115775115776115777115778115779115780115781115782115783115784115785115786115787115788115789115790115791115792115793115794115795115796115797115798115799115800115801115802115803115804115805115806115807115808115809115810115811115812115813115814115815115816115817115818115819115820115821115822115823115824115825115826115827115828115829115830115831115832115833115834115835115836115837115838115839115840115841115842115843115844115845115846115847115848115849115850115851115852115853115854115855115856115857115858115859115860115861115862115863115864115865115866115867115868115869115870115871115872115873115874115875115876115877115878115879115880115881115882115883115884115885115886115887115888115889115890115891115892115893115894115895115896115897115898115899115900115901115902115903115904115905115906115907115908115909115910115911115912115913115914115915115916115917115918115919115920115921115922115923115924115925115926115927115928115929115930115931115932115933115934115935115936115937115938115939115940115941115942115943115944115945115946115947115948115949115950115951115952115953115954115955115956115957115958115959115960115961115962115963115964115965115966115967115968115969115970115971115972115973115974115975115976115977115978115979115980115981115982115983115984115985115986115987115988115989115990115991115992115993115994115995115996115997115998115999116000116001116002116003116004116005116006116007116008116009116010116011116012116013116014116015116016116017116018116019116020116021116022116023116024116025116026116027116028116029116030116031116032116033116034116035116036116037116038116039116040116041116042116043116044116045116046116047116048116049116050116051116052116053116054116055116056116057116058116059116060116061116062116063116064116065116066116067116068116069116070116071116072116073116074116075116076116077116078116079116080116081116082116083116084116085116086116087116088116089116090116091116092116093116094116095116096116097116098116099116100116101116102116103116104116105116106116107116108116109116110116111116112116113116114116115116116116117116118116119116120116121116122116123116124116125116126116127116128116129116130116131116132116133116134116135116136116137116138116139116140116141116142116143116144116145116146116147116148116149116150116151116152116153116154116155116156116157116158116159116160116161116162116163116164116165116166116167116168116169116170116171116172116173116174116175116176116177116178116179116180116181116182116183116184116185116186116187116188116189116190116191116192116193116194116195116196116197116198116199116200116201116202116203116204116205116206116207116208116209116210116211116212116213116214116215116216116217116218116219116220116221116222116223116224116225116226116227116228116229116230116231116232116233116234116235116236116237116238116239116240116241116242116243116244116245116246116247116248116249116250116251116252116253116254116255116256116257116258116259116260116261116262116263116264116265116266116267116268116269116270116271116272116273116274116275116276116277116278116279116280116281116282116283116284116285116286116287116288116289116290116291116292116293116294116295116296116297116298116299116300116301116302116303116304116305116306116307116308116309116310116311116312116313116314116315116316116317116318116319116320116321116322116323116324116325116326116327116328116329116330116331116332116333116334116335116336116337116338116339116340116341116342116343116344116345116346116347116348116349116350116351116352116353116354116355116356116357116358116359116360116361116362116363116364116365116366116367116368116369116370116371116372116373116374116375116376116377116378116379116380116381116382116383116384116385116386116387116388116389116390116391116392116393116394116395116396116397116398116399116400116401116402116403116404116405116406116407116408116409116410116411116412116413116414116415116416116417116418116419116420116421116422116423116424116425116426116427116428116429116430116431116432116433116434116435116436116437116438116439116440116441116442116443116444116445116446116447116448116449116450116451116452116453116454116455116456116457116458116459116460116461116462116463116464116465116466116467116468116469116470116471116472116473116474116475116476116477116478116479116480116481116482116483116484116485116486116487116488116489116490116491116492116493116494116495116496116497116498116499116500116501116502116503116504116505116506116507116508116509116510116511116512116513116514116515116516116517116518116519116520116521116522116523116524116525116526116527116528116529116530116531116532116533116534116535116536116537116538116539116540116541116542116543116544116545116546116547116548116549116550116551116552116553116554116555116556116557116558116559116560116561116562116563116564116565116566116567116568116569116570116571116572116573116574116575116576116577116578116579116580116581116582116583116584116585116586116587116588116589116590116591116592116593116594116595116596116597116598116599116600116601116602116603116604116605116606116607116608116609116610116611116612116613116614116615116616116617116618116619116620116621116622116623116624116625116626116627116628116629116630116631116632116633116634116635116636116637116638116639116640116641116642116643116644116645116646116647116648116649116650116651116652116653116654116655116656116657116658116659116660116661116662116663116664116665116666116667116668116669116670116671116672116673116674116675116676116677116678116679116680116681116682116683116684116685116686116687116688116689116690116691116692116693116694116695116696116697116698116699116700116701116702116703116704116705116706116707116708116709116710116711116712116713116714116715116716116717116718116719116720116721116722116723116724116725116726116727116728116729116730116731116732116733116734116735116736116737116738116739116740116741116742116743116744116745116746116747116748116749116750116751116752116753116754116755116756116757116758116759116760116761116762116763116764116765116766116767116768116769116770116771116772116773116774116775116776116777116778116779116780116781116782116783116784116785116786116787116788116789116790116791116792116793116794116795116796116797116798116799116800116801116802116803116804116805116806116807116808116809116810116811116812116813116814116815116816116817116818116819116820116821116822116823116824116825116826116827116828116829116830116831116832116833116834116835116836116837116838116839116840116841116842116843116844116845116846116847116848116849116850116851116852116853116854116855116856116857116858116859116860116861116862116863116864116865116866116867116868116869116870116871116872116873116874116875116876116877116878116879116880116881116882116883116884116885116886116887116888116889116890116891116892116893116894116895116896116897116898116899116900116901116902116903116904116905116906116907116908116909116910116911116912116913116914116915116916116917116918116919116920116921116922116923116924116925116926116927116928116929116930116931116932116933116934116935116936116937116938116939116940116941116942116943116944116945116946116947116948116949116950116951116952116953116954116955116956116957116958116959116960116961116962116963116964116965116966116967116968116969116970116971116972116973116974116975116976116977116978116979116980116981116982116983116984116985116986116987116988116989116990116991116992116993116994116995116996116997116998116999117000117001117002117003117004117005117006117007117008117009117010117011117012117013117014117015117016117017117018117019117020117021117022117023117024117025117026117027117028117029117030117031117032117033117034117035117036117037117038117039117040117041117042117043117044117045117046117047117048117049117050117051117052117053117054117055117056117057117058117059117060117061117062117063117064117065117066117067117068117069117070117071117072117073117074117075117076117077117078117079117080117081117082117083117084117085117086117087117088117089117090117091117092117093117094117095117096117097117098117099117100117101117102117103117104117105117106117107117108117109117110117111117112117113117114117115117116117117117118117119117120117121117122117123117124117125117126117127117128117129117130117131117132117133117134117135117136117137117138117139117140117141117142117143117144117145117146117147117148117149117150117151117152117153117154117155117156117157117158117159117160117161117162117163117164117165117166117167117168117169117170117171117172117173117174117175117176117177117178117179117180117181117182117183117184117185117186117187117188117189117190117191117192117193117194117195117196117197117198117199117200117201117202117203117204117205117206117207117208117209117210117211117212117213117214117215117216117217117218117219117220117221117222117223117224117225117226117227117228117229117230117231117232117233117234117235117236117237117238117239117240117241117242117243117244117245117246117247117248117249117250117251117252117253117254117255117256117257117258117259117260117261117262117263117264117265117266117267117268117269117270117271117272117273117274117275117276117277117278117279117280117281117282117283117284117285117286117287117288117289117290117291117292117293117294117295117296117297117298117299117300117301117302117303117304117305117306117307117308117309117310117311117312117313117314117315117316117317117318117319117320117321117322117323117324117325117326117327117328117329117330117331117332117333117334117335117336117337117338117339117340117341117342117343117344117345117346117347117348117349117350117351117352117353117354117355117356117357117358117359117360117361117362117363117364117365117366117367117368117369117370117371117372117373117374117375117376117377117378117379117380117381117382117383117384117385117386117387117388117389117390117391117392117393117394117395117396117397117398117399117400117401117402117403117404117405117406117407117408117409117410117411117412117413117414117415117416117417117418117419117420117421117422117423117424117425117426117427117428117429117430117431117432117433117434117435117436117437117438117439117440117441117442117443117444117445117446117447117448117449117450117451117452117453117454117455117456117457117458117459117460117461117462117463117464117465117466117467117468117469117470117471117472117473117474117475117476117477117478117479117480117481117482117483117484117485117486117487117488117489117490117491117492117493117494117495117496117497117498117499117500117501117502117503117504117505117506117507117508117509117510117511117512117513117514117515117516117517117518117519117520117521117522117523117524117525117526117527117528117529117530117531117532117533117534117535117536117537117538117539117540117541117542117543117544117545117546117547117548117549117550117551117552117553117554117555117556117557117558117559117560117561117562117563117564117565117566117567117568117569117570117571117572117573117574117575117576117577117578117579117580117581117582117583117584117585117586117587117588117589117590117591117592117593117594117595117596117597117598117599117600117601117602117603117604117605117606117607117608117609117610117611117612117613117614117615117616117617117618117619117620117621117622117623117624117625117626117627117628117629117630117631117632117633117634117635117636117637117638117639117640117641117642117643117644117645117646117647117648117649117650117651117652117653117654117655117656117657117658117659117660117661117662117663117664117665117666117667117668117669117670117671117672117673117674117675117676117677117678117679117680117681117682117683117684117685117686117687117688117689117690117691117692117693117694117695117696117697117698117699117700117701117702117703117704117705117706117707117708117709117710117711117712117713117714117715117716117717117718117719117720117721117722117723117724117725117726117727117728117729117730117731117732117733117734117735117736117737117738117739117740117741117742117743117744117745117746117747117748117749117750117751117752117753117754117755117756117757117758117759117760117761117762117763117764117765117766117767117768117769117770117771117772117773117774117775117776117777117778117779117780117781117782117783117784117785117786117787117788117789117790117791117792117793117794117795117796117797117798117799117800117801117802117803117804117805117806117807117808117809117810117811117812117813117814117815117816117817117818117819117820117821117822117823117824117825117826117827117828117829117830117831117832117833117834117835117836117837117838117839117840117841117842117843117844117845117846117847117848117849117850117851117852117853117854117855117856117857117858117859117860117861117862117863117864117865117866117867117868117869117870117871117872117873117874117875117876117877117878117879117880117881117882117883117884117885117886117887117888117889117890117891117892117893117894117895117896117897117898117899117900117901117902117903117904117905117906117907117908117909117910117911117912117913117914117915117916117917117918117919117920117921117922117923117924117925117926117927117928117929117930117931117932117933117934117935117936117937117938117939117940117941117942117943117944117945117946117947117948117949117950117951117952117953117954117955117956117957117958117959117960117961117962117963117964117965117966117967117968117969117970117971117972117973117974117975117976117977117978117979117980117981117982117983117984117985117986117987117988117989117990117991117992117993117994117995117996117997117998117999118000118001118002118003118004118005118006118007118008118009118010118011118012118013118014118015118016118017118018118019118020118021118022118023118024118025118026118027118028118029118030118031118032118033118034118035118036118037118038118039118040118041118042118043118044118045118046118047118048118049118050118051118052118053118054118055118056118057118058118059118060118061118062118063118064118065118066118067118068118069118070118071118072118073118074118075118076118077118078118079118080118081118082118083118084118085118086118087118088118089118090118091118092118093118094118095118096118097118098118099118100118101118102118103118104118105118106118107118108118109118110118111118112118113118114118115118116118117118118118119118120118121118122118123118124118125118126118127118128118129118130118131118132118133118134118135118136118137118138118139118140118141118142118143118144118145118146118147118148118149118150118151118152118153118154118155118156118157118158118159118160118161118162118163118164118165118166118167118168118169118170118171118172118173118174118175118176118177118178118179118180118181118182118183118184118185118186118187118188118189118190118191118192118193118194118195118196118197118198118199118200118201118202118203118204118205118206118207118208118209118210118211118212118213118214118215118216118217118218118219118220118221118222118223118224118225118226118227118228118229118230118231118232118233118234118235118236118237118238118239118240118241118242118243118244118245118246118247118248118249118250118251118252118253118254118255118256118257118258118259118260118261118262118263118264118265118266118267118268118269118270118271118272118273118274118275118276118277118278118279118280118281118282118283118284118285118286118287118288118289118290118291118292118293118294118295118296118297118298118299118300118301118302118303118304118305118306118307118308118309118310118311118312118313118314118315118316118317118318118319118320118321118322118323118324118325118326118327118328118329118330118331118332118333118334118335118336118337118338118339118340118341118342118343118344118345118346118347118348118349118350118351118352118353118354118355118356118357118358118359118360118361118362118363118364118365118366118367118368118369118370118371118372118373118374118375118376118377118378118379118380118381118382118383118384118385118386118387118388118389118390118391118392118393118394118395118396118397118398118399118400118401118402118403118404118405118406118407118408118409118410118411118412118413118414118415118416118417118418118419118420118421118422118423118424118425118426118427118428118429118430118431118432118433118434118435118436118437118438118439118440118441118442118443118444118445118446118447118448118449118450118451118452118453118454118455118456118457118458118459118460118461118462118463118464118465118466118467118468118469118470118471118472118473118474118475118476118477118478118479118480118481118482118483118484118485118486118487118488118489118490118491118492118493118494118495118496118497118498118499118500118501118502118503118504118505118506118507118508118509118510118511118512118513118514118515118516118517118518118519118520118521118522118523118524118525118526118527118528118529118530118531118532118533118534118535118536118537118538118539118540118541118542118543118544118545118546118547118548118549118550118551118552118553118554118555118556118557118558118559118560118561118562118563118564118565118566118567118568118569118570118571118572118573118574118575118576118577118578118579118580118581118582118583118584118585118586118587118588118589118590118591118592118593118594118595118596118597118598118599118600118601118602118603118604118605118606118607118608118609118610118611118612118613118614118615118616118617118618118619118620118621118622118623118624118625118626118627118628118629118630118631118632118633118634118635118636118637118638118639118640118641118642118643118644118645118646118647118648118649118650118651118652118653118654118655118656118657118658118659118660118661118662118663118664118665118666118667118668118669118670118671118672118673118674118675118676118677118678118679118680118681118682118683118684118685118686118687118688118689118690118691118692118693118694118695118696118697118698118699118700118701118702118703118704118705118706118707118708118709118710118711118712118713118714118715118716118717118718118719118720118721118722118723118724118725118726118727118728118729118730118731118732118733118734118735118736118737118738118739118740118741118742118743118744118745118746118747118748118749118750118751118752118753118754118755118756118757118758118759118760118761118762118763118764118765118766118767118768118769118770118771118772118773118774118775118776118777118778118779118780118781118782118783118784118785118786118787118788118789118790118791118792118793118794118795118796118797118798118799118800118801118802118803118804118805118806118807118808118809118810118811118812118813118814118815118816118817118818118819118820118821118822118823118824118825118826118827118828118829118830118831118832118833118834118835118836118837118838118839118840118841118842118843118844118845118846118847118848118849118850118851118852118853118854118855118856118857118858118859118860118861118862118863118864118865118866118867118868118869118870118871118872118873118874118875118876118877118878118879118880118881118882118883118884118885118886118887118888118889118890118891118892118893118894118895118896118897118898118899118900118901118902118903118904118905118906118907118908118909118910118911118912118913118914118915118916118917118918118919118920118921118922118923118924118925118926118927118928118929118930118931118932118933118934118935118936118937118938118939118940118941118942118943118944118945118946118947118948118949118950118951118952118953118954118955118956118957118958118959118960118961118962118963118964118965118966118967118968118969118970118971118972118973118974118975118976118977118978118979118980118981118982118983118984118985118986118987118988118989118990118991118992118993118994118995118996118997118998118999119000119001119002119003119004119005119006119007119008119009119010119011119012119013119014119015119016119017119018119019119020119021119022119023119024119025119026119027119028119029119030119031119032119033119034119035119036119037119038119039119040119041119042119043119044119045119046119047119048119049119050119051119052119053119054119055119056119057119058119059119060119061119062119063119064119065119066119067119068119069119070119071119072119073119074119075119076119077119078119079119080119081119082119083119084119085119086119087119088119089119090119091119092119093119094119095119096119097119098119099119100119101119102119103119104119105119106119107119108119109119110119111119112119113119114119115119116119117119118119119119120119121119122119123119124119125119126119127119128119129119130119131119132119133119134119135119136119137119138119139119140119141119142119143119144119145119146119147119148119149119150119151119152119153119154119155119156119157119158119159119160119161119162119163119164119165119166119167119168119169119170119171119172119173119174119175119176119177119178119179119180119181119182119183119184119185119186119187119188119189119190119191119192119193119194119195119196119197119198119199119200119201119202119203119204119205119206119207119208119209119210119211119212119213119214119215119216119217119218119219119220119221119222119223119224119225119226119227119228119229119230119231119232119233119234119235119236119237119238119239119240119241119242119243119244119245119246119247119248119249119250119251119252119253119254119255119256119257119258119259119260119261119262119263119264119265119266119267119268119269119270119271119272119273119274119275119276119277119278119279119280119281119282119283119284119285119286119287119288119289119290119291119292119293119294119295119296119297119298119299119300119301119302119303119304119305119306119307119308119309119310119311119312119313119314119315119316119317119318119319119320119321119322119323119324119325119326119327119328119329119330119331119332119333119334119335119336119337119338119339119340119341119342119343119344119345119346119347119348119349119350119351119352119353119354119355119356119357119358119359119360119361119362119363119364119365119366119367119368119369119370119371119372119373119374119375119376119377119378119379119380119381119382119383119384119385119386119387119388119389119390119391119392119393119394119395119396119397119398119399119400119401119402119403119404119405119406119407119408119409119410119411119412119413119414119415119416119417119418119419119420119421119422119423119424119425119426119427119428119429119430119431119432119433119434119435119436119437119438119439119440119441119442119443119444119445119446119447119448119449119450119451119452119453119454119455119456119457119458119459119460119461119462119463119464119465119466119467119468119469119470119471119472119473119474119475119476119477119478119479119480119481119482119483119484119485119486119487119488119489119490119491119492119493119494119495119496119497119498119499119500119501119502119503119504119505119506119507119508119509119510119511119512119513119514119515119516119517119518119519119520119521119522119523119524119525119526119527119528119529119530119531119532119533119534119535119536119537119538119539119540119541119542119543119544119545119546119547119548119549119550119551119552119553119554119555119556119557119558119559119560119561119562119563119564119565119566119567119568119569119570119571119572119573119574119575119576119577119578119579119580119581119582119583119584119585119586119587119588119589119590119591119592119593119594119595119596119597119598119599119600119601119602119603119604119605119606119607119608119609119610119611119612119613119614119615119616119617119618119619119620119621119622119623119624119625119626119627119628119629119630119631119632119633119634119635119636119637119638119639119640119641119642119643119644119645119646119647119648119649119650119651119652119653119654119655119656119657119658119659119660119661119662119663119664119665119666119667119668119669119670119671119672119673119674119675119676119677119678119679119680119681119682119683119684119685119686119687119688119689119690119691119692119693119694119695119696119697119698119699119700119701119702119703119704119705119706119707119708119709119710119711119712119713119714119715119716119717119718119719119720119721119722119723119724119725119726119727119728119729119730119731119732119733119734119735119736119737119738119739119740119741119742119743119744119745119746119747119748119749119750119751119752119753119754119755119756119757119758119759119760119761119762119763119764119765119766119767119768119769119770119771119772119773119774119775119776119777119778119779119780119781119782119783119784119785119786119787119788119789119790119791119792119793119794119795119796119797119798119799119800119801119802119803119804119805119806119807119808119809119810119811119812119813119814119815119816119817119818119819119820119821119822119823119824119825119826119827119828119829119830119831119832119833119834119835119836119837119838119839119840119841119842119843119844119845119846119847119848119849119850119851119852119853119854119855119856119857119858119859119860119861119862119863119864119865119866119867119868119869119870119871119872119873119874119875119876119877119878119879119880119881119882119883119884119885119886119887119888119889119890119891119892119893119894119895119896119897119898119899119900119901119902119903119904119905119906119907119908119909119910119911119912119913119914119915119916119917119918119919119920119921119922119923119924119925119926119927119928119929119930119931119932119933119934119935119936119937119938119939119940119941119942119943119944119945119946119947119948119949119950119951119952119953119954119955119956119957119958119959119960119961119962119963119964119965119966119967119968119969119970119971119972119973119974119975119976119977119978119979119980119981119982119983119984119985119986119987119988119989119990119991119992119993119994119995119996119997119998119999120000120001120002120003120004120005120006120007120008120009120010120011120012120013120014120015120016120017120018120019120020120021120022120023120024120025120026120027120028120029120030120031120032120033120034120035120036120037120038120039120040120041120042120043120044120045120046120047120048120049120050120051120052120053120054120055120056120057120058120059120060120061120062120063120064120065120066120067120068120069120070120071120072120073120074120075120076120077120078120079120080120081120082120083120084120085120086120087120088120089120090120091120092120093120094120095120096120097120098120099120100120101120102120103120104120105120106120107120108120109120110120111120112120113120114120115120116120117120118120119120120120121120122120123120124120125120126120127120128120129120130120131120132120133120134120135120136120137120138120139120140120141120142120143120144120145120146120147120148120149120150120151120152120153120154120155120156120157120158120159120160120161120162120163120164120165120166120167120168120169120170120171120172120173120174120175120176120177120178120179120180120181120182120183120184120185120186120187120188120189120190120191120192120193120194120195120196120197120198120199120200120201120202120203120204120205120206120207120208120209120210120211120212120213120214120215120216120217120218120219120220120221120222120223120224120225120226120227120228120229120230120231120232120233120234120235120236120237120238120239120240120241120242120243120244120245120246120247120248120249120250120251120252120253120254120255120256120257120258120259120260120261120262120263120264120265120266120267120268120269120270120271120272120273120274120275120276120277120278120279120280120281120282120283120284120285120286120287120288120289120290120291120292120293120294120295120296120297120298120299120300120301120302120303120304120305120306120307120308120309120310120311120312120313120314120315120316120317120318120319120320120321120322120323120324120325120326120327120328120329120330120331120332120333120334120335120336120337120338120339120340120341120342120343120344120345120346120347120348120349120350120351120352120353120354120355120356120357120358120359120360120361120362120363120364120365120366120367120368120369120370120371120372120373120374120375120376120377120378120379120380120381120382120383120384120385120386120387120388120389120390120391120392120393120394120395120396120397120398120399120400120401120402120403120404120405120406120407120408120409120410120411120412120413120414120415120416120417120418120419120420120421120422120423120424120425120426120427120428120429120430120431120432120433120434120435120436120437120438120439120440120441120442120443120444120445120446120447120448120449120450120451120452120453120454120455120456120457120458120459120460120461120462120463120464120465120466120467120468120469120470120471120472120473120474120475120476120477120478120479120480120481120482120483120484120485120486120487120488120489120490120491120492120493120494120495120496120497120498120499120500120501120502120503120504120505120506120507120508120509120510120511120512120513120514120515120516120517120518120519120520120521120522120523120524120525120526120527120528120529120530120531120532120533120534120535120536120537120538120539120540120541120542120543120544120545120546120547120548120549120550120551120552120553120554120555120556120557120558120559120560120561120562120563120564120565120566120567120568120569120570120571120572120573120574120575120576120577120578120579120580120581120582120583120584120585120586120587120588120589120590120591120592120593120594120595120596120597120598120599120600120601120602120603120604120605120606120607120608120609120610120611120612120613120614120615120616120617120618120619120620120621120622120623120624120625120626120627120628120629120630120631120632120633120634120635120636120637120638120639120640120641120642120643120644120645120646120647120648120649120650120651120652120653120654120655120656120657120658120659120660120661120662120663120664120665120666120667120668120669120670120671120672120673120674120675120676120677120678120679120680120681120682120683120684120685120686120687120688120689120690120691120692120693120694120695120696120697120698120699120700120701120702120703120704120705120706120707120708120709120710120711120712120713120714120715120716120717120718120719120720120721120722120723120724120725120726120727120728120729120730120731120732120733120734120735120736120737120738120739120740120741120742120743120744120745120746120747120748120749120750120751120752120753120754120755120756120757120758120759120760120761120762120763120764120765120766120767120768120769120770120771120772120773120774120775120776120777120778120779120780120781120782120783120784120785120786120787120788120789120790120791120792120793120794120795120796120797120798120799120800120801120802120803120804120805120806120807120808120809120810120811120812120813120814120815120816120817120818120819120820120821120822120823120824120825120826120827120828120829120830120831120832120833120834120835120836120837120838120839120840120841120842120843120844120845120846120847120848120849120850120851120852120853120854120855120856120857120858120859120860120861120862120863120864120865120866120867120868120869120870120871120872120873120874120875120876120877120878120879120880120881120882120883120884120885120886120887120888120889120890120891120892120893120894120895120896120897120898120899120900120901120902120903120904120905120906120907120908120909120910120911120912120913120914120915120916120917120918120919120920120921120922120923120924120925120926120927120928120929120930120931120932120933120934120935120936120937120938120939120940120941120942120943120944120945120946120947120948120949120950120951120952120953120954120955120956120957120958120959120960120961120962120963120964120965120966120967120968120969120970120971120972120973120974120975120976120977120978120979120980120981120982120983120984120985120986120987120988120989120990120991120992120993120994120995120996120997120998120999121000121001121002121003121004121005121006121007121008121009121010121011121012121013121014121015121016121017121018121019121020121021121022121023121024121025121026121027121028121029121030121031121032121033121034121035121036121037121038121039121040121041121042121043121044121045121046121047121048121049121050121051121052121053121054121055121056121057121058121059121060121061121062121063121064121065121066121067121068121069121070121071121072121073121074121075121076121077121078121079121080121081121082121083121084121085121086121087121088121089121090121091121092121093121094121095121096121097121098121099121100121101121102121103121104121105121106121107121108121109121110121111121112121113121114121115121116121117121118121119121120121121121122121123121124121125121126121127121128121129121130121131121132121133121134121135121136121137121138121139121140121141121142121143121144121145121146121147121148121149121150121151121152121153121154121155121156121157121158121159121160121161121162121163121164121165121166121167121168121169121170121171121172121173121174121175121176121177121178121179121180121181121182121183121184121185121186121187121188121189121190121191121192121193121194121195121196121197121198121199121200121201121202121203121204121205121206121207121208121209121210121211121212121213121214121215121216121217121218121219121220121221121222121223121224121225121226121227121228121229121230121231121232121233121234121235121236121237121238121239121240121241121242121243121244121245121246121247121248121249121250121251121252121253121254121255121256121257121258121259121260121261121262121263121264121265121266121267121268121269121270121271121272121273121274121275121276121277121278121279121280121281121282121283121284121285121286121287121288121289121290121291121292121293121294121295121296121297121298121299121300121301121302121303121304121305121306121307121308121309121310121311121312121313121314121315121316121317121318121319121320121321121322121323121324121325121326121327121328121329121330121331121332121333121334121335121336121337121338121339121340121341121342121343121344121345121346121347121348121349121350121351121352121353121354121355121356121357121358121359121360121361121362121363121364121365121366121367121368121369121370121371121372121373121374121375121376121377121378121379121380121381121382121383121384121385121386121387121388121389121390121391121392121393121394121395121396121397121398121399121400121401121402121403121404121405121406121407121408121409121410121411121412121413121414121415121416121417121418121419121420121421121422121423121424121425121426121427121428121429121430121431121432121433121434121435121436121437121438121439121440121441121442121443121444121445121446121447121448121449121450121451121452121453121454121455121456121457121458121459121460121461121462121463121464121465121466121467121468121469121470121471121472121473121474121475121476121477121478121479121480121481121482121483121484121485121486121487121488121489121490121491121492121493121494121495121496121497121498121499121500121501121502121503121504121505121506121507121508121509121510121511121512121513121514121515121516121517121518121519121520121521121522121523121524121525121526121527121528121529121530121531121532121533121534121535121536121537121538121539121540121541121542121543121544121545121546121547121548121549121550121551121552121553121554121555121556121557121558121559121560121561121562121563121564121565121566121567121568121569121570121571121572121573121574121575121576121577121578121579121580121581121582121583121584121585121586121587121588121589121590121591121592121593121594121595121596121597121598121599121600121601121602121603121604121605121606121607121608121609121610121611121612121613121614121615121616121617121618121619121620121621121622121623121624121625121626121627121628121629121630121631121632121633121634121635121636121637121638121639121640121641121642121643121644121645121646121647121648121649121650121651121652121653121654121655121656121657121658121659121660121661121662121663121664121665121666121667121668121669121670121671121672121673121674121675121676121677121678121679121680121681121682121683121684121685121686121687121688121689121690121691121692121693121694121695121696121697121698121699121700121701121702121703121704121705121706121707121708121709121710121711121712121713121714121715121716121717121718121719121720121721121722121723121724121725121726121727121728121729121730121731121732121733121734121735121736121737121738121739121740121741121742121743121744121745121746121747121748121749121750121751121752121753121754121755121756121757121758121759121760121761121762121763121764121765121766121767121768121769121770121771121772121773121774121775121776121777121778121779121780121781121782121783121784121785121786121787121788121789121790121791121792121793121794121795121796121797121798121799121800121801121802121803121804121805121806121807121808121809121810121811121812121813121814121815121816121817121818121819121820121821121822121823121824121825121826121827121828121829121830121831121832121833121834121835121836121837121838121839121840121841121842121843121844121845121846121847121848121849121850121851121852121853121854121855121856121857121858121859121860121861121862121863121864121865121866121867121868121869121870121871121872121873121874121875121876121877121878121879121880121881121882121883121884121885121886121887121888121889121890121891121892121893121894121895121896121897121898121899121900121901121902121903121904121905121906121907121908121909121910121911121912121913121914121915121916121917121918121919121920121921121922121923121924121925121926121927121928121929121930121931121932121933121934121935121936121937121938121939121940121941121942121943121944121945121946121947121948121949121950121951121952121953121954121955121956121957121958121959121960121961121962121963121964121965121966121967121968121969121970121971121972121973121974121975121976121977121978121979121980121981121982121983121984121985121986121987121988121989121990121991121992121993121994121995121996121997121998121999122000122001122002122003122004122005122006122007122008122009122010122011122012122013122014122015122016122017122018122019122020122021122022122023122024122025122026122027122028122029122030122031122032122033122034122035122036122037122038122039122040122041122042122043122044122045122046122047122048122049122050122051122052122053122054122055122056122057122058122059122060122061122062122063122064122065122066122067122068122069122070122071122072122073122074122075122076122077122078122079122080122081122082122083122084122085122086122087122088122089122090122091122092122093122094122095122096122097122098122099122100122101122102122103122104122105122106122107122108122109122110122111122112122113122114122115122116122117122118122119122120122121122122122123122124122125122126122127122128122129122130122131122132122133122134122135122136122137122138122139122140122141122142122143122144122145122146122147122148122149122150122151122152122153122154122155122156122157122158122159122160122161122162122163122164122165122166122167122168122169122170122171122172122173122174122175122176122177122178122179122180122181122182122183122184122185122186122187122188122189122190122191122192122193122194122195122196122197122198122199122200122201122202122203122204122205122206122207122208122209122210122211122212122213122214122215122216122217122218122219122220122221122222122223122224122225122226122227122228122229122230122231122232122233122234122235122236122237122238122239122240122241122242122243122244122245122246122247122248122249122250122251122252122253122254122255122256122257122258122259122260122261122262122263122264122265122266122267122268122269122270122271122272122273122274122275122276122277122278122279122280122281122282122283122284122285122286122287122288122289122290122291122292122293122294122295122296122297122298122299122300122301122302122303122304122305122306122307122308122309122310122311122312122313122314122315122316122317122318122319122320122321122322122323122324122325122326122327122328122329122330122331122332122333122334122335122336122337122338122339122340122341122342122343122344122345122346122347122348122349122350122351122352122353122354122355122356122357122358122359122360122361122362122363122364122365122366122367122368122369122370122371122372122373122374122375122376122377122378122379122380122381122382122383122384122385122386122387122388122389122390122391122392122393122394122395122396122397122398122399122400122401122402122403122404122405122406122407122408122409122410122411122412122413122414122415122416122417122418122419122420122421122422122423122424122425122426122427122428122429122430122431122432122433122434122435122436122437122438122439122440122441122442122443122444122445122446122447122448122449122450122451122452122453122454122455122456122457122458122459122460122461122462122463122464122465122466122467122468122469122470122471122472122473122474122475122476122477122478122479122480122481122482122483122484122485122486122487122488122489122490122491122492122493122494122495122496122497122498122499122500122501122502122503122504122505122506122507122508122509122510122511122512122513122514122515122516122517122518122519122520122521122522122523122524122525122526122527122528122529122530122531122532122533122534122535122536122537122538122539122540122541122542122543122544122545122546122547122548122549122550122551122552122553122554122555122556122557122558122559122560122561122562122563122564122565122566122567122568122569122570122571122572122573122574122575122576122577122578122579122580122581122582122583122584122585122586122587122588122589122590122591122592122593122594122595122596122597122598122599122600122601122602122603122604122605122606122607122608122609122610122611122612122613122614122615122616122617122618122619122620122621122622122623122624122625122626122627122628122629122630122631122632122633122634122635122636122637122638122639122640122641122642122643122644122645122646122647122648122649122650122651122652122653122654122655122656122657122658122659122660122661122662122663122664122665122666122667122668122669122670122671122672122673122674122675122676122677122678122679122680122681122682122683122684122685122686122687122688122689122690122691122692122693122694122695122696122697122698122699122700122701122702122703122704122705122706122707122708122709122710122711122712122713122714122715122716122717122718122719122720122721122722122723122724122725122726122727122728122729122730122731122732122733122734122735122736122737122738122739122740122741122742122743122744122745122746122747122748122749122750122751122752122753122754122755122756122757122758122759122760122761122762122763122764122765122766122767122768122769122770122771122772122773122774122775122776122777122778122779122780122781122782122783122784122785122786122787122788122789122790122791122792122793122794122795122796122797122798122799122800122801122802122803122804122805122806122807122808122809122810122811122812122813122814122815122816122817122818122819122820122821122822122823122824122825122826122827122828122829122830122831122832122833122834122835122836122837122838122839122840122841122842122843122844122845122846122847122848122849122850122851122852122853122854122855122856122857122858122859122860122861122862122863122864122865122866122867122868122869122870122871122872122873122874122875122876122877122878122879122880122881122882122883122884122885122886122887122888122889122890122891122892122893122894122895122896122897122898122899122900122901122902122903122904122905122906122907122908122909122910122911122912122913122914122915122916122917122918122919122920122921122922122923122924122925122926122927122928122929122930122931122932122933122934122935122936122937122938122939122940122941122942122943122944122945122946122947122948122949122950122951122952122953122954122955122956122957122958122959122960122961122962122963122964122965122966122967122968122969122970122971122972122973122974122975122976122977122978122979122980122981122982122983122984122985122986122987122988122989122990122991122992122993122994122995122996122997122998122999123000123001123002123003123004123005123006123007123008123009123010123011123012123013123014123015123016123017123018123019123020123021123022123023123024123025123026123027123028123029123030123031123032123033123034123035123036123037123038123039123040123041123042123043123044123045123046123047123048123049123050123051123052123053123054123055123056123057123058123059123060123061123062123063123064123065123066123067123068123069123070123071123072123073123074123075123076123077123078123079123080123081123082123083123084123085123086123087123088123089123090123091123092123093123094123095123096123097123098123099123100123101123102123103123104123105123106123107123108123109123110123111123112123113123114123115123116123117123118123119123120123121123122123123123124123125123126123127123128123129123130123131123132123133123134123135123136123137123138123139123140123141123142123143123144123145123146123147123148123149123150123151123152123153123154123155123156123157123158123159123160123161123162123163123164123165123166123167123168123169123170123171123172123173123174123175123176123177123178123179123180123181123182123183123184123185123186123187123188123189123190123191123192123193123194123195123196123197123198123199123200123201123202123203123204123205123206123207123208123209123210123211123212123213123214123215123216123217123218123219123220123221123222123223123224123225123226123227123228123229123230123231123232123233123234123235123236123237123238123239123240123241123242123243123244123245123246123247123248123249123250123251123252123253123254123255123256123257123258123259123260123261123262123263123264123265123266123267123268123269123270123271123272123273123274123275123276123277123278123279123280123281123282123283123284123285123286123287123288123289123290123291123292123293123294123295123296123297123298123299123300123301123302123303123304123305123306123307123308123309123310123311123312123313123314123315123316123317123318123319123320123321123322123323123324123325123326123327123328123329123330123331123332123333123334123335123336123337123338123339123340123341123342123343123344123345123346123347123348123349123350123351123352123353123354123355123356123357123358123359123360123361123362123363123364123365123366123367123368123369123370123371123372123373123374123375123376123377123378123379123380123381123382123383123384123385123386123387123388123389123390123391123392123393123394123395123396123397123398123399123400123401123402123403123404123405123406123407123408123409123410123411123412123413123414123415123416123417123418123419123420123421123422123423123424123425123426123427123428123429123430123431123432123433123434123435123436123437123438123439123440123441123442123443123444123445123446123447123448123449123450123451123452123453123454123455123456123457123458123459123460123461123462123463123464123465123466123467123468123469123470123471123472123473123474123475123476123477123478123479123480123481123482123483123484123485123486123487123488123489123490123491123492123493123494123495123496123497123498123499123500123501123502123503123504123505123506123507123508123509123510123511123512123513123514123515123516123517123518123519123520123521123522123523123524123525123526123527123528123529123530123531123532123533123534123535123536123537123538123539123540123541123542123543123544123545123546123547123548123549123550123551123552123553123554123555123556123557123558123559123560123561123562123563123564123565123566123567123568123569123570123571123572123573123574123575123576123577123578123579123580123581123582123583123584123585123586123587123588123589123590123591123592123593123594123595123596123597123598123599123600123601123602123603123604123605123606123607123608123609123610123611123612123613123614123615123616123617123618123619123620123621123622123623123624123625123626123627123628123629123630123631123632123633123634123635123636123637123638123639123640123641123642123643123644123645123646123647123648123649123650123651123652123653123654123655123656123657123658123659123660123661123662123663123664123665123666123667123668123669123670123671123672123673123674123675123676123677123678123679123680123681123682123683123684123685123686123687123688123689123690123691123692123693123694123695123696123697123698123699123700123701123702123703123704123705123706123707123708123709123710123711123712123713123714123715123716123717123718123719123720123721123722123723123724123725123726123727123728123729123730123731123732123733123734123735123736123737123738123739123740123741123742123743123744123745123746123747123748123749123750123751123752123753123754123755123756123757123758123759123760123761123762123763123764123765123766123767123768123769123770123771123772123773123774123775123776123777123778123779123780123781123782123783123784123785123786123787123788123789123790123791123792123793123794123795123796123797123798123799123800123801123802123803123804123805123806123807123808123809123810123811123812123813123814123815123816123817123818123819123820123821123822123823123824123825123826123827123828123829123830123831123832123833123834123835123836123837123838123839123840123841123842123843123844123845123846123847123848123849123850123851123852123853123854123855123856123857123858123859123860123861123862123863123864123865123866123867123868123869123870123871123872123873123874123875123876123877123878123879123880123881123882123883123884123885123886123887123888123889123890123891123892123893123894123895123896123897123898123899123900123901123902123903123904123905123906123907123908123909123910123911123912123913123914123915123916123917123918123919123920123921123922123923123924123925123926123927123928123929123930123931123932123933123934123935123936123937123938123939123940123941123942123943123944123945123946123947123948123949123950123951123952123953123954123955123956123957123958123959123960123961123962123963123964123965123966123967123968123969123970123971123972123973123974123975123976123977123978123979123980123981123982123983123984123985123986123987123988123989123990123991123992123993123994123995123996123997123998123999124000124001124002124003124004124005124006124007124008124009124010124011124012124013124014124015124016124017124018124019124020124021124022124023124024124025124026124027124028124029124030124031124032124033124034124035124036124037124038124039124040124041124042124043124044124045124046124047124048124049124050124051124052124053124054124055124056124057124058124059124060124061124062124063124064124065124066124067124068124069124070124071124072124073124074124075124076124077124078124079124080124081124082124083124084124085124086124087124088124089124090124091124092124093124094124095124096124097124098124099124100124101124102124103124104124105124106124107124108124109124110124111124112124113124114124115124116124117124118124119124120124121124122124123124124124125124126124127124128124129124130124131124132124133124134124135124136124137124138124139124140124141124142124143124144124145124146124147124148124149124150124151124152124153124154124155124156124157124158124159124160124161124162124163124164124165124166124167124168124169124170124171124172124173124174124175124176124177124178124179124180124181124182124183124184124185124186124187124188124189124190124191124192124193124194124195124196124197124198124199124200124201124202124203124204124205124206124207124208124209124210124211124212124213124214124215124216124217124218124219124220124221124222124223124224124225124226124227124228124229124230124231124232124233124234124235124236124237124238124239124240124241124242124243124244124245124246124247124248124249124250124251124252124253124254124255124256124257124258124259124260124261124262124263124264124265124266124267124268124269124270124271124272124273124274124275124276124277124278124279124280124281124282124283124284124285124286124287124288124289124290124291124292124293124294124295124296124297124298124299124300124301124302124303124304124305124306124307124308124309124310124311124312124313124314124315124316124317124318124319124320124321124322124323124324124325124326124327124328124329124330124331124332124333124334124335124336124337124338124339124340124341124342124343124344124345124346124347124348124349124350124351124352124353124354124355124356124357124358124359124360124361124362124363124364124365124366124367124368124369124370124371124372124373124374124375124376124377124378124379124380124381124382124383124384124385124386124387124388124389124390124391124392124393124394124395124396124397124398124399124400124401124402124403124404124405124406124407124408124409124410124411124412124413124414124415124416124417124418124419124420124421124422124423124424124425124426124427124428124429124430124431124432124433124434124435124436124437124438124439124440124441124442124443124444124445124446124447124448124449124450124451124452124453124454124455124456124457124458124459124460124461124462124463124464124465124466124467124468124469124470124471124472124473124474124475124476124477124478124479124480124481124482124483124484124485124486124487124488124489124490124491124492124493124494124495124496124497124498124499124500124501124502124503124504124505124506124507124508124509124510124511124512124513124514124515124516124517124518124519124520124521124522124523124524124525124526124527124528124529124530124531124532124533124534124535124536124537124538124539124540124541124542124543124544124545124546124547124548124549124550124551124552124553124554124555124556124557124558124559124560124561124562124563124564124565124566124567124568124569124570124571124572124573124574124575124576124577124578124579124580124581124582124583124584124585124586124587124588124589124590124591124592124593124594124595124596124597124598124599124600124601124602124603124604124605124606124607124608124609124610124611124612124613124614124615124616124617124618124619124620124621124622124623124624124625124626124627124628124629124630124631124632124633124634124635124636124637124638124639124640124641124642124643124644124645124646124647124648124649124650124651124652124653124654124655124656124657124658124659124660124661124662124663124664124665124666124667124668124669124670124671124672124673124674124675124676124677124678124679124680124681124682124683124684124685124686124687124688124689124690124691124692124693124694124695124696124697124698124699124700124701124702124703124704124705124706124707124708124709124710124711124712124713124714124715124716124717124718124719124720124721124722124723124724124725124726124727124728124729124730124731124732124733124734124735124736124737124738124739124740124741124742124743124744124745124746124747124748124749124750124751124752124753124754124755124756124757124758124759124760124761124762124763124764124765124766124767124768124769124770124771124772124773124774124775124776124777124778124779124780124781124782124783124784124785124786124787124788124789124790124791124792124793124794124795124796124797124798124799124800124801124802124803124804124805124806124807124808124809124810124811124812124813124814124815124816124817124818124819124820124821124822124823124824124825124826124827124828124829124830124831124832124833124834124835124836124837124838124839124840124841124842124843124844124845124846124847124848124849124850124851124852124853124854124855124856124857124858124859124860124861124862124863124864124865124866124867124868124869124870124871124872124873124874124875124876124877124878124879124880124881124882124883124884124885124886124887124888124889124890124891124892124893124894124895124896124897124898124899124900124901124902124903124904124905124906124907124908124909124910124911124912124913124914124915124916124917124918124919124920124921124922124923124924124925124926124927124928124929124930124931124932124933124934124935124936124937124938124939124940124941124942124943124944124945124946124947124948124949124950124951124952124953124954124955124956124957124958124959124960124961124962124963124964124965124966124967124968124969124970124971124972124973124974124975124976124977124978124979124980124981124982124983124984124985124986124987124988124989124990124991124992124993124994124995124996124997124998124999125000125001125002125003125004125005125006125007125008125009125010125011125012125013125014125015125016125017125018125019125020125021125022125023125024125025125026125027125028125029125030125031125032125033125034125035125036125037125038125039125040125041125042125043125044125045125046125047125048125049125050125051125052125053125054125055125056125057125058125059125060125061125062125063125064125065125066125067125068125069125070125071125072125073125074125075125076125077125078125079125080125081125082125083125084125085125086125087125088125089125090125091125092125093125094125095125096125097125098125099125100125101125102125103125104125105125106125107125108125109125110125111125112125113125114125115125116125117125118125119125120125121125122125123125124125125125126125127125128125129125130125131125132125133125134125135125136125137125138125139125140125141125142125143125144125145125146125147125148125149125150125151125152125153125154125155125156125157125158125159125160125161125162125163125164125165125166125167125168125169125170125171125172125173125174125175125176125177125178125179125180125181125182125183125184125185125186125187125188125189125190125191125192125193125194125195125196125197125198125199125200125201125202125203125204125205125206125207125208125209125210125211125212125213125214125215125216125217125218125219125220125221125222125223125224125225125226125227125228125229125230125231125232125233125234125235125236125237125238125239125240125241125242125243125244125245125246125247125248125249125250125251125252125253125254125255125256125257125258125259125260125261125262125263125264125265125266125267125268125269125270125271125272125273125274125275125276125277125278125279125280125281125282125283125284125285125286125287125288125289125290125291125292125293125294125295125296125297125298125299125300125301125302125303125304125305125306125307125308125309125310125311125312125313125314125315125316125317125318125319125320125321125322125323125324125325125326125327125328125329125330125331125332125333125334125335125336125337125338125339125340125341125342125343125344125345125346125347125348125349125350125351125352125353125354125355125356125357125358125359125360125361125362125363125364125365125366125367125368125369125370125371125372125373125374125375125376125377125378125379125380125381125382125383125384125385125386125387125388125389125390125391125392125393125394125395125396125397125398125399125400125401125402125403125404125405125406125407125408125409125410125411125412125413125414125415125416125417125418125419125420125421125422125423125424125425125426125427125428125429125430125431125432125433125434125435125436125437125438125439125440125441125442125443125444125445125446125447125448125449125450125451125452125453125454125455125456125457125458125459125460125461125462125463125464125465125466125467125468125469125470125471125472125473125474125475125476125477125478125479125480125481125482125483125484125485125486125487125488125489125490125491125492125493125494125495125496125497125498125499125500125501125502125503125504125505125506125507125508125509125510125511125512125513125514125515125516125517125518125519125520125521125522125523125524125525125526125527125528125529125530125531125532125533125534125535125536125537125538125539125540125541125542125543125544125545125546125547125548125549125550125551125552125553125554125555125556125557125558125559125560125561125562125563125564125565125566125567125568125569125570125571125572125573125574125575125576125577125578125579125580125581125582125583125584125585125586125587125588125589125590125591125592125593125594125595125596125597125598125599125600125601125602125603125604125605125606125607125608125609125610125611125612125613125614125615125616125617125618125619125620125621125622125623125624125625125626125627125628125629125630125631125632125633125634125635125636125637125638125639125640125641125642125643125644125645125646125647125648125649125650125651125652125653125654125655125656125657125658125659125660125661125662125663125664125665125666125667125668125669125670125671125672125673125674125675125676125677125678125679125680125681125682125683125684125685125686125687125688125689125690125691125692125693125694125695125696125697125698125699125700125701125702125703125704125705125706125707125708125709125710125711125712125713125714125715125716125717125718125719125720125721125722125723125724125725125726125727125728125729125730125731125732125733125734125735125736125737125738125739125740125741125742125743125744125745125746125747125748125749125750125751125752125753125754125755125756125757125758125759125760125761125762125763125764125765125766125767125768125769125770125771125772125773125774125775125776125777125778125779125780125781125782125783125784125785125786125787125788125789125790125791125792125793125794125795125796125797125798125799125800125801125802125803125804125805125806125807125808125809125810125811125812125813125814125815125816125817125818125819125820125821125822125823125824125825125826125827125828125829125830125831125832125833125834125835125836125837125838125839125840125841125842125843125844125845125846125847125848125849125850125851125852125853125854125855125856125857125858125859125860125861125862125863125864125865125866125867125868125869125870125871125872125873125874125875125876125877125878125879125880125881125882125883125884125885125886125887125888125889125890125891125892125893125894125895125896125897125898125899125900125901125902125903125904125905125906125907125908125909125910125911125912125913125914125915125916125917125918125919125920125921125922125923125924125925125926125927125928125929125930125931125932125933125934125935125936125937125938125939125940125941125942125943125944125945125946125947125948125949125950125951125952125953125954125955125956125957125958125959125960125961125962125963125964125965125966125967125968125969125970125971125972125973125974125975125976125977125978125979125980125981125982125983125984125985125986125987125988125989125990125991125992125993125994125995125996125997125998125999126000126001126002126003126004126005126006126007126008126009126010126011126012126013126014126015126016126017126018126019126020126021126022126023126024126025126026126027126028126029126030126031126032126033126034126035126036126037126038126039126040126041126042126043126044126045126046126047126048126049126050126051126052126053126054126055126056126057126058126059126060126061126062126063126064126065126066126067126068126069126070126071126072126073126074126075126076126077126078126079126080126081126082126083126084126085126086126087126088126089126090126091126092126093126094126095126096126097126098126099126100126101126102126103126104126105126106126107126108126109126110126111126112126113126114126115126116126117126118126119126120126121126122126123126124126125126126126127126128126129126130126131126132126133126134126135126136126137126138126139126140126141126142126143126144126145126146126147126148126149126150126151126152126153126154126155126156126157126158126159126160126161126162126163126164126165126166126167126168126169126170126171126172126173126174126175126176126177126178126179126180126181126182126183126184126185126186126187126188126189126190126191126192126193126194126195126196126197126198126199126200126201126202126203126204126205126206126207126208126209126210126211126212126213126214126215126216126217126218126219126220126221126222126223126224126225126226126227126228126229126230126231126232126233126234126235126236126237126238126239126240126241126242126243126244126245126246126247126248126249126250126251126252126253126254126255126256126257126258126259126260126261126262126263126264126265126266126267126268126269126270126271126272126273126274126275126276126277126278126279126280126281126282126283126284126285126286126287126288126289126290126291126292126293126294126295126296126297126298126299126300126301126302126303126304126305126306126307126308126309126310126311126312126313126314126315126316126317126318126319126320126321126322126323126324126325126326126327126328126329126330126331126332126333126334126335126336126337126338126339126340126341126342126343126344126345126346126347126348126349126350126351126352126353126354126355126356126357126358126359126360126361126362126363126364126365126366126367126368126369126370126371126372126373126374126375126376126377126378126379126380126381126382126383126384126385126386126387126388126389126390126391126392126393126394126395126396126397126398126399126400126401126402126403126404126405126406126407126408126409126410126411126412126413126414126415126416126417126418126419126420126421126422126423126424126425126426126427126428126429126430126431126432126433126434126435126436126437126438126439126440126441126442126443126444126445126446126447126448126449126450126451126452126453126454126455126456126457126458126459126460126461126462126463126464126465126466126467126468126469126470126471126472126473126474126475126476126477126478126479126480126481126482126483126484126485126486126487126488126489126490126491126492126493126494126495126496126497126498126499126500126501126502126503126504126505126506126507126508126509126510126511126512126513126514126515126516126517126518126519126520126521126522126523126524126525126526126527126528126529126530126531126532126533126534126535126536126537126538126539126540126541126542126543126544126545126546126547126548126549126550126551126552126553126554126555126556126557126558126559126560126561126562126563126564126565126566126567126568126569126570126571126572126573126574126575126576126577126578126579126580126581126582126583126584126585126586126587126588126589126590126591126592126593126594126595126596126597126598126599126600126601126602126603126604126605126606126607126608126609126610126611126612126613126614126615126616126617126618126619126620126621126622126623126624126625126626126627126628126629126630126631126632126633126634126635126636126637126638126639126640126641126642126643126644126645126646126647126648126649126650126651126652126653126654126655126656126657126658126659126660126661126662126663126664126665126666126667126668126669126670126671126672126673126674126675126676126677126678126679126680126681126682126683126684126685126686126687126688126689126690126691126692126693126694126695126696126697126698126699126700126701126702126703126704126705126706126707126708126709126710126711126712126713126714126715126716126717126718126719126720126721126722126723126724126725126726126727126728126729126730126731126732126733126734126735126736126737126738126739126740126741126742126743126744126745126746126747126748126749126750126751126752126753126754126755126756126757126758126759126760126761126762126763126764126765126766126767126768126769126770126771126772126773126774126775126776126777126778126779126780126781126782126783126784126785126786126787126788126789126790126791126792126793126794126795126796126797126798126799126800126801126802126803126804126805126806126807126808126809126810126811126812126813126814126815126816126817126818126819126820126821126822126823126824126825126826126827126828126829126830126831126832126833126834126835126836126837126838126839126840126841126842126843126844126845126846126847126848126849126850126851126852126853126854126855126856126857126858126859126860126861126862126863126864126865126866126867126868126869126870126871126872126873126874126875126876126877126878126879126880126881126882126883126884126885126886126887126888126889126890126891126892126893126894126895126896126897126898126899126900126901126902126903126904126905126906126907126908126909126910126911126912126913126914126915126916126917126918126919126920126921126922126923126924126925126926126927126928126929126930126931126932126933126934126935126936126937126938126939126940126941126942126943126944126945126946126947126948126949126950126951126952126953126954126955126956126957126958126959126960126961126962126963126964126965126966126967126968126969126970126971126972126973126974126975126976126977126978126979126980126981126982126983126984126985126986126987126988126989126990126991126992126993126994126995126996126997126998126999127000127001127002127003127004127005127006127007127008127009127010127011127012127013127014127015127016127017127018127019127020127021127022127023127024127025127026127027127028127029127030127031127032127033127034127035127036127037127038127039127040127041127042127043127044127045127046127047127048127049127050127051127052127053127054127055127056127057127058127059127060127061127062127063127064127065127066127067127068127069127070127071127072127073127074127075127076127077127078127079127080127081127082127083127084127085127086127087127088127089127090127091127092127093127094127095127096127097127098127099127100127101127102127103127104127105127106127107127108127109127110127111127112127113127114127115127116127117127118127119127120127121127122127123127124127125127126127127127128127129127130127131127132127133127134127135127136127137127138127139127140127141127142127143127144127145127146127147127148127149127150127151127152127153127154127155127156127157127158127159127160127161127162127163127164127165127166127167127168127169127170127171127172127173127174127175127176127177127178127179127180127181127182127183127184127185127186127187127188127189127190127191127192127193127194127195127196127197127198127199127200127201127202127203127204127205127206127207127208127209127210127211127212127213127214127215127216127217127218127219127220127221127222127223127224127225127226127227127228127229127230127231127232127233127234127235127236127237127238127239127240127241127242127243127244127245127246127247127248127249127250127251127252127253127254127255127256127257127258127259127260127261127262127263127264127265127266127267127268127269127270127271127272127273127274127275127276127277127278127279127280127281127282127283127284127285127286127287127288127289127290127291127292127293127294127295127296127297127298127299127300127301127302127303127304127305127306127307127308127309127310127311127312127313127314127315127316127317127318127319127320127321127322127323127324127325127326127327127328127329127330127331127332127333127334127335127336127337127338127339127340127341127342127343127344127345127346127347127348127349127350127351127352127353127354127355127356127357127358127359127360127361127362127363127364127365127366127367127368127369127370127371127372127373127374127375127376127377127378127379127380127381127382127383127384127385127386127387127388127389127390127391127392127393127394127395127396127397127398127399127400127401127402127403127404127405127406127407127408127409127410127411127412127413127414127415127416127417127418127419127420127421127422127423127424127425127426127427127428127429127430127431127432127433127434127435127436127437127438127439127440127441127442127443127444127445127446127447127448127449127450127451127452127453127454127455127456127457127458127459127460127461127462127463127464127465127466127467127468127469127470127471127472127473127474127475127476127477127478127479127480127481127482127483127484127485127486127487127488127489127490127491127492127493127494127495127496127497127498127499127500127501127502127503127504127505127506127507127508127509127510127511127512127513127514127515127516127517127518127519127520127521127522127523127524127525127526127527127528127529127530127531127532127533127534127535127536127537127538127539127540127541127542127543127544127545127546127547127548127549127550127551127552127553127554127555127556127557127558127559127560127561127562127563127564127565127566127567127568127569127570127571127572127573127574127575127576127577127578127579127580127581127582127583127584127585127586127587127588127589127590127591127592127593127594127595127596127597127598127599127600127601127602127603127604127605127606127607127608127609127610127611127612127613127614127615127616127617127618127619127620127621127622127623127624127625127626127627127628127629127630127631127632127633127634127635127636127637127638127639127640127641127642127643127644127645127646127647127648127649127650127651127652127653127654127655127656127657127658127659127660127661127662127663127664127665127666127667127668127669127670127671127672127673127674127675127676127677127678127679127680127681127682127683127684127685127686127687127688127689127690127691127692127693127694127695127696127697127698127699127700127701127702127703127704127705127706127707127708127709127710127711127712127713127714127715127716127717127718127719127720127721127722127723127724127725127726127727127728127729127730127731127732127733127734127735127736127737127738127739127740127741127742127743127744127745127746127747127748127749127750127751127752127753127754127755127756127757127758127759127760127761127762127763127764127765127766127767127768127769127770127771127772127773127774127775127776127777127778127779127780127781127782127783127784127785127786127787127788127789127790127791127792127793127794127795127796127797127798127799127800127801127802127803127804127805127806127807127808127809127810127811127812127813127814127815127816127817127818127819127820127821127822127823127824127825127826127827127828127829127830127831127832127833127834127835127836127837127838127839127840127841127842127843127844127845127846127847127848127849127850127851127852127853127854127855127856127857127858127859127860127861127862127863127864127865127866127867127868127869127870127871127872127873127874127875127876127877127878127879127880127881127882127883127884127885127886127887127888127889127890127891127892127893127894127895127896127897127898127899127900127901127902127903127904127905127906127907127908127909127910127911127912127913127914127915127916127917127918127919127920127921127922127923127924127925127926127927127928127929127930127931127932127933127934127935127936127937127938127939127940127941127942127943127944127945127946127947127948127949127950127951127952127953127954127955127956127957127958127959127960127961127962127963127964127965127966127967127968127969127970127971127972127973127974127975127976127977127978127979127980127981127982127983127984127985127986127987127988127989127990127991127992127993127994127995127996127997127998127999128000128001128002128003128004128005128006128007128008128009128010128011128012128013128014128015128016128017128018128019128020128021128022128023128024128025128026128027128028128029128030128031128032128033128034128035128036128037128038128039128040128041128042128043128044128045128046128047128048128049128050128051128052128053128054128055128056128057128058128059128060128061128062128063128064128065128066128067128068128069128070128071128072128073128074128075128076128077128078128079128080128081128082128083128084128085128086128087128088128089128090128091128092128093128094128095128096128097128098128099128100128101128102128103128104128105128106128107128108128109128110128111128112128113128114128115128116128117128118128119128120128121128122128123128124128125128126128127128128128129128130128131128132128133128134128135128136128137128138128139128140128141128142128143128144128145128146128147128148128149128150128151128152128153128154128155128156128157128158128159128160128161128162128163128164128165128166128167128168128169128170128171128172128173128174128175128176128177128178128179128180128181128182128183128184128185128186128187128188128189128190128191128192128193128194128195128196128197128198128199128200128201128202128203128204128205128206128207128208128209128210128211128212128213128214128215128216128217128218128219128220128221128222128223128224128225128226128227128228128229128230128231128232128233128234128235128236128237128238128239128240128241128242128243128244128245128246128247128248128249128250128251128252128253128254128255128256128257128258128259128260128261128262128263128264128265128266128267128268128269128270128271128272128273128274128275128276128277128278128279128280128281128282128283128284128285128286128287128288128289128290128291128292128293128294128295128296128297128298128299128300128301128302128303128304128305128306128307128308128309128310128311128312128313128314128315128316128317128318128319128320128321128322128323128324128325128326128327128328128329128330128331128332128333128334128335128336128337128338128339128340128341128342128343128344128345128346128347128348128349128350128351128352128353128354128355128356128357128358128359128360128361128362128363128364128365128366128367128368128369128370128371128372128373128374128375128376128377128378128379128380128381128382128383128384128385128386128387128388128389128390128391128392128393128394128395128396128397128398128399128400128401128402128403128404128405128406128407128408128409128410128411128412128413128414128415128416128417128418128419128420128421128422128423128424128425128426128427128428128429128430128431128432128433128434128435128436128437128438128439128440128441128442128443128444128445128446128447128448128449128450128451128452128453128454128455128456128457128458128459128460128461128462128463128464128465128466128467128468128469128470128471128472128473128474128475128476128477128478128479128480128481128482128483128484128485128486128487128488128489128490128491128492128493128494128495128496128497128498128499128500128501128502128503128504128505128506128507128508128509128510128511128512128513128514128515128516128517128518128519128520128521128522128523128524128525128526128527128528128529128530128531128532128533128534128535128536128537128538128539128540128541128542128543128544128545128546128547128548128549128550128551128552128553128554128555128556128557128558128559128560128561128562128563128564128565128566128567128568128569128570128571128572128573128574128575128576128577128578128579128580128581128582128583128584128585128586128587128588128589128590128591128592128593128594128595128596128597128598128599128600128601128602128603128604128605128606128607128608128609128610128611128612128613128614128615128616128617128618128619128620128621128622128623128624128625128626128627128628128629128630128631128632128633128634128635128636128637128638128639128640128641128642128643128644128645128646128647128648128649128650128651128652128653128654128655128656128657128658128659128660128661128662128663128664128665128666128667128668128669128670128671128672128673128674128675128676128677128678128679128680128681128682128683128684128685128686128687128688128689128690128691128692128693128694128695128696128697128698128699128700128701128702128703128704128705128706128707128708128709128710128711128712128713128714128715128716128717128718128719128720128721128722128723128724128725128726128727128728128729128730128731128732128733128734128735128736128737128738128739128740128741128742128743128744128745128746128747128748128749128750128751128752128753128754128755128756128757128758128759128760128761128762128763128764128765128766128767128768128769128770128771128772128773128774128775128776128777128778128779128780128781128782128783128784128785128786128787128788128789128790128791128792128793128794128795128796128797128798128799128800128801128802128803128804128805128806128807128808128809128810128811128812128813128814128815128816128817128818128819128820128821128822128823128824128825128826128827128828128829128830128831128832128833128834128835128836128837128838128839128840128841128842128843128844128845128846128847128848128849128850128851128852128853128854128855128856128857128858128859128860128861128862128863128864128865128866128867128868128869128870128871128872128873128874128875128876128877128878128879128880128881128882128883128884128885128886128887128888128889128890128891128892128893128894128895128896128897128898128899128900128901128902128903128904128905128906128907128908128909128910128911128912128913128914128915128916128917128918128919128920128921128922128923128924128925128926128927128928128929128930128931128932128933128934128935128936128937128938128939128940128941128942128943128944128945128946128947128948128949128950128951128952128953128954128955128956128957128958128959128960128961128962128963128964128965128966128967128968128969128970128971128972128973128974128975128976128977128978128979128980128981128982128983128984128985128986128987128988128989128990128991128992128993128994128995128996128997128998128999129000129001129002129003129004129005129006129007129008129009129010129011129012129013129014129015129016129017129018129019129020129021129022129023129024129025129026129027129028129029129030129031129032129033129034129035129036129037129038129039129040129041129042129043129044129045129046129047129048129049129050129051129052129053129054129055129056129057129058129059129060129061129062129063129064129065129066129067129068129069129070129071129072129073129074129075129076129077129078129079129080129081129082129083129084129085129086129087129088129089129090129091129092129093129094129095129096129097129098129099129100129101129102129103129104129105129106129107129108129109129110129111129112129113129114129115129116129117129118129119129120129121129122129123129124129125129126129127129128129129129130129131129132129133129134129135129136129137129138129139129140129141129142129143129144129145129146129147129148129149129150129151129152129153129154129155129156129157129158129159129160129161129162129163129164129165129166129167129168129169129170129171129172129173129174129175129176129177129178129179129180129181129182129183129184129185129186129187129188129189129190129191129192129193129194129195129196129197129198129199129200129201129202129203129204129205129206129207129208129209129210129211129212129213129214129215129216129217129218129219129220129221129222129223129224129225129226129227129228129229129230129231129232129233129234129235129236129237129238129239129240129241129242129243129244129245129246129247129248129249129250129251129252129253129254129255129256129257129258129259129260129261129262129263129264129265129266129267129268129269129270129271129272129273129274129275129276129277129278129279129280129281129282129283129284129285129286129287129288129289129290129291129292129293129294129295129296129297129298129299129300129301129302129303129304129305129306129307129308129309129310129311129312129313129314129315129316129317129318129319129320129321129322129323129324129325129326129327129328129329129330129331129332129333129334129335129336129337129338129339129340129341129342129343129344129345129346129347129348129349129350129351129352129353129354129355129356129357129358129359129360129361129362129363129364129365129366129367129368129369129370129371129372129373129374129375129376129377129378129379129380129381129382129383129384129385129386129387129388129389129390129391129392129393129394129395129396129397129398129399129400129401129402129403129404129405129406129407129408129409129410129411129412129413129414129415129416129417129418129419129420129421129422129423129424129425129426129427129428129429129430129431129432129433129434129435129436129437129438129439129440129441129442129443129444129445129446129447129448129449129450129451129452129453129454129455129456129457129458129459129460129461129462129463129464129465129466129467129468129469129470129471129472129473129474129475129476129477129478129479129480129481129482129483129484129485129486129487129488129489129490129491129492129493129494129495129496129497129498129499129500129501129502129503129504129505129506129507129508129509129510129511129512129513129514129515129516129517129518129519129520129521129522129523129524129525129526129527129528129529129530129531129532129533129534129535129536129537129538129539129540129541129542129543129544129545129546129547129548129549129550129551129552129553129554129555129556129557129558129559129560129561129562129563129564129565129566129567129568129569129570129571129572129573129574129575129576129577129578129579129580129581129582129583129584129585129586129587129588129589129590129591129592129593129594129595129596129597129598129599129600129601129602129603129604129605129606129607129608129609129610129611129612129613129614129615129616129617129618129619129620129621129622129623129624129625129626129627129628129629129630129631129632129633129634129635129636129637129638129639129640129641129642129643129644129645129646129647129648129649129650129651129652129653129654129655129656129657129658129659129660129661129662129663129664129665129666129667129668129669129670129671129672129673129674129675129676129677129678129679129680129681129682129683129684129685129686129687129688129689129690129691129692129693129694129695129696129697129698129699129700129701129702129703129704129705129706129707129708129709129710129711129712129713129714129715129716129717129718129719129720129721129722129723129724129725129726129727129728129729129730129731129732129733129734129735129736129737129738129739129740129741129742129743129744129745129746129747129748129749129750129751129752129753129754129755129756129757129758129759129760129761129762129763129764129765129766129767129768129769129770129771129772129773129774129775129776129777129778129779129780129781129782129783129784129785129786129787129788129789129790129791129792129793129794129795129796129797129798129799129800129801129802129803129804129805129806129807129808129809129810129811129812129813129814129815129816129817129818129819129820129821129822129823129824129825129826129827129828129829129830129831129832129833129834129835129836129837129838129839129840129841129842129843129844129845129846129847129848129849129850129851129852129853129854129855129856129857129858129859129860129861129862129863129864129865129866129867129868129869129870129871129872129873129874129875129876129877129878129879129880129881129882129883129884129885129886129887129888129889129890129891129892129893129894129895129896129897129898129899129900129901129902129903129904129905129906129907129908129909129910129911129912129913129914129915129916129917129918129919129920129921129922129923129924129925129926129927129928129929129930129931129932129933129934129935129936129937129938129939129940129941129942129943129944129945129946129947129948129949129950129951129952129953129954129955129956129957129958129959129960129961129962129963129964129965129966129967129968129969129970129971129972129973129974129975129976129977129978129979129980129981129982129983129984129985129986129987129988129989129990129991129992129993129994129995129996129997129998129999130000130001130002130003130004130005130006130007130008130009130010130011130012130013130014130015130016130017130018130019130020130021130022130023130024130025130026130027130028130029130030130031130032130033130034130035130036130037130038130039130040130041130042130043130044130045130046130047130048130049130050130051130052130053130054130055130056130057130058130059130060130061130062130063130064130065130066130067130068130069130070130071130072130073130074130075130076130077130078130079130080130081130082130083130084130085130086130087130088130089130090130091130092130093130094130095130096130097130098130099130100130101130102130103130104130105130106130107130108130109130110130111130112130113130114130115130116130117130118130119130120130121130122130123130124130125130126130127130128130129130130130131130132130133130134130135130136130137130138130139130140130141130142130143130144130145130146130147130148130149130150130151130152130153130154130155130156130157130158130159130160130161130162130163130164130165130166130167130168130169130170130171130172130173130174130175130176130177130178130179130180130181130182130183130184130185130186130187130188130189130190130191130192130193130194130195130196130197130198130199130200130201130202130203130204130205130206130207130208130209130210130211130212130213130214130215130216130217130218130219130220130221130222130223130224130225130226130227130228130229130230130231130232130233130234130235130236130237130238130239130240130241130242130243130244130245130246130247130248130249130250130251130252130253130254130255130256130257130258130259130260130261130262130263130264130265130266130267130268130269130270130271130272130273130274130275130276130277130278130279130280130281130282130283130284130285130286130287130288130289130290130291130292130293130294130295130296130297130298130299130300130301130302130303130304130305130306130307130308130309130310130311130312130313130314130315130316130317130318130319130320130321130322130323130324130325130326130327130328130329130330130331130332130333130334130335130336130337130338130339130340130341130342130343130344130345130346130347130348130349130350130351130352130353130354130355130356130357130358130359130360130361130362130363130364130365130366130367130368130369130370130371130372130373130374130375130376130377130378130379130380130381130382130383130384130385130386130387130388130389130390130391130392130393130394130395130396130397130398130399130400130401130402130403130404130405130406130407130408130409130410130411130412130413130414130415130416130417130418130419130420130421130422130423130424130425130426130427130428130429130430130431130432130433130434130435130436130437130438130439130440130441130442130443130444130445130446130447130448130449130450130451130452130453130454130455130456130457130458130459130460130461130462130463130464130465130466130467130468130469130470130471130472130473130474130475130476130477130478130479130480130481130482130483130484130485130486130487130488130489130490130491130492130493130494130495130496130497130498130499130500130501130502130503130504130505130506130507130508130509130510130511130512130513130514130515130516130517130518130519130520130521130522130523130524130525130526130527130528130529130530130531130532130533130534130535130536130537130538130539130540130541130542130543130544130545130546130547130548130549130550130551130552130553130554130555130556130557130558130559130560130561130562130563130564130565130566130567130568130569130570130571130572130573130574130575130576130577130578130579130580130581130582130583130584130585130586130587130588130589130590130591130592130593130594130595130596130597130598130599130600130601130602130603130604130605130606130607130608130609130610130611130612130613130614130615130616130617130618130619130620130621130622130623130624130625130626130627130628130629130630130631130632130633130634130635130636130637130638130639130640130641130642130643130644130645130646130647130648130649130650130651130652130653130654130655130656130657130658130659130660130661130662130663130664130665130666130667130668130669130670130671130672130673130674130675130676130677130678130679130680130681130682130683130684130685130686130687130688130689130690130691130692130693130694130695130696130697130698130699130700130701130702130703130704130705130706130707130708130709130710130711130712130713130714130715130716130717130718130719130720130721130722130723130724130725130726130727130728130729130730130731130732130733130734130735130736130737130738130739130740130741130742130743130744130745130746130747130748130749130750130751130752130753130754130755130756130757130758130759130760130761130762130763130764130765130766130767130768130769130770130771130772130773130774130775130776130777130778130779130780130781130782130783130784130785130786130787130788130789130790130791130792130793130794130795130796130797130798130799130800130801130802130803130804130805130806130807130808130809130810130811130812130813130814130815130816130817130818130819130820130821130822130823130824130825130826130827130828130829130830130831130832130833130834130835130836130837130838130839130840130841130842130843130844130845130846130847130848130849130850130851130852130853130854130855130856130857130858130859130860130861130862130863130864130865130866130867130868130869130870130871130872130873130874130875130876130877130878130879130880130881130882130883130884130885130886130887130888130889130890130891130892130893130894130895130896130897130898130899130900130901130902130903130904130905130906130907130908130909130910130911130912130913130914130915130916130917130918130919130920130921130922130923130924130925130926130927130928130929130930130931130932130933130934130935130936130937130938130939130940130941130942130943130944130945130946130947130948130949130950130951130952130953130954130955130956130957130958130959130960130961130962130963130964130965130966130967130968130969130970130971130972130973130974130975130976130977130978130979130980130981130982130983130984130985130986130987130988130989130990130991130992130993130994130995130996130997130998130999131000131001131002131003131004131005131006131007131008131009131010131011131012131013131014131015131016131017131018131019131020131021131022131023131024131025131026131027131028131029131030131031131032131033131034131035131036131037131038131039131040131041131042131043131044131045131046131047131048131049131050131051131052131053131054131055131056131057131058131059131060131061131062131063131064131065131066131067131068131069131070131071131072131073131074131075131076131077131078131079131080131081131082131083131084131085131086131087131088131089131090131091131092131093131094131095131096131097131098131099131100131101131102131103131104131105131106131107131108131109131110131111131112131113131114131115131116131117131118131119131120131121131122131123131124131125131126131127131128131129131130131131131132131133131134131135131136131137131138131139131140131141131142131143131144131145131146131147131148131149131150131151131152131153131154131155131156131157131158131159131160131161131162131163131164131165131166131167131168131169131170131171131172131173131174131175131176131177131178131179131180131181131182131183131184131185131186131187131188131189131190131191131192131193131194131195131196131197131198131199131200131201131202131203131204131205131206131207131208131209131210131211131212131213131214131215131216131217131218131219131220131221131222131223131224131225131226131227131228131229131230131231131232131233131234131235131236131237131238131239131240131241131242131243131244131245131246131247131248131249131250131251131252131253131254131255131256131257131258131259131260131261131262131263131264131265131266131267131268131269131270131271131272131273131274131275131276131277131278131279131280131281131282131283131284131285131286131287131288131289131290131291131292131293131294131295131296131297131298131299131300131301131302131303131304131305131306131307131308131309131310131311131312131313131314131315131316131317131318131319131320131321131322131323131324131325131326131327131328131329131330131331131332131333131334131335131336131337131338131339131340131341131342131343131344131345131346131347131348131349131350131351131352131353131354131355131356131357131358131359131360131361131362131363131364131365131366131367131368131369131370131371131372131373131374131375131376131377131378131379131380131381131382131383131384131385131386131387131388131389131390131391131392131393131394131395131396131397131398131399131400131401131402131403131404131405131406131407131408131409131410131411131412131413131414131415131416131417131418131419131420131421131422131423131424131425131426131427131428131429131430131431131432131433131434131435131436131437131438131439131440131441131442131443131444131445131446131447131448131449131450131451131452131453131454131455131456131457131458131459131460131461131462131463131464131465131466131467131468131469131470131471131472131473131474131475131476131477131478131479131480131481131482131483131484131485131486131487131488131489131490131491131492131493131494131495131496131497131498131499131500131501131502131503131504131505131506131507131508131509131510131511131512131513131514131515131516131517131518131519131520131521131522131523131524131525131526131527131528131529131530131531131532131533131534131535131536131537131538131539131540131541131542131543131544131545131546131547131548131549131550131551131552131553131554131555131556131557131558131559131560131561131562131563131564131565131566131567131568131569131570131571131572131573131574131575131576131577131578131579131580131581131582131583131584131585131586131587131588131589131590131591131592131593131594131595131596131597131598131599131600131601131602131603131604131605131606131607131608131609131610131611131612131613131614131615131616131617131618131619131620131621131622131623131624131625131626131627131628131629131630131631131632131633131634131635131636131637131638131639131640131641131642131643131644131645131646131647131648131649131650131651131652131653131654131655131656131657131658131659131660131661131662131663131664131665131666131667131668131669131670131671131672131673131674131675131676131677131678131679131680131681131682131683131684131685131686131687131688131689131690131691131692131693131694131695131696131697131698131699131700131701131702131703131704131705131706131707131708131709131710131711131712131713131714131715131716131717131718131719131720131721131722131723131724131725131726131727131728131729131730131731131732131733131734131735131736131737131738131739131740131741131742131743131744131745131746131747131748131749131750131751131752131753131754131755131756131757131758131759131760131761131762131763131764131765131766131767131768131769131770131771131772131773131774131775131776131777131778131779131780131781131782131783131784131785131786131787131788131789131790131791131792131793131794131795131796131797131798131799131800131801131802131803131804131805131806131807131808131809131810131811131812131813131814131815131816131817131818131819131820131821131822131823131824131825131826131827131828131829131830131831131832131833131834131835131836131837131838131839131840131841131842131843131844131845131846131847131848131849131850131851131852131853131854131855131856131857131858131859131860131861131862131863131864131865131866131867131868131869131870131871131872131873131874131875131876131877131878131879131880131881131882131883131884131885131886131887131888131889131890131891131892131893131894131895131896131897131898131899131900131901131902131903131904131905131906131907131908131909131910131911131912131913131914131915131916131917131918131919131920131921131922131923131924131925131926131927131928131929131930131931131932131933131934131935131936131937131938131939131940131941131942131943131944131945131946131947131948131949131950131951131952131953131954131955131956131957131958131959131960131961131962131963131964131965131966131967131968131969131970131971131972131973131974131975131976131977131978131979131980131981131982131983131984131985131986131987131988131989131990131991131992131993131994131995131996131997131998131999132000132001132002132003132004132005132006132007132008132009132010132011132012132013132014132015132016132017132018132019132020132021132022132023132024132025132026132027132028132029132030132031132032132033132034132035132036132037132038132039132040132041132042132043132044132045132046132047132048132049132050132051132052132053132054132055132056132057132058132059132060132061132062132063132064132065132066132067132068132069132070132071132072132073132074132075132076132077132078132079132080132081132082132083132084132085132086132087132088132089132090132091132092132093132094132095132096132097132098132099132100132101132102132103132104132105132106132107132108132109132110132111132112132113132114132115132116132117132118132119132120132121132122132123132124132125132126132127132128132129132130132131132132132133132134132135132136132137132138132139132140132141132142132143132144132145132146132147132148132149132150132151132152132153132154132155132156132157132158132159132160132161132162132163132164132165132166132167132168132169132170132171132172132173132174132175132176132177132178132179132180132181132182132183132184132185132186132187132188132189132190132191132192132193132194132195132196132197132198132199132200132201132202132203132204132205132206132207132208132209132210132211132212132213132214132215132216132217132218132219132220132221132222132223132224132225132226132227132228132229132230132231132232132233132234132235132236132237132238132239132240132241132242132243132244132245132246132247132248132249132250132251132252132253132254132255132256132257132258132259132260132261132262132263132264132265132266132267132268132269132270132271132272132273132274132275132276132277132278132279132280132281132282132283132284132285132286132287132288132289132290132291132292132293132294132295132296132297132298132299132300132301132302132303132304132305132306132307132308132309132310132311132312132313132314132315132316132317132318132319132320132321132322132323132324132325132326132327132328132329132330132331132332132333132334132335132336132337132338132339132340132341132342132343132344132345132346132347132348132349132350132351132352132353132354132355132356132357132358132359132360132361132362132363132364132365132366132367132368132369132370132371132372132373132374132375132376132377132378132379132380132381132382132383132384132385132386132387132388132389132390132391132392132393132394132395132396132397132398132399132400132401132402132403132404132405132406132407132408132409132410132411132412132413132414132415132416132417132418132419132420132421132422132423132424132425132426132427132428132429132430132431132432132433132434132435132436132437132438132439132440132441132442132443132444132445132446132447132448132449132450132451132452132453132454132455132456132457132458132459132460132461132462132463132464132465132466132467132468132469132470132471132472132473132474132475132476132477132478132479132480132481132482132483132484132485132486132487132488132489132490132491132492132493132494132495132496132497132498132499132500132501132502132503132504132505132506132507132508132509132510132511132512132513132514132515132516132517132518132519132520132521132522132523132524132525132526132527132528132529132530132531132532132533132534132535132536132537132538132539132540132541132542132543132544132545132546132547132548132549132550132551132552132553132554132555132556132557132558132559132560132561132562132563132564132565132566132567132568132569132570132571132572132573132574132575132576132577132578132579132580132581132582132583132584132585132586132587132588132589132590132591132592132593132594132595132596132597132598132599132600132601132602132603132604132605132606132607132608132609132610132611132612132613132614132615132616132617132618132619132620132621132622132623132624132625132626132627132628132629132630132631132632132633132634132635132636132637132638132639132640132641132642132643132644132645132646132647132648132649132650132651132652132653132654132655132656132657132658132659132660132661132662132663132664132665132666132667132668132669132670132671132672132673132674132675132676132677132678132679132680132681132682132683132684132685132686132687132688132689132690132691132692132693132694132695132696132697132698132699132700132701132702132703132704132705132706132707132708132709132710132711132712132713132714132715132716132717132718132719132720132721132722132723132724132725132726132727132728132729132730132731132732132733132734132735132736132737132738132739132740132741132742132743132744132745132746132747132748132749132750132751132752132753132754132755132756132757132758132759132760132761132762132763132764132765132766132767132768132769132770132771132772132773132774132775132776132777132778132779132780132781132782132783132784132785132786132787132788132789132790132791132792132793132794132795132796132797132798132799132800132801132802132803132804132805132806132807132808132809132810132811132812132813132814132815132816132817132818132819132820132821132822132823132824132825132826132827132828132829132830132831132832132833132834132835132836132837132838132839132840132841132842132843132844132845132846132847132848132849132850132851132852132853132854132855132856132857132858132859132860132861132862132863132864132865132866132867132868132869132870132871132872132873132874132875132876132877132878132879132880132881132882132883132884132885132886132887132888132889132890132891132892132893132894132895132896132897132898132899132900132901132902132903132904132905132906132907132908132909132910132911132912132913132914132915132916132917132918132919132920132921132922132923132924132925132926132927132928132929132930132931132932132933132934132935132936132937132938132939132940132941132942132943132944132945132946132947132948132949132950132951132952132953132954132955132956132957132958132959132960132961132962132963132964132965132966132967132968132969132970132971132972132973132974132975132976132977132978132979132980132981132982132983132984132985132986132987132988132989132990132991132992132993132994132995132996132997132998132999133000133001133002133003133004133005133006133007133008133009133010133011133012133013133014133015133016133017133018133019133020133021133022133023133024133025133026133027133028133029133030133031133032133033133034133035133036133037133038133039133040133041133042133043133044133045133046133047133048133049133050133051133052133053133054133055133056133057133058133059133060133061133062133063133064133065133066133067133068133069133070133071133072133073133074133075133076133077133078133079133080133081133082133083133084133085133086133087133088133089133090133091133092133093133094133095133096133097133098133099133100133101133102133103133104133105133106133107133108133109133110133111133112133113133114133115133116133117133118133119133120133121133122133123133124133125133126133127133128133129133130133131133132133133133134133135133136133137133138133139133140133141133142133143133144133145133146133147133148133149133150133151133152133153133154133155133156133157133158133159133160133161133162133163133164133165133166133167133168133169133170133171133172133173133174133175133176133177133178133179133180133181133182133183133184133185133186133187133188133189133190133191133192133193133194133195133196133197133198133199133200133201133202133203133204133205133206133207133208133209133210133211133212133213133214133215133216133217133218133219133220133221133222133223133224133225133226133227133228133229133230133231133232133233133234133235133236133237133238133239133240133241133242133243133244133245133246133247133248133249133250133251133252133253133254133255133256133257133258133259133260133261133262133263133264133265133266133267133268133269133270133271133272133273133274133275133276133277133278133279133280133281133282133283133284133285133286133287133288133289133290133291133292133293133294133295133296133297133298133299133300133301133302133303133304133305133306133307133308133309133310133311133312133313133314133315133316133317133318133319133320133321133322133323133324133325133326133327133328133329133330133331133332133333133334133335133336133337133338133339133340133341133342133343133344133345133346133347133348133349133350133351133352133353133354133355133356133357133358133359133360133361133362133363133364133365133366133367133368133369133370133371133372133373133374133375133376133377133378133379133380133381133382133383133384133385133386133387133388133389133390133391133392133393133394133395133396133397133398133399133400133401133402133403133404133405133406133407133408133409133410133411133412133413133414133415133416133417133418133419133420133421133422133423133424133425133426133427133428133429133430133431133432133433133434133435133436133437133438133439133440133441133442133443133444133445133446133447133448133449133450133451133452133453133454133455133456133457133458133459133460133461133462133463133464133465133466133467133468133469133470133471133472133473133474133475133476133477133478133479133480133481133482133483133484133485133486133487133488133489133490133491133492133493133494133495133496133497133498133499133500133501133502133503133504133505133506133507133508133509133510133511133512133513133514133515133516133517133518133519133520133521133522133523133524133525133526133527133528133529133530133531133532133533133534133535133536133537133538133539133540133541133542133543133544133545133546133547133548133549133550133551133552133553133554133555133556133557133558133559133560133561133562133563133564133565133566133567133568133569133570133571133572133573133574133575133576133577133578133579133580133581133582133583133584133585133586133587133588133589133590133591133592133593133594133595133596133597133598133599133600133601133602133603133604133605133606133607133608133609133610133611133612133613133614133615133616133617133618133619133620133621133622133623133624133625133626133627133628133629133630133631133632133633133634133635133636133637133638133639133640133641133642133643133644133645133646133647133648133649133650133651133652133653133654133655133656133657133658133659133660133661133662133663133664133665133666133667133668133669133670133671133672133673133674133675133676133677133678133679133680133681133682133683133684133685133686133687133688133689133690133691133692133693133694133695133696133697133698133699133700133701133702133703133704133705133706133707133708133709133710133711133712133713133714133715133716133717133718133719133720133721133722133723133724133725133726133727133728133729133730133731133732133733133734133735133736133737133738133739133740133741133742133743133744133745133746133747133748133749133750133751133752133753133754133755133756133757133758133759133760133761133762133763133764133765133766133767133768133769133770133771133772133773133774133775133776133777133778133779133780133781133782133783133784133785133786133787133788133789133790133791133792133793133794133795133796133797133798133799133800133801133802133803133804133805133806133807133808133809133810133811133812133813133814133815133816133817133818133819133820133821133822133823133824133825133826133827133828133829133830133831133832133833133834133835133836133837133838133839133840133841133842133843133844133845133846133847133848133849133850133851133852133853133854133855133856133857133858133859133860133861133862133863133864133865133866133867133868133869133870133871133872133873133874133875133876133877133878133879133880133881133882133883133884133885133886133887133888133889133890133891133892133893133894133895133896133897133898133899133900133901133902133903133904133905133906133907133908133909133910133911133912133913133914133915133916133917133918133919133920133921133922133923133924133925133926133927133928133929133930133931133932133933133934133935133936133937133938133939133940133941133942133943133944133945133946133947133948133949133950133951133952133953133954133955133956133957133958133959133960133961133962133963133964133965133966133967133968133969133970133971133972133973133974133975133976133977133978133979133980133981133982133983133984133985133986133987133988133989133990133991133992133993133994133995133996133997133998133999134000134001134002134003134004134005134006134007134008134009134010134011134012134013134014134015134016134017134018134019134020134021134022134023134024134025134026134027134028134029134030134031134032134033134034134035134036134037134038134039134040134041134042134043134044134045134046134047134048134049134050134051134052134053134054134055134056134057134058134059134060134061134062134063134064134065134066134067134068134069134070134071134072134073134074134075134076134077134078134079134080134081134082134083134084134085134086134087134088134089134090134091134092134093134094134095134096134097134098134099134100134101134102134103134104134105134106134107134108134109134110134111134112134113134114134115134116134117134118134119134120134121134122134123134124134125134126134127134128134129134130134131134132134133134134134135134136134137134138134139134140134141134142134143134144134145134146134147134148134149134150134151134152134153134154134155134156134157134158134159134160134161134162134163134164134165134166134167134168134169134170134171134172134173134174134175134176134177134178134179134180134181134182134183134184134185134186134187134188134189134190134191134192134193134194134195134196134197134198134199134200134201134202134203134204134205134206134207134208134209134210134211134212134213134214134215134216134217134218134219134220134221134222134223134224134225134226134227134228134229134230134231134232134233134234134235134236134237134238134239134240134241134242134243134244134245134246134247134248134249134250134251134252134253134254134255134256134257134258134259134260134261134262134263134264134265134266134267134268134269134270134271134272134273134274134275134276134277134278134279134280134281134282134283134284134285134286134287134288134289134290134291134292134293134294134295134296134297134298134299134300134301134302134303134304134305134306134307134308134309134310134311134312134313134314134315134316134317134318134319134320134321134322134323134324134325134326134327134328134329134330134331134332134333134334134335134336134337134338134339134340134341134342134343134344134345134346134347134348134349134350134351134352134353134354134355134356134357134358134359134360134361134362134363134364134365134366134367134368134369134370134371134372134373134374134375134376134377134378134379134380134381134382134383134384134385134386134387134388134389134390134391134392134393134394134395134396134397134398134399134400134401134402134403134404134405134406134407134408134409134410134411134412134413134414134415134416134417134418134419134420134421134422134423134424134425134426134427134428134429134430134431134432134433134434134435134436134437134438134439134440134441134442134443134444134445134446134447134448134449134450134451134452134453134454134455134456134457134458134459134460134461134462134463134464134465134466134467134468134469134470134471134472134473134474134475134476134477134478134479134480134481134482134483134484134485134486134487134488134489134490134491134492134493134494134495134496134497134498134499134500134501134502134503134504134505134506134507134508134509134510134511134512134513134514134515134516134517134518134519134520134521134522134523134524134525134526134527134528134529134530134531134532134533134534134535134536134537134538134539134540134541134542134543134544134545134546134547134548134549134550134551134552134553134554134555134556134557134558134559134560134561134562134563134564134565134566134567134568134569134570134571134572134573134574134575134576134577134578134579134580134581134582134583134584134585134586134587134588134589134590134591134592134593134594134595134596134597134598134599134600134601134602134603134604134605134606134607134608134609134610134611134612134613134614134615134616134617134618134619134620134621134622134623134624134625134626134627134628134629134630134631134632134633134634134635134636134637134638134639134640134641134642134643134644134645134646134647134648134649134650134651134652134653134654134655134656134657134658134659134660134661134662134663134664134665134666134667134668134669134670134671134672134673134674134675134676134677134678134679134680134681134682134683134684134685134686134687134688134689134690134691134692134693134694134695134696134697134698134699134700134701134702134703134704134705134706134707134708134709134710134711134712134713134714134715134716134717134718134719134720134721134722134723134724134725134726134727134728134729134730134731134732134733134734134735134736134737134738134739134740134741134742134743134744134745134746134747134748134749134750134751134752134753134754134755134756134757134758134759134760134761134762134763134764134765134766134767134768134769134770134771134772134773134774134775134776134777134778134779134780134781134782134783134784134785134786134787134788134789134790134791134792134793134794134795134796134797134798134799134800134801134802134803134804134805134806134807134808134809134810134811134812134813134814134815134816134817134818134819134820134821134822134823134824134825134826134827134828134829134830134831134832134833134834134835134836134837134838134839134840134841134842134843134844134845134846134847134848134849134850134851134852134853134854134855134856134857134858134859134860134861134862134863134864134865134866134867134868134869134870134871134872134873134874134875134876134877134878134879134880134881134882134883134884134885134886134887134888134889134890134891134892134893134894134895134896134897134898134899134900134901134902134903134904134905134906134907134908134909134910134911134912134913134914134915134916134917134918134919134920134921134922134923134924134925134926134927134928134929134930134931134932134933134934134935134936134937134938134939134940134941134942134943134944134945134946134947134948134949134950134951134952134953134954134955134956134957134958134959134960134961134962134963134964134965134966134967134968134969134970134971134972134973134974134975134976134977134978134979134980134981134982134983134984134985134986134987134988134989134990134991134992134993134994134995134996134997134998134999135000135001135002135003135004135005135006135007135008135009135010135011135012135013135014135015135016135017135018135019135020135021135022135023135024135025135026135027135028135029135030135031135032135033135034135035135036135037135038135039135040135041135042135043135044135045135046135047135048135049135050135051135052135053135054135055135056135057135058135059135060135061135062135063135064135065135066135067135068135069135070135071135072135073135074135075135076135077135078135079135080135081135082135083135084135085135086135087135088135089135090135091135092135093135094135095135096135097135098135099135100135101135102135103135104135105135106135107135108135109135110135111135112135113135114135115135116135117135118135119135120135121135122135123135124135125135126135127135128135129135130135131135132135133135134135135135136135137135138135139135140135141135142135143135144135145135146135147135148135149135150135151135152135153135154135155135156135157135158135159135160135161135162135163135164135165135166135167135168135169135170135171135172135173135174135175135176135177135178135179135180135181135182135183135184135185135186135187135188135189135190135191135192135193135194135195135196135197135198135199135200135201135202135203135204135205135206135207135208135209135210135211135212135213135214135215135216135217135218135219135220135221135222135223135224135225135226135227135228135229135230135231135232135233135234135235135236135237135238135239135240135241135242135243135244135245135246135247135248135249135250135251135252135253135254135255135256135257135258135259135260135261135262135263135264135265135266135267135268135269135270135271135272135273135274135275135276135277135278135279135280135281135282135283135284135285135286135287135288135289135290135291135292135293135294135295135296135297135298135299135300135301135302135303135304135305135306135307135308135309135310135311135312135313135314135315135316135317135318135319135320135321135322135323135324135325135326135327135328135329135330135331135332135333135334135335135336135337135338135339135340135341135342135343135344135345135346135347135348135349135350135351135352135353135354135355135356135357135358135359135360135361135362135363135364135365135366135367135368135369135370135371135372135373135374135375135376135377135378135379135380135381135382135383135384135385135386135387135388135389135390135391135392135393135394135395135396135397135398135399135400135401135402135403135404135405135406135407135408135409135410135411135412135413135414135415135416135417135418135419135420135421135422135423135424135425135426135427135428135429135430135431135432135433135434135435135436135437135438135439135440135441135442135443135444135445135446135447135448135449135450135451135452135453135454135455135456135457135458135459135460135461135462135463135464135465135466135467135468135469135470135471135472135473135474135475135476135477135478135479135480135481135482135483135484135485135486135487135488135489135490135491135492135493135494135495135496135497135498135499135500135501135502135503135504135505135506135507135508135509135510135511135512135513135514135515135516135517135518135519135520135521135522135523135524135525135526135527135528135529135530135531135532135533135534135535135536135537135538135539135540135541135542135543135544135545135546135547135548135549135550135551135552135553135554135555135556135557135558135559135560135561135562135563135564135565135566135567135568135569135570135571135572135573135574135575135576135577135578135579135580135581135582135583135584135585135586135587135588135589135590135591135592135593135594135595135596135597135598135599135600135601135602135603135604135605135606135607135608135609135610135611135612135613135614135615135616135617135618135619135620135621135622135623135624135625135626135627135628135629135630135631135632135633135634135635135636135637135638135639135640135641135642135643135644135645135646135647135648135649135650135651135652135653135654135655135656135657135658135659135660135661135662135663135664135665135666135667135668135669135670135671135672135673135674135675135676135677135678135679135680135681135682135683135684135685135686135687135688135689135690135691135692135693135694135695135696135697135698135699135700135701135702135703135704135705135706135707135708135709135710135711135712135713135714135715135716135717135718135719135720135721135722135723135724135725135726135727135728135729135730135731135732135733135734135735135736135737135738135739135740135741135742135743135744135745135746135747135748135749135750135751135752135753135754135755135756135757135758135759135760135761135762135763135764135765135766135767135768135769135770135771135772135773135774135775135776135777135778135779135780135781135782135783135784135785135786135787135788135789135790135791135792135793135794135795135796135797135798135799135800135801135802135803135804135805135806135807135808135809135810135811135812135813135814135815135816135817135818135819135820135821135822135823135824135825135826135827135828135829135830135831135832135833135834135835135836135837135838135839135840135841135842135843135844135845135846135847135848135849135850135851135852135853135854135855135856135857135858135859135860135861135862135863135864135865135866135867135868135869135870135871135872135873135874135875135876135877135878135879135880135881135882135883135884135885135886135887135888135889135890135891135892135893135894135895135896135897135898135899135900135901135902135903135904135905135906135907135908135909135910135911135912135913135914135915135916135917135918135919135920135921135922135923135924135925135926135927135928135929135930135931135932135933135934135935135936135937135938135939135940135941135942135943135944135945135946135947135948135949135950135951135952135953135954135955135956135957135958135959135960135961135962135963135964135965135966135967135968135969135970135971135972135973135974135975135976135977135978135979135980135981135982135983135984135985135986135987135988135989135990135991135992135993135994135995135996135997135998135999136000136001136002136003136004136005136006136007136008136009136010136011136012136013136014136015136016136017136018136019136020136021136022136023136024136025136026136027136028136029136030136031136032136033136034136035136036136037136038136039136040136041136042136043136044136045136046136047136048136049136050136051136052136053136054136055136056136057136058136059136060136061136062136063136064136065136066136067136068136069136070136071136072136073136074136075136076136077136078136079136080136081136082136083136084136085136086136087136088136089136090136091136092136093136094136095136096136097136098136099136100136101136102136103136104136105136106136107136108136109136110136111136112136113136114136115136116136117136118136119136120136121136122136123136124136125136126136127136128136129136130136131136132136133136134136135136136136137136138136139136140136141136142136143136144136145136146136147136148136149136150136151136152136153136154136155136156136157136158136159136160136161136162136163136164136165136166136167136168136169136170136171136172136173136174136175136176136177136178136179136180136181136182136183136184136185136186136187136188136189136190136191136192136193136194136195136196136197136198136199136200136201136202136203136204136205136206136207136208136209136210136211136212136213136214136215136216136217136218136219136220136221136222136223136224136225136226136227136228136229136230136231136232136233136234136235136236136237136238136239136240136241136242136243136244136245136246136247136248136249136250136251136252136253136254136255136256136257136258136259136260136261136262136263136264136265136266136267136268136269136270136271136272136273136274136275136276136277136278136279136280136281136282136283136284136285136286136287136288136289136290136291136292136293136294136295136296136297136298136299136300136301136302136303136304136305136306136307136308136309136310136311136312136313136314136315136316136317136318136319136320136321136322136323136324136325136326136327136328136329136330136331136332136333136334136335136336136337136338136339136340136341136342136343136344136345136346136347136348136349136350136351136352136353136354136355136356136357136358136359136360136361136362136363136364136365136366136367136368136369136370136371136372136373136374136375136376136377136378136379136380136381136382136383136384136385136386136387136388136389136390136391136392136393136394136395136396136397136398136399136400136401136402136403136404136405136406136407136408136409136410136411136412136413136414136415136416136417136418136419136420136421136422136423136424136425136426136427136428136429136430136431136432136433136434136435136436136437136438136439136440136441136442136443136444136445136446136447136448136449136450136451136452136453136454136455136456136457136458136459136460136461136462136463136464136465136466136467136468136469136470136471136472136473136474136475136476136477136478136479136480136481136482136483136484136485136486136487136488136489136490136491136492136493136494136495136496136497136498136499136500136501136502136503136504136505136506136507136508136509136510136511136512136513136514136515136516136517136518136519136520136521136522136523136524136525136526136527136528136529136530136531136532136533136534136535136536136537136538136539136540136541136542136543136544136545136546136547136548136549136550136551136552136553136554136555136556136557136558136559136560136561136562136563136564136565136566136567136568136569136570136571136572136573136574136575136576136577136578136579136580136581136582136583136584136585136586136587136588136589136590136591136592136593136594136595136596136597136598136599136600136601136602136603136604136605136606136607136608136609136610136611136612136613136614136615136616136617136618136619136620136621136622136623136624136625136626136627136628136629136630136631136632136633136634136635136636136637136638136639136640136641136642136643136644136645136646136647136648136649136650136651136652136653136654136655136656136657136658136659136660136661136662136663136664136665136666136667136668136669136670136671136672136673136674136675136676136677136678136679136680136681136682136683136684136685136686136687136688136689136690136691136692136693136694136695136696136697136698136699136700136701136702136703136704136705136706136707136708136709136710136711136712136713136714136715136716136717136718136719136720136721136722136723136724136725136726136727136728136729136730136731136732136733136734136735136736136737136738136739136740136741136742136743136744136745136746136747136748136749136750136751136752136753136754136755136756136757136758136759136760136761136762136763136764136765136766136767136768136769136770136771136772136773136774136775136776136777136778136779136780136781136782136783136784136785136786136787136788136789136790136791136792136793136794136795136796136797136798136799136800136801136802136803136804136805136806136807136808136809136810136811136812136813136814136815136816136817136818136819136820136821136822136823136824136825136826136827136828136829136830136831136832136833136834136835136836136837136838136839136840136841136842136843136844136845136846136847136848136849136850136851136852136853136854136855136856136857136858136859136860136861136862136863136864136865136866136867136868136869136870136871136872136873136874136875136876136877136878136879136880136881136882136883136884136885136886136887136888136889136890136891136892136893136894136895136896136897136898136899136900136901136902136903136904136905136906136907136908136909136910136911136912136913136914136915136916136917136918136919136920136921136922136923136924136925136926136927136928136929136930136931136932136933136934136935136936136937136938136939136940136941136942136943136944136945136946136947136948136949136950136951136952136953136954136955136956136957136958136959136960136961136962136963136964136965136966136967136968136969136970136971136972136973136974136975136976136977136978136979136980136981136982136983136984136985136986136987136988136989136990136991136992136993136994136995136996136997136998136999137000137001137002137003137004137005137006137007137008137009137010137011137012137013137014137015137016137017137018137019137020137021137022137023137024137025137026137027137028137029137030137031137032137033137034137035137036137037137038137039137040137041137042137043137044137045137046137047137048137049137050137051137052137053137054137055137056137057137058137059137060137061137062137063137064137065137066137067137068137069137070137071137072137073137074137075137076137077137078137079137080137081137082137083137084137085137086137087137088137089137090137091137092137093137094137095137096137097137098137099137100137101137102137103137104137105137106137107137108137109137110137111137112137113137114137115137116137117137118137119137120137121137122137123137124137125137126137127137128137129137130137131137132137133137134137135137136137137137138137139137140137141137142137143137144137145137146137147137148137149137150137151137152137153137154137155137156137157137158137159137160137161137162137163137164137165137166137167137168137169137170137171137172137173137174137175137176137177137178137179137180137181137182137183137184137185137186137187137188137189137190137191137192137193137194137195137196137197137198137199137200137201137202137203137204137205137206137207137208137209137210137211137212137213137214137215137216137217137218137219137220137221137222137223137224137225137226137227137228137229137230137231137232137233137234137235137236137237137238137239137240137241137242137243137244137245137246137247137248137249137250137251137252137253137254137255137256137257137258137259137260137261137262137263137264137265137266137267137268137269137270137271137272137273137274137275137276137277137278137279137280137281137282137283137284137285137286137287137288137289137290137291137292137293137294137295137296137297137298137299137300137301137302137303137304137305137306137307137308137309137310137311137312137313137314137315137316137317137318137319137320137321137322137323137324137325137326137327137328137329137330137331137332137333137334137335137336137337137338137339137340137341137342137343137344137345137346137347137348137349137350137351137352137353137354137355137356137357137358137359137360137361137362137363137364137365137366137367137368137369137370137371137372137373137374137375137376137377137378137379137380137381137382137383137384137385137386137387137388137389137390137391137392137393137394137395137396137397137398137399137400137401137402137403137404137405137406137407137408137409137410137411137412137413137414137415137416137417137418137419137420137421137422137423137424137425137426137427137428137429137430137431137432137433137434137435137436137437137438137439137440137441137442137443137444137445137446137447137448137449137450137451137452137453137454137455137456137457137458137459137460137461137462137463137464137465137466137467137468137469137470137471137472137473137474137475137476137477137478137479137480137481137482137483137484137485137486137487137488137489137490137491137492137493137494137495137496137497137498137499137500137501137502137503137504137505137506137507137508137509137510137511137512137513137514137515137516137517137518137519137520137521137522137523137524137525137526137527137528137529137530137531137532137533137534137535137536137537137538137539137540137541137542137543137544137545137546137547137548137549137550137551137552137553137554137555137556137557137558137559137560137561137562137563137564137565137566137567137568137569137570137571137572137573137574137575137576137577137578137579137580137581137582137583137584137585137586137587137588137589137590137591137592137593137594137595137596137597137598137599137600137601137602137603137604137605137606137607137608137609137610137611137612137613137614137615137616137617137618137619137620137621137622137623137624137625137626137627137628137629137630137631137632137633137634137635137636137637137638137639137640137641137642137643137644137645137646137647137648137649137650137651137652137653137654137655137656137657137658137659137660137661137662137663137664137665137666137667137668137669137670137671137672137673137674137675137676137677137678137679137680137681137682137683137684137685137686137687137688137689137690137691137692137693137694137695137696137697137698137699137700137701137702137703137704137705137706137707137708137709137710137711137712137713137714137715137716137717137718137719137720137721137722137723137724137725137726137727137728137729137730137731137732137733137734137735137736137737137738137739137740137741137742137743137744137745137746137747137748137749137750137751137752137753137754137755137756137757137758137759137760137761137762137763137764137765137766137767137768137769137770137771137772137773137774137775137776137777137778137779137780137781137782137783137784137785137786137787137788137789137790137791137792137793137794137795137796137797137798137799137800137801137802137803137804137805137806137807137808137809137810137811137812137813137814137815137816137817137818137819137820137821137822137823137824137825137826137827137828137829137830137831137832137833137834137835137836137837137838137839137840137841137842137843137844137845137846137847137848137849137850137851137852137853137854137855137856137857137858137859137860137861137862137863137864137865137866137867137868137869137870137871137872137873137874137875137876137877137878137879137880137881137882137883137884137885137886137887137888137889137890137891137892137893137894137895137896137897137898137899137900137901137902137903137904137905137906137907137908137909137910137911137912137913137914137915137916137917137918137919137920137921137922137923137924137925137926137927137928137929137930137931137932137933137934137935137936137937137938137939137940137941137942137943137944137945137946137947137948137949137950137951137952137953137954137955137956137957137958137959137960137961137962137963137964137965137966137967137968137969137970137971137972137973137974137975137976137977137978137979137980137981137982137983137984137985137986137987137988137989137990137991137992137993137994137995137996137997137998137999138000138001138002138003138004138005138006138007138008138009138010138011138012138013138014138015138016138017138018138019138020138021138022138023138024138025138026138027138028138029138030138031138032138033138034138035138036138037138038138039138040138041138042138043138044138045138046138047138048138049138050138051138052138053138054138055138056138057138058138059138060138061138062138063138064138065138066138067138068138069138070138071138072138073138074138075138076138077138078138079138080138081138082138083138084138085138086138087138088138089138090138091138092138093138094138095138096138097138098138099138100138101138102138103138104138105138106138107138108138109138110138111138112138113138114138115138116138117138118138119138120138121138122138123138124138125138126138127138128138129138130138131138132138133138134138135138136138137138138138139138140138141138142138143138144138145138146138147138148138149138150138151138152138153138154138155138156138157138158138159138160138161138162138163138164138165138166138167138168138169138170138171138172138173138174138175138176138177138178138179138180138181138182138183138184138185138186138187138188138189138190138191138192138193138194138195138196138197138198138199138200138201138202138203138204138205138206138207138208138209138210138211138212138213138214138215138216138217138218138219138220138221138222138223138224138225138226138227138228138229138230138231138232138233138234138235138236138237138238138239138240138241138242138243138244138245138246138247138248138249138250138251138252138253138254138255138256138257138258138259138260138261138262138263138264138265138266138267138268138269138270138271138272138273138274138275138276138277138278138279138280138281138282138283138284138285138286138287138288138289138290138291138292138293138294138295138296138297138298138299138300138301138302138303138304138305138306138307138308138309138310138311138312138313138314138315138316138317138318138319138320138321138322138323138324138325138326138327138328138329138330138331138332138333138334138335138336138337138338138339138340138341138342138343138344138345138346138347138348138349138350138351138352138353138354138355138356138357138358138359138360138361138362138363138364138365138366138367138368138369138370138371138372138373138374138375138376138377138378138379138380138381138382138383138384138385138386138387138388138389138390138391138392138393138394138395138396138397138398138399138400138401138402138403138404138405138406138407138408138409138410138411138412138413138414138415138416138417138418138419138420138421138422138423138424138425138426138427138428138429138430138431138432138433138434138435138436138437138438138439138440138441138442138443138444138445138446138447138448138449138450138451138452138453138454138455138456138457138458138459138460138461138462138463138464138465138466138467138468138469138470138471138472138473138474138475138476138477138478138479138480138481138482138483138484138485138486138487138488138489138490138491138492138493138494138495138496138497138498138499138500138501138502138503138504138505138506138507138508138509138510138511138512138513138514138515138516138517138518138519138520138521138522138523138524138525138526138527138528138529138530138531138532138533138534138535138536138537138538138539138540138541138542138543138544138545138546138547138548138549138550138551138552138553138554138555138556138557138558138559138560138561138562138563138564138565138566138567138568138569138570138571138572138573138574138575138576138577138578138579138580138581138582138583138584138585138586138587138588138589138590138591138592138593138594138595138596138597138598138599138600138601138602138603138604138605138606138607138608138609138610138611138612138613138614138615138616138617138618138619138620138621138622138623138624138625138626138627138628138629138630138631138632138633138634138635138636138637138638138639138640138641138642138643138644138645138646138647138648138649138650138651138652138653138654138655138656138657138658138659138660138661138662138663138664138665138666138667138668138669138670138671138672138673138674138675138676138677138678138679138680138681138682138683138684138685138686138687138688138689138690138691138692138693138694138695138696138697138698138699138700138701138702138703138704138705138706138707138708138709138710138711138712138713138714138715138716138717138718138719138720138721138722138723138724138725138726138727138728138729138730138731138732138733138734138735138736138737138738138739138740138741138742138743138744138745138746138747138748138749138750138751138752138753138754138755138756138757138758138759138760138761138762138763138764138765138766138767138768138769138770138771138772138773138774138775138776138777138778138779138780138781138782138783138784138785138786138787138788138789138790138791138792138793138794138795138796138797138798138799138800138801138802138803138804138805138806138807138808138809138810138811138812138813138814138815138816138817138818138819138820138821138822138823138824138825138826138827138828138829138830138831138832138833138834138835138836138837138838138839138840138841138842138843138844138845138846138847138848138849138850138851138852138853138854138855138856138857138858138859138860138861138862138863138864138865138866138867138868138869138870138871138872138873138874138875138876138877138878138879138880138881138882138883138884138885138886138887138888138889138890138891138892138893138894138895138896138897138898138899138900138901138902138903138904138905138906138907138908138909138910138911138912138913138914138915138916138917138918138919138920138921138922138923138924138925138926138927138928138929138930138931138932138933138934138935138936138937138938138939138940138941138942138943138944138945138946138947138948138949138950138951138952138953138954138955138956138957138958138959138960138961138962138963138964138965138966138967138968138969138970138971138972138973138974138975138976138977138978138979138980138981138982138983138984138985138986138987138988138989138990138991138992138993138994138995138996138997138998138999139000139001139002139003139004139005139006139007139008139009139010139011139012139013139014139015139016139017139018139019139020139021139022139023139024139025139026139027139028139029139030139031139032139033139034139035139036139037139038139039139040139041139042139043139044139045139046139047139048139049139050139051139052139053139054139055139056139057139058139059139060139061139062139063139064139065139066139067139068139069139070139071139072139073139074139075139076139077139078139079139080139081139082139083139084139085139086139087139088139089139090139091139092139093139094139095139096139097139098139099139100139101139102139103139104139105139106139107139108139109139110139111139112139113139114139115139116139117139118139119139120139121139122139123139124139125139126139127139128139129139130139131139132139133139134139135139136139137139138139139139140139141139142139143139144139145139146139147139148139149139150139151139152139153139154139155139156139157139158139159139160139161139162139163139164139165139166139167139168139169139170139171139172139173139174139175139176139177139178139179139180139181139182139183139184139185139186139187139188139189139190139191139192139193139194139195139196139197139198139199139200139201139202139203139204139205139206139207139208139209139210139211139212139213139214139215139216139217139218139219139220139221139222139223139224139225139226139227139228139229139230139231139232139233139234139235139236139237139238139239139240139241139242139243139244139245139246139247139248139249139250139251139252139253139254139255139256139257139258139259139260139261139262139263139264139265139266139267139268139269139270139271139272139273139274139275139276139277139278139279139280139281139282139283139284139285139286139287139288139289139290139291139292139293139294139295139296139297139298139299139300139301139302139303139304139305139306139307139308139309139310139311139312139313139314139315139316139317139318139319139320139321139322139323139324139325139326139327139328139329139330139331139332139333139334139335139336139337139338139339139340139341139342139343139344139345139346139347139348139349139350139351139352139353139354139355139356139357139358139359139360139361139362139363139364139365139366139367139368139369139370139371139372139373139374139375139376139377139378139379139380139381139382139383139384139385139386139387139388139389139390139391139392139393139394139395139396139397139398139399139400139401139402139403139404139405139406139407139408139409139410139411139412139413139414139415139416139417139418139419139420139421139422139423139424139425139426139427139428139429139430139431139432139433139434139435139436139437139438139439139440139441139442139443139444139445139446139447139448139449139450139451139452139453139454139455139456139457139458139459139460139461139462139463139464139465139466139467139468139469139470139471139472139473139474139475139476139477139478139479139480139481139482139483139484139485139486139487139488139489139490139491139492139493139494139495139496139497139498139499139500139501139502139503139504139505139506139507139508139509139510139511139512139513139514139515139516139517139518139519139520139521139522139523139524139525139526139527139528139529139530139531139532139533139534139535139536139537139538139539139540139541139542139543139544139545139546139547139548139549139550139551139552139553139554139555139556139557139558139559139560139561139562139563139564139565139566139567139568139569139570139571139572139573139574139575139576139577139578139579139580139581139582139583139584139585139586139587139588139589139590139591139592139593139594139595139596139597139598139599139600139601139602139603139604139605139606139607139608139609139610139611139612139613139614139615139616139617139618139619139620139621139622139623139624139625139626139627139628139629139630139631139632139633139634139635139636139637139638139639139640139641139642139643139644139645139646139647139648139649139650139651139652139653139654139655139656139657139658139659139660139661139662139663139664139665139666139667139668139669139670139671139672139673139674139675139676139677139678139679139680139681139682139683139684139685139686139687139688139689139690139691139692139693139694139695139696139697139698139699139700139701139702139703139704139705139706139707139708139709139710139711139712139713139714139715139716139717139718139719139720139721139722139723139724139725139726139727139728139729139730139731139732139733139734139735139736139737139738139739139740139741139742139743139744139745139746139747139748139749139750139751139752139753139754139755139756139757139758139759139760139761139762139763139764139765139766139767139768139769139770139771139772139773139774139775139776139777139778139779139780139781139782139783139784139785139786139787139788139789139790139791139792139793139794139795139796139797139798139799139800139801139802139803139804139805139806139807139808139809139810139811139812139813139814139815139816139817139818139819139820139821139822139823139824139825139826139827139828139829139830139831139832139833139834139835139836139837139838139839139840139841139842139843139844139845139846139847139848139849139850139851139852139853139854139855139856139857139858139859139860139861139862139863139864139865139866139867139868139869139870139871139872139873139874139875139876139877139878139879139880139881139882139883139884139885139886139887139888139889139890139891139892139893139894139895139896139897139898139899139900139901139902139903139904139905139906139907139908139909139910139911139912139913139914139915139916139917139918139919139920139921139922139923139924139925139926139927139928139929139930139931139932139933139934139935139936139937139938139939139940139941139942139943139944139945139946139947139948139949139950139951139952139953139954139955139956139957139958139959139960139961139962139963139964139965139966139967139968139969139970139971139972139973139974139975139976139977139978139979139980139981139982139983139984139985139986139987139988139989139990139991139992139993139994139995139996139997139998139999140000140001140002140003140004140005140006140007140008140009140010140011140012140013140014140015140016140017140018140019140020140021140022140023140024140025140026140027140028140029140030140031140032140033140034140035140036140037140038140039140040140041140042140043140044140045140046140047140048140049140050140051140052140053140054140055140056140057140058140059140060140061140062140063140064140065140066140067140068140069140070140071140072140073140074140075140076140077140078140079140080140081140082140083140084140085140086140087140088140089140090140091140092140093140094140095140096140097140098140099140100140101140102140103140104140105140106140107140108140109140110140111140112140113140114140115140116140117140118140119140120140121140122140123140124140125140126140127140128140129140130140131140132140133140134140135140136140137140138140139140140140141140142140143140144140145140146140147140148140149140150140151140152140153140154140155140156140157140158140159140160140161140162140163140164140165140166140167140168140169140170140171140172140173140174140175140176140177140178140179140180140181140182140183140184140185140186140187140188140189140190140191140192140193140194140195140196140197140198140199140200140201140202140203140204140205140206140207140208140209140210140211140212140213140214140215140216140217140218140219140220140221140222140223140224140225140226140227140228140229140230140231140232140233140234140235140236140237140238140239140240140241140242140243140244140245140246140247140248140249140250140251140252140253140254140255140256140257140258140259140260140261140262140263140264140265140266140267140268140269140270140271140272140273140274140275140276140277140278140279140280140281140282140283140284140285140286140287140288140289140290140291140292140293140294140295140296140297140298140299140300140301140302140303140304140305140306140307140308140309140310140311140312140313140314140315140316140317140318140319140320140321140322140323140324140325140326140327140328140329140330140331140332140333140334140335140336140337140338140339140340140341140342140343140344140345140346140347140348140349140350140351140352140353140354140355140356140357140358140359140360140361140362140363140364140365140366140367140368140369140370140371140372140373140374140375140376140377140378140379140380140381140382140383140384140385140386140387140388140389140390140391140392140393140394140395140396140397140398140399140400140401140402140403140404140405140406140407140408140409140410140411140412140413140414140415140416140417140418140419140420140421140422140423140424140425140426140427140428140429140430140431140432140433140434140435140436140437140438140439140440140441140442140443140444140445140446140447140448140449140450140451140452140453140454140455140456140457140458140459140460140461140462140463140464140465140466140467140468140469140470140471140472140473140474140475140476140477140478140479140480140481140482140483140484140485140486140487140488140489140490140491140492140493140494140495140496140497140498140499140500140501140502140503140504140505140506140507140508140509140510140511140512140513140514140515140516140517140518140519140520140521140522140523140524140525140526140527140528140529140530140531140532140533140534140535140536140537140538140539140540140541140542140543140544140545140546140547140548140549140550140551140552140553140554140555140556140557140558140559140560140561140562140563140564140565140566140567140568140569140570140571140572140573140574140575140576140577140578140579140580140581140582140583140584140585140586140587140588140589140590140591140592140593140594140595140596140597140598140599140600140601140602140603140604140605140606140607140608140609140610140611140612140613140614140615140616140617140618140619140620140621140622140623140624140625140626140627140628140629140630140631140632140633140634140635140636140637140638140639140640140641140642140643140644140645140646140647140648140649140650140651140652140653140654140655140656140657140658140659140660140661140662140663140664140665140666140667140668140669140670140671140672140673140674140675140676140677140678140679140680140681140682140683140684140685140686140687140688140689140690140691140692140693140694140695140696140697140698140699140700140701140702140703140704140705140706140707140708140709140710140711140712140713140714140715140716140717140718140719140720140721140722140723140724140725140726140727140728140729140730140731140732140733140734140735140736140737140738140739140740140741140742140743140744140745140746140747140748140749140750140751140752140753140754140755140756140757140758140759140760140761140762140763140764140765140766140767140768140769140770140771140772140773140774140775140776140777140778140779140780140781140782140783140784140785140786140787140788140789140790140791140792140793140794140795140796140797140798140799140800140801140802140803140804140805140806140807140808140809140810140811140812140813140814140815140816140817140818140819140820140821140822140823140824140825140826140827140828140829140830140831140832140833140834140835140836140837140838140839140840140841140842140843140844140845140846140847140848140849140850140851140852140853140854140855140856140857140858140859140860140861140862140863140864140865140866140867140868140869140870140871140872140873140874140875140876140877140878140879140880140881140882140883140884140885140886140887140888140889140890140891140892140893140894140895140896140897140898140899140900140901140902140903140904140905140906140907140908140909140910140911140912140913140914140915140916140917140918140919140920140921140922140923140924140925140926140927140928140929140930140931140932140933140934140935140936140937140938140939140940140941140942140943140944140945140946140947140948140949140950140951140952140953140954140955140956140957140958140959140960140961140962140963140964140965140966140967140968140969140970140971140972140973140974140975140976140977140978140979140980140981140982140983140984140985140986140987140988140989140990140991140992140993140994140995140996140997140998140999141000141001141002141003141004141005141006141007141008141009141010141011141012141013141014141015141016141017141018141019141020141021141022141023141024141025141026141027141028141029141030141031141032141033141034141035141036141037141038141039141040141041141042141043141044141045141046141047141048141049141050141051141052141053141054141055141056141057141058141059141060141061141062141063141064141065141066141067141068141069141070141071141072141073141074141075141076141077141078141079141080141081141082141083141084141085141086141087141088141089141090141091141092141093141094141095141096141097141098141099141100141101141102141103141104141105141106141107141108141109141110141111141112141113141114141115141116141117141118141119141120141121141122141123141124141125141126141127141128141129141130141131141132141133141134141135141136141137141138141139141140141141141142141143141144141145141146141147141148141149141150141151141152141153141154141155141156141157141158141159141160141161141162141163141164141165141166141167141168141169141170141171141172141173141174141175141176141177141178141179141180141181141182141183141184141185141186141187141188141189141190141191141192141193141194141195141196141197141198141199141200141201141202141203141204141205141206141207141208141209141210141211141212141213141214141215141216141217141218141219141220141221141222141223141224141225141226141227141228141229141230141231141232141233141234141235141236141237141238141239141240141241141242141243141244141245141246141247141248141249141250141251141252141253141254141255141256141257141258141259141260141261141262141263141264141265141266141267141268141269141270141271141272141273141274141275141276141277141278141279141280141281141282141283141284141285141286141287141288141289141290141291141292141293141294141295141296141297141298141299141300141301141302141303141304141305141306141307141308141309141310141311141312141313141314141315141316141317141318141319141320141321141322141323141324141325141326141327141328141329141330141331141332141333141334141335141336141337141338141339141340141341141342141343141344141345141346141347141348141349141350141351141352141353141354141355141356141357141358141359141360141361141362141363141364141365141366141367141368141369141370141371141372141373141374141375141376141377141378141379141380141381141382141383141384141385141386141387141388141389141390141391141392141393141394141395141396141397141398141399141400141401141402141403141404141405141406141407141408141409141410141411141412141413141414141415141416141417141418141419141420141421141422141423141424141425141426141427141428141429141430141431141432141433141434141435141436141437141438141439141440141441141442141443141444141445141446141447141448141449141450141451141452141453141454141455141456141457141458141459141460141461141462141463141464141465141466141467141468141469141470141471141472141473141474141475141476141477141478141479141480141481141482141483141484141485141486141487141488141489141490141491141492141493141494141495141496141497141498141499141500141501141502141503141504141505141506141507141508141509141510141511141512141513141514141515141516141517141518141519141520141521141522141523141524141525141526141527141528141529141530141531141532141533141534141535141536141537141538141539141540141541141542141543141544141545141546141547141548141549141550141551141552141553141554141555141556141557141558141559141560141561141562141563141564141565141566141567141568141569141570141571141572141573141574141575141576141577141578141579141580141581141582141583141584141585141586141587141588141589141590141591141592141593141594141595141596141597141598141599141600141601141602141603141604141605141606141607141608141609141610141611141612141613141614141615141616141617141618141619141620141621141622141623141624141625141626141627141628141629141630141631141632141633141634141635141636141637141638141639141640141641141642141643141644141645141646141647141648141649141650141651141652141653141654141655141656141657141658141659141660141661141662141663141664141665141666141667141668141669141670141671141672141673141674141675141676141677141678141679141680141681141682141683141684141685141686141687141688141689141690141691141692141693141694141695141696141697141698141699141700141701141702141703141704141705141706141707141708141709141710141711141712141713141714141715141716141717141718141719141720141721141722141723141724141725141726141727141728141729141730141731141732141733141734141735141736141737141738141739141740141741141742141743141744141745141746141747141748141749141750141751141752141753141754141755141756141757141758141759141760141761141762141763141764141765141766141767141768141769141770141771141772141773141774141775141776141777141778141779141780141781141782141783141784141785141786141787141788141789141790141791141792141793141794141795141796141797141798141799141800141801141802141803141804141805141806141807141808141809141810141811141812141813141814141815141816141817141818141819141820141821141822141823141824141825141826141827141828141829141830141831141832141833141834141835141836141837141838141839141840141841141842141843141844141845141846141847141848141849141850141851141852141853141854141855141856141857141858141859141860141861141862141863141864141865141866141867141868141869141870141871141872141873141874141875141876141877141878141879141880141881141882141883141884141885141886141887141888141889141890141891141892141893141894141895141896141897141898141899141900141901141902141903141904141905141906141907141908141909141910141911141912141913141914141915141916141917141918141919141920141921141922141923141924141925141926141927141928141929141930141931141932141933141934141935141936141937141938141939141940141941141942141943141944141945141946141947141948141949141950141951141952141953141954141955141956141957141958141959141960141961141962141963141964141965141966141967141968141969141970141971141972141973141974141975141976141977141978141979141980141981141982141983141984141985141986141987141988141989141990141991141992141993141994141995141996141997141998141999142000142001142002142003142004142005142006142007142008142009142010142011142012142013142014142015142016142017142018142019142020142021142022142023142024142025142026142027142028142029142030142031142032142033142034142035142036142037142038142039142040142041142042142043142044142045142046142047142048142049142050142051142052142053142054142055142056142057142058142059142060142061142062142063142064142065142066142067142068142069142070142071142072142073142074142075142076142077142078142079142080142081142082142083142084142085142086142087142088142089142090142091142092142093142094142095142096142097142098142099142100142101142102142103142104142105142106142107142108142109142110142111142112142113142114142115142116142117142118142119142120142121142122142123142124142125142126142127142128142129142130142131142132142133142134142135142136142137142138142139142140142141142142142143142144142145142146142147142148142149142150142151142152142153142154142155142156142157142158142159142160142161142162142163142164142165142166142167142168142169142170142171142172142173142174142175142176142177142178142179142180142181142182142183142184142185142186142187142188142189142190142191142192142193142194142195142196142197142198142199142200142201142202142203142204142205142206142207142208142209142210142211142212142213142214142215142216142217142218142219142220142221142222142223142224142225142226142227142228142229142230142231142232142233142234142235142236142237142238142239142240142241142242142243142244142245142246142247142248142249142250142251142252142253142254142255142256142257142258142259142260142261142262142263142264142265142266142267142268142269142270142271142272142273142274142275142276142277142278142279142280142281142282142283142284142285142286142287142288142289142290142291142292142293142294142295142296142297142298142299142300142301142302142303142304142305142306142307142308142309142310142311142312142313142314142315142316142317142318142319142320142321142322142323142324142325142326142327142328142329142330142331142332142333142334142335142336142337142338142339142340142341142342142343142344142345142346142347142348142349142350142351142352142353142354142355142356142357142358142359142360142361142362142363142364142365142366142367142368142369142370142371142372142373142374142375142376142377142378142379142380142381142382142383142384142385142386142387142388142389142390142391142392142393142394142395142396142397142398142399142400142401142402142403142404142405142406142407142408142409142410142411142412142413142414142415142416142417142418142419142420142421142422142423142424142425142426142427142428142429142430142431142432142433142434142435142436142437142438142439142440142441142442142443142444142445142446142447142448142449142450142451142452142453142454142455142456142457142458142459142460142461142462142463142464142465142466142467142468142469142470142471142472142473142474142475142476142477142478142479142480142481142482142483142484142485142486142487142488142489142490142491142492142493142494142495142496142497142498142499142500142501142502142503142504142505142506142507142508142509142510142511142512142513142514142515142516142517142518142519142520142521142522142523142524142525142526142527142528142529142530142531142532142533142534142535142536142537142538142539142540142541142542142543142544142545142546142547142548142549142550142551142552142553142554142555142556142557142558142559142560142561142562142563142564142565142566142567142568142569142570142571142572142573142574142575142576142577142578142579142580142581142582142583142584142585142586142587142588142589142590142591142592142593142594142595142596142597142598142599142600142601142602142603142604142605142606142607142608142609142610142611142612142613142614142615142616142617142618142619142620142621142622142623142624142625142626142627142628142629142630142631142632142633142634142635142636142637142638142639142640142641142642142643142644142645142646142647142648142649142650142651142652142653142654142655142656142657142658142659142660142661142662142663142664142665142666142667142668142669142670142671142672142673142674142675142676142677142678142679142680142681142682142683142684142685142686142687142688142689142690142691142692142693142694142695142696142697142698142699142700142701142702142703142704142705142706142707142708142709142710142711142712142713142714142715142716142717142718142719142720142721142722142723142724142725142726142727142728142729142730142731142732142733142734142735142736142737142738142739142740142741142742142743142744142745142746142747142748142749142750142751142752142753142754142755142756142757142758142759142760142761142762142763142764142765142766142767142768142769142770142771142772142773142774142775142776142777142778142779142780142781142782142783142784142785142786142787142788142789142790142791142792142793142794142795142796142797142798142799142800142801142802142803142804142805142806142807142808142809142810142811142812142813142814142815142816142817142818142819142820142821142822142823142824142825142826142827142828142829142830142831142832142833142834142835142836142837142838142839142840142841142842142843142844142845142846142847142848142849142850142851142852142853142854142855142856142857142858142859142860142861142862142863142864142865142866142867142868142869142870142871142872142873142874142875142876142877142878142879142880142881142882142883142884142885142886142887142888142889142890142891142892142893142894142895142896142897142898142899142900142901142902142903142904142905142906142907142908142909142910142911142912142913142914142915142916142917142918142919142920142921142922142923142924142925142926142927142928142929142930142931142932142933142934142935142936142937142938142939142940142941142942142943142944142945142946142947142948142949142950142951142952142953142954142955142956142957142958142959142960142961142962142963142964142965142966142967142968142969142970142971142972142973142974142975142976142977142978142979142980142981142982142983142984142985142986142987142988142989142990142991142992142993142994142995142996142997142998142999143000143001143002143003143004143005143006143007143008143009143010143011143012143013143014143015143016143017143018143019143020143021143022143023143024143025143026143027143028143029143030143031143032143033143034143035143036143037143038143039143040143041143042143043143044143045143046143047143048143049143050143051143052143053143054143055143056143057143058143059143060143061143062143063143064143065143066143067143068143069143070143071143072143073143074143075143076143077143078143079143080143081143082143083143084143085143086143087143088143089143090143091143092143093143094143095143096143097143098143099143100143101143102143103143104143105143106143107143108143109143110143111143112143113143114143115143116143117143118143119143120143121143122143123143124143125143126143127143128143129143130143131143132143133143134143135143136143137143138143139143140143141143142143143143144143145143146143147143148143149143150143151143152143153143154143155143156143157143158143159143160143161143162143163143164143165143166143167143168143169143170143171143172143173143174143175143176143177143178143179143180143181143182143183143184143185143186143187143188143189143190143191143192143193143194143195143196143197143198143199143200143201143202143203143204143205143206143207143208143209143210143211143212143213143214143215143216143217143218143219143220143221143222143223143224143225143226143227143228143229143230143231143232143233143234143235143236143237143238143239143240143241143242143243143244143245143246143247143248143249143250143251143252143253143254143255143256143257143258143259143260143261143262143263143264143265143266143267143268143269143270143271143272143273143274143275143276143277143278143279143280143281143282143283143284143285143286143287143288143289143290143291143292143293143294143295143296143297143298143299143300143301143302143303143304143305143306143307143308143309143310143311143312143313143314143315143316143317143318143319143320143321143322143323143324143325143326143327143328143329143330143331143332143333143334143335143336143337143338143339143340143341143342143343143344143345143346143347143348143349143350143351143352143353143354143355143356143357143358143359143360143361143362143363143364143365143366143367143368143369143370143371143372143373143374143375143376143377143378143379143380143381143382143383143384143385143386143387143388143389143390143391143392143393143394143395143396143397143398143399143400143401143402143403143404143405143406143407143408143409143410143411143412143413143414143415143416143417143418143419143420143421143422143423143424143425143426143427143428143429143430143431143432143433143434143435143436143437143438143439143440143441143442143443143444143445143446143447143448143449143450143451143452143453143454143455143456143457143458143459143460143461143462143463143464143465143466143467143468143469143470143471143472143473143474143475143476143477143478143479143480143481143482143483143484143485143486143487143488143489143490143491143492143493143494143495143496143497143498143499143500143501143502143503143504143505143506143507143508143509143510143511143512143513143514143515143516143517143518143519143520143521143522143523143524143525143526143527143528143529143530143531143532143533143534143535143536143537143538143539143540143541143542143543143544143545143546143547143548143549143550143551143552143553143554143555143556143557143558143559143560143561143562143563143564143565143566143567143568143569143570143571143572143573143574143575143576143577143578143579143580143581143582143583143584143585143586143587143588143589143590143591143592143593143594143595143596143597143598143599143600143601143602143603143604143605143606143607143608143609143610143611143612143613143614143615143616143617143618143619143620143621143622143623143624143625143626143627143628143629143630143631143632143633143634143635143636143637143638143639143640143641143642143643143644143645143646143647143648143649143650143651143652143653143654143655143656143657143658143659143660143661143662143663143664143665143666143667143668143669143670143671143672143673143674143675143676143677143678143679143680143681143682143683143684143685143686143687143688143689143690143691143692143693143694143695143696143697143698143699143700143701143702143703143704143705143706143707143708143709143710143711143712143713143714143715143716143717143718143719143720143721143722143723143724143725143726143727143728143729143730143731143732143733143734143735143736143737143738143739143740143741143742143743143744143745143746143747143748143749143750143751143752143753143754143755143756143757143758143759143760143761143762143763143764143765143766143767143768143769143770143771143772143773143774143775143776143777143778143779143780143781143782143783143784143785143786143787143788143789143790143791143792143793143794143795143796143797143798143799143800143801143802143803143804143805143806143807143808143809143810143811143812143813143814143815143816143817143818143819143820143821143822143823143824143825143826143827143828143829143830143831143832143833143834143835143836143837143838143839143840143841143842143843143844143845143846143847143848143849143850143851143852143853143854143855143856143857143858143859143860143861143862143863143864143865143866143867143868143869143870143871143872143873143874143875143876143877143878143879143880143881143882143883143884143885143886143887143888143889143890143891143892143893143894143895143896143897143898143899143900143901143902143903143904143905143906143907143908143909143910143911143912143913143914143915143916143917143918143919143920143921143922143923143924143925143926143927143928143929143930143931143932143933143934143935143936143937143938143939143940143941143942143943143944143945143946143947143948143949143950143951143952143953143954143955143956143957143958143959143960143961143962143963143964143965143966143967143968143969143970143971143972143973143974143975143976143977143978143979143980143981143982143983143984143985143986143987143988143989143990143991143992143993143994143995143996143997143998143999144000144001144002144003144004144005144006144007144008144009144010144011144012144013144014144015144016144017144018144019144020144021144022144023144024144025144026144027144028144029144030144031144032144033144034144035144036144037144038144039144040144041144042144043144044144045144046144047144048144049144050144051144052144053144054144055144056144057144058144059144060144061144062144063144064144065144066144067144068144069144070144071144072144073144074144075144076144077144078144079144080144081144082144083144084144085144086144087144088144089144090144091144092144093144094144095144096144097144098144099144100144101144102144103144104144105144106144107144108144109144110144111144112144113144114144115144116144117144118144119144120144121144122144123144124144125144126144127144128144129144130144131144132144133144134144135144136144137144138144139144140144141144142144143144144144145144146144147144148144149144150144151144152144153144154144155144156144157144158144159144160144161144162144163144164144165144166144167144168144169144170144171144172144173144174144175144176144177144178144179144180144181144182144183144184144185144186144187144188144189144190144191144192144193144194144195144196144197144198144199144200144201144202144203144204144205144206144207144208144209144210144211144212144213144214144215144216144217144218144219144220144221144222144223144224144225144226144227144228144229144230144231144232144233144234144235144236144237144238144239144240144241144242144243144244144245144246144247144248144249144250144251144252144253144254144255144256144257144258144259144260144261144262144263144264144265144266144267144268144269144270144271144272144273144274144275144276144277144278144279144280144281144282144283144284144285144286144287144288144289144290144291144292144293144294144295144296144297144298144299144300144301144302144303144304144305144306144307144308144309144310144311144312144313144314144315144316144317144318144319144320144321144322144323144324144325144326144327144328144329144330144331144332144333144334144335144336144337144338144339144340144341144342144343144344144345144346144347144348144349144350144351144352144353144354144355144356144357144358144359144360144361144362144363144364144365144366144367144368144369144370144371144372144373144374144375144376144377144378144379144380144381144382144383144384144385144386144387144388144389144390144391144392144393144394144395144396144397144398144399144400144401144402144403144404144405144406144407144408144409144410144411144412144413144414144415144416144417144418144419144420144421144422144423144424144425144426144427144428144429144430144431144432144433144434144435144436144437144438144439144440144441144442144443144444144445144446144447144448144449144450144451144452144453144454144455144456144457144458144459144460144461144462144463144464144465144466144467144468144469144470144471144472144473144474144475144476144477144478144479144480144481144482144483144484144485144486144487144488144489144490144491144492144493144494144495144496144497144498144499144500144501144502144503144504144505144506144507144508144509144510144511144512144513144514144515144516144517144518144519144520144521144522144523144524144525144526144527144528144529144530144531144532144533144534144535144536144537144538144539144540144541144542144543144544144545144546144547144548144549144550144551144552144553144554144555144556144557144558144559144560144561144562144563144564144565144566144567144568144569144570144571144572144573144574144575144576144577144578144579144580144581144582144583144584144585144586144587144588144589144590144591144592144593144594144595144596144597144598144599144600144601144602144603144604144605144606144607144608144609144610144611144612144613144614144615144616144617144618144619144620144621144622144623144624144625144626144627144628144629144630144631144632144633144634144635144636144637144638144639144640144641144642144643144644144645144646144647144648144649144650144651144652144653144654144655144656144657144658144659144660144661144662144663144664144665144666144667144668144669144670144671144672144673144674144675144676144677144678144679144680144681144682144683144684144685144686144687144688144689144690144691144692144693144694144695144696144697144698144699144700144701144702144703144704144705144706144707144708144709144710144711144712144713144714144715144716144717144718144719144720144721144722144723144724144725144726144727144728144729144730144731144732144733144734144735144736144737144738144739144740144741144742144743144744144745144746144747144748144749144750144751144752144753144754144755144756144757144758144759144760144761144762144763144764144765144766144767144768144769144770144771144772144773144774144775144776144777144778144779144780144781144782144783144784144785144786144787144788144789144790144791144792144793144794144795144796144797144798144799144800144801144802144803144804144805144806144807144808144809144810144811144812144813144814144815144816144817144818144819144820144821144822144823144824144825144826144827144828144829144830144831144832144833144834144835144836144837144838144839144840144841144842144843144844144845144846144847144848144849144850144851144852144853144854144855144856144857144858144859144860144861144862144863144864144865144866144867144868144869144870144871144872144873144874144875144876144877144878144879144880144881144882144883144884144885144886144887144888144889144890144891144892144893144894144895144896144897144898144899144900144901144902144903144904144905144906144907144908144909144910144911144912144913144914144915144916144917144918144919144920144921144922144923144924144925144926144927144928144929144930144931144932144933144934144935144936144937144938144939144940144941144942144943144944144945144946144947144948144949144950144951144952144953144954144955144956144957144958144959144960144961144962144963144964144965144966144967144968144969144970144971144972144973144974144975144976144977144978144979144980144981144982144983144984144985144986144987144988144989144990144991144992144993144994144995144996144997144998144999145000145001145002145003145004145005145006145007145008145009145010145011145012145013145014145015145016145017145018145019145020145021145022145023145024145025145026145027145028145029145030145031145032145033145034145035145036145037145038145039145040145041145042145043145044145045145046145047145048145049145050145051145052145053145054145055145056145057145058145059145060145061145062145063145064145065145066145067145068145069145070145071145072145073145074145075145076145077145078145079145080145081145082145083145084145085145086145087145088145089145090145091145092145093145094145095145096145097145098145099145100145101145102145103145104145105145106145107145108145109145110145111145112145113145114145115145116145117145118145119145120145121145122145123145124145125145126145127145128145129145130145131145132145133145134145135145136145137145138145139145140145141145142145143145144145145145146145147145148145149145150145151145152145153145154145155145156145157145158145159145160145161145162145163145164145165145166145167145168145169145170145171145172145173145174145175145176145177145178145179145180145181145182145183145184145185145186145187145188145189145190145191145192145193145194145195145196145197145198145199145200145201145202145203145204145205145206145207145208145209145210145211145212145213145214145215145216145217145218145219145220145221145222145223145224145225145226145227145228145229145230145231145232145233145234145235145236145237145238145239145240145241145242145243145244145245145246145247145248145249145250145251145252145253145254145255145256145257145258145259145260145261145262145263145264145265145266145267145268145269145270145271145272145273145274145275145276145277145278145279145280145281145282145283145284145285145286145287145288145289145290145291145292145293145294145295145296145297145298145299145300145301145302145303145304145305145306145307145308145309145310145311145312145313145314145315145316145317145318145319145320145321145322145323145324145325145326145327145328145329145330145331145332145333145334145335145336145337145338145339145340145341145342145343145344145345145346145347145348145349145350145351145352145353145354145355145356145357145358145359145360145361145362145363145364145365145366145367145368145369145370145371145372145373145374145375145376145377145378145379145380145381145382145383145384145385145386145387145388145389145390145391145392145393145394145395145396145397145398145399145400145401145402145403145404145405145406145407145408145409145410145411145412145413145414145415145416145417145418145419145420145421145422145423145424145425145426145427145428145429145430145431145432145433145434145435145436145437145438145439145440145441145442145443145444145445145446145447145448145449145450145451145452145453145454145455145456145457145458145459145460145461145462145463145464145465145466145467145468145469145470145471145472145473145474145475145476145477145478145479145480145481145482145483145484145485145486145487145488145489145490145491145492145493145494145495145496145497145498145499145500145501145502145503145504145505145506145507145508145509145510145511145512145513145514145515145516145517145518145519145520145521145522145523145524145525145526145527145528145529145530145531145532145533145534145535145536145537145538145539145540145541145542145543145544145545145546145547145548145549145550145551145552145553145554145555145556145557145558145559145560145561145562145563145564145565145566145567145568145569145570145571145572145573145574145575145576145577145578145579145580145581145582145583145584145585145586145587145588145589145590145591145592145593145594145595145596145597145598145599145600145601145602145603145604145605145606145607145608145609145610145611145612145613145614145615145616145617145618145619145620145621145622145623145624145625145626145627145628145629145630145631145632145633145634145635145636145637145638145639145640145641145642145643145644145645145646145647145648145649145650145651145652145653145654145655145656145657145658145659145660145661145662145663145664145665145666145667145668145669145670145671145672145673145674145675145676145677145678145679145680145681145682145683145684145685145686145687145688145689145690145691145692145693145694145695145696145697145698145699145700145701145702145703145704145705145706145707145708145709145710145711145712145713145714145715145716145717145718145719145720145721145722145723145724145725145726145727145728145729145730145731145732145733145734145735145736145737145738145739145740145741145742145743145744145745145746145747145748145749145750145751145752145753145754145755145756145757145758145759145760145761145762145763145764145765145766145767145768145769145770145771145772145773145774145775145776145777145778145779145780145781145782145783145784145785145786145787145788145789145790145791145792145793145794145795145796145797145798145799145800145801145802145803145804145805145806145807145808145809145810145811145812145813145814145815145816145817145818145819145820145821145822145823145824145825145826145827145828145829145830145831145832145833145834145835145836145837145838145839145840145841145842145843145844145845145846145847145848145849145850145851145852145853145854145855145856145857145858145859145860145861145862145863145864145865145866145867145868145869145870145871145872145873145874145875145876145877145878145879145880145881145882145883145884145885145886145887145888145889145890145891145892145893145894145895145896145897145898145899145900145901145902145903145904145905145906145907145908145909145910145911145912145913145914145915145916145917145918145919145920145921145922145923145924145925145926145927145928145929145930145931145932145933145934145935145936145937145938145939145940145941145942145943145944145945145946145947145948145949145950145951145952145953145954145955145956145957145958145959145960145961145962145963145964145965145966145967145968145969145970145971145972145973145974145975145976145977145978145979145980145981145982145983145984145985145986145987145988145989145990145991145992145993145994145995145996145997145998145999146000146001146002146003146004146005146006146007146008146009146010146011146012146013146014146015146016146017146018146019146020146021146022146023146024146025146026146027146028146029146030146031146032146033146034146035146036146037146038146039146040146041146042146043146044146045146046146047146048146049146050146051146052146053146054146055146056146057146058146059146060146061146062146063146064146065146066146067146068146069146070146071146072146073146074146075146076146077146078146079146080146081146082146083146084146085146086146087146088146089146090146091146092146093146094146095146096146097146098146099146100146101146102146103146104146105146106146107146108146109146110146111146112146113146114146115146116146117146118146119146120146121146122146123146124146125146126146127146128146129146130146131146132146133146134146135146136146137146138146139146140146141146142146143146144146145146146146147146148146149146150146151146152146153146154146155146156146157146158146159146160146161146162146163146164146165146166146167146168146169146170146171146172146173146174146175146176146177146178146179146180146181146182146183146184146185146186146187146188146189146190146191146192146193146194146195146196146197146198146199146200146201146202146203146204146205146206146207146208146209146210146211146212146213146214146215146216146217146218146219146220146221146222146223146224146225146226146227146228146229146230146231146232146233146234146235146236146237146238146239146240146241146242146243146244146245146246146247146248146249146250146251146252146253146254146255146256146257146258146259146260146261146262146263146264146265146266146267146268146269146270146271146272146273146274146275146276146277146278146279146280146281146282146283146284146285146286146287146288146289146290146291146292146293146294146295146296146297146298146299146300146301146302146303146304146305146306146307146308146309146310146311146312146313146314146315146316146317146318146319146320146321146322146323146324146325146326146327146328146329146330146331146332146333146334146335146336146337146338146339146340146341146342146343146344146345146346146347146348146349146350146351146352146353146354146355146356146357146358146359146360146361146362146363146364146365146366146367146368146369146370146371146372146373146374146375146376146377146378146379146380146381146382146383146384146385146386146387146388146389146390146391146392146393146394146395146396146397146398146399146400146401146402146403146404146405146406146407146408146409146410146411146412146413146414146415146416146417146418146419146420146421146422146423146424146425146426146427146428146429146430146431146432146433146434146435146436146437146438146439146440146441146442146443146444146445146446146447146448146449146450146451146452146453146454146455146456146457146458146459146460146461146462146463146464146465146466146467146468146469146470146471146472146473146474146475146476146477146478146479146480146481146482146483146484146485146486146487146488146489146490146491146492146493146494146495146496146497146498146499146500146501146502146503146504146505146506146507146508146509146510146511146512146513146514146515146516146517146518146519146520146521146522146523146524146525146526146527146528146529146530146531146532146533146534146535146536146537146538146539146540146541146542146543146544146545146546146547146548146549146550146551146552146553146554146555146556146557146558146559146560146561146562146563146564146565146566146567146568146569146570146571146572146573146574146575146576146577146578146579146580146581146582146583146584146585146586146587146588146589146590146591146592146593146594146595146596146597146598146599146600146601146602146603146604146605146606146607146608146609146610146611146612146613146614146615146616146617146618146619146620146621146622146623146624146625146626146627146628146629146630146631146632146633146634146635146636146637146638146639146640146641146642146643146644146645146646146647146648146649146650146651146652146653146654146655146656146657146658146659146660146661146662146663146664146665146666146667146668146669146670146671146672146673146674146675146676146677146678146679146680146681146682146683146684146685146686146687146688146689146690146691146692146693146694146695146696146697146698146699146700146701146702146703146704146705146706146707146708146709146710146711146712146713146714146715146716146717146718146719146720146721146722146723146724146725146726146727146728146729146730146731146732146733146734146735146736146737146738146739146740146741146742146743146744146745146746146747146748146749146750146751146752146753146754146755146756146757146758146759146760146761146762146763146764146765146766146767146768146769146770146771146772146773146774146775146776146777146778146779146780146781146782146783146784146785146786146787146788146789146790146791146792146793146794146795146796146797146798146799146800146801146802146803146804146805146806146807146808146809146810146811146812146813146814146815146816146817146818146819146820146821146822146823146824146825146826146827146828146829146830146831146832146833146834146835146836146837146838146839146840146841146842146843146844146845146846146847146848146849146850146851146852146853146854146855146856146857146858146859146860146861146862146863146864146865146866146867146868146869146870146871146872146873146874146875146876146877146878146879146880146881146882146883146884146885146886146887146888146889146890146891146892146893146894146895146896146897146898146899146900146901146902146903146904146905146906146907146908146909146910146911146912146913146914146915146916146917146918146919146920146921146922146923146924146925146926146927146928146929146930146931146932146933146934146935146936146937146938146939146940146941146942146943146944146945146946146947146948146949146950146951146952146953146954146955146956146957146958146959146960146961146962146963146964146965146966146967146968146969146970146971146972146973146974146975146976146977146978146979146980146981146982146983146984146985146986146987146988146989146990146991146992146993146994146995146996146997146998146999147000147001147002147003147004147005147006147007147008147009147010147011147012147013147014147015147016147017147018147019147020147021147022147023147024147025147026147027147028147029147030147031147032147033147034147035147036147037147038147039147040147041147042147043147044147045147046147047147048147049147050147051147052147053147054147055147056147057147058147059147060147061147062147063147064147065147066147067147068147069147070147071147072147073147074147075147076147077147078147079147080147081147082147083147084147085147086147087147088147089147090147091147092147093147094147095147096147097147098147099147100147101147102147103147104147105147106147107147108147109147110147111147112147113147114147115147116147117147118147119147120147121147122147123147124147125147126147127147128147129147130147131147132147133147134147135147136147137147138147139147140147141147142147143147144147145147146147147147148147149147150147151147152147153147154147155147156147157147158147159147160147161147162147163147164147165147166147167147168147169147170147171147172147173147174147175147176147177147178147179147180147181147182147183147184147185147186147187147188147189147190147191147192147193147194147195147196147197147198147199147200147201147202147203147204147205147206147207147208147209147210147211147212147213147214147215147216147217147218147219147220147221147222147223147224147225147226147227147228147229147230147231147232147233147234147235147236147237147238147239147240147241147242147243147244147245147246147247147248147249147250147251147252147253147254147255147256147257147258147259147260147261147262147263147264147265147266147267147268147269147270147271147272147273147274147275147276147277147278147279147280147281147282147283147284147285147286147287147288147289147290147291147292147293147294147295147296147297147298147299147300147301147302147303147304147305147306147307147308147309147310147311147312147313147314147315147316147317147318147319147320147321147322147323147324147325147326147327147328147329147330147331147332147333147334147335147336147337147338147339147340147341147342147343147344147345147346147347147348147349147350147351147352147353147354147355147356147357147358147359147360147361147362147363147364147365147366147367147368147369147370147371147372147373147374147375147376147377147378147379147380147381147382147383147384147385147386147387147388147389147390147391147392147393147394147395147396147397147398147399147400147401147402147403147404147405147406147407147408147409147410147411147412147413147414147415147416147417147418147419147420147421147422147423147424147425147426147427147428147429147430147431147432147433147434147435147436147437147438147439147440147441147442147443147444147445147446147447147448147449147450147451147452147453147454147455147456147457147458147459147460147461147462147463147464147465147466147467147468147469147470147471147472147473147474147475147476147477147478147479147480147481147482147483147484147485147486147487147488147489147490147491147492147493147494147495147496147497147498147499147500147501147502147503147504147505147506147507147508147509147510147511147512147513147514147515147516147517147518147519147520147521147522147523147524147525147526147527147528147529147530147531147532147533147534147535147536147537147538147539147540147541147542147543147544147545147546147547147548147549147550147551147552147553147554147555147556147557147558147559147560147561147562147563147564147565147566147567147568147569147570147571147572147573147574147575147576147577147578147579147580147581147582147583147584147585147586147587147588147589147590147591147592147593147594147595147596147597147598147599147600147601147602147603147604147605147606147607147608147609147610147611147612147613147614147615147616147617147618147619147620147621147622147623147624147625147626147627147628147629147630147631147632147633147634147635147636147637147638147639147640147641147642147643147644147645147646147647147648147649147650147651147652147653147654147655147656147657147658147659147660147661147662147663147664147665147666147667147668147669147670147671147672147673147674147675147676147677147678147679147680147681147682147683147684147685147686147687147688147689147690147691147692147693147694147695147696147697147698147699147700147701147702147703147704147705147706147707147708147709147710147711147712147713147714147715147716147717147718147719147720147721147722147723147724147725147726147727147728147729147730147731147732147733147734147735147736147737147738147739147740147741147742147743147744147745147746147747147748147749147750147751147752147753147754147755147756147757147758147759147760147761147762147763147764147765147766147767147768147769147770147771147772147773147774147775147776147777147778147779147780147781147782147783147784147785147786147787147788147789147790147791147792147793147794147795147796147797147798147799147800147801147802147803147804147805147806147807147808147809147810147811147812147813147814147815147816147817147818147819147820147821147822147823147824147825147826147827147828147829147830147831147832147833147834147835147836147837147838147839147840147841147842147843147844147845147846147847147848147849147850147851147852147853147854147855147856147857147858147859147860147861147862147863147864147865147866147867147868147869147870147871147872147873147874147875147876147877147878147879147880147881147882147883147884147885147886147887147888147889147890147891147892147893147894147895147896147897147898147899147900147901147902147903147904147905147906147907147908147909147910147911147912147913147914147915147916147917147918147919147920147921147922147923147924147925147926147927147928147929147930147931147932147933147934147935147936147937147938147939147940147941147942147943147944147945147946147947147948147949147950147951147952147953147954147955147956147957147958147959147960147961147962147963147964147965147966147967147968147969147970147971147972147973147974147975147976147977147978147979147980147981147982147983147984147985147986147987147988147989147990147991147992147993147994147995147996147997147998147999148000148001148002148003148004148005148006148007148008148009148010148011148012148013148014148015148016148017148018148019148020148021148022148023148024148025148026148027148028148029148030148031148032148033148034148035148036148037148038148039148040148041148042148043148044148045148046148047148048148049148050148051148052148053148054148055148056148057148058148059148060148061148062148063148064148065148066148067148068148069148070148071148072148073148074148075148076148077148078148079148080148081148082148083148084148085148086148087148088148089148090148091148092148093148094148095148096148097148098148099148100148101148102148103148104148105148106148107148108148109148110148111148112148113148114148115148116148117148118148119148120148121148122148123148124148125148126148127148128148129148130148131148132148133148134148135148136148137148138148139148140148141148142148143148144148145148146148147148148148149148150148151148152148153148154148155148156148157148158148159148160148161148162148163148164148165148166148167148168148169148170148171148172148173148174148175148176148177148178148179148180148181148182148183148184148185148186148187148188148189148190148191148192148193148194148195148196148197148198148199148200148201148202148203148204148205148206148207148208148209148210148211148212148213148214148215148216148217148218148219148220148221148222148223148224148225148226148227148228148229148230148231148232148233148234148235148236148237148238148239148240148241148242148243148244148245148246148247148248148249148250148251148252148253148254148255148256148257148258148259148260148261148262148263148264148265148266148267148268148269148270148271148272148273148274148275148276148277148278148279148280148281148282148283148284148285148286148287148288148289148290148291148292148293148294148295148296148297148298148299148300148301148302148303148304148305148306148307148308148309148310148311148312148313148314148315148316148317148318148319148320148321148322148323148324148325148326148327148328148329148330148331148332148333148334148335148336148337148338148339148340148341148342148343148344148345148346148347148348148349148350148351148352148353148354148355148356148357148358148359148360148361148362148363148364148365148366148367148368148369148370148371148372148373148374148375148376148377148378148379148380148381148382148383148384148385148386148387148388148389148390148391148392148393148394148395148396148397148398148399148400148401148402148403148404148405148406148407148408148409148410148411148412148413148414148415148416148417148418148419148420148421148422148423148424148425148426148427148428148429148430148431148432148433148434148435148436148437148438148439148440148441148442148443148444148445148446148447148448148449148450148451148452148453148454148455148456148457148458148459148460148461148462148463148464148465148466148467148468148469148470148471148472148473148474148475148476148477148478148479148480148481148482148483148484148485148486148487148488148489148490148491148492148493148494148495148496148497148498148499148500148501148502148503148504148505148506148507148508148509148510148511148512148513148514148515148516148517148518148519148520148521148522148523148524148525148526148527148528148529148530148531148532148533148534148535148536148537148538148539148540148541148542148543148544148545148546148547148548148549148550148551148552148553148554148555148556148557148558148559148560148561148562148563148564148565148566148567148568148569148570148571148572148573148574148575148576148577148578148579148580148581148582148583148584148585148586148587148588148589148590148591148592148593148594148595148596148597148598148599148600148601148602148603148604148605148606148607148608148609148610148611148612148613148614148615148616148617148618148619148620148621148622148623148624148625148626148627148628148629148630148631148632148633148634148635148636
  1. declare module "babylonjs/types" {
  2. /** Alias type for value that can be null */
  3. export type Nullable<T> = T | null;
  4. /**
  5. * Alias type for number that are floats
  6. * @ignorenaming
  7. */
  8. export type float = number;
  9. /**
  10. * Alias type for number that are doubles.
  11. * @ignorenaming
  12. */
  13. export type double = number;
  14. /**
  15. * Alias type for number that are integer
  16. * @ignorenaming
  17. */
  18. export type int = number;
  19. /** Alias type for number array or Float32Array */
  20. export type FloatArray = number[] | Float32Array;
  21. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  22. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  23. /**
  24. * Alias for types that can be used by a Buffer or VertexBuffer.
  25. */
  26. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  27. /**
  28. * Alias type for primitive types
  29. * @ignorenaming
  30. */
  31. type Primitive = undefined | null | boolean | string | number | Function;
  32. /**
  33. * Type modifier to make all the properties of an object Readonly
  34. */
  35. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  36. /**
  37. * Type modifier to make all the properties of an object Readonly recursively
  38. */
  39. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  40. /**
  41. * Type modifier to make object properties readonly.
  42. */
  43. export type DeepImmutableObject<T> = {
  44. readonly [K in keyof T]: DeepImmutable<T[K]>;
  45. };
  46. /** @hidden */
  47. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  48. }
  49. }
  50. declare module "babylonjs/Misc/observable" {
  51. import { Nullable } from "babylonjs/types";
  52. /**
  53. * A class serves as a medium between the observable and its observers
  54. */
  55. export class EventState {
  56. /**
  57. * Create a new EventState
  58. * @param mask defines the mask associated with this state
  59. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  60. * @param target defines the original target of the state
  61. * @param currentTarget defines the current target of the state
  62. */
  63. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  64. /**
  65. * Initialize the current event state
  66. * @param mask defines the mask associated with this state
  67. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  68. * @param target defines the original target of the state
  69. * @param currentTarget defines the current target of the state
  70. * @returns the current event state
  71. */
  72. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  73. /**
  74. * An Observer can set this property to true to prevent subsequent observers of being notified
  75. */
  76. skipNextObservers: boolean;
  77. /**
  78. * Get the mask value that were used to trigger the event corresponding to this EventState object
  79. */
  80. mask: number;
  81. /**
  82. * The object that originally notified the event
  83. */
  84. target?: any;
  85. /**
  86. * The current object in the bubbling phase
  87. */
  88. currentTarget?: any;
  89. /**
  90. * This will be populated with the return value of the last function that was executed.
  91. * If it is the first function in the callback chain it will be the event data.
  92. */
  93. lastReturnValue?: any;
  94. }
  95. /**
  96. * Represent an Observer registered to a given Observable object.
  97. */
  98. export class Observer<T> {
  99. /**
  100. * Defines the callback to call when the observer is notified
  101. */
  102. callback: (eventData: T, eventState: EventState) => void;
  103. /**
  104. * Defines the mask of the observer (used to filter notifications)
  105. */
  106. mask: number;
  107. /**
  108. * Defines the current scope used to restore the JS context
  109. */
  110. scope: any;
  111. /** @hidden */
  112. _willBeUnregistered: boolean;
  113. /**
  114. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  115. */
  116. unregisterOnNextCall: boolean;
  117. /**
  118. * Creates a new observer
  119. * @param callback defines the callback to call when the observer is notified
  120. * @param mask defines the mask of the observer (used to filter notifications)
  121. * @param scope defines the current scope used to restore the JS context
  122. */
  123. constructor(
  124. /**
  125. * Defines the callback to call when the observer is notified
  126. */
  127. callback: (eventData: T, eventState: EventState) => void,
  128. /**
  129. * Defines the mask of the observer (used to filter notifications)
  130. */
  131. mask: number,
  132. /**
  133. * Defines the current scope used to restore the JS context
  134. */
  135. scope?: any);
  136. }
  137. /**
  138. * Represent a list of observers registered to multiple Observables object.
  139. */
  140. export class MultiObserver<T> {
  141. private _observers;
  142. private _observables;
  143. /**
  144. * Release associated resources
  145. */
  146. dispose(): void;
  147. /**
  148. * Raise a callback when one of the observable will notify
  149. * @param observables defines a list of observables to watch
  150. * @param callback defines the callback to call on notification
  151. * @param mask defines the mask used to filter notifications
  152. * @param scope defines the current scope used to restore the JS context
  153. * @returns the new MultiObserver
  154. */
  155. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  156. }
  157. /**
  158. * The Observable class is a simple implementation of the Observable pattern.
  159. *
  160. * There's one slight particularity though: a given Observable can notify its observer using a particular mask value, only the Observers registered with this mask value will be notified.
  161. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  162. * For instance you may have a given Observable that have four different types of notifications: Move (mask = 0x01), Stop (mask = 0x02), Turn Right (mask = 0X04), Turn Left (mask = 0X08).
  163. * A given observer can register itself with only Move and Stop (mask = 0x03), then it will only be notified when one of these two occurs and will never be for Turn Left/Right.
  164. */
  165. export class Observable<T> {
  166. private _observers;
  167. private _eventState;
  168. private _onObserverAdded;
  169. /**
  170. * Gets the list of observers
  171. */
  172. get observers(): Array<Observer<T>>;
  173. /**
  174. * Creates a new observable
  175. * @param onObserverAdded defines a callback to call when a new observer is added
  176. */
  177. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  178. /**
  179. * Create a new Observer with the specified callback
  180. * @param callback the callback that will be executed for that Observer
  181. * @param mask the mask used to filter observers
  182. * @param insertFirst if true the callback will be inserted at the first position, hence executed before the others ones. If false (default behavior) the callback will be inserted at the last position, executed after all the others already present.
  183. * @param scope optional scope for the callback to be called from
  184. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  185. * @returns the new observer created for the callback
  186. */
  187. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  188. /**
  189. * Create a new Observer with the specified callback and unregisters after the next notification
  190. * @param callback the callback that will be executed for that Observer
  191. * @returns the new observer created for the callback
  192. */
  193. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  194. /**
  195. * Remove an Observer from the Observable object
  196. * @param observer the instance of the Observer to remove
  197. * @returns false if it doesn't belong to this Observable
  198. */
  199. remove(observer: Nullable<Observer<T>>): boolean;
  200. /**
  201. * Remove a callback from the Observable object
  202. * @param callback the callback to remove
  203. * @param scope optional scope. If used only the callbacks with this scope will be removed
  204. * @returns false if it doesn't belong to this Observable
  205. */
  206. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  207. private _deferUnregister;
  208. private _remove;
  209. /**
  210. * Moves the observable to the top of the observer list making it get called first when notified
  211. * @param observer the observer to move
  212. */
  213. makeObserverTopPriority(observer: Observer<T>): void;
  214. /**
  215. * Moves the observable to the bottom of the observer list making it get called last when notified
  216. * @param observer the observer to move
  217. */
  218. makeObserverBottomPriority(observer: Observer<T>): void;
  219. /**
  220. * Notify all Observers by calling their respective callback with the given data
  221. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  222. * @param eventData defines the data to send to all observers
  223. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  224. * @param target defines the original target of the state
  225. * @param currentTarget defines the current target of the state
  226. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  227. */
  228. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  229. /**
  230. * Calling this will execute each callback, expecting it to be a promise or return a value.
  231. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  232. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  233. * and it is crucial that all callbacks will be executed.
  234. * The order of the callbacks is kept, callbacks are not executed parallel.
  235. *
  236. * @param eventData The data to be sent to each callback
  237. * @param mask is used to filter observers defaults to -1
  238. * @param target defines the callback target (see EventState)
  239. * @param currentTarget defines he current object in the bubbling phase
  240. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  241. */
  242. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  243. /**
  244. * Notify a specific observer
  245. * @param observer defines the observer to notify
  246. * @param eventData defines the data to be sent to each callback
  247. * @param mask is used to filter observers defaults to -1
  248. */
  249. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  250. /**
  251. * Gets a boolean indicating if the observable has at least one observer
  252. * @returns true is the Observable has at least one Observer registered
  253. */
  254. hasObservers(): boolean;
  255. /**
  256. * Clear the list of observers
  257. */
  258. clear(): void;
  259. /**
  260. * Clone the current observable
  261. * @returns a new observable
  262. */
  263. clone(): Observable<T>;
  264. /**
  265. * Does this observable handles observer registered with a given mask
  266. * @param mask defines the mask to be tested
  267. * @return whether or not one observer registered with the given mask is handeled
  268. **/
  269. hasSpecificMask(mask?: number): boolean;
  270. }
  271. }
  272. declare module "babylonjs/Misc/domManagement" {
  273. /**
  274. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  275. * Babylon.js
  276. */
  277. export class DomManagement {
  278. /**
  279. * Checks if the window object exists
  280. * @returns true if the window object exists
  281. */
  282. static IsWindowObjectExist(): boolean;
  283. /**
  284. * Checks if the navigator object exists
  285. * @returns true if the navigator object exists
  286. */
  287. static IsNavigatorAvailable(): boolean;
  288. /**
  289. * Check if the document object exists
  290. * @returns true if the document object exists
  291. */
  292. static IsDocumentAvailable(): boolean;
  293. /**
  294. * Extracts text content from a DOM element hierarchy
  295. * @param element defines the root element
  296. * @returns a string
  297. */
  298. static GetDOMTextContent(element: HTMLElement): string;
  299. }
  300. }
  301. declare module "babylonjs/Misc/logger" {
  302. /**
  303. * Logger used througouht the application to allow configuration of
  304. * the log level required for the messages.
  305. */
  306. export class Logger {
  307. /**
  308. * No log
  309. */
  310. static readonly NoneLogLevel: number;
  311. /**
  312. * Only message logs
  313. */
  314. static readonly MessageLogLevel: number;
  315. /**
  316. * Only warning logs
  317. */
  318. static readonly WarningLogLevel: number;
  319. /**
  320. * Only error logs
  321. */
  322. static readonly ErrorLogLevel: number;
  323. /**
  324. * All logs
  325. */
  326. static readonly AllLogLevel: number;
  327. private static _LogCache;
  328. /**
  329. * Gets a value indicating the number of loading errors
  330. * @ignorenaming
  331. */
  332. static errorsCount: number;
  333. /**
  334. * Callback called when a new log is added
  335. */
  336. static OnNewCacheEntry: (entry: string) => void;
  337. private static _AddLogEntry;
  338. private static _FormatMessage;
  339. private static _LogDisabled;
  340. private static _LogEnabled;
  341. private static _WarnDisabled;
  342. private static _WarnEnabled;
  343. private static _ErrorDisabled;
  344. private static _ErrorEnabled;
  345. /**
  346. * Log a message to the console
  347. */
  348. static Log: (message: string) => void;
  349. /**
  350. * Write a warning message to the console
  351. */
  352. static Warn: (message: string) => void;
  353. /**
  354. * Write an error message to the console
  355. */
  356. static Error: (message: string) => void;
  357. /**
  358. * Gets current log cache (list of logs)
  359. */
  360. static get LogCache(): string;
  361. /**
  362. * Clears the log cache
  363. */
  364. static ClearLogCache(): void;
  365. /**
  366. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  367. */
  368. static set LogLevels(level: number);
  369. }
  370. }
  371. declare module "babylonjs/Misc/typeStore" {
  372. /** @hidden */
  373. export class _TypeStore {
  374. /** @hidden */
  375. static RegisteredTypes: {
  376. [key: string]: Object;
  377. };
  378. /** @hidden */
  379. static GetClass(fqdn: string): any;
  380. }
  381. }
  382. declare module "babylonjs/Misc/stringTools" {
  383. /**
  384. * Helper to manipulate strings
  385. */
  386. export class StringTools {
  387. /**
  388. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  389. * @param str Source string
  390. * @param suffix Suffix to search for in the source string
  391. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  392. */
  393. static EndsWith(str: string, suffix: string): boolean;
  394. /**
  395. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  396. * @param str Source string
  397. * @param suffix Suffix to search for in the source string
  398. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  399. */
  400. static StartsWith(str: string, suffix: string): boolean;
  401. /**
  402. * Decodes a buffer into a string
  403. * @param buffer The buffer to decode
  404. * @returns The decoded string
  405. */
  406. static Decode(buffer: Uint8Array | Uint16Array): string;
  407. /**
  408. * Encode a buffer to a base64 string
  409. * @param buffer defines the buffer to encode
  410. * @returns the encoded string
  411. */
  412. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  413. /**
  414. * Converts a number to string and pads with preceeding zeroes until it is of specified length.
  415. * @param num the number to convert and pad
  416. * @param length the expected length of the string
  417. * @returns the padded string
  418. */
  419. static PadNumber(num: number, length: number): string;
  420. }
  421. }
  422. declare module "babylonjs/Misc/deepCopier" {
  423. /**
  424. * Class containing a set of static utilities functions for deep copy.
  425. */
  426. export class DeepCopier {
  427. /**
  428. * Tries to copy an object by duplicating every property
  429. * @param source defines the source object
  430. * @param destination defines the target object
  431. * @param doNotCopyList defines a list of properties to avoid
  432. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  433. */
  434. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  435. }
  436. }
  437. declare module "babylonjs/Misc/precisionDate" {
  438. /**
  439. * Class containing a set of static utilities functions for precision date
  440. */
  441. export class PrecisionDate {
  442. /**
  443. * Gets either window.performance.now() if supported or Date.now() else
  444. */
  445. static get Now(): number;
  446. }
  447. }
  448. declare module "babylonjs/Misc/devTools" {
  449. /** @hidden */
  450. export class _DevTools {
  451. static WarnImport(name: string): string;
  452. }
  453. }
  454. declare module "babylonjs/Misc/interfaces/iWebRequest" {
  455. /**
  456. * Interface used to define the mechanism to get data from the network
  457. */
  458. export interface IWebRequest {
  459. /**
  460. * Returns client's response url
  461. */
  462. responseURL: string;
  463. /**
  464. * Returns client's status
  465. */
  466. status: number;
  467. /**
  468. * Returns client's status as a text
  469. */
  470. statusText: string;
  471. }
  472. }
  473. declare module "babylonjs/Misc/webRequest" {
  474. import { IWebRequest } from "babylonjs/Misc/interfaces/iWebRequest";
  475. import { Nullable } from "babylonjs/types";
  476. /**
  477. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  478. */
  479. export class WebRequest implements IWebRequest {
  480. private _xhr;
  481. /**
  482. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  483. * i.e. when loading files, where the server/service expects an Authorization header
  484. */
  485. static CustomRequestHeaders: {
  486. [key: string]: string;
  487. };
  488. /**
  489. * Add callback functions in this array to update all the requests before they get sent to the network
  490. */
  491. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  492. private _injectCustomRequestHeaders;
  493. /**
  494. * Gets or sets a function to be called when loading progress changes
  495. */
  496. get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  497. set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
  498. /**
  499. * Returns client's state
  500. */
  501. get readyState(): number;
  502. /**
  503. * Returns client's status
  504. */
  505. get status(): number;
  506. /**
  507. * Returns client's status as a text
  508. */
  509. get statusText(): string;
  510. /**
  511. * Returns client's response
  512. */
  513. get response(): any;
  514. /**
  515. * Returns client's response url
  516. */
  517. get responseURL(): string;
  518. /**
  519. * Returns client's response as text
  520. */
  521. get responseText(): string;
  522. /**
  523. * Gets or sets the expected response type
  524. */
  525. get responseType(): XMLHttpRequestResponseType;
  526. set responseType(value: XMLHttpRequestResponseType);
  527. /** @hidden */
  528. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  529. /** @hidden */
  530. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  531. /**
  532. * Cancels any network activity
  533. */
  534. abort(): void;
  535. /**
  536. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  537. * @param body defines an optional request body
  538. */
  539. send(body?: Document | BodyInit | null): void;
  540. /**
  541. * Sets the request method, request URL
  542. * @param method defines the method to use (GET, POST, etc..)
  543. * @param url defines the url to connect with
  544. */
  545. open(method: string, url: string): void;
  546. /**
  547. * Sets the value of a request header.
  548. * @param name The name of the header whose value is to be set
  549. * @param value The value to set as the body of the header
  550. */
  551. setRequestHeader(name: string, value: string): void;
  552. /**
  553. * Get the string containing the text of a particular header's value.
  554. * @param name The name of the header
  555. * @returns The string containing the text of the given header name
  556. */
  557. getResponseHeader(name: string): Nullable<string>;
  558. }
  559. }
  560. declare module "babylonjs/Misc/fileRequest" {
  561. import { Observable } from "babylonjs/Misc/observable";
  562. /**
  563. * File request interface
  564. */
  565. export interface IFileRequest {
  566. /**
  567. * Raised when the request is complete (success or error).
  568. */
  569. onCompleteObservable: Observable<IFileRequest>;
  570. /**
  571. * Aborts the request for a file.
  572. */
  573. abort: () => void;
  574. }
  575. }
  576. declare module "babylonjs/Materials/Textures/renderTargetCreationOptions" {
  577. /**
  578. * Define options used to create a render target texture
  579. */
  580. export class RenderTargetCreationOptions {
  581. /**
  582. * Specifies is mipmaps must be generated
  583. */
  584. generateMipMaps?: boolean;
  585. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  586. generateDepthBuffer?: boolean;
  587. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  588. generateStencilBuffer?: boolean;
  589. /** Defines texture type (int by default) */
  590. type?: number;
  591. /** Defines sampling mode (trilinear by default) */
  592. samplingMode?: number;
  593. /** Defines format (RGBA by default) */
  594. format?: number;
  595. }
  596. }
  597. declare module "babylonjs/Engines/constants" {
  598. /** Defines the cross module used constants to avoid circular dependncies */
  599. export class Constants {
  600. /** Defines that alpha blending is disabled */
  601. static readonly ALPHA_DISABLE: number;
  602. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  603. static readonly ALPHA_ADD: number;
  604. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  605. static readonly ALPHA_COMBINE: number;
  606. /** Defines that alpha blending is DEST - SRC * DEST */
  607. static readonly ALPHA_SUBTRACT: number;
  608. /** Defines that alpha blending is SRC * DEST */
  609. static readonly ALPHA_MULTIPLY: number;
  610. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  611. static readonly ALPHA_MAXIMIZED: number;
  612. /** Defines that alpha blending is SRC + DEST */
  613. static readonly ALPHA_ONEONE: number;
  614. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  615. static readonly ALPHA_PREMULTIPLIED: number;
  616. /**
  617. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  618. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  619. */
  620. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  621. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  622. static readonly ALPHA_INTERPOLATE: number;
  623. /**
  624. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  625. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  626. */
  627. static readonly ALPHA_SCREENMODE: number;
  628. /**
  629. * Defines that alpha blending is SRC + DST
  630. * Alpha will be set to SRC ALPHA + DST ALPHA
  631. */
  632. static readonly ALPHA_ONEONE_ONEONE: number;
  633. /**
  634. * Defines that alpha blending is SRC * DST ALPHA + DST
  635. * Alpha will be set to 0
  636. */
  637. static readonly ALPHA_ALPHATOCOLOR: number;
  638. /**
  639. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  640. */
  641. static readonly ALPHA_REVERSEONEMINUS: number;
  642. /**
  643. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  644. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  645. */
  646. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  647. /**
  648. * Defines that alpha blending is SRC + DST
  649. * Alpha will be set to SRC ALPHA
  650. */
  651. static readonly ALPHA_ONEONE_ONEZERO: number;
  652. /**
  653. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  654. * Alpha will be set to DST ALPHA
  655. */
  656. static readonly ALPHA_EXCLUSION: number;
  657. /** Defines that alpha blending equation a SUM */
  658. static readonly ALPHA_EQUATION_ADD: number;
  659. /** Defines that alpha blending equation a SUBSTRACTION */
  660. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  661. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  662. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  663. /** Defines that alpha blending equation a MAX operation */
  664. static readonly ALPHA_EQUATION_MAX: number;
  665. /** Defines that alpha blending equation a MIN operation */
  666. static readonly ALPHA_EQUATION_MIN: number;
  667. /**
  668. * Defines that alpha blending equation a DARKEN operation:
  669. * It takes the min of the src and sums the alpha channels.
  670. */
  671. static readonly ALPHA_EQUATION_DARKEN: number;
  672. /** Defines that the ressource is not delayed*/
  673. static readonly DELAYLOADSTATE_NONE: number;
  674. /** Defines that the ressource was successfully delay loaded */
  675. static readonly DELAYLOADSTATE_LOADED: number;
  676. /** Defines that the ressource is currently delay loading */
  677. static readonly DELAYLOADSTATE_LOADING: number;
  678. /** Defines that the ressource is delayed and has not started loading */
  679. static readonly DELAYLOADSTATE_NOTLOADED: number;
  680. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  681. static readonly NEVER: number;
  682. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will always pass. i.e. Pixels will be drawn in the order they are drawn */
  683. static readonly ALWAYS: number;
  684. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  685. static readonly LESS: number;
  686. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  687. static readonly EQUAL: number;
  688. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than or equal to the stored value */
  689. static readonly LEQUAL: number;
  690. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  691. static readonly GREATER: number;
  692. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than or equal to the stored value */
  693. static readonly GEQUAL: number;
  694. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is not equal to the stored value */
  695. static readonly NOTEQUAL: number;
  696. /** Passed to stencilOperation to specify that stencil value must be kept */
  697. static readonly KEEP: number;
  698. /** Passed to stencilOperation to specify that stencil value must be replaced */
  699. static readonly REPLACE: number;
  700. /** Passed to stencilOperation to specify that stencil value must be incremented */
  701. static readonly INCR: number;
  702. /** Passed to stencilOperation to specify that stencil value must be decremented */
  703. static readonly DECR: number;
  704. /** Passed to stencilOperation to specify that stencil value must be inverted */
  705. static readonly INVERT: number;
  706. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  707. static readonly INCR_WRAP: number;
  708. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  709. static readonly DECR_WRAP: number;
  710. /** Texture is not repeating outside of 0..1 UVs */
  711. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  712. /** Texture is repeating outside of 0..1 UVs */
  713. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  714. /** Texture is repeating and mirrored */
  715. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  716. /** ALPHA */
  717. static readonly TEXTUREFORMAT_ALPHA: number;
  718. /** LUMINANCE */
  719. static readonly TEXTUREFORMAT_LUMINANCE: number;
  720. /** LUMINANCE_ALPHA */
  721. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  722. /** RGB */
  723. static readonly TEXTUREFORMAT_RGB: number;
  724. /** RGBA */
  725. static readonly TEXTUREFORMAT_RGBA: number;
  726. /** RED */
  727. static readonly TEXTUREFORMAT_RED: number;
  728. /** RED (2nd reference) */
  729. static readonly TEXTUREFORMAT_R: number;
  730. /** RG */
  731. static readonly TEXTUREFORMAT_RG: number;
  732. /** RED_INTEGER */
  733. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  734. /** RED_INTEGER (2nd reference) */
  735. static readonly TEXTUREFORMAT_R_INTEGER: number;
  736. /** RG_INTEGER */
  737. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  738. /** RGB_INTEGER */
  739. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  740. /** RGBA_INTEGER */
  741. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  742. /** UNSIGNED_BYTE */
  743. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  744. /** UNSIGNED_BYTE (2nd reference) */
  745. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  746. /** FLOAT */
  747. static readonly TEXTURETYPE_FLOAT: number;
  748. /** HALF_FLOAT */
  749. static readonly TEXTURETYPE_HALF_FLOAT: number;
  750. /** BYTE */
  751. static readonly TEXTURETYPE_BYTE: number;
  752. /** SHORT */
  753. static readonly TEXTURETYPE_SHORT: number;
  754. /** UNSIGNED_SHORT */
  755. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  756. /** INT */
  757. static readonly TEXTURETYPE_INT: number;
  758. /** UNSIGNED_INT */
  759. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  760. /** UNSIGNED_SHORT_4_4_4_4 */
  761. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  762. /** UNSIGNED_SHORT_5_5_5_1 */
  763. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  764. /** UNSIGNED_SHORT_5_6_5 */
  765. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  766. /** UNSIGNED_INT_2_10_10_10_REV */
  767. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  768. /** UNSIGNED_INT_24_8 */
  769. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  770. /** UNSIGNED_INT_10F_11F_11F_REV */
  771. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  772. /** UNSIGNED_INT_5_9_9_9_REV */
  773. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  774. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  775. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  776. /** nearest is mag = nearest and min = nearest and no mip */
  777. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  778. /** mag = nearest and min = nearest and mip = none */
  779. static readonly TEXTURE_NEAREST_NEAREST: number;
  780. /** Bilinear is mag = linear and min = linear and no mip */
  781. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  782. /** mag = linear and min = linear and mip = none */
  783. static readonly TEXTURE_LINEAR_LINEAR: number;
  784. /** Trilinear is mag = linear and min = linear and mip = linear */
  785. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  786. /** Trilinear is mag = linear and min = linear and mip = linear */
  787. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  788. /** mag = nearest and min = nearest and mip = nearest */
  789. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  790. /** mag = nearest and min = linear and mip = nearest */
  791. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  792. /** mag = nearest and min = linear and mip = linear */
  793. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  794. /** mag = nearest and min = linear and mip = none */
  795. static readonly TEXTURE_NEAREST_LINEAR: number;
  796. /** nearest is mag = nearest and min = nearest and mip = linear */
  797. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  798. /** mag = linear and min = nearest and mip = nearest */
  799. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  800. /** mag = linear and min = nearest and mip = linear */
  801. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  802. /** Bilinear is mag = linear and min = linear and mip = nearest */
  803. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  804. /** mag = linear and min = nearest and mip = none */
  805. static readonly TEXTURE_LINEAR_NEAREST: number;
  806. /** Explicit coordinates mode */
  807. static readonly TEXTURE_EXPLICIT_MODE: number;
  808. /** Spherical coordinates mode */
  809. static readonly TEXTURE_SPHERICAL_MODE: number;
  810. /** Planar coordinates mode */
  811. static readonly TEXTURE_PLANAR_MODE: number;
  812. /** Cubic coordinates mode */
  813. static readonly TEXTURE_CUBIC_MODE: number;
  814. /** Projection coordinates mode */
  815. static readonly TEXTURE_PROJECTION_MODE: number;
  816. /** Skybox coordinates mode */
  817. static readonly TEXTURE_SKYBOX_MODE: number;
  818. /** Inverse Cubic coordinates mode */
  819. static readonly TEXTURE_INVCUBIC_MODE: number;
  820. /** Equirectangular coordinates mode */
  821. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  822. /** Equirectangular Fixed coordinates mode */
  823. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  824. /** Equirectangular Fixed Mirrored coordinates mode */
  825. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  826. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  827. static readonly SCALEMODE_FLOOR: number;
  828. /** Defines that texture rescaling will look for the nearest power of 2 size */
  829. static readonly SCALEMODE_NEAREST: number;
  830. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  831. static readonly SCALEMODE_CEILING: number;
  832. /**
  833. * The dirty texture flag value
  834. */
  835. static readonly MATERIAL_TextureDirtyFlag: number;
  836. /**
  837. * The dirty light flag value
  838. */
  839. static readonly MATERIAL_LightDirtyFlag: number;
  840. /**
  841. * The dirty fresnel flag value
  842. */
  843. static readonly MATERIAL_FresnelDirtyFlag: number;
  844. /**
  845. * The dirty attribute flag value
  846. */
  847. static readonly MATERIAL_AttributesDirtyFlag: number;
  848. /**
  849. * The dirty misc flag value
  850. */
  851. static readonly MATERIAL_MiscDirtyFlag: number;
  852. /**
  853. * The all dirty flag value
  854. */
  855. static readonly MATERIAL_AllDirtyFlag: number;
  856. /**
  857. * Returns the triangle fill mode
  858. */
  859. static readonly MATERIAL_TriangleFillMode: number;
  860. /**
  861. * Returns the wireframe mode
  862. */
  863. static readonly MATERIAL_WireFrameFillMode: number;
  864. /**
  865. * Returns the point fill mode
  866. */
  867. static readonly MATERIAL_PointFillMode: number;
  868. /**
  869. * Returns the point list draw mode
  870. */
  871. static readonly MATERIAL_PointListDrawMode: number;
  872. /**
  873. * Returns the line list draw mode
  874. */
  875. static readonly MATERIAL_LineListDrawMode: number;
  876. /**
  877. * Returns the line loop draw mode
  878. */
  879. static readonly MATERIAL_LineLoopDrawMode: number;
  880. /**
  881. * Returns the line strip draw mode
  882. */
  883. static readonly MATERIAL_LineStripDrawMode: number;
  884. /**
  885. * Returns the triangle strip draw mode
  886. */
  887. static readonly MATERIAL_TriangleStripDrawMode: number;
  888. /**
  889. * Returns the triangle fan draw mode
  890. */
  891. static readonly MATERIAL_TriangleFanDrawMode: number;
  892. /**
  893. * Stores the clock-wise side orientation
  894. */
  895. static readonly MATERIAL_ClockWiseSideOrientation: number;
  896. /**
  897. * Stores the counter clock-wise side orientation
  898. */
  899. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  900. /**
  901. * Nothing
  902. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  903. */
  904. static readonly ACTION_NothingTrigger: number;
  905. /**
  906. * On pick
  907. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  908. */
  909. static readonly ACTION_OnPickTrigger: number;
  910. /**
  911. * On left pick
  912. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  913. */
  914. static readonly ACTION_OnLeftPickTrigger: number;
  915. /**
  916. * On right pick
  917. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  918. */
  919. static readonly ACTION_OnRightPickTrigger: number;
  920. /**
  921. * On center pick
  922. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  923. */
  924. static readonly ACTION_OnCenterPickTrigger: number;
  925. /**
  926. * On pick down
  927. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  928. */
  929. static readonly ACTION_OnPickDownTrigger: number;
  930. /**
  931. * On double pick
  932. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  933. */
  934. static readonly ACTION_OnDoublePickTrigger: number;
  935. /**
  936. * On pick up
  937. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  938. */
  939. static readonly ACTION_OnPickUpTrigger: number;
  940. /**
  941. * On pick out.
  942. * This trigger will only be raised if you also declared a OnPickDown
  943. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  944. */
  945. static readonly ACTION_OnPickOutTrigger: number;
  946. /**
  947. * On long press
  948. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  949. */
  950. static readonly ACTION_OnLongPressTrigger: number;
  951. /**
  952. * On pointer over
  953. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  954. */
  955. static readonly ACTION_OnPointerOverTrigger: number;
  956. /**
  957. * On pointer out
  958. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  959. */
  960. static readonly ACTION_OnPointerOutTrigger: number;
  961. /**
  962. * On every frame
  963. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  964. */
  965. static readonly ACTION_OnEveryFrameTrigger: number;
  966. /**
  967. * On intersection enter
  968. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  969. */
  970. static readonly ACTION_OnIntersectionEnterTrigger: number;
  971. /**
  972. * On intersection exit
  973. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  974. */
  975. static readonly ACTION_OnIntersectionExitTrigger: number;
  976. /**
  977. * On key down
  978. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  979. */
  980. static readonly ACTION_OnKeyDownTrigger: number;
  981. /**
  982. * On key up
  983. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  984. */
  985. static readonly ACTION_OnKeyUpTrigger: number;
  986. /**
  987. * Billboard mode will only apply to Y axis
  988. */
  989. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  990. /**
  991. * Billboard mode will apply to all axes
  992. */
  993. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  994. /**
  995. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  996. */
  997. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  998. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  999. * Test order :
  1000. * Is the bounding sphere outside the frustum ?
  1001. * If not, are the bounding box vertices outside the frustum ?
  1002. * It not, then the cullable object is in the frustum.
  1003. */
  1004. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  1005. /** Culling strategy : Bounding Sphere Only.
  1006. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  1007. * It's also less accurate than the standard because some not visible objects can still be selected.
  1008. * Test : is the bounding sphere outside the frustum ?
  1009. * If not, then the cullable object is in the frustum.
  1010. */
  1011. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  1012. /** Culling strategy : Optimistic Inclusion.
  1013. * This in an inclusion test first, then the standard exclusion test.
  1014. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  1015. * This could also be a little slower than the standard test when the tested object center is not the frustum but one of its bounding box vertex is still inside.
  1016. * Anyway, it's as accurate as the standard strategy.
  1017. * Test :
  1018. * Is the cullable object bounding sphere center in the frustum ?
  1019. * If not, apply the default culling strategy.
  1020. */
  1021. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  1022. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  1023. * This in an inclusion test first, then the bounding sphere only exclusion test.
  1024. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  1025. * This could also be a little slower than the BoundingSphereOnly strategy when the tested object center is not in the frustum but its bounding sphere still intersects it.
  1026. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  1027. * Test :
  1028. * Is the cullable object bounding sphere center in the frustum ?
  1029. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  1030. */
  1031. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  1032. /**
  1033. * No logging while loading
  1034. */
  1035. static readonly SCENELOADER_NO_LOGGING: number;
  1036. /**
  1037. * Minimal logging while loading
  1038. */
  1039. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  1040. /**
  1041. * Summary logging while loading
  1042. */
  1043. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  1044. /**
  1045. * Detailled logging while loading
  1046. */
  1047. static readonly SCENELOADER_DETAILED_LOGGING: number;
  1048. }
  1049. }
  1050. declare module "babylonjs/Materials/Textures/internalTextureLoader" {
  1051. import { Nullable } from "babylonjs/types";
  1052. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  1053. /**
  1054. * This represents the required contract to create a new type of texture loader.
  1055. */
  1056. export interface IInternalTextureLoader {
  1057. /**
  1058. * Defines wether the loader supports cascade loading the different faces.
  1059. */
  1060. supportCascades: boolean;
  1061. /**
  1062. * This returns if the loader support the current file information.
  1063. * @param extension defines the file extension of the file being loaded
  1064. * @returns true if the loader can load the specified file
  1065. */
  1066. canLoad(extension: string): boolean;
  1067. /**
  1068. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  1069. * @param data contains the texture data
  1070. * @param texture defines the BabylonJS internal texture
  1071. * @param createPolynomials will be true if polynomials have been requested
  1072. * @param onLoad defines the callback to trigger once the texture is ready
  1073. * @param onError defines the callback to trigger in case of error
  1074. */
  1075. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  1076. /**
  1077. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  1078. * @param data contains the texture data
  1079. * @param texture defines the BabylonJS internal texture
  1080. * @param callback defines the method to call once ready to upload
  1081. */
  1082. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  1083. }
  1084. }
  1085. declare module "babylonjs/Engines/IPipelineContext" {
  1086. /**
  1087. * Class used to store and describe the pipeline context associated with an effect
  1088. */
  1089. export interface IPipelineContext {
  1090. /**
  1091. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  1092. */
  1093. isAsync: boolean;
  1094. /**
  1095. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  1096. */
  1097. isReady: boolean;
  1098. /** @hidden */
  1099. _getVertexShaderCode(): string | null;
  1100. /** @hidden */
  1101. _getFragmentShaderCode(): string | null;
  1102. /** @hidden */
  1103. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  1104. }
  1105. }
  1106. declare module "babylonjs/Meshes/dataBuffer" {
  1107. /**
  1108. * Class used to store gfx data (like WebGLBuffer)
  1109. */
  1110. export class DataBuffer {
  1111. /**
  1112. * Gets or sets the number of objects referencing this buffer
  1113. */
  1114. references: number;
  1115. /** Gets or sets the size of the underlying buffer */
  1116. capacity: number;
  1117. /**
  1118. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  1119. */
  1120. is32Bits: boolean;
  1121. /**
  1122. * Gets the underlying buffer
  1123. */
  1124. get underlyingResource(): any;
  1125. }
  1126. }
  1127. declare module "babylonjs/Engines/Processors/iShaderProcessor" {
  1128. /** @hidden */
  1129. export interface IShaderProcessor {
  1130. attributeProcessor?: (attribute: string) => string;
  1131. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  1132. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  1133. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  1134. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  1135. lineProcessor?: (line: string, isFragment: boolean) => string;
  1136. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1137. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1138. }
  1139. }
  1140. declare module "babylonjs/Engines/Processors/shaderProcessingOptions" {
  1141. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  1142. /** @hidden */
  1143. export interface ProcessingOptions {
  1144. defines: string[];
  1145. indexParameters: any;
  1146. isFragment: boolean;
  1147. shouldUseHighPrecisionShader: boolean;
  1148. supportsUniformBuffers: boolean;
  1149. shadersRepository: string;
  1150. includesShadersStore: {
  1151. [key: string]: string;
  1152. };
  1153. processor?: IShaderProcessor;
  1154. version: string;
  1155. platformName: string;
  1156. lookForClosingBracketForUniformBuffer?: boolean;
  1157. }
  1158. }
  1159. declare module "babylonjs/Engines/Processors/shaderCodeNode" {
  1160. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1161. /** @hidden */
  1162. export class ShaderCodeNode {
  1163. line: string;
  1164. children: ShaderCodeNode[];
  1165. additionalDefineKey?: string;
  1166. additionalDefineValue?: string;
  1167. isValid(preprocessors: {
  1168. [key: string]: string;
  1169. }): boolean;
  1170. process(preprocessors: {
  1171. [key: string]: string;
  1172. }, options: ProcessingOptions): string;
  1173. }
  1174. }
  1175. declare module "babylonjs/Engines/Processors/shaderCodeCursor" {
  1176. /** @hidden */
  1177. export class ShaderCodeCursor {
  1178. private _lines;
  1179. lineIndex: number;
  1180. get currentLine(): string;
  1181. get canRead(): boolean;
  1182. set lines(value: string[]);
  1183. }
  1184. }
  1185. declare module "babylonjs/Engines/Processors/shaderCodeConditionNode" {
  1186. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  1187. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1188. /** @hidden */
  1189. export class ShaderCodeConditionNode extends ShaderCodeNode {
  1190. process(preprocessors: {
  1191. [key: string]: string;
  1192. }, options: ProcessingOptions): string;
  1193. }
  1194. }
  1195. declare module "babylonjs/Engines/Processors/Expressions/shaderDefineExpression" {
  1196. /** @hidden */
  1197. export class ShaderDefineExpression {
  1198. isTrue(preprocessors: {
  1199. [key: string]: string;
  1200. }): boolean;
  1201. private static _OperatorPriority;
  1202. private static _Stack;
  1203. static postfixToInfix(postfix: string[]): string;
  1204. static infixToPostfix(infix: string): string[];
  1205. }
  1206. }
  1207. declare module "babylonjs/Engines/Processors/shaderCodeTestNode" {
  1208. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  1209. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1210. /** @hidden */
  1211. export class ShaderCodeTestNode extends ShaderCodeNode {
  1212. testExpression: ShaderDefineExpression;
  1213. isValid(preprocessors: {
  1214. [key: string]: string;
  1215. }): boolean;
  1216. }
  1217. }
  1218. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator" {
  1219. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1220. /** @hidden */
  1221. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  1222. define: string;
  1223. not: boolean;
  1224. constructor(define: string, not?: boolean);
  1225. isTrue(preprocessors: {
  1226. [key: string]: string;
  1227. }): boolean;
  1228. }
  1229. }
  1230. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator" {
  1231. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1232. /** @hidden */
  1233. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  1234. leftOperand: ShaderDefineExpression;
  1235. rightOperand: ShaderDefineExpression;
  1236. isTrue(preprocessors: {
  1237. [key: string]: string;
  1238. }): boolean;
  1239. }
  1240. }
  1241. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator" {
  1242. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1243. /** @hidden */
  1244. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  1245. leftOperand: ShaderDefineExpression;
  1246. rightOperand: ShaderDefineExpression;
  1247. isTrue(preprocessors: {
  1248. [key: string]: string;
  1249. }): boolean;
  1250. }
  1251. }
  1252. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator" {
  1253. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1254. /** @hidden */
  1255. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  1256. define: string;
  1257. operand: string;
  1258. testValue: string;
  1259. constructor(define: string, operand: string, testValue: string);
  1260. isTrue(preprocessors: {
  1261. [key: string]: string;
  1262. }): boolean;
  1263. }
  1264. }
  1265. declare module "babylonjs/Offline/IOfflineProvider" {
  1266. /**
  1267. * Class used to enable access to offline support
  1268. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  1269. */
  1270. export interface IOfflineProvider {
  1271. /**
  1272. * Gets a boolean indicating if scene must be saved in the database
  1273. */
  1274. enableSceneOffline: boolean;
  1275. /**
  1276. * Gets a boolean indicating if textures must be saved in the database
  1277. */
  1278. enableTexturesOffline: boolean;
  1279. /**
  1280. * Open the offline support and make it available
  1281. * @param successCallback defines the callback to call on success
  1282. * @param errorCallback defines the callback to call on error
  1283. */
  1284. open(successCallback: () => void, errorCallback: () => void): void;
  1285. /**
  1286. * Loads an image from the offline support
  1287. * @param url defines the url to load from
  1288. * @param image defines the target DOM image
  1289. */
  1290. loadImage(url: string, image: HTMLImageElement): void;
  1291. /**
  1292. * Loads a file from offline support
  1293. * @param url defines the URL to load from
  1294. * @param sceneLoaded defines a callback to call on success
  1295. * @param progressCallBack defines a callback to call when progress changed
  1296. * @param errorCallback defines a callback to call on error
  1297. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  1298. */
  1299. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  1300. }
  1301. }
  1302. declare module "babylonjs/Misc/filesInputStore" {
  1303. /**
  1304. * Class used to help managing file picking and drag'n'drop
  1305. * File Storage
  1306. */
  1307. export class FilesInputStore {
  1308. /**
  1309. * List of files ready to be loaded
  1310. */
  1311. static FilesToLoad: {
  1312. [key: string]: File;
  1313. };
  1314. }
  1315. }
  1316. declare module "babylonjs/Misc/retryStrategy" {
  1317. import { WebRequest } from "babylonjs/Misc/webRequest";
  1318. /**
  1319. * Class used to define a retry strategy when error happens while loading assets
  1320. */
  1321. export class RetryStrategy {
  1322. /**
  1323. * Function used to defines an exponential back off strategy
  1324. * @param maxRetries defines the maximum number of retries (3 by default)
  1325. * @param baseInterval defines the interval between retries
  1326. * @returns the strategy function to use
  1327. */
  1328. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  1329. }
  1330. }
  1331. declare module "babylonjs/Misc/baseError" {
  1332. /**
  1333. * @ignore
  1334. * Application error to support additional information when loading a file
  1335. */
  1336. export abstract class BaseError extends Error {
  1337. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  1338. }
  1339. }
  1340. declare module "babylonjs/Misc/fileTools" {
  1341. import { WebRequest } from "babylonjs/Misc/webRequest";
  1342. import { Nullable } from "babylonjs/types";
  1343. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  1344. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  1345. import { BaseError } from "babylonjs/Misc/baseError";
  1346. /** @ignore */
  1347. export class LoadFileError extends BaseError {
  1348. request?: WebRequest;
  1349. file?: File;
  1350. /**
  1351. * Creates a new LoadFileError
  1352. * @param message defines the message of the error
  1353. * @param request defines the optional web request
  1354. * @param file defines the optional file
  1355. */
  1356. constructor(message: string, object?: WebRequest | File);
  1357. }
  1358. /** @ignore */
  1359. export class RequestFileError extends BaseError {
  1360. request: WebRequest;
  1361. /**
  1362. * Creates a new LoadFileError
  1363. * @param message defines the message of the error
  1364. * @param request defines the optional web request
  1365. */
  1366. constructor(message: string, request: WebRequest);
  1367. }
  1368. /** @ignore */
  1369. export class ReadFileError extends BaseError {
  1370. file: File;
  1371. /**
  1372. * Creates a new ReadFileError
  1373. * @param message defines the message of the error
  1374. * @param file defines the optional file
  1375. */
  1376. constructor(message: string, file: File);
  1377. }
  1378. /**
  1379. * @hidden
  1380. */
  1381. export class FileTools {
  1382. /**
  1383. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  1384. */
  1385. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  1386. /**
  1387. * Gets or sets the base URL to use to load assets
  1388. */
  1389. static BaseUrl: string;
  1390. /**
  1391. * Default behaviour for cors in the application.
  1392. * It can be a string if the expected behavior is identical in the entire app.
  1393. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  1394. */
  1395. static CorsBehavior: string | ((url: string | string[]) => string);
  1396. /**
  1397. * Gets or sets a function used to pre-process url before using them to load assets
  1398. */
  1399. static PreprocessUrl: (url: string) => string;
  1400. /**
  1401. * Removes unwanted characters from an url
  1402. * @param url defines the url to clean
  1403. * @returns the cleaned url
  1404. */
  1405. private static _CleanUrl;
  1406. /**
  1407. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  1408. * @param url define the url we are trying
  1409. * @param element define the dom element where to configure the cors policy
  1410. */
  1411. static SetCorsBehavior(url: string | string[], element: {
  1412. crossOrigin: string | null;
  1413. }): void;
  1414. /**
  1415. * Loads an image as an HTMLImageElement.
  1416. * @param input url string, ArrayBuffer, or Blob to load
  1417. * @param onLoad callback called when the image successfully loads
  1418. * @param onError callback called when the image fails to load
  1419. * @param offlineProvider offline provider for caching
  1420. * @param mimeType optional mime type
  1421. * @returns the HTMLImageElement of the loaded image
  1422. */
  1423. static LoadImage(input: string | ArrayBuffer | ArrayBufferView | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  1424. /**
  1425. * Reads a file from a File object
  1426. * @param file defines the file to load
  1427. * @param onSuccess defines the callback to call when data is loaded
  1428. * @param onProgress defines the callback to call during loading process
  1429. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  1430. * @param onError defines the callback to call when an error occurs
  1431. * @returns a file request object
  1432. */
  1433. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  1434. /**
  1435. * Loads a file from a url
  1436. * @param url url to load
  1437. * @param onSuccess callback called when the file successfully loads
  1438. * @param onProgress callback called while file is loading (if the server supports this mode)
  1439. * @param offlineProvider defines the offline provider for caching
  1440. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1441. * @param onError callback called when the file fails to load
  1442. * @returns a file request object
  1443. */
  1444. static LoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  1445. /**
  1446. * Loads a file
  1447. * @param url url to load
  1448. * @param onSuccess callback called when the file successfully loads
  1449. * @param onProgress callback called while file is loading (if the server supports this mode)
  1450. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1451. * @param onError callback called when the file fails to load
  1452. * @param onOpened callback called when the web request is opened
  1453. * @returns a file request object
  1454. */
  1455. static RequestFile(url: string, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, onProgress?: (event: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  1456. /**
  1457. * Checks if the loaded document was accessed via `file:`-Protocol.
  1458. * @returns boolean
  1459. */
  1460. static IsFileURL(): boolean;
  1461. }
  1462. }
  1463. declare module "babylonjs/Engines/Processors/shaderProcessor" {
  1464. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1465. import { WebRequest } from "babylonjs/Misc/webRequest";
  1466. import { LoadFileError } from "babylonjs/Misc/fileTools";
  1467. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  1468. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  1469. /** @hidden */
  1470. export class ShaderProcessor {
  1471. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  1472. private static _ProcessPrecision;
  1473. private static _ExtractOperation;
  1474. private static _BuildSubExpression;
  1475. private static _BuildExpression;
  1476. private static _MoveCursorWithinIf;
  1477. private static _MoveCursor;
  1478. private static _EvaluatePreProcessors;
  1479. private static _PreparePreProcessors;
  1480. private static _ProcessShaderConversion;
  1481. private static _ProcessIncludes;
  1482. /**
  1483. * Loads a file from a url
  1484. * @param url url to load
  1485. * @param onSuccess callback called when the file successfully loads
  1486. * @param onProgress callback called while file is loading (if the server supports this mode)
  1487. * @param offlineProvider defines the offline provider for caching
  1488. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1489. * @param onError callback called when the file fails to load
  1490. * @returns a file request object
  1491. * @hidden
  1492. */
  1493. static _FileToolsLoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  1494. }
  1495. }
  1496. declare module "babylonjs/Maths/math.like" {
  1497. import { float, int, DeepImmutable } from "babylonjs/types";
  1498. /**
  1499. * @hidden
  1500. */
  1501. export interface IColor4Like {
  1502. r: float;
  1503. g: float;
  1504. b: float;
  1505. a: float;
  1506. }
  1507. /**
  1508. * @hidden
  1509. */
  1510. export interface IColor3Like {
  1511. r: float;
  1512. g: float;
  1513. b: float;
  1514. }
  1515. /**
  1516. * @hidden
  1517. */
  1518. export interface IVector4Like {
  1519. x: float;
  1520. y: float;
  1521. z: float;
  1522. w: float;
  1523. }
  1524. /**
  1525. * @hidden
  1526. */
  1527. export interface IVector3Like {
  1528. x: float;
  1529. y: float;
  1530. z: float;
  1531. }
  1532. /**
  1533. * @hidden
  1534. */
  1535. export interface IVector2Like {
  1536. x: float;
  1537. y: float;
  1538. }
  1539. /**
  1540. * @hidden
  1541. */
  1542. export interface IMatrixLike {
  1543. toArray(): DeepImmutable<Float32Array>;
  1544. updateFlag: int;
  1545. }
  1546. /**
  1547. * @hidden
  1548. */
  1549. export interface IViewportLike {
  1550. x: float;
  1551. y: float;
  1552. width: float;
  1553. height: float;
  1554. }
  1555. /**
  1556. * @hidden
  1557. */
  1558. export interface IPlaneLike {
  1559. normal: IVector3Like;
  1560. d: float;
  1561. normalize(): void;
  1562. }
  1563. }
  1564. declare module "babylonjs/Materials/iEffectFallbacks" {
  1565. import { Effect } from "babylonjs/Materials/effect";
  1566. /**
  1567. * Interface used to define common properties for effect fallbacks
  1568. */
  1569. export interface IEffectFallbacks {
  1570. /**
  1571. * Removes the defines that should be removed when falling back.
  1572. * @param currentDefines defines the current define statements for the shader.
  1573. * @param effect defines the current effect we try to compile
  1574. * @returns The resulting defines with defines of the current rank removed.
  1575. */
  1576. reduce(currentDefines: string, effect: Effect): string;
  1577. /**
  1578. * Removes the fallback from the bound mesh.
  1579. */
  1580. unBindMesh(): void;
  1581. /**
  1582. * Checks to see if more fallbacks are still availible.
  1583. */
  1584. hasMoreFallbacks: boolean;
  1585. }
  1586. }
  1587. declare module "babylonjs/Misc/andOrNotEvaluator" {
  1588. /**
  1589. * Class used to evalaute queries containing `and` and `or` operators
  1590. */
  1591. export class AndOrNotEvaluator {
  1592. /**
  1593. * Evaluate a query
  1594. * @param query defines the query to evaluate
  1595. * @param evaluateCallback defines the callback used to filter result
  1596. * @returns true if the query matches
  1597. */
  1598. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  1599. private static _HandleParenthesisContent;
  1600. private static _SimplifyNegation;
  1601. }
  1602. }
  1603. declare module "babylonjs/Misc/tags" {
  1604. /**
  1605. * Class used to store custom tags
  1606. */
  1607. export class Tags {
  1608. /**
  1609. * Adds support for tags on the given object
  1610. * @param obj defines the object to use
  1611. */
  1612. static EnableFor(obj: any): void;
  1613. /**
  1614. * Removes tags support
  1615. * @param obj defines the object to use
  1616. */
  1617. static DisableFor(obj: any): void;
  1618. /**
  1619. * Gets a boolean indicating if the given object has tags
  1620. * @param obj defines the object to use
  1621. * @returns a boolean
  1622. */
  1623. static HasTags(obj: any): boolean;
  1624. /**
  1625. * Gets the tags available on a given object
  1626. * @param obj defines the object to use
  1627. * @param asString defines if the tags must be returned as a string instead of an array of strings
  1628. * @returns the tags
  1629. */
  1630. static GetTags(obj: any, asString?: boolean): any;
  1631. /**
  1632. * Adds tags to an object
  1633. * @param obj defines the object to use
  1634. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  1635. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  1636. */
  1637. static AddTagsTo(obj: any, tagsString: string): void;
  1638. /**
  1639. * @hidden
  1640. */
  1641. static _AddTagTo(obj: any, tag: string): void;
  1642. /**
  1643. * Removes specific tags from a specific object
  1644. * @param obj defines the object to use
  1645. * @param tagsString defines the tags to remove
  1646. */
  1647. static RemoveTagsFrom(obj: any, tagsString: string): void;
  1648. /**
  1649. * @hidden
  1650. */
  1651. static _RemoveTagFrom(obj: any, tag: string): void;
  1652. /**
  1653. * Defines if tags hosted on an object match a given query
  1654. * @param obj defines the object to use
  1655. * @param tagsQuery defines the tag query
  1656. * @returns a boolean
  1657. */
  1658. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  1659. }
  1660. }
  1661. declare module "babylonjs/Maths/math.scalar" {
  1662. /**
  1663. * Scalar computation library
  1664. */
  1665. export class Scalar {
  1666. /**
  1667. * Two pi constants convenient for computation.
  1668. */
  1669. static TwoPi: number;
  1670. /**
  1671. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1672. * @param a number
  1673. * @param b number
  1674. * @param epsilon (default = 1.401298E-45)
  1675. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1676. */
  1677. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  1678. /**
  1679. * Returns a string : the upper case translation of the number i to hexadecimal.
  1680. * @param i number
  1681. * @returns the upper case translation of the number i to hexadecimal.
  1682. */
  1683. static ToHex(i: number): string;
  1684. /**
  1685. * Returns -1 if value is negative and +1 is value is positive.
  1686. * @param value the value
  1687. * @returns the value itself if it's equal to zero.
  1688. */
  1689. static Sign(value: number): number;
  1690. /**
  1691. * Returns the value itself if it's between min and max.
  1692. * Returns min if the value is lower than min.
  1693. * Returns max if the value is greater than max.
  1694. * @param value the value to clmap
  1695. * @param min the min value to clamp to (default: 0)
  1696. * @param max the max value to clamp to (default: 1)
  1697. * @returns the clamped value
  1698. */
  1699. static Clamp(value: number, min?: number, max?: number): number;
  1700. /**
  1701. * the log2 of value.
  1702. * @param value the value to compute log2 of
  1703. * @returns the log2 of value.
  1704. */
  1705. static Log2(value: number): number;
  1706. /**
  1707. * Loops the value, so that it is never larger than length and never smaller than 0.
  1708. *
  1709. * This is similar to the modulo operator but it works with floating point numbers.
  1710. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  1711. * With t = 5 and length = 2.5, the result would be 0.0.
  1712. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  1713. * @param value the value
  1714. * @param length the length
  1715. * @returns the looped value
  1716. */
  1717. static Repeat(value: number, length: number): number;
  1718. /**
  1719. * Normalize the value between 0.0 and 1.0 using min and max values
  1720. * @param value value to normalize
  1721. * @param min max to normalize between
  1722. * @param max min to normalize between
  1723. * @returns the normalized value
  1724. */
  1725. static Normalize(value: number, min: number, max: number): number;
  1726. /**
  1727. * Denormalize the value from 0.0 and 1.0 using min and max values
  1728. * @param normalized value to denormalize
  1729. * @param min max to denormalize between
  1730. * @param max min to denormalize between
  1731. * @returns the denormalized value
  1732. */
  1733. static Denormalize(normalized: number, min: number, max: number): number;
  1734. /**
  1735. * Calculates the shortest difference between two given angles given in degrees.
  1736. * @param current current angle in degrees
  1737. * @param target target angle in degrees
  1738. * @returns the delta
  1739. */
  1740. static DeltaAngle(current: number, target: number): number;
  1741. /**
  1742. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  1743. * @param tx value
  1744. * @param length length
  1745. * @returns The returned value will move back and forth between 0 and length
  1746. */
  1747. static PingPong(tx: number, length: number): number;
  1748. /**
  1749. * Interpolates between min and max with smoothing at the limits.
  1750. *
  1751. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  1752. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  1753. * @param from from
  1754. * @param to to
  1755. * @param tx value
  1756. * @returns the smooth stepped value
  1757. */
  1758. static SmoothStep(from: number, to: number, tx: number): number;
  1759. /**
  1760. * Moves a value current towards target.
  1761. *
  1762. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  1763. * Negative values of maxDelta pushes the value away from target.
  1764. * @param current current value
  1765. * @param target target value
  1766. * @param maxDelta max distance to move
  1767. * @returns resulting value
  1768. */
  1769. static MoveTowards(current: number, target: number, maxDelta: number): number;
  1770. /**
  1771. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1772. *
  1773. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  1774. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  1775. * @param current current value
  1776. * @param target target value
  1777. * @param maxDelta max distance to move
  1778. * @returns resulting angle
  1779. */
  1780. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  1781. /**
  1782. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  1783. * @param start start value
  1784. * @param end target value
  1785. * @param amount amount to lerp between
  1786. * @returns the lerped value
  1787. */
  1788. static Lerp(start: number, end: number, amount: number): number;
  1789. /**
  1790. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1791. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  1792. * @param start start value
  1793. * @param end target value
  1794. * @param amount amount to lerp between
  1795. * @returns the lerped value
  1796. */
  1797. static LerpAngle(start: number, end: number, amount: number): number;
  1798. /**
  1799. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  1800. * @param a start value
  1801. * @param b target value
  1802. * @param value value between a and b
  1803. * @returns the inverseLerp value
  1804. */
  1805. static InverseLerp(a: number, b: number, value: number): number;
  1806. /**
  1807. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  1808. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  1809. * @param value1 spline value
  1810. * @param tangent1 spline value
  1811. * @param value2 spline value
  1812. * @param tangent2 spline value
  1813. * @param amount input value
  1814. * @returns hermite result
  1815. */
  1816. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  1817. /**
  1818. * Returns a random float number between and min and max values
  1819. * @param min min value of random
  1820. * @param max max value of random
  1821. * @returns random value
  1822. */
  1823. static RandomRange(min: number, max: number): number;
  1824. /**
  1825. * This function returns percentage of a number in a given range.
  1826. *
  1827. * RangeToPercent(40,20,60) will return 0.5 (50%)
  1828. * RangeToPercent(34,0,100) will return 0.34 (34%)
  1829. * @param number to convert to percentage
  1830. * @param min min range
  1831. * @param max max range
  1832. * @returns the percentage
  1833. */
  1834. static RangeToPercent(number: number, min: number, max: number): number;
  1835. /**
  1836. * This function returns number that corresponds to the percentage in a given range.
  1837. *
  1838. * PercentToRange(0.34,0,100) will return 34.
  1839. * @param percent to convert to number
  1840. * @param min min range
  1841. * @param max max range
  1842. * @returns the number
  1843. */
  1844. static PercentToRange(percent: number, min: number, max: number): number;
  1845. /**
  1846. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  1847. * @param angle The angle to normalize in radian.
  1848. * @return The converted angle.
  1849. */
  1850. static NormalizeRadians(angle: number): number;
  1851. }
  1852. }
  1853. declare module "babylonjs/Maths/math.constants" {
  1854. /**
  1855. * Constant used to convert a value to gamma space
  1856. * @ignorenaming
  1857. */
  1858. export const ToGammaSpace: number;
  1859. /**
  1860. * Constant used to convert a value to linear space
  1861. * @ignorenaming
  1862. */
  1863. export const ToLinearSpace = 2.2;
  1864. /**
  1865. * Constant used to define the minimal number value in Babylon.js
  1866. * @ignorenaming
  1867. */
  1868. let Epsilon: number;
  1869. export { Epsilon };
  1870. }
  1871. declare module "babylonjs/Maths/math.viewport" {
  1872. /**
  1873. * Class used to represent a viewport on screen
  1874. */
  1875. export class Viewport {
  1876. /** viewport left coordinate */
  1877. x: number;
  1878. /** viewport top coordinate */
  1879. y: number;
  1880. /**viewport width */
  1881. width: number;
  1882. /** viewport height */
  1883. height: number;
  1884. /**
  1885. * Creates a Viewport object located at (x, y) and sized (width, height)
  1886. * @param x defines viewport left coordinate
  1887. * @param y defines viewport top coordinate
  1888. * @param width defines the viewport width
  1889. * @param height defines the viewport height
  1890. */
  1891. constructor(
  1892. /** viewport left coordinate */
  1893. x: number,
  1894. /** viewport top coordinate */
  1895. y: number,
  1896. /**viewport width */
  1897. width: number,
  1898. /** viewport height */
  1899. height: number);
  1900. /**
  1901. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  1902. * @param renderWidth defines the rendering width
  1903. * @param renderHeight defines the rendering height
  1904. * @returns a new Viewport
  1905. */
  1906. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  1907. /**
  1908. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  1909. * @param renderWidth defines the rendering width
  1910. * @param renderHeight defines the rendering height
  1911. * @param ref defines the target viewport
  1912. * @returns the current viewport
  1913. */
  1914. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  1915. /**
  1916. * Returns a new Viewport copied from the current one
  1917. * @returns a new Viewport
  1918. */
  1919. clone(): Viewport;
  1920. }
  1921. }
  1922. declare module "babylonjs/Misc/arrayTools" {
  1923. /**
  1924. * Class containing a set of static utilities functions for arrays.
  1925. */
  1926. export class ArrayTools {
  1927. /**
  1928. * Returns an array of the given size filled with element built from the given constructor and the paramters
  1929. * @param size the number of element to construct and put in the array
  1930. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  1931. * @returns a new array filled with new objects
  1932. */
  1933. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  1934. }
  1935. }
  1936. declare module "babylonjs/Maths/math.plane" {
  1937. import { DeepImmutable } from "babylonjs/types";
  1938. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  1939. /**
  1940. * Represens a plane by the equation ax + by + cz + d = 0
  1941. */
  1942. export class Plane {
  1943. private static _TmpMatrix;
  1944. /**
  1945. * Normal of the plane (a,b,c)
  1946. */
  1947. normal: Vector3;
  1948. /**
  1949. * d component of the plane
  1950. */
  1951. d: number;
  1952. /**
  1953. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  1954. * @param a a component of the plane
  1955. * @param b b component of the plane
  1956. * @param c c component of the plane
  1957. * @param d d component of the plane
  1958. */
  1959. constructor(a: number, b: number, c: number, d: number);
  1960. /**
  1961. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  1962. */
  1963. asArray(): number[];
  1964. /**
  1965. * @returns a new plane copied from the current Plane.
  1966. */
  1967. clone(): Plane;
  1968. /**
  1969. * @returns the string "Plane".
  1970. */
  1971. getClassName(): string;
  1972. /**
  1973. * @returns the Plane hash code.
  1974. */
  1975. getHashCode(): number;
  1976. /**
  1977. * Normalize the current Plane in place.
  1978. * @returns the updated Plane.
  1979. */
  1980. normalize(): Plane;
  1981. /**
  1982. * Applies a transformation the plane and returns the result
  1983. * @param transformation the transformation matrix to be applied to the plane
  1984. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  1985. */
  1986. transform(transformation: DeepImmutable<Matrix>): Plane;
  1987. /**
  1988. * Compute the dot product between the point and the plane normal
  1989. * @param point point to calculate the dot product with
  1990. * @returns the dot product (float) of the point coordinates and the plane normal.
  1991. */
  1992. dotCoordinate(point: DeepImmutable<Vector3>): number;
  1993. /**
  1994. * Updates the current Plane from the plane defined by the three given points.
  1995. * @param point1 one of the points used to contruct the plane
  1996. * @param point2 one of the points used to contruct the plane
  1997. * @param point3 one of the points used to contruct the plane
  1998. * @returns the updated Plane.
  1999. */
  2000. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  2001. /**
  2002. * Checks if the plane is facing a given direction
  2003. * @param direction the direction to check if the plane is facing
  2004. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  2005. * @returns True is the vector "direction" is the same side than the plane normal.
  2006. */
  2007. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  2008. /**
  2009. * Calculates the distance to a point
  2010. * @param point point to calculate distance to
  2011. * @returns the signed distance (float) from the given point to the Plane.
  2012. */
  2013. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  2014. /**
  2015. * Creates a plane from an array
  2016. * @param array the array to create a plane from
  2017. * @returns a new Plane from the given array.
  2018. */
  2019. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  2020. /**
  2021. * Creates a plane from three points
  2022. * @param point1 point used to create the plane
  2023. * @param point2 point used to create the plane
  2024. * @param point3 point used to create the plane
  2025. * @returns a new Plane defined by the three given points.
  2026. */
  2027. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  2028. /**
  2029. * Creates a plane from an origin point and a normal
  2030. * @param origin origin of the plane to be constructed
  2031. * @param normal normal of the plane to be constructed
  2032. * @returns a new Plane the normal vector to this plane at the given origin point.
  2033. * Note : the vector "normal" is updated because normalized.
  2034. */
  2035. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  2036. /**
  2037. * Calculates the distance from a plane and a point
  2038. * @param origin origin of the plane to be constructed
  2039. * @param normal normal of the plane to be constructed
  2040. * @param point point to calculate distance to
  2041. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  2042. */
  2043. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  2044. }
  2045. }
  2046. declare module "babylonjs/Maths/math.vector" {
  2047. import { Viewport } from "babylonjs/Maths/math.viewport";
  2048. import { DeepImmutable, Nullable, FloatArray, float } from "babylonjs/types";
  2049. import { IPlaneLike } from "babylonjs/Maths/math.like";
  2050. import { Plane } from "babylonjs/Maths/math.plane";
  2051. /**
  2052. * Class representing a vector containing 2 coordinates
  2053. */
  2054. export class Vector2 {
  2055. /** defines the first coordinate */
  2056. x: number;
  2057. /** defines the second coordinate */
  2058. y: number;
  2059. /**
  2060. * Creates a new Vector2 from the given x and y coordinates
  2061. * @param x defines the first coordinate
  2062. * @param y defines the second coordinate
  2063. */
  2064. constructor(
  2065. /** defines the first coordinate */
  2066. x?: number,
  2067. /** defines the second coordinate */
  2068. y?: number);
  2069. /**
  2070. * Gets a string with the Vector2 coordinates
  2071. * @returns a string with the Vector2 coordinates
  2072. */
  2073. toString(): string;
  2074. /**
  2075. * Gets class name
  2076. * @returns the string "Vector2"
  2077. */
  2078. getClassName(): string;
  2079. /**
  2080. * Gets current vector hash code
  2081. * @returns the Vector2 hash code as a number
  2082. */
  2083. getHashCode(): number;
  2084. /**
  2085. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  2086. * @param array defines the source array
  2087. * @param index defines the offset in source array
  2088. * @returns the current Vector2
  2089. */
  2090. toArray(array: FloatArray, index?: number): Vector2;
  2091. /**
  2092. * Copy the current vector to an array
  2093. * @returns a new array with 2 elements: the Vector2 coordinates.
  2094. */
  2095. asArray(): number[];
  2096. /**
  2097. * Sets the Vector2 coordinates with the given Vector2 coordinates
  2098. * @param source defines the source Vector2
  2099. * @returns the current updated Vector2
  2100. */
  2101. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  2102. /**
  2103. * Sets the Vector2 coordinates with the given floats
  2104. * @param x defines the first coordinate
  2105. * @param y defines the second coordinate
  2106. * @returns the current updated Vector2
  2107. */
  2108. copyFromFloats(x: number, y: number): Vector2;
  2109. /**
  2110. * Sets the Vector2 coordinates with the given floats
  2111. * @param x defines the first coordinate
  2112. * @param y defines the second coordinate
  2113. * @returns the current updated Vector2
  2114. */
  2115. set(x: number, y: number): Vector2;
  2116. /**
  2117. * Add another vector with the current one
  2118. * @param otherVector defines the other vector
  2119. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  2120. */
  2121. add(otherVector: DeepImmutable<Vector2>): Vector2;
  2122. /**
  2123. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  2124. * @param otherVector defines the other vector
  2125. * @param result defines the target vector
  2126. * @returns the unmodified current Vector2
  2127. */
  2128. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2129. /**
  2130. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  2131. * @param otherVector defines the other vector
  2132. * @returns the current updated Vector2
  2133. */
  2134. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2135. /**
  2136. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  2137. * @param otherVector defines the other vector
  2138. * @returns a new Vector2
  2139. */
  2140. addVector3(otherVector: Vector3): Vector2;
  2141. /**
  2142. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  2143. * @param otherVector defines the other vector
  2144. * @returns a new Vector2
  2145. */
  2146. subtract(otherVector: Vector2): Vector2;
  2147. /**
  2148. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  2149. * @param otherVector defines the other vector
  2150. * @param result defines the target vector
  2151. * @returns the unmodified current Vector2
  2152. */
  2153. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2154. /**
  2155. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  2156. * @param otherVector defines the other vector
  2157. * @returns the current updated Vector2
  2158. */
  2159. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2160. /**
  2161. * Multiplies in place the current Vector2 coordinates by the given ones
  2162. * @param otherVector defines the other vector
  2163. * @returns the current updated Vector2
  2164. */
  2165. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2166. /**
  2167. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  2168. * @param otherVector defines the other vector
  2169. * @returns a new Vector2
  2170. */
  2171. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  2172. /**
  2173. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  2174. * @param otherVector defines the other vector
  2175. * @param result defines the target vector
  2176. * @returns the unmodified current Vector2
  2177. */
  2178. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2179. /**
  2180. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  2181. * @param x defines the first coordinate
  2182. * @param y defines the second coordinate
  2183. * @returns a new Vector2
  2184. */
  2185. multiplyByFloats(x: number, y: number): Vector2;
  2186. /**
  2187. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  2188. * @param otherVector defines the other vector
  2189. * @returns a new Vector2
  2190. */
  2191. divide(otherVector: Vector2): Vector2;
  2192. /**
  2193. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  2194. * @param otherVector defines the other vector
  2195. * @param result defines the target vector
  2196. * @returns the unmodified current Vector2
  2197. */
  2198. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2199. /**
  2200. * Divides the current Vector2 coordinates by the given ones
  2201. * @param otherVector defines the other vector
  2202. * @returns the current updated Vector2
  2203. */
  2204. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2205. /**
  2206. * Gets a new Vector2 with current Vector2 negated coordinates
  2207. * @returns a new Vector2
  2208. */
  2209. negate(): Vector2;
  2210. /**
  2211. * Negate this vector in place
  2212. * @returns this
  2213. */
  2214. negateInPlace(): Vector2;
  2215. /**
  2216. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  2217. * @param result defines the Vector3 object where to store the result
  2218. * @returns the current Vector2
  2219. */
  2220. negateToRef(result: Vector2): Vector2;
  2221. /**
  2222. * Multiply the Vector2 coordinates by scale
  2223. * @param scale defines the scaling factor
  2224. * @returns the current updated Vector2
  2225. */
  2226. scaleInPlace(scale: number): Vector2;
  2227. /**
  2228. * Returns a new Vector2 scaled by "scale" from the current Vector2
  2229. * @param scale defines the scaling factor
  2230. * @returns a new Vector2
  2231. */
  2232. scale(scale: number): Vector2;
  2233. /**
  2234. * Scale the current Vector2 values by a factor to a given Vector2
  2235. * @param scale defines the scale factor
  2236. * @param result defines the Vector2 object where to store the result
  2237. * @returns the unmodified current Vector2
  2238. */
  2239. scaleToRef(scale: number, result: Vector2): Vector2;
  2240. /**
  2241. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  2242. * @param scale defines the scale factor
  2243. * @param result defines the Vector2 object where to store the result
  2244. * @returns the unmodified current Vector2
  2245. */
  2246. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  2247. /**
  2248. * Gets a boolean if two vectors are equals
  2249. * @param otherVector defines the other vector
  2250. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  2251. */
  2252. equals(otherVector: DeepImmutable<Vector2>): boolean;
  2253. /**
  2254. * Gets a boolean if two vectors are equals (using an epsilon value)
  2255. * @param otherVector defines the other vector
  2256. * @param epsilon defines the minimal distance to consider equality
  2257. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  2258. */
  2259. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  2260. /**
  2261. * Gets a new Vector2 from current Vector2 floored values
  2262. * @returns a new Vector2
  2263. */
  2264. floor(): Vector2;
  2265. /**
  2266. * Gets a new Vector2 from current Vector2 floored values
  2267. * @returns a new Vector2
  2268. */
  2269. fract(): Vector2;
  2270. /**
  2271. * Gets the length of the vector
  2272. * @returns the vector length (float)
  2273. */
  2274. length(): number;
  2275. /**
  2276. * Gets the vector squared length
  2277. * @returns the vector squared length (float)
  2278. */
  2279. lengthSquared(): number;
  2280. /**
  2281. * Normalize the vector
  2282. * @returns the current updated Vector2
  2283. */
  2284. normalize(): Vector2;
  2285. /**
  2286. * Gets a new Vector2 copied from the Vector2
  2287. * @returns a new Vector2
  2288. */
  2289. clone(): Vector2;
  2290. /**
  2291. * Gets a new Vector2(0, 0)
  2292. * @returns a new Vector2
  2293. */
  2294. static Zero(): Vector2;
  2295. /**
  2296. * Gets a new Vector2(1, 1)
  2297. * @returns a new Vector2
  2298. */
  2299. static One(): Vector2;
  2300. /**
  2301. * Gets a new Vector2 set from the given index element of the given array
  2302. * @param array defines the data source
  2303. * @param offset defines the offset in the data source
  2304. * @returns a new Vector2
  2305. */
  2306. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  2307. /**
  2308. * Sets "result" from the given index element of the given array
  2309. * @param array defines the data source
  2310. * @param offset defines the offset in the data source
  2311. * @param result defines the target vector
  2312. */
  2313. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  2314. /**
  2315. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  2316. * @param value1 defines 1st point of control
  2317. * @param value2 defines 2nd point of control
  2318. * @param value3 defines 3rd point of control
  2319. * @param value4 defines 4th point of control
  2320. * @param amount defines the interpolation factor
  2321. * @returns a new Vector2
  2322. */
  2323. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  2324. /**
  2325. * Returns a new Vector2 set with same the coordinates than "value" ones if the vector "value" is in the square defined by "min" and "max".
  2326. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  2327. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  2328. * @param value defines the value to clamp
  2329. * @param min defines the lower limit
  2330. * @param max defines the upper limit
  2331. * @returns a new Vector2
  2332. */
  2333. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  2334. /**
  2335. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  2336. * @param value1 defines the 1st control point
  2337. * @param tangent1 defines the outgoing tangent
  2338. * @param value2 defines the 2nd control point
  2339. * @param tangent2 defines the incoming tangent
  2340. * @param amount defines the interpolation factor
  2341. * @returns a new Vector2
  2342. */
  2343. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  2344. /**
  2345. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  2346. * @param start defines the start vector
  2347. * @param end defines the end vector
  2348. * @param amount defines the interpolation factor
  2349. * @returns a new Vector2
  2350. */
  2351. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  2352. /**
  2353. * Gets the dot product of the vector "left" and the vector "right"
  2354. * @param left defines first vector
  2355. * @param right defines second vector
  2356. * @returns the dot product (float)
  2357. */
  2358. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  2359. /**
  2360. * Returns a new Vector2 equal to the normalized given vector
  2361. * @param vector defines the vector to normalize
  2362. * @returns a new Vector2
  2363. */
  2364. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  2365. /**
  2366. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  2367. * @param left defines 1st vector
  2368. * @param right defines 2nd vector
  2369. * @returns a new Vector2
  2370. */
  2371. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2372. /**
  2373. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  2374. * @param left defines 1st vector
  2375. * @param right defines 2nd vector
  2376. * @returns a new Vector2
  2377. */
  2378. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2379. /**
  2380. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  2381. * @param vector defines the vector to transform
  2382. * @param transformation defines the matrix to apply
  2383. * @returns a new Vector2
  2384. */
  2385. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  2386. /**
  2387. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  2388. * @param vector defines the vector to transform
  2389. * @param transformation defines the matrix to apply
  2390. * @param result defines the target vector
  2391. */
  2392. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  2393. /**
  2394. * Determines if a given vector is included in a triangle
  2395. * @param p defines the vector to test
  2396. * @param p0 defines 1st triangle point
  2397. * @param p1 defines 2nd triangle point
  2398. * @param p2 defines 3rd triangle point
  2399. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  2400. */
  2401. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  2402. /**
  2403. * Gets the distance between the vectors "value1" and "value2"
  2404. * @param value1 defines first vector
  2405. * @param value2 defines second vector
  2406. * @returns the distance between vectors
  2407. */
  2408. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2409. /**
  2410. * Returns the squared distance between the vectors "value1" and "value2"
  2411. * @param value1 defines first vector
  2412. * @param value2 defines second vector
  2413. * @returns the squared distance between vectors
  2414. */
  2415. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2416. /**
  2417. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  2418. * @param value1 defines first vector
  2419. * @param value2 defines second vector
  2420. * @returns a new Vector2
  2421. */
  2422. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  2423. /**
  2424. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  2425. * @param p defines the middle point
  2426. * @param segA defines one point of the segment
  2427. * @param segB defines the other point of the segment
  2428. * @returns the shortest distance
  2429. */
  2430. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  2431. }
  2432. /**
  2433. * Class used to store (x,y,z) vector representation
  2434. * A Vector3 is the main object used in 3D geometry
  2435. * It can represent etiher the coordinates of a point the space, either a direction
  2436. * Reminder: js uses a left handed forward facing system
  2437. */
  2438. export class Vector3 {
  2439. /**
  2440. * Defines the first coordinates (on X axis)
  2441. */
  2442. x: number;
  2443. /**
  2444. * Defines the second coordinates (on Y axis)
  2445. */
  2446. y: number;
  2447. /**
  2448. * Defines the third coordinates (on Z axis)
  2449. */
  2450. z: number;
  2451. private static _UpReadOnly;
  2452. private static _ZeroReadOnly;
  2453. /**
  2454. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  2455. * @param x defines the first coordinates (on X axis)
  2456. * @param y defines the second coordinates (on Y axis)
  2457. * @param z defines the third coordinates (on Z axis)
  2458. */
  2459. constructor(
  2460. /**
  2461. * Defines the first coordinates (on X axis)
  2462. */
  2463. x?: number,
  2464. /**
  2465. * Defines the second coordinates (on Y axis)
  2466. */
  2467. y?: number,
  2468. /**
  2469. * Defines the third coordinates (on Z axis)
  2470. */
  2471. z?: number);
  2472. /**
  2473. * Creates a string representation of the Vector3
  2474. * @returns a string with the Vector3 coordinates.
  2475. */
  2476. toString(): string;
  2477. /**
  2478. * Gets the class name
  2479. * @returns the string "Vector3"
  2480. */
  2481. getClassName(): string;
  2482. /**
  2483. * Creates the Vector3 hash code
  2484. * @returns a number which tends to be unique between Vector3 instances
  2485. */
  2486. getHashCode(): number;
  2487. /**
  2488. * Creates an array containing three elements : the coordinates of the Vector3
  2489. * @returns a new array of numbers
  2490. */
  2491. asArray(): number[];
  2492. /**
  2493. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  2494. * @param array defines the destination array
  2495. * @param index defines the offset in the destination array
  2496. * @returns the current Vector3
  2497. */
  2498. toArray(array: FloatArray, index?: number): Vector3;
  2499. /**
  2500. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  2501. * @returns a new Quaternion object, computed from the Vector3 coordinates
  2502. */
  2503. toQuaternion(): Quaternion;
  2504. /**
  2505. * Adds the given vector to the current Vector3
  2506. * @param otherVector defines the second operand
  2507. * @returns the current updated Vector3
  2508. */
  2509. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2510. /**
  2511. * Adds the given coordinates to the current Vector3
  2512. * @param x defines the x coordinate of the operand
  2513. * @param y defines the y coordinate of the operand
  2514. * @param z defines the z coordinate of the operand
  2515. * @returns the current updated Vector3
  2516. */
  2517. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2518. /**
  2519. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  2520. * @param otherVector defines the second operand
  2521. * @returns the resulting Vector3
  2522. */
  2523. add(otherVector: DeepImmutable<Vector3>): Vector3;
  2524. /**
  2525. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  2526. * @param otherVector defines the second operand
  2527. * @param result defines the Vector3 object where to store the result
  2528. * @returns the current Vector3
  2529. */
  2530. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2531. /**
  2532. * Subtract the given vector from the current Vector3
  2533. * @param otherVector defines the second operand
  2534. * @returns the current updated Vector3
  2535. */
  2536. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2537. /**
  2538. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  2539. * @param otherVector defines the second operand
  2540. * @returns the resulting Vector3
  2541. */
  2542. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  2543. /**
  2544. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  2545. * @param otherVector defines the second operand
  2546. * @param result defines the Vector3 object where to store the result
  2547. * @returns the current Vector3
  2548. */
  2549. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2550. /**
  2551. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  2552. * @param x defines the x coordinate of the operand
  2553. * @param y defines the y coordinate of the operand
  2554. * @param z defines the z coordinate of the operand
  2555. * @returns the resulting Vector3
  2556. */
  2557. subtractFromFloats(x: number, y: number, z: number): Vector3;
  2558. /**
  2559. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  2560. * @param x defines the x coordinate of the operand
  2561. * @param y defines the y coordinate of the operand
  2562. * @param z defines the z coordinate of the operand
  2563. * @param result defines the Vector3 object where to store the result
  2564. * @returns the current Vector3
  2565. */
  2566. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  2567. /**
  2568. * Gets a new Vector3 set with the current Vector3 negated coordinates
  2569. * @returns a new Vector3
  2570. */
  2571. negate(): Vector3;
  2572. /**
  2573. * Negate this vector in place
  2574. * @returns this
  2575. */
  2576. negateInPlace(): Vector3;
  2577. /**
  2578. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  2579. * @param result defines the Vector3 object where to store the result
  2580. * @returns the current Vector3
  2581. */
  2582. negateToRef(result: Vector3): Vector3;
  2583. /**
  2584. * Multiplies the Vector3 coordinates by the float "scale"
  2585. * @param scale defines the multiplier factor
  2586. * @returns the current updated Vector3
  2587. */
  2588. scaleInPlace(scale: number): Vector3;
  2589. /**
  2590. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  2591. * @param scale defines the multiplier factor
  2592. * @returns a new Vector3
  2593. */
  2594. scale(scale: number): Vector3;
  2595. /**
  2596. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  2597. * @param scale defines the multiplier factor
  2598. * @param result defines the Vector3 object where to store the result
  2599. * @returns the current Vector3
  2600. */
  2601. scaleToRef(scale: number, result: Vector3): Vector3;
  2602. /**
  2603. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  2604. * @param scale defines the scale factor
  2605. * @param result defines the Vector3 object where to store the result
  2606. * @returns the unmodified current Vector3
  2607. */
  2608. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  2609. /**
  2610. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  2611. * @param origin defines the origin of the projection ray
  2612. * @param plane defines the plane to project to
  2613. * @returns the projected vector3
  2614. */
  2615. projectOnPlane(plane: Plane, origin: Vector3): Vector3;
  2616. /**
  2617. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  2618. * @param origin defines the origin of the projection ray
  2619. * @param plane defines the plane to project to
  2620. * @param result defines the Vector3 where to store the result
  2621. */
  2622. projectOnPlaneToRef(plane: Plane, origin: Vector3, result: Vector3): void;
  2623. /**
  2624. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  2625. * @param otherVector defines the second operand
  2626. * @returns true if both vectors are equals
  2627. */
  2628. equals(otherVector: DeepImmutable<Vector3>): boolean;
  2629. /**
  2630. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  2631. * @param otherVector defines the second operand
  2632. * @param epsilon defines the minimal distance to define values as equals
  2633. * @returns true if both vectors are distant less than epsilon
  2634. */
  2635. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  2636. /**
  2637. * Returns true if the current Vector3 coordinates equals the given floats
  2638. * @param x defines the x coordinate of the operand
  2639. * @param y defines the y coordinate of the operand
  2640. * @param z defines the z coordinate of the operand
  2641. * @returns true if both vectors are equals
  2642. */
  2643. equalsToFloats(x: number, y: number, z: number): boolean;
  2644. /**
  2645. * Multiplies the current Vector3 coordinates by the given ones
  2646. * @param otherVector defines the second operand
  2647. * @returns the current updated Vector3
  2648. */
  2649. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2650. /**
  2651. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  2652. * @param otherVector defines the second operand
  2653. * @returns the new Vector3
  2654. */
  2655. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  2656. /**
  2657. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  2658. * @param otherVector defines the second operand
  2659. * @param result defines the Vector3 object where to store the result
  2660. * @returns the current Vector3
  2661. */
  2662. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2663. /**
  2664. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  2665. * @param x defines the x coordinate of the operand
  2666. * @param y defines the y coordinate of the operand
  2667. * @param z defines the z coordinate of the operand
  2668. * @returns the new Vector3
  2669. */
  2670. multiplyByFloats(x: number, y: number, z: number): Vector3;
  2671. /**
  2672. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  2673. * @param otherVector defines the second operand
  2674. * @returns the new Vector3
  2675. */
  2676. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  2677. /**
  2678. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  2679. * @param otherVector defines the second operand
  2680. * @param result defines the Vector3 object where to store the result
  2681. * @returns the current Vector3
  2682. */
  2683. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2684. /**
  2685. * Divides the current Vector3 coordinates by the given ones.
  2686. * @param otherVector defines the second operand
  2687. * @returns the current updated Vector3
  2688. */
  2689. divideInPlace(otherVector: Vector3): Vector3;
  2690. /**
  2691. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  2692. * @param other defines the second operand
  2693. * @returns the current updated Vector3
  2694. */
  2695. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2696. /**
  2697. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  2698. * @param other defines the second operand
  2699. * @returns the current updated Vector3
  2700. */
  2701. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2702. /**
  2703. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  2704. * @param x defines the x coordinate of the operand
  2705. * @param y defines the y coordinate of the operand
  2706. * @param z defines the z coordinate of the operand
  2707. * @returns the current updated Vector3
  2708. */
  2709. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2710. /**
  2711. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  2712. * @param x defines the x coordinate of the operand
  2713. * @param y defines the y coordinate of the operand
  2714. * @param z defines the z coordinate of the operand
  2715. * @returns the current updated Vector3
  2716. */
  2717. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2718. /**
  2719. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  2720. * Check if is non uniform within a certain amount of decimal places to account for this
  2721. * @param epsilon the amount the values can differ
  2722. * @returns if the the vector is non uniform to a certain number of decimal places
  2723. */
  2724. isNonUniformWithinEpsilon(epsilon: number): boolean;
  2725. /**
  2726. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  2727. */
  2728. get isNonUniform(): boolean;
  2729. /**
  2730. * Gets a new Vector3 from current Vector3 floored values
  2731. * @returns a new Vector3
  2732. */
  2733. floor(): Vector3;
  2734. /**
  2735. * Gets a new Vector3 from current Vector3 floored values
  2736. * @returns a new Vector3
  2737. */
  2738. fract(): Vector3;
  2739. /**
  2740. * Gets the length of the Vector3
  2741. * @returns the length of the Vector3
  2742. */
  2743. length(): number;
  2744. /**
  2745. * Gets the squared length of the Vector3
  2746. * @returns squared length of the Vector3
  2747. */
  2748. lengthSquared(): number;
  2749. /**
  2750. * Normalize the current Vector3.
  2751. * Please note that this is an in place operation.
  2752. * @returns the current updated Vector3
  2753. */
  2754. normalize(): Vector3;
  2755. /**
  2756. * Reorders the x y z properties of the vector in place
  2757. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  2758. * @returns the current updated vector
  2759. */
  2760. reorderInPlace(order: string): this;
  2761. /**
  2762. * Rotates the vector around 0,0,0 by a quaternion
  2763. * @param quaternion the rotation quaternion
  2764. * @param result vector to store the result
  2765. * @returns the resulting vector
  2766. */
  2767. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  2768. /**
  2769. * Rotates a vector around a given point
  2770. * @param quaternion the rotation quaternion
  2771. * @param point the point to rotate around
  2772. * @param result vector to store the result
  2773. * @returns the resulting vector
  2774. */
  2775. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  2776. /**
  2777. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  2778. * The cross product is then orthogonal to both current and "other"
  2779. * @param other defines the right operand
  2780. * @returns the cross product
  2781. */
  2782. cross(other: Vector3): Vector3;
  2783. /**
  2784. * Normalize the current Vector3 with the given input length.
  2785. * Please note that this is an in place operation.
  2786. * @param len the length of the vector
  2787. * @returns the current updated Vector3
  2788. */
  2789. normalizeFromLength(len: number): Vector3;
  2790. /**
  2791. * Normalize the current Vector3 to a new vector
  2792. * @returns the new Vector3
  2793. */
  2794. normalizeToNew(): Vector3;
  2795. /**
  2796. * Normalize the current Vector3 to the reference
  2797. * @param reference define the Vector3 to update
  2798. * @returns the updated Vector3
  2799. */
  2800. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  2801. /**
  2802. * Creates a new Vector3 copied from the current Vector3
  2803. * @returns the new Vector3
  2804. */
  2805. clone(): Vector3;
  2806. /**
  2807. * Copies the given vector coordinates to the current Vector3 ones
  2808. * @param source defines the source Vector3
  2809. * @returns the current updated Vector3
  2810. */
  2811. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  2812. /**
  2813. * Copies the given floats to the current Vector3 coordinates
  2814. * @param x defines the x coordinate of the operand
  2815. * @param y defines the y coordinate of the operand
  2816. * @param z defines the z coordinate of the operand
  2817. * @returns the current updated Vector3
  2818. */
  2819. copyFromFloats(x: number, y: number, z: number): Vector3;
  2820. /**
  2821. * Copies the given floats to the current Vector3 coordinates
  2822. * @param x defines the x coordinate of the operand
  2823. * @param y defines the y coordinate of the operand
  2824. * @param z defines the z coordinate of the operand
  2825. * @returns the current updated Vector3
  2826. */
  2827. set(x: number, y: number, z: number): Vector3;
  2828. /**
  2829. * Copies the given float to the current Vector3 coordinates
  2830. * @param v defines the x, y and z coordinates of the operand
  2831. * @returns the current updated Vector3
  2832. */
  2833. setAll(v: number): Vector3;
  2834. /**
  2835. * Get the clip factor between two vectors
  2836. * @param vector0 defines the first operand
  2837. * @param vector1 defines the second operand
  2838. * @param axis defines the axis to use
  2839. * @param size defines the size along the axis
  2840. * @returns the clip factor
  2841. */
  2842. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  2843. /**
  2844. * Get angle between two vectors
  2845. * @param vector0 angle between vector0 and vector1
  2846. * @param vector1 angle between vector0 and vector1
  2847. * @param normal direction of the normal
  2848. * @return the angle between vector0 and vector1
  2849. */
  2850. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  2851. /**
  2852. * Returns a new Vector3 set from the index "offset" of the given array
  2853. * @param array defines the source array
  2854. * @param offset defines the offset in the source array
  2855. * @returns the new Vector3
  2856. */
  2857. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  2858. /**
  2859. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  2860. * @param array defines the source array
  2861. * @param offset defines the offset in the source array
  2862. * @returns the new Vector3
  2863. * @deprecated Please use FromArray instead.
  2864. */
  2865. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  2866. /**
  2867. * Sets the given vector "result" with the element values from the index "offset" of the given array
  2868. * @param array defines the source array
  2869. * @param offset defines the offset in the source array
  2870. * @param result defines the Vector3 where to store the result
  2871. */
  2872. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  2873. /**
  2874. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  2875. * @param array defines the source array
  2876. * @param offset defines the offset in the source array
  2877. * @param result defines the Vector3 where to store the result
  2878. * @deprecated Please use FromArrayToRef instead.
  2879. */
  2880. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  2881. /**
  2882. * Sets the given vector "result" with the given floats.
  2883. * @param x defines the x coordinate of the source
  2884. * @param y defines the y coordinate of the source
  2885. * @param z defines the z coordinate of the source
  2886. * @param result defines the Vector3 where to store the result
  2887. */
  2888. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  2889. /**
  2890. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  2891. * @returns a new empty Vector3
  2892. */
  2893. static Zero(): Vector3;
  2894. /**
  2895. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  2896. * @returns a new unit Vector3
  2897. */
  2898. static One(): Vector3;
  2899. /**
  2900. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  2901. * @returns a new up Vector3
  2902. */
  2903. static Up(): Vector3;
  2904. /**
  2905. * Gets a up Vector3 that must not be updated
  2906. */
  2907. static get UpReadOnly(): DeepImmutable<Vector3>;
  2908. /**
  2909. * Gets a zero Vector3 that must not be updated
  2910. */
  2911. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  2912. /**
  2913. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  2914. * @returns a new down Vector3
  2915. */
  2916. static Down(): Vector3;
  2917. /**
  2918. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  2919. * @param rightHandedSystem is the scene right-handed (negative z)
  2920. * @returns a new forward Vector3
  2921. */
  2922. static Forward(rightHandedSystem?: boolean): Vector3;
  2923. /**
  2924. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  2925. * @param rightHandedSystem is the scene right-handed (negative-z)
  2926. * @returns a new forward Vector3
  2927. */
  2928. static Backward(rightHandedSystem?: boolean): Vector3;
  2929. /**
  2930. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  2931. * @returns a new right Vector3
  2932. */
  2933. static Right(): Vector3;
  2934. /**
  2935. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  2936. * @returns a new left Vector3
  2937. */
  2938. static Left(): Vector3;
  2939. /**
  2940. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  2941. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2942. * @param vector defines the Vector3 to transform
  2943. * @param transformation defines the transformation matrix
  2944. * @returns the transformed Vector3
  2945. */
  2946. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2947. /**
  2948. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  2949. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2950. * @param vector defines the Vector3 to transform
  2951. * @param transformation defines the transformation matrix
  2952. * @param result defines the Vector3 where to store the result
  2953. */
  2954. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2955. /**
  2956. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  2957. * This method computes tranformed coordinates only, not transformed direction vectors
  2958. * @param x define the x coordinate of the source vector
  2959. * @param y define the y coordinate of the source vector
  2960. * @param z define the z coordinate of the source vector
  2961. * @param transformation defines the transformation matrix
  2962. * @param result defines the Vector3 where to store the result
  2963. */
  2964. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2965. /**
  2966. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  2967. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2968. * @param vector defines the Vector3 to transform
  2969. * @param transformation defines the transformation matrix
  2970. * @returns the new Vector3
  2971. */
  2972. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2973. /**
  2974. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  2975. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2976. * @param vector defines the Vector3 to transform
  2977. * @param transformation defines the transformation matrix
  2978. * @param result defines the Vector3 where to store the result
  2979. */
  2980. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2981. /**
  2982. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  2983. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2984. * @param x define the x coordinate of the source vector
  2985. * @param y define the y coordinate of the source vector
  2986. * @param z define the z coordinate of the source vector
  2987. * @param transformation defines the transformation matrix
  2988. * @param result defines the Vector3 where to store the result
  2989. */
  2990. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2991. /**
  2992. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  2993. * @param value1 defines the first control point
  2994. * @param value2 defines the second control point
  2995. * @param value3 defines the third control point
  2996. * @param value4 defines the fourth control point
  2997. * @param amount defines the amount on the spline to use
  2998. * @returns the new Vector3
  2999. */
  3000. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  3001. /**
  3002. * Returns a new Vector3 set with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max"
  3003. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  3004. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  3005. * @param value defines the current value
  3006. * @param min defines the lower range value
  3007. * @param max defines the upper range value
  3008. * @returns the new Vector3
  3009. */
  3010. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  3011. /**
  3012. * Sets the given vector "result" with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max"
  3013. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  3014. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  3015. * @param value defines the current value
  3016. * @param min defines the lower range value
  3017. * @param max defines the upper range value
  3018. * @param result defines the Vector3 where to store the result
  3019. */
  3020. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  3021. /**
  3022. * Checks if a given vector is inside a specific range
  3023. * @param v defines the vector to test
  3024. * @param min defines the minimum range
  3025. * @param max defines the maximum range
  3026. */
  3027. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  3028. /**
  3029. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  3030. * @param value1 defines the first control point
  3031. * @param tangent1 defines the first tangent vector
  3032. * @param value2 defines the second control point
  3033. * @param tangent2 defines the second tangent vector
  3034. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  3035. * @returns the new Vector3
  3036. */
  3037. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  3038. /**
  3039. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  3040. * @param start defines the start value
  3041. * @param end defines the end value
  3042. * @param amount max defines amount between both (between 0 and 1)
  3043. * @returns the new Vector3
  3044. */
  3045. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  3046. /**
  3047. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  3048. * @param start defines the start value
  3049. * @param end defines the end value
  3050. * @param amount max defines amount between both (between 0 and 1)
  3051. * @param result defines the Vector3 where to store the result
  3052. */
  3053. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  3054. /**
  3055. * Returns the dot product (float) between the vectors "left" and "right"
  3056. * @param left defines the left operand
  3057. * @param right defines the right operand
  3058. * @returns the dot product
  3059. */
  3060. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  3061. /**
  3062. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  3063. * The cross product is then orthogonal to both "left" and "right"
  3064. * @param left defines the left operand
  3065. * @param right defines the right operand
  3066. * @returns the cross product
  3067. */
  3068. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3069. /**
  3070. * Sets the given vector "result" with the cross product of "left" and "right"
  3071. * The cross product is then orthogonal to both "left" and "right"
  3072. * @param left defines the left operand
  3073. * @param right defines the right operand
  3074. * @param result defines the Vector3 where to store the result
  3075. */
  3076. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  3077. /**
  3078. * Returns a new Vector3 as the normalization of the given vector
  3079. * @param vector defines the Vector3 to normalize
  3080. * @returns the new Vector3
  3081. */
  3082. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  3083. /**
  3084. * Sets the given vector "result" with the normalization of the given first vector
  3085. * @param vector defines the Vector3 to normalize
  3086. * @param result defines the Vector3 where to store the result
  3087. */
  3088. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  3089. /**
  3090. * Project a Vector3 onto screen space
  3091. * @param vector defines the Vector3 to project
  3092. * @param world defines the world matrix to use
  3093. * @param transform defines the transform (view x projection) matrix to use
  3094. * @param viewport defines the screen viewport to use
  3095. * @returns the new Vector3
  3096. */
  3097. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  3098. /** @hidden */
  3099. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  3100. /**
  3101. * Unproject from screen space to object space
  3102. * @param source defines the screen space Vector3 to use
  3103. * @param viewportWidth defines the current width of the viewport
  3104. * @param viewportHeight defines the current height of the viewport
  3105. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3106. * @param transform defines the transform (view x projection) matrix to use
  3107. * @returns the new Vector3
  3108. */
  3109. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  3110. /**
  3111. * Unproject from screen space to object space
  3112. * @param source defines the screen space Vector3 to use
  3113. * @param viewportWidth defines the current width of the viewport
  3114. * @param viewportHeight defines the current height of the viewport
  3115. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3116. * @param view defines the view matrix to use
  3117. * @param projection defines the projection matrix to use
  3118. * @returns the new Vector3
  3119. */
  3120. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  3121. /**
  3122. * Unproject from screen space to object space
  3123. * @param source defines the screen space Vector3 to use
  3124. * @param viewportWidth defines the current width of the viewport
  3125. * @param viewportHeight defines the current height of the viewport
  3126. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3127. * @param view defines the view matrix to use
  3128. * @param projection defines the projection matrix to use
  3129. * @param result defines the Vector3 where to store the result
  3130. */
  3131. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3132. /**
  3133. * Unproject from screen space to object space
  3134. * @param sourceX defines the screen space x coordinate to use
  3135. * @param sourceY defines the screen space y coordinate to use
  3136. * @param sourceZ defines the screen space z coordinate to use
  3137. * @param viewportWidth defines the current width of the viewport
  3138. * @param viewportHeight defines the current height of the viewport
  3139. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3140. * @param view defines the view matrix to use
  3141. * @param projection defines the projection matrix to use
  3142. * @param result defines the Vector3 where to store the result
  3143. */
  3144. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3145. /**
  3146. * Gets the minimal coordinate values between two Vector3
  3147. * @param left defines the first operand
  3148. * @param right defines the second operand
  3149. * @returns the new Vector3
  3150. */
  3151. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3152. /**
  3153. * Gets the maximal coordinate values between two Vector3
  3154. * @param left defines the first operand
  3155. * @param right defines the second operand
  3156. * @returns the new Vector3
  3157. */
  3158. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3159. /**
  3160. * Returns the distance between the vectors "value1" and "value2"
  3161. * @param value1 defines the first operand
  3162. * @param value2 defines the second operand
  3163. * @returns the distance
  3164. */
  3165. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3166. /**
  3167. * Returns the squared distance between the vectors "value1" and "value2"
  3168. * @param value1 defines the first operand
  3169. * @param value2 defines the second operand
  3170. * @returns the squared distance
  3171. */
  3172. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3173. /**
  3174. * Returns a new Vector3 located at the center between "value1" and "value2"
  3175. * @param value1 defines the first operand
  3176. * @param value2 defines the second operand
  3177. * @returns the new Vector3
  3178. */
  3179. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  3180. /**
  3181. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  3182. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  3183. * to something in order to rotate it from its local system to the given target system
  3184. * Note: axis1, axis2 and axis3 are normalized during this operation
  3185. * @param axis1 defines the first axis
  3186. * @param axis2 defines the second axis
  3187. * @param axis3 defines the third axis
  3188. * @returns a new Vector3
  3189. */
  3190. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  3191. /**
  3192. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  3193. * @param axis1 defines the first axis
  3194. * @param axis2 defines the second axis
  3195. * @param axis3 defines the third axis
  3196. * @param ref defines the Vector3 where to store the result
  3197. */
  3198. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  3199. }
  3200. /**
  3201. * Vector4 class created for EulerAngle class conversion to Quaternion
  3202. */
  3203. export class Vector4 {
  3204. /** x value of the vector */
  3205. x: number;
  3206. /** y value of the vector */
  3207. y: number;
  3208. /** z value of the vector */
  3209. z: number;
  3210. /** w value of the vector */
  3211. w: number;
  3212. /**
  3213. * Creates a Vector4 object from the given floats.
  3214. * @param x x value of the vector
  3215. * @param y y value of the vector
  3216. * @param z z value of the vector
  3217. * @param w w value of the vector
  3218. */
  3219. constructor(
  3220. /** x value of the vector */
  3221. x: number,
  3222. /** y value of the vector */
  3223. y: number,
  3224. /** z value of the vector */
  3225. z: number,
  3226. /** w value of the vector */
  3227. w: number);
  3228. /**
  3229. * Returns the string with the Vector4 coordinates.
  3230. * @returns a string containing all the vector values
  3231. */
  3232. toString(): string;
  3233. /**
  3234. * Returns the string "Vector4".
  3235. * @returns "Vector4"
  3236. */
  3237. getClassName(): string;
  3238. /**
  3239. * Returns the Vector4 hash code.
  3240. * @returns a unique hash code
  3241. */
  3242. getHashCode(): number;
  3243. /**
  3244. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  3245. * @returns the resulting array
  3246. */
  3247. asArray(): number[];
  3248. /**
  3249. * Populates the given array from the given index with the Vector4 coordinates.
  3250. * @param array array to populate
  3251. * @param index index of the array to start at (default: 0)
  3252. * @returns the Vector4.
  3253. */
  3254. toArray(array: FloatArray, index?: number): Vector4;
  3255. /**
  3256. * Adds the given vector to the current Vector4.
  3257. * @param otherVector the vector to add
  3258. * @returns the updated Vector4.
  3259. */
  3260. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3261. /**
  3262. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  3263. * @param otherVector the vector to add
  3264. * @returns the resulting vector
  3265. */
  3266. add(otherVector: DeepImmutable<Vector4>): Vector4;
  3267. /**
  3268. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  3269. * @param otherVector the vector to add
  3270. * @param result the vector to store the result
  3271. * @returns the current Vector4.
  3272. */
  3273. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3274. /**
  3275. * Subtract in place the given vector from the current Vector4.
  3276. * @param otherVector the vector to subtract
  3277. * @returns the updated Vector4.
  3278. */
  3279. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3280. /**
  3281. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  3282. * @param otherVector the vector to add
  3283. * @returns the new vector with the result
  3284. */
  3285. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  3286. /**
  3287. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  3288. * @param otherVector the vector to subtract
  3289. * @param result the vector to store the result
  3290. * @returns the current Vector4.
  3291. */
  3292. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3293. /**
  3294. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3295. */
  3296. /**
  3297. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3298. * @param x value to subtract
  3299. * @param y value to subtract
  3300. * @param z value to subtract
  3301. * @param w value to subtract
  3302. * @returns new vector containing the result
  3303. */
  3304. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3305. /**
  3306. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3307. * @param x value to subtract
  3308. * @param y value to subtract
  3309. * @param z value to subtract
  3310. * @param w value to subtract
  3311. * @param result the vector to store the result in
  3312. * @returns the current Vector4.
  3313. */
  3314. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  3315. /**
  3316. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  3317. * @returns a new vector with the negated values
  3318. */
  3319. negate(): Vector4;
  3320. /**
  3321. * Negate this vector in place
  3322. * @returns this
  3323. */
  3324. negateInPlace(): Vector4;
  3325. /**
  3326. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  3327. * @param result defines the Vector3 object where to store the result
  3328. * @returns the current Vector4
  3329. */
  3330. negateToRef(result: Vector4): Vector4;
  3331. /**
  3332. * Multiplies the current Vector4 coordinates by scale (float).
  3333. * @param scale the number to scale with
  3334. * @returns the updated Vector4.
  3335. */
  3336. scaleInPlace(scale: number): Vector4;
  3337. /**
  3338. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  3339. * @param scale the number to scale with
  3340. * @returns a new vector with the result
  3341. */
  3342. scale(scale: number): Vector4;
  3343. /**
  3344. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  3345. * @param scale the number to scale with
  3346. * @param result a vector to store the result in
  3347. * @returns the current Vector4.
  3348. */
  3349. scaleToRef(scale: number, result: Vector4): Vector4;
  3350. /**
  3351. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  3352. * @param scale defines the scale factor
  3353. * @param result defines the Vector4 object where to store the result
  3354. * @returns the unmodified current Vector4
  3355. */
  3356. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  3357. /**
  3358. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  3359. * @param otherVector the vector to compare against
  3360. * @returns true if they are equal
  3361. */
  3362. equals(otherVector: DeepImmutable<Vector4>): boolean;
  3363. /**
  3364. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  3365. * @param otherVector vector to compare against
  3366. * @param epsilon (Default: very small number)
  3367. * @returns true if they are equal
  3368. */
  3369. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  3370. /**
  3371. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  3372. * @param x x value to compare against
  3373. * @param y y value to compare against
  3374. * @param z z value to compare against
  3375. * @param w w value to compare against
  3376. * @returns true if equal
  3377. */
  3378. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  3379. /**
  3380. * Multiplies in place the current Vector4 by the given one.
  3381. * @param otherVector vector to multiple with
  3382. * @returns the updated Vector4.
  3383. */
  3384. multiplyInPlace(otherVector: Vector4): Vector4;
  3385. /**
  3386. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  3387. * @param otherVector vector to multiple with
  3388. * @returns resulting new vector
  3389. */
  3390. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  3391. /**
  3392. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  3393. * @param otherVector vector to multiple with
  3394. * @param result vector to store the result
  3395. * @returns the current Vector4.
  3396. */
  3397. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3398. /**
  3399. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  3400. * @param x x value multiply with
  3401. * @param y y value multiply with
  3402. * @param z z value multiply with
  3403. * @param w w value multiply with
  3404. * @returns resulting new vector
  3405. */
  3406. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  3407. /**
  3408. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  3409. * @param otherVector vector to devide with
  3410. * @returns resulting new vector
  3411. */
  3412. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  3413. /**
  3414. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  3415. * @param otherVector vector to devide with
  3416. * @param result vector to store the result
  3417. * @returns the current Vector4.
  3418. */
  3419. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3420. /**
  3421. * Divides the current Vector3 coordinates by the given ones.
  3422. * @param otherVector vector to devide with
  3423. * @returns the updated Vector3.
  3424. */
  3425. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3426. /**
  3427. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  3428. * @param other defines the second operand
  3429. * @returns the current updated Vector4
  3430. */
  3431. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3432. /**
  3433. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  3434. * @param other defines the second operand
  3435. * @returns the current updated Vector4
  3436. */
  3437. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3438. /**
  3439. * Gets a new Vector4 from current Vector4 floored values
  3440. * @returns a new Vector4
  3441. */
  3442. floor(): Vector4;
  3443. /**
  3444. * Gets a new Vector4 from current Vector3 floored values
  3445. * @returns a new Vector4
  3446. */
  3447. fract(): Vector4;
  3448. /**
  3449. * Returns the Vector4 length (float).
  3450. * @returns the length
  3451. */
  3452. length(): number;
  3453. /**
  3454. * Returns the Vector4 squared length (float).
  3455. * @returns the length squared
  3456. */
  3457. lengthSquared(): number;
  3458. /**
  3459. * Normalizes in place the Vector4.
  3460. * @returns the updated Vector4.
  3461. */
  3462. normalize(): Vector4;
  3463. /**
  3464. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  3465. * @returns this converted to a new vector3
  3466. */
  3467. toVector3(): Vector3;
  3468. /**
  3469. * Returns a new Vector4 copied from the current one.
  3470. * @returns the new cloned vector
  3471. */
  3472. clone(): Vector4;
  3473. /**
  3474. * Updates the current Vector4 with the given one coordinates.
  3475. * @param source the source vector to copy from
  3476. * @returns the updated Vector4.
  3477. */
  3478. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  3479. /**
  3480. * Updates the current Vector4 coordinates with the given floats.
  3481. * @param x float to copy from
  3482. * @param y float to copy from
  3483. * @param z float to copy from
  3484. * @param w float to copy from
  3485. * @returns the updated Vector4.
  3486. */
  3487. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3488. /**
  3489. * Updates the current Vector4 coordinates with the given floats.
  3490. * @param x float to set from
  3491. * @param y float to set from
  3492. * @param z float to set from
  3493. * @param w float to set from
  3494. * @returns the updated Vector4.
  3495. */
  3496. set(x: number, y: number, z: number, w: number): Vector4;
  3497. /**
  3498. * Copies the given float to the current Vector3 coordinates
  3499. * @param v defines the x, y, z and w coordinates of the operand
  3500. * @returns the current updated Vector3
  3501. */
  3502. setAll(v: number): Vector4;
  3503. /**
  3504. * Returns a new Vector4 set from the starting index of the given array.
  3505. * @param array the array to pull values from
  3506. * @param offset the offset into the array to start at
  3507. * @returns the new vector
  3508. */
  3509. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  3510. /**
  3511. * Updates the given vector "result" from the starting index of the given array.
  3512. * @param array the array to pull values from
  3513. * @param offset the offset into the array to start at
  3514. * @param result the vector to store the result in
  3515. */
  3516. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  3517. /**
  3518. * Updates the given vector "result" from the starting index of the given Float32Array.
  3519. * @param array the array to pull values from
  3520. * @param offset the offset into the array to start at
  3521. * @param result the vector to store the result in
  3522. */
  3523. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  3524. /**
  3525. * Updates the given vector "result" coordinates from the given floats.
  3526. * @param x float to set from
  3527. * @param y float to set from
  3528. * @param z float to set from
  3529. * @param w float to set from
  3530. * @param result the vector to the floats in
  3531. */
  3532. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  3533. /**
  3534. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  3535. * @returns the new vector
  3536. */
  3537. static Zero(): Vector4;
  3538. /**
  3539. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  3540. * @returns the new vector
  3541. */
  3542. static One(): Vector4;
  3543. /**
  3544. * Returns a new normalized Vector4 from the given one.
  3545. * @param vector the vector to normalize
  3546. * @returns the vector
  3547. */
  3548. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  3549. /**
  3550. * Updates the given vector "result" from the normalization of the given one.
  3551. * @param vector the vector to normalize
  3552. * @param result the vector to store the result in
  3553. */
  3554. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  3555. /**
  3556. * Returns a vector with the minimum values from the left and right vectors
  3557. * @param left left vector to minimize
  3558. * @param right right vector to minimize
  3559. * @returns a new vector with the minimum of the left and right vector values
  3560. */
  3561. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3562. /**
  3563. * Returns a vector with the maximum values from the left and right vectors
  3564. * @param left left vector to maximize
  3565. * @param right right vector to maximize
  3566. * @returns a new vector with the maximum of the left and right vector values
  3567. */
  3568. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3569. /**
  3570. * Returns the distance (float) between the vectors "value1" and "value2".
  3571. * @param value1 value to calulate the distance between
  3572. * @param value2 value to calulate the distance between
  3573. * @return the distance between the two vectors
  3574. */
  3575. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3576. /**
  3577. * Returns the squared distance (float) between the vectors "value1" and "value2".
  3578. * @param value1 value to calulate the distance between
  3579. * @param value2 value to calulate the distance between
  3580. * @return the distance between the two vectors squared
  3581. */
  3582. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3583. /**
  3584. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  3585. * @param value1 value to calulate the center between
  3586. * @param value2 value to calulate the center between
  3587. * @return the center between the two vectors
  3588. */
  3589. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  3590. /**
  3591. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  3592. * This methods computes transformed normalized direction vectors only.
  3593. * @param vector the vector to transform
  3594. * @param transformation the transformation matrix to apply
  3595. * @returns the new vector
  3596. */
  3597. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  3598. /**
  3599. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  3600. * This methods computes transformed normalized direction vectors only.
  3601. * @param vector the vector to transform
  3602. * @param transformation the transformation matrix to apply
  3603. * @param result the vector to store the result in
  3604. */
  3605. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3606. /**
  3607. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  3608. * This methods computes transformed normalized direction vectors only.
  3609. * @param x value to transform
  3610. * @param y value to transform
  3611. * @param z value to transform
  3612. * @param w value to transform
  3613. * @param transformation the transformation matrix to apply
  3614. * @param result the vector to store the results in
  3615. */
  3616. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3617. /**
  3618. * Creates a new Vector4 from a Vector3
  3619. * @param source defines the source data
  3620. * @param w defines the 4th component (default is 0)
  3621. * @returns a new Vector4
  3622. */
  3623. static FromVector3(source: Vector3, w?: number): Vector4;
  3624. }
  3625. /**
  3626. * Class used to store quaternion data
  3627. * @see https://en.wikipedia.org/wiki/Quaternion
  3628. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  3629. */
  3630. export class Quaternion {
  3631. /** defines the first component (0 by default) */
  3632. x: number;
  3633. /** defines the second component (0 by default) */
  3634. y: number;
  3635. /** defines the third component (0 by default) */
  3636. z: number;
  3637. /** defines the fourth component (1.0 by default) */
  3638. w: number;
  3639. /**
  3640. * Creates a new Quaternion from the given floats
  3641. * @param x defines the first component (0 by default)
  3642. * @param y defines the second component (0 by default)
  3643. * @param z defines the third component (0 by default)
  3644. * @param w defines the fourth component (1.0 by default)
  3645. */
  3646. constructor(
  3647. /** defines the first component (0 by default) */
  3648. x?: number,
  3649. /** defines the second component (0 by default) */
  3650. y?: number,
  3651. /** defines the third component (0 by default) */
  3652. z?: number,
  3653. /** defines the fourth component (1.0 by default) */
  3654. w?: number);
  3655. /**
  3656. * Gets a string representation for the current quaternion
  3657. * @returns a string with the Quaternion coordinates
  3658. */
  3659. toString(): string;
  3660. /**
  3661. * Gets the class name of the quaternion
  3662. * @returns the string "Quaternion"
  3663. */
  3664. getClassName(): string;
  3665. /**
  3666. * Gets a hash code for this quaternion
  3667. * @returns the quaternion hash code
  3668. */
  3669. getHashCode(): number;
  3670. /**
  3671. * Copy the quaternion to an array
  3672. * @returns a new array populated with 4 elements from the quaternion coordinates
  3673. */
  3674. asArray(): number[];
  3675. /**
  3676. * Check if two quaternions are equals
  3677. * @param otherQuaternion defines the second operand
  3678. * @return true if the current quaternion and the given one coordinates are strictly equals
  3679. */
  3680. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  3681. /**
  3682. * Gets a boolean if two quaternions are equals (using an epsilon value)
  3683. * @param otherQuaternion defines the other quaternion
  3684. * @param epsilon defines the minimal distance to consider equality
  3685. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  3686. */
  3687. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  3688. /**
  3689. * Clone the current quaternion
  3690. * @returns a new quaternion copied from the current one
  3691. */
  3692. clone(): Quaternion;
  3693. /**
  3694. * Copy a quaternion to the current one
  3695. * @param other defines the other quaternion
  3696. * @returns the updated current quaternion
  3697. */
  3698. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  3699. /**
  3700. * Updates the current quaternion with the given float coordinates
  3701. * @param x defines the x coordinate
  3702. * @param y defines the y coordinate
  3703. * @param z defines the z coordinate
  3704. * @param w defines the w coordinate
  3705. * @returns the updated current quaternion
  3706. */
  3707. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  3708. /**
  3709. * Updates the current quaternion from the given float coordinates
  3710. * @param x defines the x coordinate
  3711. * @param y defines the y coordinate
  3712. * @param z defines the z coordinate
  3713. * @param w defines the w coordinate
  3714. * @returns the updated current quaternion
  3715. */
  3716. set(x: number, y: number, z: number, w: number): Quaternion;
  3717. /**
  3718. * Adds two quaternions
  3719. * @param other defines the second operand
  3720. * @returns a new quaternion as the addition result of the given one and the current quaternion
  3721. */
  3722. add(other: DeepImmutable<Quaternion>): Quaternion;
  3723. /**
  3724. * Add a quaternion to the current one
  3725. * @param other defines the quaternion to add
  3726. * @returns the current quaternion
  3727. */
  3728. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  3729. /**
  3730. * Subtract two quaternions
  3731. * @param other defines the second operand
  3732. * @returns a new quaternion as the subtraction result of the given one from the current one
  3733. */
  3734. subtract(other: Quaternion): Quaternion;
  3735. /**
  3736. * Multiplies the current quaternion by a scale factor
  3737. * @param value defines the scale factor
  3738. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  3739. */
  3740. scale(value: number): Quaternion;
  3741. /**
  3742. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  3743. * @param scale defines the scale factor
  3744. * @param result defines the Quaternion object where to store the result
  3745. * @returns the unmodified current quaternion
  3746. */
  3747. scaleToRef(scale: number, result: Quaternion): Quaternion;
  3748. /**
  3749. * Multiplies in place the current quaternion by a scale factor
  3750. * @param value defines the scale factor
  3751. * @returns the current modified quaternion
  3752. */
  3753. scaleInPlace(value: number): Quaternion;
  3754. /**
  3755. * Scale the current quaternion values by a factor and add the result to a given quaternion
  3756. * @param scale defines the scale factor
  3757. * @param result defines the Quaternion object where to store the result
  3758. * @returns the unmodified current quaternion
  3759. */
  3760. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  3761. /**
  3762. * Multiplies two quaternions
  3763. * @param q1 defines the second operand
  3764. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  3765. */
  3766. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  3767. /**
  3768. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  3769. * @param q1 defines the second operand
  3770. * @param result defines the target quaternion
  3771. * @returns the current quaternion
  3772. */
  3773. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  3774. /**
  3775. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  3776. * @param q1 defines the second operand
  3777. * @returns the currentupdated quaternion
  3778. */
  3779. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  3780. /**
  3781. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  3782. * @param ref defines the target quaternion
  3783. * @returns the current quaternion
  3784. */
  3785. conjugateToRef(ref: Quaternion): Quaternion;
  3786. /**
  3787. * Conjugates in place (1-q) the current quaternion
  3788. * @returns the current updated quaternion
  3789. */
  3790. conjugateInPlace(): Quaternion;
  3791. /**
  3792. * Conjugates in place (1-q) the current quaternion
  3793. * @returns a new quaternion
  3794. */
  3795. conjugate(): Quaternion;
  3796. /**
  3797. * Gets length of current quaternion
  3798. * @returns the quaternion length (float)
  3799. */
  3800. length(): number;
  3801. /**
  3802. * Normalize in place the current quaternion
  3803. * @returns the current updated quaternion
  3804. */
  3805. normalize(): Quaternion;
  3806. /**
  3807. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  3808. * @param order is a reserved parameter and is ignore for now
  3809. * @returns a new Vector3 containing the Euler angles
  3810. */
  3811. toEulerAngles(order?: string): Vector3;
  3812. /**
  3813. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  3814. * @param result defines the vector which will be filled with the Euler angles
  3815. * @param order is a reserved parameter and is ignore for now
  3816. * @returns the current unchanged quaternion
  3817. */
  3818. toEulerAnglesToRef(result: Vector3): Quaternion;
  3819. /**
  3820. * Updates the given rotation matrix with the current quaternion values
  3821. * @param result defines the target matrix
  3822. * @returns the current unchanged quaternion
  3823. */
  3824. toRotationMatrix(result: Matrix): Quaternion;
  3825. /**
  3826. * Updates the current quaternion from the given rotation matrix values
  3827. * @param matrix defines the source matrix
  3828. * @returns the current updated quaternion
  3829. */
  3830. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3831. /**
  3832. * Creates a new quaternion from a rotation matrix
  3833. * @param matrix defines the source matrix
  3834. * @returns a new quaternion created from the given rotation matrix values
  3835. */
  3836. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3837. /**
  3838. * Updates the given quaternion with the given rotation matrix values
  3839. * @param matrix defines the source matrix
  3840. * @param result defines the target quaternion
  3841. */
  3842. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  3843. /**
  3844. * Returns the dot product (float) between the quaternions "left" and "right"
  3845. * @param left defines the left operand
  3846. * @param right defines the right operand
  3847. * @returns the dot product
  3848. */
  3849. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  3850. /**
  3851. * Checks if the two quaternions are close to each other
  3852. * @param quat0 defines the first quaternion to check
  3853. * @param quat1 defines the second quaternion to check
  3854. * @returns true if the two quaternions are close to each other
  3855. */
  3856. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  3857. /**
  3858. * Creates an empty quaternion
  3859. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  3860. */
  3861. static Zero(): Quaternion;
  3862. /**
  3863. * Inverse a given quaternion
  3864. * @param q defines the source quaternion
  3865. * @returns a new quaternion as the inverted current quaternion
  3866. */
  3867. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  3868. /**
  3869. * Inverse a given quaternion
  3870. * @param q defines the source quaternion
  3871. * @param result the quaternion the result will be stored in
  3872. * @returns the result quaternion
  3873. */
  3874. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  3875. /**
  3876. * Creates an identity quaternion
  3877. * @returns the identity quaternion
  3878. */
  3879. static Identity(): Quaternion;
  3880. /**
  3881. * Gets a boolean indicating if the given quaternion is identity
  3882. * @param quaternion defines the quaternion to check
  3883. * @returns true if the quaternion is identity
  3884. */
  3885. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  3886. /**
  3887. * Creates a quaternion from a rotation around an axis
  3888. * @param axis defines the axis to use
  3889. * @param angle defines the angle to use
  3890. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  3891. */
  3892. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  3893. /**
  3894. * Creates a rotation around an axis and stores it into the given quaternion
  3895. * @param axis defines the axis to use
  3896. * @param angle defines the angle to use
  3897. * @param result defines the target quaternion
  3898. * @returns the target quaternion
  3899. */
  3900. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  3901. /**
  3902. * Creates a new quaternion from data stored into an array
  3903. * @param array defines the data source
  3904. * @param offset defines the offset in the source array where the data starts
  3905. * @returns a new quaternion
  3906. */
  3907. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  3908. /**
  3909. * Updates the given quaternion "result" from the starting index of the given array.
  3910. * @param array the array to pull values from
  3911. * @param offset the offset into the array to start at
  3912. * @param result the quaternion to store the result in
  3913. */
  3914. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Quaternion): void;
  3915. /**
  3916. * Create a quaternion from Euler rotation angles
  3917. * @param x Pitch
  3918. * @param y Yaw
  3919. * @param z Roll
  3920. * @returns the new Quaternion
  3921. */
  3922. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  3923. /**
  3924. * Updates a quaternion from Euler rotation angles
  3925. * @param x Pitch
  3926. * @param y Yaw
  3927. * @param z Roll
  3928. * @param result the quaternion to store the result
  3929. * @returns the updated quaternion
  3930. */
  3931. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  3932. /**
  3933. * Create a quaternion from Euler rotation vector
  3934. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3935. * @returns the new Quaternion
  3936. */
  3937. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  3938. /**
  3939. * Updates a quaternion from Euler rotation vector
  3940. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3941. * @param result the quaternion to store the result
  3942. * @returns the updated quaternion
  3943. */
  3944. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  3945. /**
  3946. * Creates a new quaternion from the given Euler float angles (y, x, z)
  3947. * @param yaw defines the rotation around Y axis
  3948. * @param pitch defines the rotation around X axis
  3949. * @param roll defines the rotation around Z axis
  3950. * @returns the new quaternion
  3951. */
  3952. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  3953. /**
  3954. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  3955. * @param yaw defines the rotation around Y axis
  3956. * @param pitch defines the rotation around X axis
  3957. * @param roll defines the rotation around Z axis
  3958. * @param result defines the target quaternion
  3959. */
  3960. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  3961. /**
  3962. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  3963. * @param alpha defines the rotation around first axis
  3964. * @param beta defines the rotation around second axis
  3965. * @param gamma defines the rotation around third axis
  3966. * @returns the new quaternion
  3967. */
  3968. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  3969. /**
  3970. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  3971. * @param alpha defines the rotation around first axis
  3972. * @param beta defines the rotation around second axis
  3973. * @param gamma defines the rotation around third axis
  3974. * @param result defines the target quaternion
  3975. */
  3976. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  3977. /**
  3978. * Creates a new quaternion containing the rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system (axis1, axis2 and axis3 are normalized during this operation)
  3979. * @param axis1 defines the first axis
  3980. * @param axis2 defines the second axis
  3981. * @param axis3 defines the third axis
  3982. * @returns the new quaternion
  3983. */
  3984. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  3985. /**
  3986. * Creates a rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system (axis1, axis2 and axis3 are normalized during this operation) and stores it in the target quaternion
  3987. * @param axis1 defines the first axis
  3988. * @param axis2 defines the second axis
  3989. * @param axis3 defines the third axis
  3990. * @param ref defines the target quaternion
  3991. */
  3992. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  3993. /**
  3994. * Interpolates between two quaternions
  3995. * @param left defines first quaternion
  3996. * @param right defines second quaternion
  3997. * @param amount defines the gradient to use
  3998. * @returns the new interpolated quaternion
  3999. */
  4000. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  4001. /**
  4002. * Interpolates between two quaternions and stores it into a target quaternion
  4003. * @param left defines first quaternion
  4004. * @param right defines second quaternion
  4005. * @param amount defines the gradient to use
  4006. * @param result defines the target quaternion
  4007. */
  4008. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  4009. /**
  4010. * Interpolate between two quaternions using Hermite interpolation
  4011. * @param value1 defines first quaternion
  4012. * @param tangent1 defines the incoming tangent
  4013. * @param value2 defines second quaternion
  4014. * @param tangent2 defines the outgoing tangent
  4015. * @param amount defines the target quaternion
  4016. * @returns the new interpolated quaternion
  4017. */
  4018. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  4019. }
  4020. /**
  4021. * Class used to store matrix data (4x4)
  4022. */
  4023. export class Matrix {
  4024. private static _updateFlagSeed;
  4025. private static _identityReadOnly;
  4026. private _isIdentity;
  4027. private _isIdentityDirty;
  4028. private _isIdentity3x2;
  4029. private _isIdentity3x2Dirty;
  4030. /**
  4031. * Gets the update flag of the matrix which is an unique number for the matrix.
  4032. * It will be incremented every time the matrix data change.
  4033. * You can use it to speed the comparison between two versions of the same matrix.
  4034. */
  4035. updateFlag: number;
  4036. private readonly _m;
  4037. /**
  4038. * Gets the internal data of the matrix
  4039. */
  4040. get m(): DeepImmutable<Float32Array>;
  4041. /** @hidden */
  4042. _markAsUpdated(): void;
  4043. /** @hidden */
  4044. private _updateIdentityStatus;
  4045. /**
  4046. * Creates an empty matrix (filled with zeros)
  4047. */
  4048. constructor();
  4049. /**
  4050. * Check if the current matrix is identity
  4051. * @returns true is the matrix is the identity matrix
  4052. */
  4053. isIdentity(): boolean;
  4054. /**
  4055. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  4056. * @returns true is the matrix is the identity matrix
  4057. */
  4058. isIdentityAs3x2(): boolean;
  4059. /**
  4060. * Gets the determinant of the matrix
  4061. * @returns the matrix determinant
  4062. */
  4063. determinant(): number;
  4064. /**
  4065. * Returns the matrix as a Float32Array
  4066. * @returns the matrix underlying array
  4067. */
  4068. toArray(): DeepImmutable<Float32Array>;
  4069. /**
  4070. * Returns the matrix as a Float32Array
  4071. * @returns the matrix underlying array.
  4072. */
  4073. asArray(): DeepImmutable<Float32Array>;
  4074. /**
  4075. * Inverts the current matrix in place
  4076. * @returns the current inverted matrix
  4077. */
  4078. invert(): Matrix;
  4079. /**
  4080. * Sets all the matrix elements to zero
  4081. * @returns the current matrix
  4082. */
  4083. reset(): Matrix;
  4084. /**
  4085. * Adds the current matrix with a second one
  4086. * @param other defines the matrix to add
  4087. * @returns a new matrix as the addition of the current matrix and the given one
  4088. */
  4089. add(other: DeepImmutable<Matrix>): Matrix;
  4090. /**
  4091. * Sets the given matrix "result" to the addition of the current matrix and the given one
  4092. * @param other defines the matrix to add
  4093. * @param result defines the target matrix
  4094. * @returns the current matrix
  4095. */
  4096. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4097. /**
  4098. * Adds in place the given matrix to the current matrix
  4099. * @param other defines the second operand
  4100. * @returns the current updated matrix
  4101. */
  4102. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  4103. /**
  4104. * Sets the given matrix to the current inverted Matrix
  4105. * @param other defines the target matrix
  4106. * @returns the unmodified current matrix
  4107. */
  4108. invertToRef(other: Matrix): Matrix;
  4109. /**
  4110. * add a value at the specified position in the current Matrix
  4111. * @param index the index of the value within the matrix. between 0 and 15.
  4112. * @param value the value to be added
  4113. * @returns the current updated matrix
  4114. */
  4115. addAtIndex(index: number, value: number): Matrix;
  4116. /**
  4117. * mutiply the specified position in the current Matrix by a value
  4118. * @param index the index of the value within the matrix. between 0 and 15.
  4119. * @param value the value to be added
  4120. * @returns the current updated matrix
  4121. */
  4122. multiplyAtIndex(index: number, value: number): Matrix;
  4123. /**
  4124. * Inserts the translation vector (using 3 floats) in the current matrix
  4125. * @param x defines the 1st component of the translation
  4126. * @param y defines the 2nd component of the translation
  4127. * @param z defines the 3rd component of the translation
  4128. * @returns the current updated matrix
  4129. */
  4130. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4131. /**
  4132. * Adds the translation vector (using 3 floats) in the current matrix
  4133. * @param x defines the 1st component of the translation
  4134. * @param y defines the 2nd component of the translation
  4135. * @param z defines the 3rd component of the translation
  4136. * @returns the current updated matrix
  4137. */
  4138. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4139. /**
  4140. * Inserts the translation vector in the current matrix
  4141. * @param vector3 defines the translation to insert
  4142. * @returns the current updated matrix
  4143. */
  4144. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  4145. /**
  4146. * Gets the translation value of the current matrix
  4147. * @returns a new Vector3 as the extracted translation from the matrix
  4148. */
  4149. getTranslation(): Vector3;
  4150. /**
  4151. * Fill a Vector3 with the extracted translation from the matrix
  4152. * @param result defines the Vector3 where to store the translation
  4153. * @returns the current matrix
  4154. */
  4155. getTranslationToRef(result: Vector3): Matrix;
  4156. /**
  4157. * Remove rotation and scaling part from the matrix
  4158. * @returns the updated matrix
  4159. */
  4160. removeRotationAndScaling(): Matrix;
  4161. /**
  4162. * Multiply two matrices
  4163. * @param other defines the second operand
  4164. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  4165. */
  4166. multiply(other: DeepImmutable<Matrix>): Matrix;
  4167. /**
  4168. * Copy the current matrix from the given one
  4169. * @param other defines the source matrix
  4170. * @returns the current updated matrix
  4171. */
  4172. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  4173. /**
  4174. * Populates the given array from the starting index with the current matrix values
  4175. * @param array defines the target array
  4176. * @param offset defines the offset in the target array where to start storing values
  4177. * @returns the current matrix
  4178. */
  4179. copyToArray(array: Float32Array, offset?: number): Matrix;
  4180. /**
  4181. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  4182. * @param other defines the second operand
  4183. * @param result defines the matrix where to store the multiplication
  4184. * @returns the current matrix
  4185. */
  4186. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4187. /**
  4188. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  4189. * @param other defines the second operand
  4190. * @param result defines the array where to store the multiplication
  4191. * @param offset defines the offset in the target array where to start storing values
  4192. * @returns the current matrix
  4193. */
  4194. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  4195. /**
  4196. * Check equality between this matrix and a second one
  4197. * @param value defines the second matrix to compare
  4198. * @returns true is the current matrix and the given one values are strictly equal
  4199. */
  4200. equals(value: DeepImmutable<Matrix>): boolean;
  4201. /**
  4202. * Clone the current matrix
  4203. * @returns a new matrix from the current matrix
  4204. */
  4205. clone(): Matrix;
  4206. /**
  4207. * Returns the name of the current matrix class
  4208. * @returns the string "Matrix"
  4209. */
  4210. getClassName(): string;
  4211. /**
  4212. * Gets the hash code of the current matrix
  4213. * @returns the hash code
  4214. */
  4215. getHashCode(): number;
  4216. /**
  4217. * Decomposes the current Matrix into a translation, rotation and scaling components
  4218. * @param scale defines the scale vector3 given as a reference to update
  4219. * @param rotation defines the rotation quaternion given as a reference to update
  4220. * @param translation defines the translation vector3 given as a reference to update
  4221. * @returns true if operation was successful
  4222. */
  4223. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  4224. /**
  4225. * Gets specific row of the matrix
  4226. * @param index defines the number of the row to get
  4227. * @returns the index-th row of the current matrix as a new Vector4
  4228. */
  4229. getRow(index: number): Nullable<Vector4>;
  4230. /**
  4231. * Sets the index-th row of the current matrix to the vector4 values
  4232. * @param index defines the number of the row to set
  4233. * @param row defines the target vector4
  4234. * @returns the updated current matrix
  4235. */
  4236. setRow(index: number, row: Vector4): Matrix;
  4237. /**
  4238. * Compute the transpose of the matrix
  4239. * @returns the new transposed matrix
  4240. */
  4241. transpose(): Matrix;
  4242. /**
  4243. * Compute the transpose of the matrix and store it in a given matrix
  4244. * @param result defines the target matrix
  4245. * @returns the current matrix
  4246. */
  4247. transposeToRef(result: Matrix): Matrix;
  4248. /**
  4249. * Sets the index-th row of the current matrix with the given 4 x float values
  4250. * @param index defines the row index
  4251. * @param x defines the x component to set
  4252. * @param y defines the y component to set
  4253. * @param z defines the z component to set
  4254. * @param w defines the w component to set
  4255. * @returns the updated current matrix
  4256. */
  4257. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  4258. /**
  4259. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  4260. * @param scale defines the scale factor
  4261. * @returns a new matrix
  4262. */
  4263. scale(scale: number): Matrix;
  4264. /**
  4265. * Scale the current matrix values by a factor to a given result matrix
  4266. * @param scale defines the scale factor
  4267. * @param result defines the matrix to store the result
  4268. * @returns the current matrix
  4269. */
  4270. scaleToRef(scale: number, result: Matrix): Matrix;
  4271. /**
  4272. * Scale the current matrix values by a factor and add the result to a given matrix
  4273. * @param scale defines the scale factor
  4274. * @param result defines the Matrix to store the result
  4275. * @returns the current matrix
  4276. */
  4277. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  4278. /**
  4279. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  4280. * @param ref matrix to store the result
  4281. */
  4282. toNormalMatrix(ref: Matrix): void;
  4283. /**
  4284. * Gets only rotation part of the current matrix
  4285. * @returns a new matrix sets to the extracted rotation matrix from the current one
  4286. */
  4287. getRotationMatrix(): Matrix;
  4288. /**
  4289. * Extracts the rotation matrix from the current one and sets it as the given "result"
  4290. * @param result defines the target matrix to store data to
  4291. * @returns the current matrix
  4292. */
  4293. getRotationMatrixToRef(result: Matrix): Matrix;
  4294. /**
  4295. * Toggles model matrix from being right handed to left handed in place and vice versa
  4296. */
  4297. toggleModelMatrixHandInPlace(): void;
  4298. /**
  4299. * Toggles projection matrix from being right handed to left handed in place and vice versa
  4300. */
  4301. toggleProjectionMatrixHandInPlace(): void;
  4302. /**
  4303. * Creates a matrix from an array
  4304. * @param array defines the source array
  4305. * @param offset defines an offset in the source array
  4306. * @returns a new Matrix set from the starting index of the given array
  4307. */
  4308. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  4309. /**
  4310. * Copy the content of an array into a given matrix
  4311. * @param array defines the source array
  4312. * @param offset defines an offset in the source array
  4313. * @param result defines the target matrix
  4314. */
  4315. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  4316. /**
  4317. * Stores an array into a matrix after having multiplied each component by a given factor
  4318. * @param array defines the source array
  4319. * @param offset defines the offset in the source array
  4320. * @param scale defines the scaling factor
  4321. * @param result defines the target matrix
  4322. */
  4323. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  4324. /**
  4325. * Gets an identity matrix that must not be updated
  4326. */
  4327. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  4328. /**
  4329. * Stores a list of values (16) inside a given matrix
  4330. * @param initialM11 defines 1st value of 1st row
  4331. * @param initialM12 defines 2nd value of 1st row
  4332. * @param initialM13 defines 3rd value of 1st row
  4333. * @param initialM14 defines 4th value of 1st row
  4334. * @param initialM21 defines 1st value of 2nd row
  4335. * @param initialM22 defines 2nd value of 2nd row
  4336. * @param initialM23 defines 3rd value of 2nd row
  4337. * @param initialM24 defines 4th value of 2nd row
  4338. * @param initialM31 defines 1st value of 3rd row
  4339. * @param initialM32 defines 2nd value of 3rd row
  4340. * @param initialM33 defines 3rd value of 3rd row
  4341. * @param initialM34 defines 4th value of 3rd row
  4342. * @param initialM41 defines 1st value of 4th row
  4343. * @param initialM42 defines 2nd value of 4th row
  4344. * @param initialM43 defines 3rd value of 4th row
  4345. * @param initialM44 defines 4th value of 4th row
  4346. * @param result defines the target matrix
  4347. */
  4348. static FromValuesToRef(initialM11: number, initialM12: number, initialM13: number, initialM14: number, initialM21: number, initialM22: number, initialM23: number, initialM24: number, initialM31: number, initialM32: number, initialM33: number, initialM34: number, initialM41: number, initialM42: number, initialM43: number, initialM44: number, result: Matrix): void;
  4349. /**
  4350. * Creates new matrix from a list of values (16)
  4351. * @param initialM11 defines 1st value of 1st row
  4352. * @param initialM12 defines 2nd value of 1st row
  4353. * @param initialM13 defines 3rd value of 1st row
  4354. * @param initialM14 defines 4th value of 1st row
  4355. * @param initialM21 defines 1st value of 2nd row
  4356. * @param initialM22 defines 2nd value of 2nd row
  4357. * @param initialM23 defines 3rd value of 2nd row
  4358. * @param initialM24 defines 4th value of 2nd row
  4359. * @param initialM31 defines 1st value of 3rd row
  4360. * @param initialM32 defines 2nd value of 3rd row
  4361. * @param initialM33 defines 3rd value of 3rd row
  4362. * @param initialM34 defines 4th value of 3rd row
  4363. * @param initialM41 defines 1st value of 4th row
  4364. * @param initialM42 defines 2nd value of 4th row
  4365. * @param initialM43 defines 3rd value of 4th row
  4366. * @param initialM44 defines 4th value of 4th row
  4367. * @returns the new matrix
  4368. */
  4369. static FromValues(initialM11: number, initialM12: number, initialM13: number, initialM14: number, initialM21: number, initialM22: number, initialM23: number, initialM24: number, initialM31: number, initialM32: number, initialM33: number, initialM34: number, initialM41: number, initialM42: number, initialM43: number, initialM44: number): Matrix;
  4370. /**
  4371. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4372. * @param scale defines the scale vector3
  4373. * @param rotation defines the rotation quaternion
  4374. * @param translation defines the translation vector3
  4375. * @returns a new matrix
  4376. */
  4377. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  4378. /**
  4379. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4380. * @param scale defines the scale vector3
  4381. * @param rotation defines the rotation quaternion
  4382. * @param translation defines the translation vector3
  4383. * @param result defines the target matrix
  4384. */
  4385. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  4386. /**
  4387. * Creates a new identity matrix
  4388. * @returns a new identity matrix
  4389. */
  4390. static Identity(): Matrix;
  4391. /**
  4392. * Creates a new identity matrix and stores the result in a given matrix
  4393. * @param result defines the target matrix
  4394. */
  4395. static IdentityToRef(result: Matrix): void;
  4396. /**
  4397. * Creates a new zero matrix
  4398. * @returns a new zero matrix
  4399. */
  4400. static Zero(): Matrix;
  4401. /**
  4402. * Creates a new rotation matrix for "angle" radians around the X axis
  4403. * @param angle defines the angle (in radians) to use
  4404. * @return the new matrix
  4405. */
  4406. static RotationX(angle: number): Matrix;
  4407. /**
  4408. * Creates a new matrix as the invert of a given matrix
  4409. * @param source defines the source matrix
  4410. * @returns the new matrix
  4411. */
  4412. static Invert(source: DeepImmutable<Matrix>): Matrix;
  4413. /**
  4414. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  4415. * @param angle defines the angle (in radians) to use
  4416. * @param result defines the target matrix
  4417. */
  4418. static RotationXToRef(angle: number, result: Matrix): void;
  4419. /**
  4420. * Creates a new rotation matrix for "angle" radians around the Y axis
  4421. * @param angle defines the angle (in radians) to use
  4422. * @return the new matrix
  4423. */
  4424. static RotationY(angle: number): Matrix;
  4425. /**
  4426. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  4427. * @param angle defines the angle (in radians) to use
  4428. * @param result defines the target matrix
  4429. */
  4430. static RotationYToRef(angle: number, result: Matrix): void;
  4431. /**
  4432. * Creates a new rotation matrix for "angle" radians around the Z axis
  4433. * @param angle defines the angle (in radians) to use
  4434. * @return the new matrix
  4435. */
  4436. static RotationZ(angle: number): Matrix;
  4437. /**
  4438. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  4439. * @param angle defines the angle (in radians) to use
  4440. * @param result defines the target matrix
  4441. */
  4442. static RotationZToRef(angle: number, result: Matrix): void;
  4443. /**
  4444. * Creates a new rotation matrix for "angle" radians around the given axis
  4445. * @param axis defines the axis to use
  4446. * @param angle defines the angle (in radians) to use
  4447. * @return the new matrix
  4448. */
  4449. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  4450. /**
  4451. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  4452. * @param axis defines the axis to use
  4453. * @param angle defines the angle (in radians) to use
  4454. * @param result defines the target matrix
  4455. */
  4456. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  4457. /**
  4458. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  4459. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  4460. * @param from defines the vector to align
  4461. * @param to defines the vector to align to
  4462. * @param result defines the target matrix
  4463. */
  4464. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  4465. /**
  4466. * Creates a rotation matrix
  4467. * @param yaw defines the yaw angle in radians (Y axis)
  4468. * @param pitch defines the pitch angle in radians (X axis)
  4469. * @param roll defines the roll angle in radians (X axis)
  4470. * @returns the new rotation matrix
  4471. */
  4472. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  4473. /**
  4474. * Creates a rotation matrix and stores it in a given matrix
  4475. * @param yaw defines the yaw angle in radians (Y axis)
  4476. * @param pitch defines the pitch angle in radians (X axis)
  4477. * @param roll defines the roll angle in radians (X axis)
  4478. * @param result defines the target matrix
  4479. */
  4480. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  4481. /**
  4482. * Creates a scaling matrix
  4483. * @param x defines the scale factor on X axis
  4484. * @param y defines the scale factor on Y axis
  4485. * @param z defines the scale factor on Z axis
  4486. * @returns the new matrix
  4487. */
  4488. static Scaling(x: number, y: number, z: number): Matrix;
  4489. /**
  4490. * Creates a scaling matrix and stores it in a given matrix
  4491. * @param x defines the scale factor on X axis
  4492. * @param y defines the scale factor on Y axis
  4493. * @param z defines the scale factor on Z axis
  4494. * @param result defines the target matrix
  4495. */
  4496. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  4497. /**
  4498. * Creates a translation matrix
  4499. * @param x defines the translation on X axis
  4500. * @param y defines the translation on Y axis
  4501. * @param z defines the translationon Z axis
  4502. * @returns the new matrix
  4503. */
  4504. static Translation(x: number, y: number, z: number): Matrix;
  4505. /**
  4506. * Creates a translation matrix and stores it in a given matrix
  4507. * @param x defines the translation on X axis
  4508. * @param y defines the translation on Y axis
  4509. * @param z defines the translationon Z axis
  4510. * @param result defines the target matrix
  4511. */
  4512. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  4513. /**
  4514. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4515. * @param startValue defines the start value
  4516. * @param endValue defines the end value
  4517. * @param gradient defines the gradient factor
  4518. * @returns the new matrix
  4519. */
  4520. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4521. /**
  4522. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4523. * @param startValue defines the start value
  4524. * @param endValue defines the end value
  4525. * @param gradient defines the gradient factor
  4526. * @param result defines the Matrix object where to store data
  4527. */
  4528. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4529. /**
  4530. * Builds a new matrix whose values are computed by:
  4531. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4532. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4533. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4534. * @param startValue defines the first matrix
  4535. * @param endValue defines the second matrix
  4536. * @param gradient defines the gradient between the two matrices
  4537. * @returns the new matrix
  4538. */
  4539. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4540. /**
  4541. * Update a matrix to values which are computed by:
  4542. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4543. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4544. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4545. * @param startValue defines the first matrix
  4546. * @param endValue defines the second matrix
  4547. * @param gradient defines the gradient between the two matrices
  4548. * @param result defines the target matrix
  4549. */
  4550. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4551. /**
  4552. * Gets a new rotation matrix used to rotate an entity so as it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up"
  4553. * This function works in left handed mode
  4554. * @param eye defines the final position of the entity
  4555. * @param target defines where the entity should look at
  4556. * @param up defines the up vector for the entity
  4557. * @returns the new matrix
  4558. */
  4559. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4560. /**
  4561. * Sets the given "result" Matrix to a rotation matrix used to rotate an entity so that it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up".
  4562. * This function works in left handed mode
  4563. * @param eye defines the final position of the entity
  4564. * @param target defines where the entity should look at
  4565. * @param up defines the up vector for the entity
  4566. * @param result defines the target matrix
  4567. */
  4568. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4569. /**
  4570. * Gets a new rotation matrix used to rotate an entity so as it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up"
  4571. * This function works in right handed mode
  4572. * @param eye defines the final position of the entity
  4573. * @param target defines where the entity should look at
  4574. * @param up defines the up vector for the entity
  4575. * @returns the new matrix
  4576. */
  4577. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4578. /**
  4579. * Sets the given "result" Matrix to a rotation matrix used to rotate an entity so that it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up".
  4580. * This function works in right handed mode
  4581. * @param eye defines the final position of the entity
  4582. * @param target defines where the entity should look at
  4583. * @param up defines the up vector for the entity
  4584. * @param result defines the target matrix
  4585. */
  4586. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4587. /**
  4588. * Create a left-handed orthographic projection matrix
  4589. * @param width defines the viewport width
  4590. * @param height defines the viewport height
  4591. * @param znear defines the near clip plane
  4592. * @param zfar defines the far clip plane
  4593. * @returns a new matrix as a left-handed orthographic projection matrix
  4594. */
  4595. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4596. /**
  4597. * Store a left-handed orthographic projection to a given matrix
  4598. * @param width defines the viewport width
  4599. * @param height defines the viewport height
  4600. * @param znear defines the near clip plane
  4601. * @param zfar defines the far clip plane
  4602. * @param result defines the target matrix
  4603. */
  4604. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  4605. /**
  4606. * Create a left-handed orthographic projection matrix
  4607. * @param left defines the viewport left coordinate
  4608. * @param right defines the viewport right coordinate
  4609. * @param bottom defines the viewport bottom coordinate
  4610. * @param top defines the viewport top coordinate
  4611. * @param znear defines the near clip plane
  4612. * @param zfar defines the far clip plane
  4613. * @returns a new matrix as a left-handed orthographic projection matrix
  4614. */
  4615. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4616. /**
  4617. * Stores a left-handed orthographic projection into a given matrix
  4618. * @param left defines the viewport left coordinate
  4619. * @param right defines the viewport right coordinate
  4620. * @param bottom defines the viewport bottom coordinate
  4621. * @param top defines the viewport top coordinate
  4622. * @param znear defines the near clip plane
  4623. * @param zfar defines the far clip plane
  4624. * @param result defines the target matrix
  4625. */
  4626. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4627. /**
  4628. * Creates a right-handed orthographic projection matrix
  4629. * @param left defines the viewport left coordinate
  4630. * @param right defines the viewport right coordinate
  4631. * @param bottom defines the viewport bottom coordinate
  4632. * @param top defines the viewport top coordinate
  4633. * @param znear defines the near clip plane
  4634. * @param zfar defines the far clip plane
  4635. * @returns a new matrix as a right-handed orthographic projection matrix
  4636. */
  4637. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4638. /**
  4639. * Stores a right-handed orthographic projection into a given matrix
  4640. * @param left defines the viewport left coordinate
  4641. * @param right defines the viewport right coordinate
  4642. * @param bottom defines the viewport bottom coordinate
  4643. * @param top defines the viewport top coordinate
  4644. * @param znear defines the near clip plane
  4645. * @param zfar defines the far clip plane
  4646. * @param result defines the target matrix
  4647. */
  4648. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4649. /**
  4650. * Creates a left-handed perspective projection matrix
  4651. * @param width defines the viewport width
  4652. * @param height defines the viewport height
  4653. * @param znear defines the near clip plane
  4654. * @param zfar defines the far clip plane
  4655. * @returns a new matrix as a left-handed perspective projection matrix
  4656. */
  4657. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4658. /**
  4659. * Creates a left-handed perspective projection matrix
  4660. * @param fov defines the horizontal field of view
  4661. * @param aspect defines the aspect ratio
  4662. * @param znear defines the near clip plane
  4663. * @param zfar defines the far clip plane
  4664. * @returns a new matrix as a left-handed perspective projection matrix
  4665. */
  4666. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4667. /**
  4668. * Stores a left-handed perspective projection into a given matrix
  4669. * @param fov defines the horizontal field of view
  4670. * @param aspect defines the aspect ratio
  4671. * @param znear defines the near clip plane
  4672. * @param zfar defines the far clip plane
  4673. * @param result defines the target matrix
  4674. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4675. */
  4676. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4677. /**
  4678. * Stores a left-handed perspective projection into a given matrix with depth reversed
  4679. * @param fov defines the horizontal field of view
  4680. * @param aspect defines the aspect ratio
  4681. * @param znear defines the near clip plane
  4682. * @param zfar not used as infinity is used as far clip
  4683. * @param result defines the target matrix
  4684. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4685. */
  4686. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4687. /**
  4688. * Creates a right-handed perspective projection matrix
  4689. * @param fov defines the horizontal field of view
  4690. * @param aspect defines the aspect ratio
  4691. * @param znear defines the near clip plane
  4692. * @param zfar defines the far clip plane
  4693. * @returns a new matrix as a right-handed perspective projection matrix
  4694. */
  4695. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4696. /**
  4697. * Stores a right-handed perspective projection into a given matrix
  4698. * @param fov defines the horizontal field of view
  4699. * @param aspect defines the aspect ratio
  4700. * @param znear defines the near clip plane
  4701. * @param zfar defines the far clip plane
  4702. * @param result defines the target matrix
  4703. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4704. */
  4705. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4706. /**
  4707. * Stores a right-handed perspective projection into a given matrix
  4708. * @param fov defines the horizontal field of view
  4709. * @param aspect defines the aspect ratio
  4710. * @param znear defines the near clip plane
  4711. * @param zfar not used as infinity is used as far clip
  4712. * @param result defines the target matrix
  4713. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4714. */
  4715. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4716. /**
  4717. * Stores a perspective projection for WebVR info a given matrix
  4718. * @param fov defines the field of view
  4719. * @param znear defines the near clip plane
  4720. * @param zfar defines the far clip plane
  4721. * @param result defines the target matrix
  4722. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  4723. */
  4724. static PerspectiveFovWebVRToRef(fov: {
  4725. upDegrees: number;
  4726. downDegrees: number;
  4727. leftDegrees: number;
  4728. rightDegrees: number;
  4729. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  4730. /**
  4731. * Computes a complete transformation matrix
  4732. * @param viewport defines the viewport to use
  4733. * @param world defines the world matrix
  4734. * @param view defines the view matrix
  4735. * @param projection defines the projection matrix
  4736. * @param zmin defines the near clip plane
  4737. * @param zmax defines the far clip plane
  4738. * @returns the transformation matrix
  4739. */
  4740. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  4741. /**
  4742. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  4743. * @param matrix defines the matrix to use
  4744. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  4745. */
  4746. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  4747. /**
  4748. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  4749. * @param matrix defines the matrix to use
  4750. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  4751. */
  4752. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  4753. /**
  4754. * Compute the transpose of a given matrix
  4755. * @param matrix defines the matrix to transpose
  4756. * @returns the new matrix
  4757. */
  4758. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  4759. /**
  4760. * Compute the transpose of a matrix and store it in a target matrix
  4761. * @param matrix defines the matrix to transpose
  4762. * @param result defines the target matrix
  4763. */
  4764. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  4765. /**
  4766. * Computes a reflection matrix from a plane
  4767. * @param plane defines the reflection plane
  4768. * @returns a new matrix
  4769. */
  4770. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  4771. /**
  4772. * Computes a reflection matrix from a plane
  4773. * @param plane defines the reflection plane
  4774. * @param result defines the target matrix
  4775. */
  4776. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  4777. /**
  4778. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  4779. * @param xaxis defines the value of the 1st axis
  4780. * @param yaxis defines the value of the 2nd axis
  4781. * @param zaxis defines the value of the 3rd axis
  4782. * @param result defines the target matrix
  4783. */
  4784. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  4785. /**
  4786. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  4787. * @param quat defines the quaternion to use
  4788. * @param result defines the target matrix
  4789. */
  4790. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  4791. }
  4792. /**
  4793. * @hidden
  4794. */
  4795. export class TmpVectors {
  4796. static Vector2: Vector2[];
  4797. static Vector3: Vector3[];
  4798. static Vector4: Vector4[];
  4799. static Quaternion: Quaternion[];
  4800. static Matrix: Matrix[];
  4801. }
  4802. }
  4803. declare module "babylonjs/Maths/math.path" {
  4804. import { DeepImmutable, Nullable } from "babylonjs/types";
  4805. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  4806. /**
  4807. * Defines potential orientation for back face culling
  4808. */
  4809. export enum Orientation {
  4810. /**
  4811. * Clockwise
  4812. */
  4813. CW = 0,
  4814. /** Counter clockwise */
  4815. CCW = 1
  4816. }
  4817. /** Class used to represent a Bezier curve */
  4818. export class BezierCurve {
  4819. /**
  4820. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  4821. * @param t defines the time
  4822. * @param x1 defines the left coordinate on X axis
  4823. * @param y1 defines the left coordinate on Y axis
  4824. * @param x2 defines the right coordinate on X axis
  4825. * @param y2 defines the right coordinate on Y axis
  4826. * @returns the interpolated value
  4827. */
  4828. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  4829. }
  4830. /**
  4831. * Defines angle representation
  4832. */
  4833. export class Angle {
  4834. private _radians;
  4835. /**
  4836. * Creates an Angle object of "radians" radians (float).
  4837. * @param radians the angle in radians
  4838. */
  4839. constructor(radians: number);
  4840. /**
  4841. * Get value in degrees
  4842. * @returns the Angle value in degrees (float)
  4843. */
  4844. degrees(): number;
  4845. /**
  4846. * Get value in radians
  4847. * @returns the Angle value in radians (float)
  4848. */
  4849. radians(): number;
  4850. /**
  4851. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  4852. * @param a defines first vector
  4853. * @param b defines second vector
  4854. * @returns a new Angle
  4855. */
  4856. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  4857. /**
  4858. * Gets a new Angle object from the given float in radians
  4859. * @param radians defines the angle value in radians
  4860. * @returns a new Angle
  4861. */
  4862. static FromRadians(radians: number): Angle;
  4863. /**
  4864. * Gets a new Angle object from the given float in degrees
  4865. * @param degrees defines the angle value in degrees
  4866. * @returns a new Angle
  4867. */
  4868. static FromDegrees(degrees: number): Angle;
  4869. }
  4870. /**
  4871. * This represents an arc in a 2d space.
  4872. */
  4873. export class Arc2 {
  4874. /** Defines the start point of the arc */
  4875. startPoint: Vector2;
  4876. /** Defines the mid point of the arc */
  4877. midPoint: Vector2;
  4878. /** Defines the end point of the arc */
  4879. endPoint: Vector2;
  4880. /**
  4881. * Defines the center point of the arc.
  4882. */
  4883. centerPoint: Vector2;
  4884. /**
  4885. * Defines the radius of the arc.
  4886. */
  4887. radius: number;
  4888. /**
  4889. * Defines the angle of the arc (from mid point to end point).
  4890. */
  4891. angle: Angle;
  4892. /**
  4893. * Defines the start angle of the arc (from start point to middle point).
  4894. */
  4895. startAngle: Angle;
  4896. /**
  4897. * Defines the orientation of the arc (clock wise/counter clock wise).
  4898. */
  4899. orientation: Orientation;
  4900. /**
  4901. * Creates an Arc object from the three given points : start, middle and end.
  4902. * @param startPoint Defines the start point of the arc
  4903. * @param midPoint Defines the midlle point of the arc
  4904. * @param endPoint Defines the end point of the arc
  4905. */
  4906. constructor(
  4907. /** Defines the start point of the arc */
  4908. startPoint: Vector2,
  4909. /** Defines the mid point of the arc */
  4910. midPoint: Vector2,
  4911. /** Defines the end point of the arc */
  4912. endPoint: Vector2);
  4913. }
  4914. /**
  4915. * Represents a 2D path made up of multiple 2D points
  4916. */
  4917. export class Path2 {
  4918. private _points;
  4919. private _length;
  4920. /**
  4921. * If the path start and end point are the same
  4922. */
  4923. closed: boolean;
  4924. /**
  4925. * Creates a Path2 object from the starting 2D coordinates x and y.
  4926. * @param x the starting points x value
  4927. * @param y the starting points y value
  4928. */
  4929. constructor(x: number, y: number);
  4930. /**
  4931. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  4932. * @param x the added points x value
  4933. * @param y the added points y value
  4934. * @returns the updated Path2.
  4935. */
  4936. addLineTo(x: number, y: number): Path2;
  4937. /**
  4938. * Adds _numberOfSegments_ segments according to the arc definition (middle point coordinates, end point coordinates, the arc start point being the current Path2 last point) to the current Path2.
  4939. * @param midX middle point x value
  4940. * @param midY middle point y value
  4941. * @param endX end point x value
  4942. * @param endY end point y value
  4943. * @param numberOfSegments (default: 36)
  4944. * @returns the updated Path2.
  4945. */
  4946. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  4947. /**
  4948. * Closes the Path2.
  4949. * @returns the Path2.
  4950. */
  4951. close(): Path2;
  4952. /**
  4953. * Gets the sum of the distance between each sequential point in the path
  4954. * @returns the Path2 total length (float).
  4955. */
  4956. length(): number;
  4957. /**
  4958. * Gets the points which construct the path
  4959. * @returns the Path2 internal array of points.
  4960. */
  4961. getPoints(): Vector2[];
  4962. /**
  4963. * Retreives the point at the distance aways from the starting point
  4964. * @param normalizedLengthPosition the length along the path to retreive the point from
  4965. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  4966. */
  4967. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  4968. /**
  4969. * Creates a new path starting from an x and y position
  4970. * @param x starting x value
  4971. * @param y starting y value
  4972. * @returns a new Path2 starting at the coordinates (x, y).
  4973. */
  4974. static StartingAt(x: number, y: number): Path2;
  4975. }
  4976. /**
  4977. * Represents a 3D path made up of multiple 3D points
  4978. */
  4979. export class Path3D {
  4980. /**
  4981. * an array of Vector3, the curve axis of the Path3D
  4982. */
  4983. path: Vector3[];
  4984. private _curve;
  4985. private _distances;
  4986. private _tangents;
  4987. private _normals;
  4988. private _binormals;
  4989. private _raw;
  4990. private _alignTangentsWithPath;
  4991. private readonly _pointAtData;
  4992. /**
  4993. * new Path3D(path, normal, raw)
  4994. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  4995. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  4996. * @param path an array of Vector3, the curve axis of the Path3D
  4997. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  4998. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  4999. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  5000. */
  5001. constructor(
  5002. /**
  5003. * an array of Vector3, the curve axis of the Path3D
  5004. */
  5005. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  5006. /**
  5007. * Returns the Path3D array of successive Vector3 designing its curve.
  5008. * @returns the Path3D array of successive Vector3 designing its curve.
  5009. */
  5010. getCurve(): Vector3[];
  5011. /**
  5012. * Returns the Path3D array of successive Vector3 designing its curve.
  5013. * @returns the Path3D array of successive Vector3 designing its curve.
  5014. */
  5015. getPoints(): Vector3[];
  5016. /**
  5017. * @returns the computed length (float) of the path.
  5018. */
  5019. length(): number;
  5020. /**
  5021. * Returns an array populated with tangent vectors on each Path3D curve point.
  5022. * @returns an array populated with tangent vectors on each Path3D curve point.
  5023. */
  5024. getTangents(): Vector3[];
  5025. /**
  5026. * Returns an array populated with normal vectors on each Path3D curve point.
  5027. * @returns an array populated with normal vectors on each Path3D curve point.
  5028. */
  5029. getNormals(): Vector3[];
  5030. /**
  5031. * Returns an array populated with binormal vectors on each Path3D curve point.
  5032. * @returns an array populated with binormal vectors on each Path3D curve point.
  5033. */
  5034. getBinormals(): Vector3[];
  5035. /**
  5036. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  5037. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  5038. */
  5039. getDistances(): number[];
  5040. /**
  5041. * Returns an interpolated point along this path
  5042. * @param position the position of the point along this path, from 0.0 to 1.0
  5043. * @returns a new Vector3 as the point
  5044. */
  5045. getPointAt(position: number): Vector3;
  5046. /**
  5047. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  5048. * @param position the position of the point along this path, from 0.0 to 1.0
  5049. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  5050. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  5051. */
  5052. getTangentAt(position: number, interpolated?: boolean): Vector3;
  5053. /**
  5054. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  5055. * @param position the position of the point along this path, from 0.0 to 1.0
  5056. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  5057. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  5058. */
  5059. getNormalAt(position: number, interpolated?: boolean): Vector3;
  5060. /**
  5061. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  5062. * @param position the position of the point along this path, from 0.0 to 1.0
  5063. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  5064. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  5065. */
  5066. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  5067. /**
  5068. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  5069. * @param position the position of the point along this path, from 0.0 to 1.0
  5070. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  5071. */
  5072. getDistanceAt(position: number): number;
  5073. /**
  5074. * Returns the array index of the previous point of an interpolated point along this path
  5075. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  5076. * @returns the array index
  5077. */
  5078. getPreviousPointIndexAt(position: number): number;
  5079. /**
  5080. * Returns the position of an interpolated point relative to the two path points it lies between, from 0.0 (point A) to 1.0 (point B)
  5081. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  5082. * @returns the sub position
  5083. */
  5084. getSubPositionAt(position: number): number;
  5085. /**
  5086. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  5087. * @param target the vector of which to get the closest position to
  5088. * @returns the position of the closest virtual point on this path to the target vector
  5089. */
  5090. getClosestPositionTo(target: Vector3): number;
  5091. /**
  5092. * Returns a sub path (slice) of this path
  5093. * @param start the position of the fist path point, from 0.0 to 1.0, or a negative value, which will get wrapped around from the end of the path to 0.0 to 1.0 values
  5094. * @param end the position of the last path point, from 0.0 to 1.0, or a negative value, which will get wrapped around from the end of the path to 0.0 to 1.0 values
  5095. * @returns a sub path (slice) of this path
  5096. */
  5097. slice(start?: number, end?: number): Path3D;
  5098. /**
  5099. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  5100. * @param path path which all values are copied into the curves points
  5101. * @param firstNormal which should be projected onto the curve
  5102. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  5103. * @returns the same object updated.
  5104. */
  5105. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  5106. private _compute;
  5107. private _getFirstNonNullVector;
  5108. private _getLastNonNullVector;
  5109. private _normalVector;
  5110. /**
  5111. * Updates the point at data for an interpolated point along this curve
  5112. * @param position the position of the point along this curve, from 0.0 to 1.0
  5113. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  5114. * @returns the (updated) point at data
  5115. */
  5116. private _updatePointAtData;
  5117. /**
  5118. * Updates the point at data from the specified parameters
  5119. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  5120. * @param point the interpolated point
  5121. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  5122. */
  5123. private _setPointAtData;
  5124. /**
  5125. * Updates the point at interpolation matrix for the tangents, normals and binormals
  5126. */
  5127. private _updateInterpolationMatrix;
  5128. }
  5129. /**
  5130. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5131. * A Curve3 is designed from a series of successive Vector3.
  5132. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  5133. */
  5134. export class Curve3 {
  5135. private _points;
  5136. private _length;
  5137. /**
  5138. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  5139. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  5140. * @param v1 (Vector3) the control point
  5141. * @param v2 (Vector3) the end point of the Quadratic Bezier
  5142. * @param nbPoints (integer) the wanted number of points in the curve
  5143. * @returns the created Curve3
  5144. */
  5145. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5146. /**
  5147. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  5148. * @param v0 (Vector3) the origin point of the Cubic Bezier
  5149. * @param v1 (Vector3) the first control point
  5150. * @param v2 (Vector3) the second control point
  5151. * @param v3 (Vector3) the end point of the Cubic Bezier
  5152. * @param nbPoints (integer) the wanted number of points in the curve
  5153. * @returns the created Curve3
  5154. */
  5155. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5156. /**
  5157. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  5158. * @param p1 (Vector3) the origin point of the Hermite Spline
  5159. * @param t1 (Vector3) the tangent vector at the origin point
  5160. * @param p2 (Vector3) the end point of the Hermite Spline
  5161. * @param t2 (Vector3) the tangent vector at the end point
  5162. * @param nbPoints (integer) the wanted number of points in the curve
  5163. * @returns the created Curve3
  5164. */
  5165. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5166. /**
  5167. * Returns a Curve3 object along a CatmullRom Spline curve :
  5168. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  5169. * @param nbPoints (integer) the wanted number of points between each curve control points
  5170. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  5171. * @returns the created Curve3
  5172. */
  5173. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  5174. /**
  5175. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5176. * A Curve3 is designed from a series of successive Vector3.
  5177. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  5178. * @param points points which make up the curve
  5179. */
  5180. constructor(points: Vector3[]);
  5181. /**
  5182. * @returns the Curve3 stored array of successive Vector3
  5183. */
  5184. getPoints(): Vector3[];
  5185. /**
  5186. * @returns the computed length (float) of the curve.
  5187. */
  5188. length(): number;
  5189. /**
  5190. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  5191. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  5192. * curveA and curveB keep unchanged.
  5193. * @param curve the curve to continue from this curve
  5194. * @returns the newly constructed curve
  5195. */
  5196. continue(curve: DeepImmutable<Curve3>): Curve3;
  5197. private _computeLength;
  5198. }
  5199. }
  5200. declare module "babylonjs/Animations/easing" {
  5201. /**
  5202. * This represents the main contract an easing function should follow.
  5203. * Easing functions are used throughout the animation system.
  5204. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5205. */
  5206. export interface IEasingFunction {
  5207. /**
  5208. * Given an input gradient between 0 and 1, this returns the corrseponding value
  5209. * of the easing function.
  5210. * The link below provides some of the most common examples of easing functions.
  5211. * @see https://easings.net/
  5212. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5213. * @returns the corresponding value on the curve defined by the easing function
  5214. */
  5215. ease(gradient: number): number;
  5216. }
  5217. /**
  5218. * Base class used for every default easing function.
  5219. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5220. */
  5221. export class EasingFunction implements IEasingFunction {
  5222. /**
  5223. * Interpolation follows the mathematical formula associated with the easing function.
  5224. */
  5225. static readonly EASINGMODE_EASEIN: number;
  5226. /**
  5227. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  5228. */
  5229. static readonly EASINGMODE_EASEOUT: number;
  5230. /**
  5231. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  5232. */
  5233. static readonly EASINGMODE_EASEINOUT: number;
  5234. private _easingMode;
  5235. /**
  5236. * Sets the easing mode of the current function.
  5237. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  5238. */
  5239. setEasingMode(easingMode: number): void;
  5240. /**
  5241. * Gets the current easing mode.
  5242. * @returns the easing mode
  5243. */
  5244. getEasingMode(): number;
  5245. /**
  5246. * @hidden
  5247. */
  5248. easeInCore(gradient: number): number;
  5249. /**
  5250. * Given an input gradient between 0 and 1, this returns the corresponding value
  5251. * of the easing function.
  5252. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5253. * @returns the corresponding value on the curve defined by the easing function
  5254. */
  5255. ease(gradient: number): number;
  5256. }
  5257. /**
  5258. * Easing function with a circle shape (see link below).
  5259. * @see https://easings.net/#easeInCirc
  5260. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5261. */
  5262. export class CircleEase extends EasingFunction implements IEasingFunction {
  5263. /** @hidden */
  5264. easeInCore(gradient: number): number;
  5265. }
  5266. /**
  5267. * Easing function with a ease back shape (see link below).
  5268. * @see https://easings.net/#easeInBack
  5269. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5270. */
  5271. export class BackEase extends EasingFunction implements IEasingFunction {
  5272. /** Defines the amplitude of the function */
  5273. amplitude: number;
  5274. /**
  5275. * Instantiates a back ease easing
  5276. * @see https://easings.net/#easeInBack
  5277. * @param amplitude Defines the amplitude of the function
  5278. */
  5279. constructor(
  5280. /** Defines the amplitude of the function */
  5281. amplitude?: number);
  5282. /** @hidden */
  5283. easeInCore(gradient: number): number;
  5284. }
  5285. /**
  5286. * Easing function with a bouncing shape (see link below).
  5287. * @see https://easings.net/#easeInBounce
  5288. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5289. */
  5290. export class BounceEase extends EasingFunction implements IEasingFunction {
  5291. /** Defines the number of bounces */
  5292. bounces: number;
  5293. /** Defines the amplitude of the bounce */
  5294. bounciness: number;
  5295. /**
  5296. * Instantiates a bounce easing
  5297. * @see https://easings.net/#easeInBounce
  5298. * @param bounces Defines the number of bounces
  5299. * @param bounciness Defines the amplitude of the bounce
  5300. */
  5301. constructor(
  5302. /** Defines the number of bounces */
  5303. bounces?: number,
  5304. /** Defines the amplitude of the bounce */
  5305. bounciness?: number);
  5306. /** @hidden */
  5307. easeInCore(gradient: number): number;
  5308. }
  5309. /**
  5310. * Easing function with a power of 3 shape (see link below).
  5311. * @see https://easings.net/#easeInCubic
  5312. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5313. */
  5314. export class CubicEase extends EasingFunction implements IEasingFunction {
  5315. /** @hidden */
  5316. easeInCore(gradient: number): number;
  5317. }
  5318. /**
  5319. * Easing function with an elastic shape (see link below).
  5320. * @see https://easings.net/#easeInElastic
  5321. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5322. */
  5323. export class ElasticEase extends EasingFunction implements IEasingFunction {
  5324. /** Defines the number of oscillations*/
  5325. oscillations: number;
  5326. /** Defines the amplitude of the oscillations*/
  5327. springiness: number;
  5328. /**
  5329. * Instantiates an elastic easing function
  5330. * @see https://easings.net/#easeInElastic
  5331. * @param oscillations Defines the number of oscillations
  5332. * @param springiness Defines the amplitude of the oscillations
  5333. */
  5334. constructor(
  5335. /** Defines the number of oscillations*/
  5336. oscillations?: number,
  5337. /** Defines the amplitude of the oscillations*/
  5338. springiness?: number);
  5339. /** @hidden */
  5340. easeInCore(gradient: number): number;
  5341. }
  5342. /**
  5343. * Easing function with an exponential shape (see link below).
  5344. * @see https://easings.net/#easeInExpo
  5345. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5346. */
  5347. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  5348. /** Defines the exponent of the function */
  5349. exponent: number;
  5350. /**
  5351. * Instantiates an exponential easing function
  5352. * @see https://easings.net/#easeInExpo
  5353. * @param exponent Defines the exponent of the function
  5354. */
  5355. constructor(
  5356. /** Defines the exponent of the function */
  5357. exponent?: number);
  5358. /** @hidden */
  5359. easeInCore(gradient: number): number;
  5360. }
  5361. /**
  5362. * Easing function with a power shape (see link below).
  5363. * @see https://easings.net/#easeInQuad
  5364. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5365. */
  5366. export class PowerEase extends EasingFunction implements IEasingFunction {
  5367. /** Defines the power of the function */
  5368. power: number;
  5369. /**
  5370. * Instantiates an power base easing function
  5371. * @see https://easings.net/#easeInQuad
  5372. * @param power Defines the power of the function
  5373. */
  5374. constructor(
  5375. /** Defines the power of the function */
  5376. power?: number);
  5377. /** @hidden */
  5378. easeInCore(gradient: number): number;
  5379. }
  5380. /**
  5381. * Easing function with a power of 2 shape (see link below).
  5382. * @see https://easings.net/#easeInQuad
  5383. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5384. */
  5385. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  5386. /** @hidden */
  5387. easeInCore(gradient: number): number;
  5388. }
  5389. /**
  5390. * Easing function with a power of 4 shape (see link below).
  5391. * @see https://easings.net/#easeInQuart
  5392. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5393. */
  5394. export class QuarticEase extends EasingFunction implements IEasingFunction {
  5395. /** @hidden */
  5396. easeInCore(gradient: number): number;
  5397. }
  5398. /**
  5399. * Easing function with a power of 5 shape (see link below).
  5400. * @see https://easings.net/#easeInQuint
  5401. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5402. */
  5403. export class QuinticEase extends EasingFunction implements IEasingFunction {
  5404. /** @hidden */
  5405. easeInCore(gradient: number): number;
  5406. }
  5407. /**
  5408. * Easing function with a sin shape (see link below).
  5409. * @see https://easings.net/#easeInSine
  5410. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5411. */
  5412. export class SineEase extends EasingFunction implements IEasingFunction {
  5413. /** @hidden */
  5414. easeInCore(gradient: number): number;
  5415. }
  5416. /**
  5417. * Easing function with a bezier shape (see link below).
  5418. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5419. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5420. */
  5421. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  5422. /** Defines the x component of the start tangent in the bezier curve */
  5423. x1: number;
  5424. /** Defines the y component of the start tangent in the bezier curve */
  5425. y1: number;
  5426. /** Defines the x component of the end tangent in the bezier curve */
  5427. x2: number;
  5428. /** Defines the y component of the end tangent in the bezier curve */
  5429. y2: number;
  5430. /**
  5431. * Instantiates a bezier function
  5432. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5433. * @param x1 Defines the x component of the start tangent in the bezier curve
  5434. * @param y1 Defines the y component of the start tangent in the bezier curve
  5435. * @param x2 Defines the x component of the end tangent in the bezier curve
  5436. * @param y2 Defines the y component of the end tangent in the bezier curve
  5437. */
  5438. constructor(
  5439. /** Defines the x component of the start tangent in the bezier curve */
  5440. x1?: number,
  5441. /** Defines the y component of the start tangent in the bezier curve */
  5442. y1?: number,
  5443. /** Defines the x component of the end tangent in the bezier curve */
  5444. x2?: number,
  5445. /** Defines the y component of the end tangent in the bezier curve */
  5446. y2?: number);
  5447. /** @hidden */
  5448. easeInCore(gradient: number): number;
  5449. }
  5450. }
  5451. declare module "babylonjs/Maths/math.color" {
  5452. import { DeepImmutable, FloatArray } from "babylonjs/types";
  5453. /**
  5454. * Class used to hold a RBG color
  5455. */
  5456. export class Color3 {
  5457. /**
  5458. * Defines the red component (between 0 and 1, default is 0)
  5459. */
  5460. r: number;
  5461. /**
  5462. * Defines the green component (between 0 and 1, default is 0)
  5463. */
  5464. g: number;
  5465. /**
  5466. * Defines the blue component (between 0 and 1, default is 0)
  5467. */
  5468. b: number;
  5469. /**
  5470. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  5471. * @param r defines the red component (between 0 and 1, default is 0)
  5472. * @param g defines the green component (between 0 and 1, default is 0)
  5473. * @param b defines the blue component (between 0 and 1, default is 0)
  5474. */
  5475. constructor(
  5476. /**
  5477. * Defines the red component (between 0 and 1, default is 0)
  5478. */
  5479. r?: number,
  5480. /**
  5481. * Defines the green component (between 0 and 1, default is 0)
  5482. */
  5483. g?: number,
  5484. /**
  5485. * Defines the blue component (between 0 and 1, default is 0)
  5486. */
  5487. b?: number);
  5488. /**
  5489. * Creates a string with the Color3 current values
  5490. * @returns the string representation of the Color3 object
  5491. */
  5492. toString(): string;
  5493. /**
  5494. * Returns the string "Color3"
  5495. * @returns "Color3"
  5496. */
  5497. getClassName(): string;
  5498. /**
  5499. * Compute the Color3 hash code
  5500. * @returns an unique number that can be used to hash Color3 objects
  5501. */
  5502. getHashCode(): number;
  5503. /**
  5504. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  5505. * @param array defines the array where to store the r,g,b components
  5506. * @param index defines an optional index in the target array to define where to start storing values
  5507. * @returns the current Color3 object
  5508. */
  5509. toArray(array: FloatArray, index?: number): Color3;
  5510. /**
  5511. * Returns a new Color4 object from the current Color3 and the given alpha
  5512. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  5513. * @returns a new Color4 object
  5514. */
  5515. toColor4(alpha?: number): Color4;
  5516. /**
  5517. * Returns a new array populated with 3 numeric elements : red, green and blue values
  5518. * @returns the new array
  5519. */
  5520. asArray(): number[];
  5521. /**
  5522. * Returns the luminance value
  5523. * @returns a float value
  5524. */
  5525. toLuminance(): number;
  5526. /**
  5527. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  5528. * @param otherColor defines the second operand
  5529. * @returns the new Color3 object
  5530. */
  5531. multiply(otherColor: DeepImmutable<Color3>): Color3;
  5532. /**
  5533. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  5534. * @param otherColor defines the second operand
  5535. * @param result defines the Color3 object where to store the result
  5536. * @returns the current Color3
  5537. */
  5538. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5539. /**
  5540. * Determines equality between Color3 objects
  5541. * @param otherColor defines the second operand
  5542. * @returns true if the rgb values are equal to the given ones
  5543. */
  5544. equals(otherColor: DeepImmutable<Color3>): boolean;
  5545. /**
  5546. * Determines equality between the current Color3 object and a set of r,b,g values
  5547. * @param r defines the red component to check
  5548. * @param g defines the green component to check
  5549. * @param b defines the blue component to check
  5550. * @returns true if the rgb values are equal to the given ones
  5551. */
  5552. equalsFloats(r: number, g: number, b: number): boolean;
  5553. /**
  5554. * Multiplies in place each rgb value by scale
  5555. * @param scale defines the scaling factor
  5556. * @returns the updated Color3
  5557. */
  5558. scale(scale: number): Color3;
  5559. /**
  5560. * Multiplies the rgb values by scale and stores the result into "result"
  5561. * @param scale defines the scaling factor
  5562. * @param result defines the Color3 object where to store the result
  5563. * @returns the unmodified current Color3
  5564. */
  5565. scaleToRef(scale: number, result: Color3): Color3;
  5566. /**
  5567. * Scale the current Color3 values by a factor and add the result to a given Color3
  5568. * @param scale defines the scale factor
  5569. * @param result defines color to store the result into
  5570. * @returns the unmodified current Color3
  5571. */
  5572. scaleAndAddToRef(scale: number, result: Color3): Color3;
  5573. /**
  5574. * Clamps the rgb values by the min and max values and stores the result into "result"
  5575. * @param min defines minimum clamping value (default is 0)
  5576. * @param max defines maximum clamping value (default is 1)
  5577. * @param result defines color to store the result into
  5578. * @returns the original Color3
  5579. */
  5580. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  5581. /**
  5582. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  5583. * @param otherColor defines the second operand
  5584. * @returns the new Color3
  5585. */
  5586. add(otherColor: DeepImmutable<Color3>): Color3;
  5587. /**
  5588. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  5589. * @param otherColor defines the second operand
  5590. * @param result defines Color3 object to store the result into
  5591. * @returns the unmodified current Color3
  5592. */
  5593. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5594. /**
  5595. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  5596. * @param otherColor defines the second operand
  5597. * @returns the new Color3
  5598. */
  5599. subtract(otherColor: DeepImmutable<Color3>): Color3;
  5600. /**
  5601. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  5602. * @param otherColor defines the second operand
  5603. * @param result defines Color3 object to store the result into
  5604. * @returns the unmodified current Color3
  5605. */
  5606. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5607. /**
  5608. * Copy the current object
  5609. * @returns a new Color3 copied the current one
  5610. */
  5611. clone(): Color3;
  5612. /**
  5613. * Copies the rgb values from the source in the current Color3
  5614. * @param source defines the source Color3 object
  5615. * @returns the updated Color3 object
  5616. */
  5617. copyFrom(source: DeepImmutable<Color3>): Color3;
  5618. /**
  5619. * Updates the Color3 rgb values from the given floats
  5620. * @param r defines the red component to read from
  5621. * @param g defines the green component to read from
  5622. * @param b defines the blue component to read from
  5623. * @returns the current Color3 object
  5624. */
  5625. copyFromFloats(r: number, g: number, b: number): Color3;
  5626. /**
  5627. * Updates the Color3 rgb values from the given floats
  5628. * @param r defines the red component to read from
  5629. * @param g defines the green component to read from
  5630. * @param b defines the blue component to read from
  5631. * @returns the current Color3 object
  5632. */
  5633. set(r: number, g: number, b: number): Color3;
  5634. /**
  5635. * Compute the Color3 hexadecimal code as a string
  5636. * @returns a string containing the hexadecimal representation of the Color3 object
  5637. */
  5638. toHexString(): string;
  5639. /**
  5640. * Computes a new Color3 converted from the current one to linear space
  5641. * @returns a new Color3 object
  5642. */
  5643. toLinearSpace(): Color3;
  5644. /**
  5645. * Converts current color in rgb space to HSV values
  5646. * @returns a new color3 representing the HSV values
  5647. */
  5648. toHSV(): Color3;
  5649. /**
  5650. * Converts current color in rgb space to HSV values
  5651. * @param result defines the Color3 where to store the HSV values
  5652. */
  5653. toHSVToRef(result: Color3): void;
  5654. /**
  5655. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  5656. * @param convertedColor defines the Color3 object where to store the linear space version
  5657. * @returns the unmodified Color3
  5658. */
  5659. toLinearSpaceToRef(convertedColor: Color3): Color3;
  5660. /**
  5661. * Computes a new Color3 converted from the current one to gamma space
  5662. * @returns a new Color3 object
  5663. */
  5664. toGammaSpace(): Color3;
  5665. /**
  5666. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  5667. * @param convertedColor defines the Color3 object where to store the gamma space version
  5668. * @returns the unmodified Color3
  5669. */
  5670. toGammaSpaceToRef(convertedColor: Color3): Color3;
  5671. private static _BlackReadOnly;
  5672. /**
  5673. * Convert Hue, saturation and value to a Color3 (RGB)
  5674. * @param hue defines the hue
  5675. * @param saturation defines the saturation
  5676. * @param value defines the value
  5677. * @param result defines the Color3 where to store the RGB values
  5678. */
  5679. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  5680. /**
  5681. * Creates a new Color3 from the string containing valid hexadecimal values
  5682. * @param hex defines a string containing valid hexadecimal values
  5683. * @returns a new Color3 object
  5684. */
  5685. static FromHexString(hex: string): Color3;
  5686. /**
  5687. * Creates a new Color3 from the starting index of the given array
  5688. * @param array defines the source array
  5689. * @param offset defines an offset in the source array
  5690. * @returns a new Color3 object
  5691. */
  5692. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5693. /**
  5694. * Creates a new Color3 from integer values (< 256)
  5695. * @param r defines the red component to read from (value between 0 and 255)
  5696. * @param g defines the green component to read from (value between 0 and 255)
  5697. * @param b defines the blue component to read from (value between 0 and 255)
  5698. * @returns a new Color3 object
  5699. */
  5700. static FromInts(r: number, g: number, b: number): Color3;
  5701. /**
  5702. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5703. * @param start defines the start Color3 value
  5704. * @param end defines the end Color3 value
  5705. * @param amount defines the gradient value between start and end
  5706. * @returns a new Color3 object
  5707. */
  5708. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  5709. /**
  5710. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5711. * @param left defines the start value
  5712. * @param right defines the end value
  5713. * @param amount defines the gradient factor
  5714. * @param result defines the Color3 object where to store the result
  5715. */
  5716. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  5717. /**
  5718. * Returns a Color3 value containing a red color
  5719. * @returns a new Color3 object
  5720. */
  5721. static Red(): Color3;
  5722. /**
  5723. * Returns a Color3 value containing a green color
  5724. * @returns a new Color3 object
  5725. */
  5726. static Green(): Color3;
  5727. /**
  5728. * Returns a Color3 value containing a blue color
  5729. * @returns a new Color3 object
  5730. */
  5731. static Blue(): Color3;
  5732. /**
  5733. * Returns a Color3 value containing a black color
  5734. * @returns a new Color3 object
  5735. */
  5736. static Black(): Color3;
  5737. /**
  5738. * Gets a Color3 value containing a black color that must not be updated
  5739. */
  5740. static get BlackReadOnly(): DeepImmutable<Color3>;
  5741. /**
  5742. * Returns a Color3 value containing a white color
  5743. * @returns a new Color3 object
  5744. */
  5745. static White(): Color3;
  5746. /**
  5747. * Returns a Color3 value containing a purple color
  5748. * @returns a new Color3 object
  5749. */
  5750. static Purple(): Color3;
  5751. /**
  5752. * Returns a Color3 value containing a magenta color
  5753. * @returns a new Color3 object
  5754. */
  5755. static Magenta(): Color3;
  5756. /**
  5757. * Returns a Color3 value containing a yellow color
  5758. * @returns a new Color3 object
  5759. */
  5760. static Yellow(): Color3;
  5761. /**
  5762. * Returns a Color3 value containing a gray color
  5763. * @returns a new Color3 object
  5764. */
  5765. static Gray(): Color3;
  5766. /**
  5767. * Returns a Color3 value containing a teal color
  5768. * @returns a new Color3 object
  5769. */
  5770. static Teal(): Color3;
  5771. /**
  5772. * Returns a Color3 value containing a random color
  5773. * @returns a new Color3 object
  5774. */
  5775. static Random(): Color3;
  5776. }
  5777. /**
  5778. * Class used to hold a RBGA color
  5779. */
  5780. export class Color4 {
  5781. /**
  5782. * Defines the red component (between 0 and 1, default is 0)
  5783. */
  5784. r: number;
  5785. /**
  5786. * Defines the green component (between 0 and 1, default is 0)
  5787. */
  5788. g: number;
  5789. /**
  5790. * Defines the blue component (between 0 and 1, default is 0)
  5791. */
  5792. b: number;
  5793. /**
  5794. * Defines the alpha component (between 0 and 1, default is 1)
  5795. */
  5796. a: number;
  5797. /**
  5798. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  5799. * @param r defines the red component (between 0 and 1, default is 0)
  5800. * @param g defines the green component (between 0 and 1, default is 0)
  5801. * @param b defines the blue component (between 0 and 1, default is 0)
  5802. * @param a defines the alpha component (between 0 and 1, default is 1)
  5803. */
  5804. constructor(
  5805. /**
  5806. * Defines the red component (between 0 and 1, default is 0)
  5807. */
  5808. r?: number,
  5809. /**
  5810. * Defines the green component (between 0 and 1, default is 0)
  5811. */
  5812. g?: number,
  5813. /**
  5814. * Defines the blue component (between 0 and 1, default is 0)
  5815. */
  5816. b?: number,
  5817. /**
  5818. * Defines the alpha component (between 0 and 1, default is 1)
  5819. */
  5820. a?: number);
  5821. /**
  5822. * Adds in place the given Color4 values to the current Color4 object
  5823. * @param right defines the second operand
  5824. * @returns the current updated Color4 object
  5825. */
  5826. addInPlace(right: DeepImmutable<Color4>): Color4;
  5827. /**
  5828. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  5829. * @returns the new array
  5830. */
  5831. asArray(): number[];
  5832. /**
  5833. * Stores from the starting index in the given array the Color4 successive values
  5834. * @param array defines the array where to store the r,g,b components
  5835. * @param index defines an optional index in the target array to define where to start storing values
  5836. * @returns the current Color4 object
  5837. */
  5838. toArray(array: number[], index?: number): Color4;
  5839. /**
  5840. * Determines equality between Color4 objects
  5841. * @param otherColor defines the second operand
  5842. * @returns true if the rgba values are equal to the given ones
  5843. */
  5844. equals(otherColor: DeepImmutable<Color4>): boolean;
  5845. /**
  5846. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  5847. * @param right defines the second operand
  5848. * @returns a new Color4 object
  5849. */
  5850. add(right: DeepImmutable<Color4>): Color4;
  5851. /**
  5852. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  5853. * @param right defines the second operand
  5854. * @returns a new Color4 object
  5855. */
  5856. subtract(right: DeepImmutable<Color4>): Color4;
  5857. /**
  5858. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  5859. * @param right defines the second operand
  5860. * @param result defines the Color4 object where to store the result
  5861. * @returns the current Color4 object
  5862. */
  5863. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  5864. /**
  5865. * Creates a new Color4 with the current Color4 values multiplied by scale
  5866. * @param scale defines the scaling factor to apply
  5867. * @returns a new Color4 object
  5868. */
  5869. scale(scale: number): Color4;
  5870. /**
  5871. * Multiplies the current Color4 values by scale and stores the result in "result"
  5872. * @param scale defines the scaling factor to apply
  5873. * @param result defines the Color4 object where to store the result
  5874. * @returns the current unmodified Color4
  5875. */
  5876. scaleToRef(scale: number, result: Color4): Color4;
  5877. /**
  5878. * Scale the current Color4 values by a factor and add the result to a given Color4
  5879. * @param scale defines the scale factor
  5880. * @param result defines the Color4 object where to store the result
  5881. * @returns the unmodified current Color4
  5882. */
  5883. scaleAndAddToRef(scale: number, result: Color4): Color4;
  5884. /**
  5885. * Clamps the rgb values by the min and max values and stores the result into "result"
  5886. * @param min defines minimum clamping value (default is 0)
  5887. * @param max defines maximum clamping value (default is 1)
  5888. * @param result defines color to store the result into.
  5889. * @returns the cuurent Color4
  5890. */
  5891. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  5892. /**
  5893. * Multipy an Color4 value by another and return a new Color4 object
  5894. * @param color defines the Color4 value to multiply by
  5895. * @returns a new Color4 object
  5896. */
  5897. multiply(color: Color4): Color4;
  5898. /**
  5899. * Multipy a Color4 value by another and push the result in a reference value
  5900. * @param color defines the Color4 value to multiply by
  5901. * @param result defines the Color4 to fill the result in
  5902. * @returns the result Color4
  5903. */
  5904. multiplyToRef(color: Color4, result: Color4): Color4;
  5905. /**
  5906. * Creates a string with the Color4 current values
  5907. * @returns the string representation of the Color4 object
  5908. */
  5909. toString(): string;
  5910. /**
  5911. * Returns the string "Color4"
  5912. * @returns "Color4"
  5913. */
  5914. getClassName(): string;
  5915. /**
  5916. * Compute the Color4 hash code
  5917. * @returns an unique number that can be used to hash Color4 objects
  5918. */
  5919. getHashCode(): number;
  5920. /**
  5921. * Creates a new Color4 copied from the current one
  5922. * @returns a new Color4 object
  5923. */
  5924. clone(): Color4;
  5925. /**
  5926. * Copies the given Color4 values into the current one
  5927. * @param source defines the source Color4 object
  5928. * @returns the current updated Color4 object
  5929. */
  5930. copyFrom(source: Color4): Color4;
  5931. /**
  5932. * Copies the given float values into the current one
  5933. * @param r defines the red component to read from
  5934. * @param g defines the green component to read from
  5935. * @param b defines the blue component to read from
  5936. * @param a defines the alpha component to read from
  5937. * @returns the current updated Color4 object
  5938. */
  5939. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  5940. /**
  5941. * Copies the given float values into the current one
  5942. * @param r defines the red component to read from
  5943. * @param g defines the green component to read from
  5944. * @param b defines the blue component to read from
  5945. * @param a defines the alpha component to read from
  5946. * @returns the current updated Color4 object
  5947. */
  5948. set(r: number, g: number, b: number, a: number): Color4;
  5949. /**
  5950. * Compute the Color4 hexadecimal code as a string
  5951. * @param returnAsColor3 defines if the string should only contains RGB values (off by default)
  5952. * @returns a string containing the hexadecimal representation of the Color4 object
  5953. */
  5954. toHexString(returnAsColor3?: boolean): string;
  5955. /**
  5956. * Computes a new Color4 converted from the current one to linear space
  5957. * @returns a new Color4 object
  5958. */
  5959. toLinearSpace(): Color4;
  5960. /**
  5961. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  5962. * @param convertedColor defines the Color4 object where to store the linear space version
  5963. * @returns the unmodified Color4
  5964. */
  5965. toLinearSpaceToRef(convertedColor: Color4): Color4;
  5966. /**
  5967. * Computes a new Color4 converted from the current one to gamma space
  5968. * @returns a new Color4 object
  5969. */
  5970. toGammaSpace(): Color4;
  5971. /**
  5972. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  5973. * @param convertedColor defines the Color4 object where to store the gamma space version
  5974. * @returns the unmodified Color4
  5975. */
  5976. toGammaSpaceToRef(convertedColor: Color4): Color4;
  5977. /**
  5978. * Creates a new Color4 from the string containing valid hexadecimal values
  5979. * @param hex defines a string containing valid hexadecimal values
  5980. * @returns a new Color4 object
  5981. */
  5982. static FromHexString(hex: string): Color4;
  5983. /**
  5984. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5985. * @param left defines the start value
  5986. * @param right defines the end value
  5987. * @param amount defines the gradient factor
  5988. * @returns a new Color4 object
  5989. */
  5990. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  5991. /**
  5992. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5993. * @param left defines the start value
  5994. * @param right defines the end value
  5995. * @param amount defines the gradient factor
  5996. * @param result defines the Color4 object where to store data
  5997. */
  5998. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  5999. /**
  6000. * Creates a new Color4 from a Color3 and an alpha value
  6001. * @param color3 defines the source Color3 to read from
  6002. * @param alpha defines the alpha component (1.0 by default)
  6003. * @returns a new Color4 object
  6004. */
  6005. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  6006. /**
  6007. * Creates a new Color4 from the starting index element of the given array
  6008. * @param array defines the source array to read from
  6009. * @param offset defines the offset in the source array
  6010. * @returns a new Color4 object
  6011. */
  6012. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  6013. /**
  6014. * Creates a new Color3 from integer values (< 256)
  6015. * @param r defines the red component to read from (value between 0 and 255)
  6016. * @param g defines the green component to read from (value between 0 and 255)
  6017. * @param b defines the blue component to read from (value between 0 and 255)
  6018. * @param a defines the alpha component to read from (value between 0 and 255)
  6019. * @returns a new Color3 object
  6020. */
  6021. static FromInts(r: number, g: number, b: number, a: number): Color4;
  6022. /**
  6023. * Check the content of a given array and convert it to an array containing RGBA data
  6024. * If the original array was already containing count * 4 values then it is returned directly
  6025. * @param colors defines the array to check
  6026. * @param count defines the number of RGBA data to expect
  6027. * @returns an array containing count * 4 values (RGBA)
  6028. */
  6029. static CheckColors4(colors: number[], count: number): number[];
  6030. }
  6031. /**
  6032. * @hidden
  6033. */
  6034. export class TmpColors {
  6035. static Color3: Color3[];
  6036. static Color4: Color4[];
  6037. }
  6038. }
  6039. declare module "babylonjs/Animations/animationKey" {
  6040. /**
  6041. * Defines an interface which represents an animation key frame
  6042. */
  6043. export interface IAnimationKey {
  6044. /**
  6045. * Frame of the key frame
  6046. */
  6047. frame: number;
  6048. /**
  6049. * Value at the specifies key frame
  6050. */
  6051. value: any;
  6052. /**
  6053. * The input tangent for the cubic hermite spline
  6054. */
  6055. inTangent?: any;
  6056. /**
  6057. * The output tangent for the cubic hermite spline
  6058. */
  6059. outTangent?: any;
  6060. /**
  6061. * The animation interpolation type
  6062. */
  6063. interpolation?: AnimationKeyInterpolation;
  6064. }
  6065. /**
  6066. * Enum for the animation key frame interpolation type
  6067. */
  6068. export enum AnimationKeyInterpolation {
  6069. /**
  6070. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6071. */
  6072. STEP = 1
  6073. }
  6074. }
  6075. declare module "babylonjs/Animations/animationRange" {
  6076. /**
  6077. * Represents the range of an animation
  6078. */
  6079. export class AnimationRange {
  6080. /**The name of the animation range**/
  6081. name: string;
  6082. /**The starting frame of the animation */
  6083. from: number;
  6084. /**The ending frame of the animation*/
  6085. to: number;
  6086. /**
  6087. * Initializes the range of an animation
  6088. * @param name The name of the animation range
  6089. * @param from The starting frame of the animation
  6090. * @param to The ending frame of the animation
  6091. */
  6092. constructor(
  6093. /**The name of the animation range**/
  6094. name: string,
  6095. /**The starting frame of the animation */
  6096. from: number,
  6097. /**The ending frame of the animation*/
  6098. to: number);
  6099. /**
  6100. * Makes a copy of the animation range
  6101. * @returns A copy of the animation range
  6102. */
  6103. clone(): AnimationRange;
  6104. }
  6105. }
  6106. declare module "babylonjs/Animations/animationEvent" {
  6107. /**
  6108. * Composed of a frame, and an action function
  6109. */
  6110. export class AnimationEvent {
  6111. /** The frame for which the event is triggered **/
  6112. frame: number;
  6113. /** The event to perform when triggered **/
  6114. action: (currentFrame: number) => void;
  6115. /** Specifies if the event should be triggered only once**/
  6116. onlyOnce?: boolean | undefined;
  6117. /**
  6118. * Specifies if the animation event is done
  6119. */
  6120. isDone: boolean;
  6121. /**
  6122. * Initializes the animation event
  6123. * @param frame The frame for which the event is triggered
  6124. * @param action The event to perform when triggered
  6125. * @param onlyOnce Specifies if the event should be triggered only once
  6126. */
  6127. constructor(
  6128. /** The frame for which the event is triggered **/
  6129. frame: number,
  6130. /** The event to perform when triggered **/
  6131. action: (currentFrame: number) => void,
  6132. /** Specifies if the event should be triggered only once**/
  6133. onlyOnce?: boolean | undefined);
  6134. /** @hidden */
  6135. _clone(): AnimationEvent;
  6136. }
  6137. }
  6138. declare module "babylonjs/Behaviors/behavior" {
  6139. import { Nullable } from "babylonjs/types";
  6140. /**
  6141. * Interface used to define a behavior
  6142. */
  6143. export interface Behavior<T> {
  6144. /** gets or sets behavior's name */
  6145. name: string;
  6146. /**
  6147. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6148. */
  6149. init(): void;
  6150. /**
  6151. * Called when the behavior is attached to a target
  6152. * @param target defines the target where the behavior is attached to
  6153. */
  6154. attach(target: T): void;
  6155. /**
  6156. * Called when the behavior is detached from its target
  6157. */
  6158. detach(): void;
  6159. }
  6160. /**
  6161. * Interface implemented by classes supporting behaviors
  6162. */
  6163. export interface IBehaviorAware<T> {
  6164. /**
  6165. * Attach a behavior
  6166. * @param behavior defines the behavior to attach
  6167. * @returns the current host
  6168. */
  6169. addBehavior(behavior: Behavior<T>): T;
  6170. /**
  6171. * Remove a behavior from the current object
  6172. * @param behavior defines the behavior to detach
  6173. * @returns the current host
  6174. */
  6175. removeBehavior(behavior: Behavior<T>): T;
  6176. /**
  6177. * Gets a behavior using its name to search
  6178. * @param name defines the name to search
  6179. * @returns the behavior or null if not found
  6180. */
  6181. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6182. }
  6183. }
  6184. declare module "babylonjs/Misc/smartArray" {
  6185. /**
  6186. * Defines an array and its length.
  6187. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  6188. */
  6189. export interface ISmartArrayLike<T> {
  6190. /**
  6191. * The data of the array.
  6192. */
  6193. data: Array<T>;
  6194. /**
  6195. * The active length of the array.
  6196. */
  6197. length: number;
  6198. }
  6199. /**
  6200. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6201. */
  6202. export class SmartArray<T> implements ISmartArrayLike<T> {
  6203. /**
  6204. * The full set of data from the array.
  6205. */
  6206. data: Array<T>;
  6207. /**
  6208. * The active length of the array.
  6209. */
  6210. length: number;
  6211. protected _id: number;
  6212. /**
  6213. * Instantiates a Smart Array.
  6214. * @param capacity defines the default capacity of the array.
  6215. */
  6216. constructor(capacity: number);
  6217. /**
  6218. * Pushes a value at the end of the active data.
  6219. * @param value defines the object to push in the array.
  6220. */
  6221. push(value: T): void;
  6222. /**
  6223. * Iterates over the active data and apply the lambda to them.
  6224. * @param func defines the action to apply on each value.
  6225. */
  6226. forEach(func: (content: T) => void): void;
  6227. /**
  6228. * Sorts the full sets of data.
  6229. * @param compareFn defines the comparison function to apply.
  6230. */
  6231. sort(compareFn: (a: T, b: T) => number): void;
  6232. /**
  6233. * Resets the active data to an empty array.
  6234. */
  6235. reset(): void;
  6236. /**
  6237. * Releases all the data from the array as well as the array.
  6238. */
  6239. dispose(): void;
  6240. /**
  6241. * Concats the active data with a given array.
  6242. * @param array defines the data to concatenate with.
  6243. */
  6244. concat(array: any): void;
  6245. /**
  6246. * Returns the position of a value in the active data.
  6247. * @param value defines the value to find the index for
  6248. * @returns the index if found in the active data otherwise -1
  6249. */
  6250. indexOf(value: T): number;
  6251. /**
  6252. * Returns whether an element is part of the active data.
  6253. * @param value defines the value to look for
  6254. * @returns true if found in the active data otherwise false
  6255. */
  6256. contains(value: T): boolean;
  6257. private static _GlobalId;
  6258. }
  6259. /**
  6260. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6261. * The data in this array can only be present once
  6262. */
  6263. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  6264. private _duplicateId;
  6265. /**
  6266. * Pushes a value at the end of the active data.
  6267. * THIS DOES NOT PREVENT DUPPLICATE DATA
  6268. * @param value defines the object to push in the array.
  6269. */
  6270. push(value: T): void;
  6271. /**
  6272. * Pushes a value at the end of the active data.
  6273. * If the data is already present, it won t be added again
  6274. * @param value defines the object to push in the array.
  6275. * @returns true if added false if it was already present
  6276. */
  6277. pushNoDuplicate(value: T): boolean;
  6278. /**
  6279. * Resets the active data to an empty array.
  6280. */
  6281. reset(): void;
  6282. /**
  6283. * Concats the active data with a given array.
  6284. * This ensures no dupplicate will be present in the result.
  6285. * @param array defines the data to concatenate with.
  6286. */
  6287. concatWithNoDuplicate(array: any): void;
  6288. }
  6289. }
  6290. declare module "babylonjs/Cameras/cameraInputsManager" {
  6291. import { Nullable } from "babylonjs/types";
  6292. import { Camera } from "babylonjs/Cameras/camera";
  6293. /**
  6294. * @ignore
  6295. * This is a list of all the different input types that are available in the application.
  6296. * Fo instance: ArcRotateCameraGamepadInput...
  6297. */
  6298. export var CameraInputTypes: {};
  6299. /**
  6300. * This is the contract to implement in order to create a new input class.
  6301. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  6302. */
  6303. export interface ICameraInput<TCamera extends Camera> {
  6304. /**
  6305. * Defines the camera the input is attached to.
  6306. */
  6307. camera: Nullable<TCamera>;
  6308. /**
  6309. * Gets the class name of the current intput.
  6310. * @returns the class name
  6311. */
  6312. getClassName(): string;
  6313. /**
  6314. * Get the friendly name associated with the input class.
  6315. * @returns the input friendly name
  6316. */
  6317. getSimpleName(): string;
  6318. /**
  6319. * Attach the input controls to a specific dom element to get the input from.
  6320. * @param element Defines the element the controls should be listened from
  6321. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6322. */
  6323. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6324. /**
  6325. * Detach the current controls from the specified dom element.
  6326. * @param element Defines the element to stop listening the inputs from
  6327. */
  6328. detachControl(element: Nullable<HTMLElement>): void;
  6329. /**
  6330. * Update the current camera state depending on the inputs that have been used this frame.
  6331. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6332. */
  6333. checkInputs?: () => void;
  6334. }
  6335. /**
  6336. * Represents a map of input types to input instance or input index to input instance.
  6337. */
  6338. export interface CameraInputsMap<TCamera extends Camera> {
  6339. /**
  6340. * Accessor to the input by input type.
  6341. */
  6342. [name: string]: ICameraInput<TCamera>;
  6343. /**
  6344. * Accessor to the input by input index.
  6345. */
  6346. [idx: number]: ICameraInput<TCamera>;
  6347. }
  6348. /**
  6349. * This represents the input manager used within a camera.
  6350. * It helps dealing with all the different kind of input attached to a camera.
  6351. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6352. */
  6353. export class CameraInputsManager<TCamera extends Camera> {
  6354. /**
  6355. * Defines the list of inputs attahed to the camera.
  6356. */
  6357. attached: CameraInputsMap<TCamera>;
  6358. /**
  6359. * Defines the dom element the camera is collecting inputs from.
  6360. * This is null if the controls have not been attached.
  6361. */
  6362. attachedElement: Nullable<HTMLElement>;
  6363. /**
  6364. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6365. */
  6366. noPreventDefault: boolean;
  6367. /**
  6368. * Defined the camera the input manager belongs to.
  6369. */
  6370. camera: TCamera;
  6371. /**
  6372. * Update the current camera state depending on the inputs that have been used this frame.
  6373. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6374. */
  6375. checkInputs: () => void;
  6376. /**
  6377. * Instantiate a new Camera Input Manager.
  6378. * @param camera Defines the camera the input manager blongs to
  6379. */
  6380. constructor(camera: TCamera);
  6381. /**
  6382. * Add an input method to a camera
  6383. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6384. * @param input camera input method
  6385. */
  6386. add(input: ICameraInput<TCamera>): void;
  6387. /**
  6388. * Remove a specific input method from a camera
  6389. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6390. * @param inputToRemove camera input method
  6391. */
  6392. remove(inputToRemove: ICameraInput<TCamera>): void;
  6393. /**
  6394. * Remove a specific input type from a camera
  6395. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6396. * @param inputType the type of the input to remove
  6397. */
  6398. removeByType(inputType: string): void;
  6399. private _addCheckInputs;
  6400. /**
  6401. * Attach the input controls to the currently attached dom element to listen the events from.
  6402. * @param input Defines the input to attach
  6403. */
  6404. attachInput(input: ICameraInput<TCamera>): void;
  6405. /**
  6406. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6407. * @param element Defines the dom element to collect the events from
  6408. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6409. */
  6410. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6411. /**
  6412. * Detach the current manager inputs controls from a specific dom element.
  6413. * @param element Defines the dom element to collect the events from
  6414. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6415. */
  6416. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6417. /**
  6418. * Rebuild the dynamic inputCheck function from the current list of
  6419. * defined inputs in the manager.
  6420. */
  6421. rebuildInputCheck(): void;
  6422. /**
  6423. * Remove all attached input methods from a camera
  6424. */
  6425. clear(): void;
  6426. /**
  6427. * Serialize the current input manager attached to a camera.
  6428. * This ensures than once parsed,
  6429. * the input associated to the camera will be identical to the current ones
  6430. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6431. */
  6432. serialize(serializedCamera: any): void;
  6433. /**
  6434. * Parses an input manager serialized JSON to restore the previous list of inputs
  6435. * and states associated to a camera.
  6436. * @param parsedCamera Defines the JSON to parse
  6437. */
  6438. parse(parsedCamera: any): void;
  6439. }
  6440. }
  6441. declare module "babylonjs/Meshes/buffer" {
  6442. import { Nullable, DataArray } from "babylonjs/types";
  6443. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  6444. /**
  6445. * Class used to store data that will be store in GPU memory
  6446. */
  6447. export class Buffer {
  6448. private _engine;
  6449. private _buffer;
  6450. /** @hidden */
  6451. _data: Nullable<DataArray>;
  6452. private _updatable;
  6453. private _instanced;
  6454. private _divisor;
  6455. /**
  6456. * Gets the byte stride.
  6457. */
  6458. readonly byteStride: number;
  6459. /**
  6460. * Constructor
  6461. * @param engine the engine
  6462. * @param data the data to use for this buffer
  6463. * @param updatable whether the data is updatable
  6464. * @param stride the stride (optional)
  6465. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6466. * @param instanced whether the buffer is instanced (optional)
  6467. * @param useBytes set to true if the stride in in bytes (optional)
  6468. * @param divisor sets an optional divisor for instances (1 by default)
  6469. */
  6470. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  6471. /**
  6472. * Create a new VertexBuffer based on the current buffer
  6473. * @param kind defines the vertex buffer kind (position, normal, etc.)
  6474. * @param offset defines offset in the buffer (0 by default)
  6475. * @param size defines the size in floats of attributes (position is 3 for instance)
  6476. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  6477. * @param instanced defines if the vertex buffer contains indexed data
  6478. * @param useBytes defines if the offset and stride are in bytes *
  6479. * @param divisor sets an optional divisor for instances (1 by default)
  6480. * @returns the new vertex buffer
  6481. */
  6482. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  6483. /**
  6484. * Gets a boolean indicating if the Buffer is updatable?
  6485. * @returns true if the buffer is updatable
  6486. */
  6487. isUpdatable(): boolean;
  6488. /**
  6489. * Gets current buffer's data
  6490. * @returns a DataArray or null
  6491. */
  6492. getData(): Nullable<DataArray>;
  6493. /**
  6494. * Gets underlying native buffer
  6495. * @returns underlying native buffer
  6496. */
  6497. getBuffer(): Nullable<DataBuffer>;
  6498. /**
  6499. * Gets the stride in float32 units (i.e. byte stride / 4).
  6500. * May not be an integer if the byte stride is not divisible by 4.
  6501. * @returns the stride in float32 units
  6502. * @deprecated Please use byteStride instead.
  6503. */
  6504. getStrideSize(): number;
  6505. /**
  6506. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6507. * @param data defines the data to store
  6508. */
  6509. create(data?: Nullable<DataArray>): void;
  6510. /** @hidden */
  6511. _rebuild(): void;
  6512. /**
  6513. * Update current buffer data
  6514. * @param data defines the data to store
  6515. */
  6516. update(data: DataArray): void;
  6517. /**
  6518. * Updates the data directly.
  6519. * @param data the new data
  6520. * @param offset the new offset
  6521. * @param vertexCount the vertex count (optional)
  6522. * @param useBytes set to true if the offset is in bytes
  6523. */
  6524. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  6525. /**
  6526. * Release all resources
  6527. */
  6528. dispose(): void;
  6529. }
  6530. /**
  6531. * Specialized buffer used to store vertex data
  6532. */
  6533. export class VertexBuffer {
  6534. /** @hidden */
  6535. _buffer: Buffer;
  6536. private _kind;
  6537. private _size;
  6538. private _ownsBuffer;
  6539. private _instanced;
  6540. private _instanceDivisor;
  6541. /**
  6542. * The byte type.
  6543. */
  6544. static readonly BYTE: number;
  6545. /**
  6546. * The unsigned byte type.
  6547. */
  6548. static readonly UNSIGNED_BYTE: number;
  6549. /**
  6550. * The short type.
  6551. */
  6552. static readonly SHORT: number;
  6553. /**
  6554. * The unsigned short type.
  6555. */
  6556. static readonly UNSIGNED_SHORT: number;
  6557. /**
  6558. * The integer type.
  6559. */
  6560. static readonly INT: number;
  6561. /**
  6562. * The unsigned integer type.
  6563. */
  6564. static readonly UNSIGNED_INT: number;
  6565. /**
  6566. * The float type.
  6567. */
  6568. static readonly FLOAT: number;
  6569. /**
  6570. * Gets or sets the instance divisor when in instanced mode
  6571. */
  6572. get instanceDivisor(): number;
  6573. set instanceDivisor(value: number);
  6574. /**
  6575. * Gets the byte stride.
  6576. */
  6577. readonly byteStride: number;
  6578. /**
  6579. * Gets the byte offset.
  6580. */
  6581. readonly byteOffset: number;
  6582. /**
  6583. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  6584. */
  6585. readonly normalized: boolean;
  6586. /**
  6587. * Gets the data type of each component in the array.
  6588. */
  6589. readonly type: number;
  6590. /**
  6591. * Constructor
  6592. * @param engine the engine
  6593. * @param data the data to use for this vertex buffer
  6594. * @param kind the vertex buffer kind
  6595. * @param updatable whether the data is updatable
  6596. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6597. * @param stride the stride (optional)
  6598. * @param instanced whether the buffer is instanced (optional)
  6599. * @param offset the offset of the data (optional)
  6600. * @param size the number of components (optional)
  6601. * @param type the type of the component (optional)
  6602. * @param normalized whether the data contains normalized data (optional)
  6603. * @param useBytes set to true if stride and offset are in bytes (optional)
  6604. * @param divisor defines the instance divisor to use (1 by default)
  6605. */
  6606. constructor(engine: any, data: DataArray | Buffer, kind: string, updatable: boolean, postponeInternalCreation?: boolean, stride?: number, instanced?: boolean, offset?: number, size?: number, type?: number, normalized?: boolean, useBytes?: boolean, divisor?: number);
  6607. /** @hidden */
  6608. _rebuild(): void;
  6609. /**
  6610. * Returns the kind of the VertexBuffer (string)
  6611. * @returns a string
  6612. */
  6613. getKind(): string;
  6614. /**
  6615. * Gets a boolean indicating if the VertexBuffer is updatable?
  6616. * @returns true if the buffer is updatable
  6617. */
  6618. isUpdatable(): boolean;
  6619. /**
  6620. * Gets current buffer's data
  6621. * @returns a DataArray or null
  6622. */
  6623. getData(): Nullable<DataArray>;
  6624. /**
  6625. * Gets underlying native buffer
  6626. * @returns underlying native buffer
  6627. */
  6628. getBuffer(): Nullable<DataBuffer>;
  6629. /**
  6630. * Gets the stride in float32 units (i.e. byte stride / 4).
  6631. * May not be an integer if the byte stride is not divisible by 4.
  6632. * @returns the stride in float32 units
  6633. * @deprecated Please use byteStride instead.
  6634. */
  6635. getStrideSize(): number;
  6636. /**
  6637. * Returns the offset as a multiple of the type byte length.
  6638. * @returns the offset in bytes
  6639. * @deprecated Please use byteOffset instead.
  6640. */
  6641. getOffset(): number;
  6642. /**
  6643. * Returns the number of components per vertex attribute (integer)
  6644. * @returns the size in float
  6645. */
  6646. getSize(): number;
  6647. /**
  6648. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  6649. * @returns true if this buffer is instanced
  6650. */
  6651. getIsInstanced(): boolean;
  6652. /**
  6653. * Returns the instancing divisor, zero for non-instanced (integer).
  6654. * @returns a number
  6655. */
  6656. getInstanceDivisor(): number;
  6657. /**
  6658. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6659. * @param data defines the data to store
  6660. */
  6661. create(data?: DataArray): void;
  6662. /**
  6663. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  6664. * This function will create a new buffer if the current one is not updatable
  6665. * @param data defines the data to store
  6666. */
  6667. update(data: DataArray): void;
  6668. /**
  6669. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  6670. * Returns the directly updated WebGLBuffer.
  6671. * @param data the new data
  6672. * @param offset the new offset
  6673. * @param useBytes set to true if the offset is in bytes
  6674. */
  6675. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  6676. /**
  6677. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  6678. */
  6679. dispose(): void;
  6680. /**
  6681. * Enumerates each value of this vertex buffer as numbers.
  6682. * @param count the number of values to enumerate
  6683. * @param callback the callback function called for each value
  6684. */
  6685. forEach(count: number, callback: (value: number, index: number) => void): void;
  6686. /**
  6687. * Positions
  6688. */
  6689. static readonly PositionKind: string;
  6690. /**
  6691. * Normals
  6692. */
  6693. static readonly NormalKind: string;
  6694. /**
  6695. * Tangents
  6696. */
  6697. static readonly TangentKind: string;
  6698. /**
  6699. * Texture coordinates
  6700. */
  6701. static readonly UVKind: string;
  6702. /**
  6703. * Texture coordinates 2
  6704. */
  6705. static readonly UV2Kind: string;
  6706. /**
  6707. * Texture coordinates 3
  6708. */
  6709. static readonly UV3Kind: string;
  6710. /**
  6711. * Texture coordinates 4
  6712. */
  6713. static readonly UV4Kind: string;
  6714. /**
  6715. * Texture coordinates 5
  6716. */
  6717. static readonly UV5Kind: string;
  6718. /**
  6719. * Texture coordinates 6
  6720. */
  6721. static readonly UV6Kind: string;
  6722. /**
  6723. * Colors
  6724. */
  6725. static readonly ColorKind: string;
  6726. /**
  6727. * Matrix indices (for bones)
  6728. */
  6729. static readonly MatricesIndicesKind: string;
  6730. /**
  6731. * Matrix weights (for bones)
  6732. */
  6733. static readonly MatricesWeightsKind: string;
  6734. /**
  6735. * Additional matrix indices (for bones)
  6736. */
  6737. static readonly MatricesIndicesExtraKind: string;
  6738. /**
  6739. * Additional matrix weights (for bones)
  6740. */
  6741. static readonly MatricesWeightsExtraKind: string;
  6742. /**
  6743. * Deduces the stride given a kind.
  6744. * @param kind The kind string to deduce
  6745. * @returns The deduced stride
  6746. */
  6747. static DeduceStride(kind: string): number;
  6748. /**
  6749. * Gets the byte length of the given type.
  6750. * @param type the type
  6751. * @returns the number of bytes
  6752. */
  6753. static GetTypeByteLength(type: number): number;
  6754. /**
  6755. * Enumerates each value of the given parameters as numbers.
  6756. * @param data the data to enumerate
  6757. * @param byteOffset the byte offset of the data
  6758. * @param byteStride the byte stride of the data
  6759. * @param componentCount the number of components per element
  6760. * @param componentType the type of the component
  6761. * @param count the number of values to enumerate
  6762. * @param normalized whether the data is normalized
  6763. * @param callback the callback function called for each value
  6764. */
  6765. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  6766. private static _GetFloatValue;
  6767. }
  6768. }
  6769. declare module "babylonjs/Collisions/intersectionInfo" {
  6770. import { Nullable } from "babylonjs/types";
  6771. /**
  6772. * @hidden
  6773. */
  6774. export class IntersectionInfo {
  6775. bu: Nullable<number>;
  6776. bv: Nullable<number>;
  6777. distance: number;
  6778. faceId: number;
  6779. subMeshId: number;
  6780. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6781. }
  6782. }
  6783. declare module "babylonjs/Culling/boundingSphere" {
  6784. import { DeepImmutable } from "babylonjs/types";
  6785. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6786. import { Plane } from "babylonjs/Maths/math.plane";
  6787. /**
  6788. * Class used to store bounding sphere information
  6789. */
  6790. export class BoundingSphere {
  6791. /**
  6792. * Gets the center of the bounding sphere in local space
  6793. */
  6794. readonly center: Vector3;
  6795. /**
  6796. * Radius of the bounding sphere in local space
  6797. */
  6798. radius: number;
  6799. /**
  6800. * Gets the center of the bounding sphere in world space
  6801. */
  6802. readonly centerWorld: Vector3;
  6803. /**
  6804. * Radius of the bounding sphere in world space
  6805. */
  6806. radiusWorld: number;
  6807. /**
  6808. * Gets the minimum vector in local space
  6809. */
  6810. readonly minimum: Vector3;
  6811. /**
  6812. * Gets the maximum vector in local space
  6813. */
  6814. readonly maximum: Vector3;
  6815. private _worldMatrix;
  6816. private static readonly TmpVector3;
  6817. /**
  6818. * Creates a new bounding sphere
  6819. * @param min defines the minimum vector (in local space)
  6820. * @param max defines the maximum vector (in local space)
  6821. * @param worldMatrix defines the new world matrix
  6822. */
  6823. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6824. /**
  6825. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6826. * @param min defines the new minimum vector (in local space)
  6827. * @param max defines the new maximum vector (in local space)
  6828. * @param worldMatrix defines the new world matrix
  6829. */
  6830. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6831. /**
  6832. * Scale the current bounding sphere by applying a scale factor
  6833. * @param factor defines the scale factor to apply
  6834. * @returns the current bounding box
  6835. */
  6836. scale(factor: number): BoundingSphere;
  6837. /**
  6838. * Gets the world matrix of the bounding box
  6839. * @returns a matrix
  6840. */
  6841. getWorldMatrix(): DeepImmutable<Matrix>;
  6842. /** @hidden */
  6843. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6844. /**
  6845. * Tests if the bounding sphere is intersecting the frustum planes
  6846. * @param frustumPlanes defines the frustum planes to test
  6847. * @returns true if there is an intersection
  6848. */
  6849. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6850. /**
  6851. * Tests if the bounding sphere center is in between the frustum planes.
  6852. * Used for optimistic fast inclusion.
  6853. * @param frustumPlanes defines the frustum planes to test
  6854. * @returns true if the sphere center is in between the frustum planes
  6855. */
  6856. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6857. /**
  6858. * Tests if a point is inside the bounding sphere
  6859. * @param point defines the point to test
  6860. * @returns true if the point is inside the bounding sphere
  6861. */
  6862. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6863. /**
  6864. * Checks if two sphere intersct
  6865. * @param sphere0 sphere 0
  6866. * @param sphere1 sphere 1
  6867. * @returns true if the speres intersect
  6868. */
  6869. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6870. }
  6871. }
  6872. declare module "babylonjs/Culling/boundingBox" {
  6873. import { DeepImmutable } from "babylonjs/types";
  6874. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6875. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  6876. import { ICullable } from "babylonjs/Culling/boundingInfo";
  6877. import { Plane } from "babylonjs/Maths/math.plane";
  6878. /**
  6879. * Class used to store bounding box information
  6880. */
  6881. export class BoundingBox implements ICullable {
  6882. /**
  6883. * Gets the 8 vectors representing the bounding box in local space
  6884. */
  6885. readonly vectors: Vector3[];
  6886. /**
  6887. * Gets the center of the bounding box in local space
  6888. */
  6889. readonly center: Vector3;
  6890. /**
  6891. * Gets the center of the bounding box in world space
  6892. */
  6893. readonly centerWorld: Vector3;
  6894. /**
  6895. * Gets the extend size in local space
  6896. */
  6897. readonly extendSize: Vector3;
  6898. /**
  6899. * Gets the extend size in world space
  6900. */
  6901. readonly extendSizeWorld: Vector3;
  6902. /**
  6903. * Gets the OBB (object bounding box) directions
  6904. */
  6905. readonly directions: Vector3[];
  6906. /**
  6907. * Gets the 8 vectors representing the bounding box in world space
  6908. */
  6909. readonly vectorsWorld: Vector3[];
  6910. /**
  6911. * Gets the minimum vector in world space
  6912. */
  6913. readonly minimumWorld: Vector3;
  6914. /**
  6915. * Gets the maximum vector in world space
  6916. */
  6917. readonly maximumWorld: Vector3;
  6918. /**
  6919. * Gets the minimum vector in local space
  6920. */
  6921. readonly minimum: Vector3;
  6922. /**
  6923. * Gets the maximum vector in local space
  6924. */
  6925. readonly maximum: Vector3;
  6926. private _worldMatrix;
  6927. private static readonly TmpVector3;
  6928. /**
  6929. * @hidden
  6930. */
  6931. _tag: number;
  6932. /**
  6933. * Creates a new bounding box
  6934. * @param min defines the minimum vector (in local space)
  6935. * @param max defines the maximum vector (in local space)
  6936. * @param worldMatrix defines the new world matrix
  6937. */
  6938. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6939. /**
  6940. * Recreates the entire bounding box from scratch as if we call the constructor in place
  6941. * @param min defines the new minimum vector (in local space)
  6942. * @param max defines the new maximum vector (in local space)
  6943. * @param worldMatrix defines the new world matrix
  6944. */
  6945. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6946. /**
  6947. * Scale the current bounding box by applying a scale factor
  6948. * @param factor defines the scale factor to apply
  6949. * @returns the current bounding box
  6950. */
  6951. scale(factor: number): BoundingBox;
  6952. /**
  6953. * Gets the world matrix of the bounding box
  6954. * @returns a matrix
  6955. */
  6956. getWorldMatrix(): DeepImmutable<Matrix>;
  6957. /** @hidden */
  6958. _update(world: DeepImmutable<Matrix>): void;
  6959. /**
  6960. * Tests if the bounding box is intersecting the frustum planes
  6961. * @param frustumPlanes defines the frustum planes to test
  6962. * @returns true if there is an intersection
  6963. */
  6964. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6965. /**
  6966. * Tests if the bounding box is entirely inside the frustum planes
  6967. * @param frustumPlanes defines the frustum planes to test
  6968. * @returns true if there is an inclusion
  6969. */
  6970. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6971. /**
  6972. * Tests if a point is inside the bounding box
  6973. * @param point defines the point to test
  6974. * @returns true if the point is inside the bounding box
  6975. */
  6976. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6977. /**
  6978. * Tests if the bounding box intersects with a bounding sphere
  6979. * @param sphere defines the sphere to test
  6980. * @returns true if there is an intersection
  6981. */
  6982. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  6983. /**
  6984. * Tests if the bounding box intersects with a box defined by a min and max vectors
  6985. * @param min defines the min vector to use
  6986. * @param max defines the max vector to use
  6987. * @returns true if there is an intersection
  6988. */
  6989. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  6990. /**
  6991. * Tests if two bounding boxes are intersections
  6992. * @param box0 defines the first box to test
  6993. * @param box1 defines the second box to test
  6994. * @returns true if there is an intersection
  6995. */
  6996. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  6997. /**
  6998. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  6999. * @param minPoint defines the minimum vector of the bounding box
  7000. * @param maxPoint defines the maximum vector of the bounding box
  7001. * @param sphereCenter defines the sphere center
  7002. * @param sphereRadius defines the sphere radius
  7003. * @returns true if there is an intersection
  7004. */
  7005. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7006. /**
  7007. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7008. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7009. * @param frustumPlanes defines the frustum planes to test
  7010. * @return true if there is an inclusion
  7011. */
  7012. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7013. /**
  7014. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7015. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7016. * @param frustumPlanes defines the frustum planes to test
  7017. * @return true if there is an intersection
  7018. */
  7019. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7020. }
  7021. }
  7022. declare module "babylonjs/Collisions/collider" {
  7023. import { Nullable, IndicesArray } from "babylonjs/types";
  7024. import { Vector3 } from "babylonjs/Maths/math.vector";
  7025. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  7026. import { Plane } from "babylonjs/Maths/math.plane";
  7027. /** @hidden */
  7028. export class Collider {
  7029. /** Define if a collision was found */
  7030. collisionFound: boolean;
  7031. /**
  7032. * Define last intersection point in local space
  7033. */
  7034. intersectionPoint: Vector3;
  7035. /**
  7036. * Define last collided mesh
  7037. */
  7038. collidedMesh: Nullable<AbstractMesh>;
  7039. private _collisionPoint;
  7040. private _planeIntersectionPoint;
  7041. private _tempVector;
  7042. private _tempVector2;
  7043. private _tempVector3;
  7044. private _tempVector4;
  7045. private _edge;
  7046. private _baseToVertex;
  7047. private _destinationPoint;
  7048. private _slidePlaneNormal;
  7049. private _displacementVector;
  7050. /** @hidden */
  7051. _radius: Vector3;
  7052. /** @hidden */
  7053. _retry: number;
  7054. private _velocity;
  7055. private _basePoint;
  7056. private _epsilon;
  7057. /** @hidden */
  7058. _velocityWorldLength: number;
  7059. /** @hidden */
  7060. _basePointWorld: Vector3;
  7061. private _velocityWorld;
  7062. private _normalizedVelocity;
  7063. /** @hidden */
  7064. _initialVelocity: Vector3;
  7065. /** @hidden */
  7066. _initialPosition: Vector3;
  7067. private _nearestDistance;
  7068. private _collisionMask;
  7069. get collisionMask(): number;
  7070. set collisionMask(mask: number);
  7071. /**
  7072. * Gets the plane normal used to compute the sliding response (in local space)
  7073. */
  7074. get slidePlaneNormal(): Vector3;
  7075. /** @hidden */
  7076. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7077. /** @hidden */
  7078. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7079. /** @hidden */
  7080. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7081. /** @hidden */
  7082. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7083. /** @hidden */
  7084. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7085. /** @hidden */
  7086. _getResponse(pos: Vector3, vel: Vector3): void;
  7087. }
  7088. }
  7089. declare module "babylonjs/Culling/boundingInfo" {
  7090. import { DeepImmutable } from "babylonjs/types";
  7091. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7092. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  7093. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7094. import { Plane } from "babylonjs/Maths/math.plane";
  7095. import { Collider } from "babylonjs/Collisions/collider";
  7096. /**
  7097. * Interface for cullable objects
  7098. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7099. */
  7100. export interface ICullable {
  7101. /**
  7102. * Checks if the object or part of the object is in the frustum
  7103. * @param frustumPlanes Camera near/planes
  7104. * @returns true if the object is in frustum otherwise false
  7105. */
  7106. isInFrustum(frustumPlanes: Plane[]): boolean;
  7107. /**
  7108. * Checks if a cullable object (mesh...) is in the camera frustum
  7109. * Unlike isInFrustum this cheks the full bounding box
  7110. * @param frustumPlanes Camera near/planes
  7111. * @returns true if the object is in frustum otherwise false
  7112. */
  7113. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7114. }
  7115. /**
  7116. * Info for a bounding data of a mesh
  7117. */
  7118. export class BoundingInfo implements ICullable {
  7119. /**
  7120. * Bounding box for the mesh
  7121. */
  7122. readonly boundingBox: BoundingBox;
  7123. /**
  7124. * Bounding sphere for the mesh
  7125. */
  7126. readonly boundingSphere: BoundingSphere;
  7127. private _isLocked;
  7128. private static readonly TmpVector3;
  7129. /**
  7130. * Constructs bounding info
  7131. * @param minimum min vector of the bounding box/sphere
  7132. * @param maximum max vector of the bounding box/sphere
  7133. * @param worldMatrix defines the new world matrix
  7134. */
  7135. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7136. /**
  7137. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7138. * @param min defines the new minimum vector (in local space)
  7139. * @param max defines the new maximum vector (in local space)
  7140. * @param worldMatrix defines the new world matrix
  7141. */
  7142. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7143. /**
  7144. * min vector of the bounding box/sphere
  7145. */
  7146. get minimum(): Vector3;
  7147. /**
  7148. * max vector of the bounding box/sphere
  7149. */
  7150. get maximum(): Vector3;
  7151. /**
  7152. * If the info is locked and won't be updated to avoid perf overhead
  7153. */
  7154. get isLocked(): boolean;
  7155. set isLocked(value: boolean);
  7156. /**
  7157. * Updates the bounding sphere and box
  7158. * @param world world matrix to be used to update
  7159. */
  7160. update(world: DeepImmutable<Matrix>): void;
  7161. /**
  7162. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7163. * @param center New center of the bounding info
  7164. * @param extend New extend of the bounding info
  7165. * @returns the current bounding info
  7166. */
  7167. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7168. /**
  7169. * Scale the current bounding info by applying a scale factor
  7170. * @param factor defines the scale factor to apply
  7171. * @returns the current bounding info
  7172. */
  7173. scale(factor: number): BoundingInfo;
  7174. /**
  7175. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7176. * @param frustumPlanes defines the frustum to test
  7177. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7178. * @returns true if the bounding info is in the frustum planes
  7179. */
  7180. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7181. /**
  7182. * Gets the world distance between the min and max points of the bounding box
  7183. */
  7184. get diagonalLength(): number;
  7185. /**
  7186. * Checks if a cullable object (mesh...) is in the camera frustum
  7187. * Unlike isInFrustum this cheks the full bounding box
  7188. * @param frustumPlanes Camera near/planes
  7189. * @returns true if the object is in frustum otherwise false
  7190. */
  7191. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7192. /** @hidden */
  7193. _checkCollision(collider: Collider): boolean;
  7194. /**
  7195. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7196. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7197. * @param point the point to check intersection with
  7198. * @returns if the point intersects
  7199. */
  7200. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7201. /**
  7202. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7203. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7204. * @param boundingInfo the bounding info to check intersection with
  7205. * @param precise if the intersection should be done using OBB
  7206. * @returns if the bounding info intersects
  7207. */
  7208. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7209. }
  7210. }
  7211. declare module "babylonjs/Maths/math.functions" {
  7212. import { FloatArray, Nullable, IndicesArray } from "babylonjs/types";
  7213. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  7214. /**
  7215. * Extracts minimum and maximum values from a list of indexed positions
  7216. * @param positions defines the positions to use
  7217. * @param indices defines the indices to the positions
  7218. * @param indexStart defines the start index
  7219. * @param indexCount defines the end index
  7220. * @param bias defines bias value to add to the result
  7221. * @return minimum and maximum values
  7222. */
  7223. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7224. minimum: Vector3;
  7225. maximum: Vector3;
  7226. };
  7227. /**
  7228. * Extracts minimum and maximum values from a list of positions
  7229. * @param positions defines the positions to use
  7230. * @param start defines the start index in the positions array
  7231. * @param count defines the number of positions to handle
  7232. * @param bias defines bias value to add to the result
  7233. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7234. * @return minimum and maximum values
  7235. */
  7236. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7237. minimum: Vector3;
  7238. maximum: Vector3;
  7239. };
  7240. }
  7241. declare module "babylonjs/Meshes/WebGL/webGLDataBuffer" {
  7242. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7243. /** @hidden */
  7244. export class WebGLDataBuffer extends DataBuffer {
  7245. private _buffer;
  7246. constructor(resource: WebGLBuffer);
  7247. get underlyingResource(): any;
  7248. }
  7249. }
  7250. declare module "babylonjs/Engines/WebGL/webGLPipelineContext" {
  7251. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  7252. import { Nullable } from "babylonjs/types";
  7253. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  7254. /** @hidden */
  7255. export class WebGLPipelineContext implements IPipelineContext {
  7256. engine: ThinEngine;
  7257. program: Nullable<WebGLProgram>;
  7258. context?: WebGLRenderingContext;
  7259. vertexShader?: WebGLShader;
  7260. fragmentShader?: WebGLShader;
  7261. isParallelCompiled: boolean;
  7262. onCompiled?: () => void;
  7263. transformFeedback?: WebGLTransformFeedback | null;
  7264. vertexCompilationError: Nullable<string>;
  7265. fragmentCompilationError: Nullable<string>;
  7266. programLinkError: Nullable<string>;
  7267. programValidationError: Nullable<string>;
  7268. get isAsync(): boolean;
  7269. get isReady(): boolean;
  7270. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  7271. _getVertexShaderCode(): string | null;
  7272. _getFragmentShaderCode(): string | null;
  7273. }
  7274. }
  7275. declare module "babylonjs/Engines/Extensions/engine.uniformBuffer" {
  7276. import { FloatArray, Nullable } from "babylonjs/types";
  7277. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7278. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  7279. module "babylonjs/Engines/thinEngine" {
  7280. interface ThinEngine {
  7281. /**
  7282. * Create an uniform buffer
  7283. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7284. * @param elements defines the content of the uniform buffer
  7285. * @returns the webGL uniform buffer
  7286. */
  7287. createUniformBuffer(elements: FloatArray): DataBuffer;
  7288. /**
  7289. * Create a dynamic uniform buffer
  7290. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7291. * @param elements defines the content of the uniform buffer
  7292. * @returns the webGL uniform buffer
  7293. */
  7294. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  7295. /**
  7296. * Update an existing uniform buffer
  7297. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7298. * @param uniformBuffer defines the target uniform buffer
  7299. * @param elements defines the content to update
  7300. * @param offset defines the offset in the uniform buffer where update should start
  7301. * @param count defines the size of the data to update
  7302. */
  7303. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  7304. /**
  7305. * Bind an uniform buffer to the current webGL context
  7306. * @param buffer defines the buffer to bind
  7307. */
  7308. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  7309. /**
  7310. * Bind a buffer to the current webGL context at a given location
  7311. * @param buffer defines the buffer to bind
  7312. * @param location defines the index where to bind the buffer
  7313. */
  7314. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  7315. /**
  7316. * Bind a specific block at a given index in a specific shader program
  7317. * @param pipelineContext defines the pipeline context to use
  7318. * @param blockName defines the block name
  7319. * @param index defines the index where to bind the block
  7320. */
  7321. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  7322. }
  7323. }
  7324. }
  7325. declare module "babylonjs/Materials/uniformBuffer" {
  7326. import { Nullable, FloatArray } from "babylonjs/types";
  7327. import { Matrix, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  7328. import { Engine } from "babylonjs/Engines/engine";
  7329. import { Effect } from "babylonjs/Materials/effect";
  7330. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7331. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7332. import { Color3 } from "babylonjs/Maths/math.color";
  7333. import "babylonjs/Engines/Extensions/engine.uniformBuffer";
  7334. /**
  7335. * Uniform buffer objects.
  7336. *
  7337. * Handles blocks of uniform on the GPU.
  7338. *
  7339. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7340. *
  7341. * For more information, please refer to :
  7342. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7343. */
  7344. export class UniformBuffer {
  7345. private _engine;
  7346. private _buffer;
  7347. private _data;
  7348. private _bufferData;
  7349. private _dynamic?;
  7350. private _uniformLocations;
  7351. private _uniformSizes;
  7352. private _uniformLocationPointer;
  7353. private _needSync;
  7354. private _noUBO;
  7355. private _currentEffect;
  7356. /** @hidden */
  7357. _alreadyBound: boolean;
  7358. private static _MAX_UNIFORM_SIZE;
  7359. private static _tempBuffer;
  7360. /**
  7361. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  7362. * This is dynamic to allow compat with webgl 1 and 2.
  7363. * You will need to pass the name of the uniform as well as the value.
  7364. */
  7365. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  7366. /**
  7367. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  7368. * This is dynamic to allow compat with webgl 1 and 2.
  7369. * You will need to pass the name of the uniform as well as the value.
  7370. */
  7371. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  7372. /**
  7373. * Lambda to Update a single float in a uniform buffer.
  7374. * This is dynamic to allow compat with webgl 1 and 2.
  7375. * You will need to pass the name of the uniform as well as the value.
  7376. */
  7377. updateFloat: (name: string, x: number) => void;
  7378. /**
  7379. * Lambda to Update a vec2 of float in a uniform buffer.
  7380. * This is dynamic to allow compat with webgl 1 and 2.
  7381. * You will need to pass the name of the uniform as well as the value.
  7382. */
  7383. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  7384. /**
  7385. * Lambda to Update a vec3 of float in a uniform buffer.
  7386. * This is dynamic to allow compat with webgl 1 and 2.
  7387. * You will need to pass the name of the uniform as well as the value.
  7388. */
  7389. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  7390. /**
  7391. * Lambda to Update a vec4 of float in a uniform buffer.
  7392. * This is dynamic to allow compat with webgl 1 and 2.
  7393. * You will need to pass the name of the uniform as well as the value.
  7394. */
  7395. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  7396. /**
  7397. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  7398. * This is dynamic to allow compat with webgl 1 and 2.
  7399. * You will need to pass the name of the uniform as well as the value.
  7400. */
  7401. updateMatrix: (name: string, mat: Matrix) => void;
  7402. /**
  7403. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  7404. * This is dynamic to allow compat with webgl 1 and 2.
  7405. * You will need to pass the name of the uniform as well as the value.
  7406. */
  7407. updateVector3: (name: string, vector: Vector3) => void;
  7408. /**
  7409. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  7410. * This is dynamic to allow compat with webgl 1 and 2.
  7411. * You will need to pass the name of the uniform as well as the value.
  7412. */
  7413. updateVector4: (name: string, vector: Vector4) => void;
  7414. /**
  7415. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  7416. * This is dynamic to allow compat with webgl 1 and 2.
  7417. * You will need to pass the name of the uniform as well as the value.
  7418. */
  7419. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  7420. /**
  7421. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  7422. * This is dynamic to allow compat with webgl 1 and 2.
  7423. * You will need to pass the name of the uniform as well as the value.
  7424. */
  7425. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  7426. /**
  7427. * Instantiates a new Uniform buffer objects.
  7428. *
  7429. * Handles blocks of uniform on the GPU.
  7430. *
  7431. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7432. *
  7433. * For more information, please refer to :
  7434. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7435. * @param engine Define the engine the buffer is associated with
  7436. * @param data Define the data contained in the buffer
  7437. * @param dynamic Define if the buffer is updatable
  7438. */
  7439. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  7440. /**
  7441. * Indicates if the buffer is using the WebGL2 UBO implementation,
  7442. * or just falling back on setUniformXXX calls.
  7443. */
  7444. get useUbo(): boolean;
  7445. /**
  7446. * Indicates if the WebGL underlying uniform buffer is in sync
  7447. * with the javascript cache data.
  7448. */
  7449. get isSync(): boolean;
  7450. /**
  7451. * Indicates if the WebGL underlying uniform buffer is dynamic.
  7452. * Also, a dynamic UniformBuffer will disable cache verification and always
  7453. * update the underlying WebGL uniform buffer to the GPU.
  7454. * @returns if Dynamic, otherwise false
  7455. */
  7456. isDynamic(): boolean;
  7457. /**
  7458. * The data cache on JS side.
  7459. * @returns the underlying data as a float array
  7460. */
  7461. getData(): Float32Array;
  7462. /**
  7463. * The underlying WebGL Uniform buffer.
  7464. * @returns the webgl buffer
  7465. */
  7466. getBuffer(): Nullable<DataBuffer>;
  7467. /**
  7468. * std140 layout specifies how to align data within an UBO structure.
  7469. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  7470. * for specs.
  7471. */
  7472. private _fillAlignment;
  7473. /**
  7474. * Adds an uniform in the buffer.
  7475. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  7476. * for the layout to be correct !
  7477. * @param name Name of the uniform, as used in the uniform block in the shader.
  7478. * @param size Data size, or data directly.
  7479. */
  7480. addUniform(name: string, size: number | number[]): void;
  7481. /**
  7482. * Adds a Matrix 4x4 to the uniform buffer.
  7483. * @param name Name of the uniform, as used in the uniform block in the shader.
  7484. * @param mat A 4x4 matrix.
  7485. */
  7486. addMatrix(name: string, mat: Matrix): void;
  7487. /**
  7488. * Adds a vec2 to the uniform buffer.
  7489. * @param name Name of the uniform, as used in the uniform block in the shader.
  7490. * @param x Define the x component value of the vec2
  7491. * @param y Define the y component value of the vec2
  7492. */
  7493. addFloat2(name: string, x: number, y: number): void;
  7494. /**
  7495. * Adds a vec3 to the uniform buffer.
  7496. * @param name Name of the uniform, as used in the uniform block in the shader.
  7497. * @param x Define the x component value of the vec3
  7498. * @param y Define the y component value of the vec3
  7499. * @param z Define the z component value of the vec3
  7500. */
  7501. addFloat3(name: string, x: number, y: number, z: number): void;
  7502. /**
  7503. * Adds a vec3 to the uniform buffer.
  7504. * @param name Name of the uniform, as used in the uniform block in the shader.
  7505. * @param color Define the vec3 from a Color
  7506. */
  7507. addColor3(name: string, color: Color3): void;
  7508. /**
  7509. * Adds a vec4 to the uniform buffer.
  7510. * @param name Name of the uniform, as used in the uniform block in the shader.
  7511. * @param color Define the rgb components from a Color
  7512. * @param alpha Define the a component of the vec4
  7513. */
  7514. addColor4(name: string, color: Color3, alpha: number): void;
  7515. /**
  7516. * Adds a vec3 to the uniform buffer.
  7517. * @param name Name of the uniform, as used in the uniform block in the shader.
  7518. * @param vector Define the vec3 components from a Vector
  7519. */
  7520. addVector3(name: string, vector: Vector3): void;
  7521. /**
  7522. * Adds a Matrix 3x3 to the uniform buffer.
  7523. * @param name Name of the uniform, as used in the uniform block in the shader.
  7524. */
  7525. addMatrix3x3(name: string): void;
  7526. /**
  7527. * Adds a Matrix 2x2 to the uniform buffer.
  7528. * @param name Name of the uniform, as used in the uniform block in the shader.
  7529. */
  7530. addMatrix2x2(name: string): void;
  7531. /**
  7532. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  7533. */
  7534. create(): void;
  7535. /** @hidden */
  7536. _rebuild(): void;
  7537. /**
  7538. * Updates the WebGL Uniform Buffer on the GPU.
  7539. * If the `dynamic` flag is set to true, no cache comparison is done.
  7540. * Otherwise, the buffer will be updated only if the cache differs.
  7541. */
  7542. update(): void;
  7543. /**
  7544. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  7545. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7546. * @param data Define the flattened data
  7547. * @param size Define the size of the data.
  7548. */
  7549. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  7550. private _valueCache;
  7551. private _cacheMatrix;
  7552. private _updateMatrix3x3ForUniform;
  7553. private _updateMatrix3x3ForEffect;
  7554. private _updateMatrix2x2ForEffect;
  7555. private _updateMatrix2x2ForUniform;
  7556. private _updateFloatForEffect;
  7557. private _updateFloatForUniform;
  7558. private _updateFloat2ForEffect;
  7559. private _updateFloat2ForUniform;
  7560. private _updateFloat3ForEffect;
  7561. private _updateFloat3ForUniform;
  7562. private _updateFloat4ForEffect;
  7563. private _updateFloat4ForUniform;
  7564. private _updateMatrixForEffect;
  7565. private _updateMatrixForUniform;
  7566. private _updateVector3ForEffect;
  7567. private _updateVector3ForUniform;
  7568. private _updateVector4ForEffect;
  7569. private _updateVector4ForUniform;
  7570. private _updateColor3ForEffect;
  7571. private _updateColor3ForUniform;
  7572. private _updateColor4ForEffect;
  7573. private _updateColor4ForUniform;
  7574. /**
  7575. * Sets a sampler uniform on the effect.
  7576. * @param name Define the name of the sampler.
  7577. * @param texture Define the texture to set in the sampler
  7578. */
  7579. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  7580. /**
  7581. * Directly updates the value of the uniform in the cache AND on the GPU.
  7582. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7583. * @param data Define the flattened data
  7584. */
  7585. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  7586. /**
  7587. * Binds this uniform buffer to an effect.
  7588. * @param effect Define the effect to bind the buffer to
  7589. * @param name Name of the uniform block in the shader.
  7590. */
  7591. bindToEffect(effect: Effect, name: string): void;
  7592. /**
  7593. * Disposes the uniform buffer.
  7594. */
  7595. dispose(): void;
  7596. }
  7597. }
  7598. declare module "babylonjs/Misc/iInspectable" {
  7599. /**
  7600. * Enum that determines the text-wrapping mode to use.
  7601. */
  7602. export enum InspectableType {
  7603. /**
  7604. * Checkbox for booleans
  7605. */
  7606. Checkbox = 0,
  7607. /**
  7608. * Sliders for numbers
  7609. */
  7610. Slider = 1,
  7611. /**
  7612. * Vector3
  7613. */
  7614. Vector3 = 2,
  7615. /**
  7616. * Quaternions
  7617. */
  7618. Quaternion = 3,
  7619. /**
  7620. * Color3
  7621. */
  7622. Color3 = 4,
  7623. /**
  7624. * String
  7625. */
  7626. String = 5
  7627. }
  7628. /**
  7629. * Interface used to define custom inspectable properties.
  7630. * This interface is used by the inspector to display custom property grids
  7631. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7632. */
  7633. export interface IInspectable {
  7634. /**
  7635. * Gets the label to display
  7636. */
  7637. label: string;
  7638. /**
  7639. * Gets the name of the property to edit
  7640. */
  7641. propertyName: string;
  7642. /**
  7643. * Gets the type of the editor to use
  7644. */
  7645. type: InspectableType;
  7646. /**
  7647. * Gets the minimum value of the property when using in "slider" mode
  7648. */
  7649. min?: number;
  7650. /**
  7651. * Gets the maximum value of the property when using in "slider" mode
  7652. */
  7653. max?: number;
  7654. /**
  7655. * Gets the setp to use when using in "slider" mode
  7656. */
  7657. step?: number;
  7658. }
  7659. }
  7660. declare module "babylonjs/Misc/timingTools" {
  7661. /**
  7662. * Class used to provide helper for timing
  7663. */
  7664. export class TimingTools {
  7665. /**
  7666. * Polyfill for setImmediate
  7667. * @param action defines the action to execute after the current execution block
  7668. */
  7669. static SetImmediate(action: () => void): void;
  7670. }
  7671. }
  7672. declare module "babylonjs/Misc/instantiationTools" {
  7673. /**
  7674. * Class used to enable instatition of objects by class name
  7675. */
  7676. export class InstantiationTools {
  7677. /**
  7678. * Use this object to register external classes like custom textures or material
  7679. * to allow the laoders to instantiate them
  7680. */
  7681. static RegisteredExternalClasses: {
  7682. [key: string]: Object;
  7683. };
  7684. /**
  7685. * Tries to instantiate a new object from a given class name
  7686. * @param className defines the class name to instantiate
  7687. * @returns the new object or null if the system was not able to do the instantiation
  7688. */
  7689. static Instantiate(className: string): any;
  7690. }
  7691. }
  7692. declare module "babylonjs/Engines/depthTextureCreationOptions" {
  7693. /**
  7694. * Define options used to create a depth texture
  7695. */
  7696. export class DepthTextureCreationOptions {
  7697. /** Specifies whether or not a stencil should be allocated in the texture */
  7698. generateStencil?: boolean;
  7699. /** Specifies whether or not bilinear filtering is enable on the texture */
  7700. bilinearFiltering?: boolean;
  7701. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  7702. comparisonFunction?: number;
  7703. /** Specifies if the created texture is a cube texture */
  7704. isCube?: boolean;
  7705. }
  7706. }
  7707. declare module "babylonjs/Engines/Extensions/engine.cubeTexture" {
  7708. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  7709. import { Nullable } from "babylonjs/types";
  7710. import { Scene } from "babylonjs/scene";
  7711. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  7712. module "babylonjs/Engines/thinEngine" {
  7713. interface ThinEngine {
  7714. /**
  7715. * Creates a depth stencil cube texture.
  7716. * This is only available in WebGL 2.
  7717. * @param size The size of face edge in the cube texture.
  7718. * @param options The options defining the cube texture.
  7719. * @returns The cube texture
  7720. */
  7721. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7722. /**
  7723. * Creates a cube texture
  7724. * @param rootUrl defines the url where the files to load is located
  7725. * @param scene defines the current scene
  7726. * @param files defines the list of files to load (1 per face)
  7727. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7728. * @param onLoad defines an optional callback raised when the texture is loaded
  7729. * @param onError defines an optional callback raised if there is an issue to load the texture
  7730. * @param format defines the format of the data
  7731. * @param forcedExtension defines the extension to use to pick the right loader
  7732. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7733. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7734. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7735. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7736. * @returns the cube texture as an InternalTexture
  7737. */
  7738. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean | undefined, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number, fallback: Nullable<InternalTexture>): InternalTexture;
  7739. /**
  7740. * Creates a cube texture
  7741. * @param rootUrl defines the url where the files to load is located
  7742. * @param scene defines the current scene
  7743. * @param files defines the list of files to load (1 per face)
  7744. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7745. * @param onLoad defines an optional callback raised when the texture is loaded
  7746. * @param onError defines an optional callback raised if there is an issue to load the texture
  7747. * @param format defines the format of the data
  7748. * @param forcedExtension defines the extension to use to pick the right loader
  7749. * @returns the cube texture as an InternalTexture
  7750. */
  7751. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any): InternalTexture;
  7752. /**
  7753. * Creates a cube texture
  7754. * @param rootUrl defines the url where the files to load is located
  7755. * @param scene defines the current scene
  7756. * @param files defines the list of files to load (1 per face)
  7757. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7758. * @param onLoad defines an optional callback raised when the texture is loaded
  7759. * @param onError defines an optional callback raised if there is an issue to load the texture
  7760. * @param format defines the format of the data
  7761. * @param forcedExtension defines the extension to use to pick the right loader
  7762. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7763. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7764. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7765. * @returns the cube texture as an InternalTexture
  7766. */
  7767. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number): InternalTexture;
  7768. /** @hidden */
  7769. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7770. /** @hidden */
  7771. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7772. /** @hidden */
  7773. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7774. /** @hidden */
  7775. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7776. /**
  7777. * @hidden
  7778. */
  7779. _setCubeMapTextureParams(loadMipmap: boolean): void;
  7780. }
  7781. }
  7782. }
  7783. declare module "babylonjs/Materials/Textures/cubeTexture" {
  7784. import { Nullable } from "babylonjs/types";
  7785. import { Scene } from "babylonjs/scene";
  7786. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7787. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7788. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  7789. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  7790. import { Observable } from "babylonjs/Misc/observable";
  7791. /**
  7792. * Class for creating a cube texture
  7793. */
  7794. export class CubeTexture extends BaseTexture {
  7795. private _delayedOnLoad;
  7796. /**
  7797. * Observable triggered once the texture has been loaded.
  7798. */
  7799. onLoadObservable: Observable<CubeTexture>;
  7800. /**
  7801. * The url of the texture
  7802. */
  7803. url: string;
  7804. /**
  7805. * Gets or sets the center of the bounding box associated with the cube texture.
  7806. * It must define where the camera used to render the texture was set
  7807. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7808. */
  7809. boundingBoxPosition: Vector3;
  7810. private _boundingBoxSize;
  7811. /**
  7812. * Gets or sets the size of the bounding box associated with the cube texture
  7813. * When defined, the cubemap will switch to local mode
  7814. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7815. * @example https://www.babylonjs-playground.com/#RNASML
  7816. */
  7817. set boundingBoxSize(value: Vector3);
  7818. /**
  7819. * Returns the bounding box size
  7820. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7821. */
  7822. get boundingBoxSize(): Vector3;
  7823. protected _rotationY: number;
  7824. /**
  7825. * Sets texture matrix rotation angle around Y axis in radians.
  7826. */
  7827. set rotationY(value: number);
  7828. /**
  7829. * Gets texture matrix rotation angle around Y axis radians.
  7830. */
  7831. get rotationY(): number;
  7832. /**
  7833. * Are mip maps generated for this texture or not.
  7834. */
  7835. get noMipmap(): boolean;
  7836. private _noMipmap;
  7837. private _files;
  7838. protected _forcedExtension: Nullable<string>;
  7839. private _extensions;
  7840. private _textureMatrix;
  7841. private _format;
  7842. private _createPolynomials;
  7843. /** @hidden */
  7844. _prefiltered: boolean;
  7845. /**
  7846. * Creates a cube texture from an array of image urls
  7847. * @param files defines an array of image urls
  7848. * @param scene defines the hosting scene
  7849. * @param noMipmap specifies if mip maps are not used
  7850. * @returns a cube texture
  7851. */
  7852. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7853. /**
  7854. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7855. * @param url defines the url of the prefiltered texture
  7856. * @param scene defines the scene the texture is attached to
  7857. * @param forcedExtension defines the extension of the file if different from the url
  7858. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7859. * @return the prefiltered texture
  7860. */
  7861. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7862. /**
  7863. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7864. * as prefiltered data.
  7865. * @param rootUrl defines the url of the texture or the root name of the six images
  7866. * @param null defines the scene or engine the texture is attached to
  7867. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7868. * @param noMipmap defines if mipmaps should be created or not
  7869. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7870. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7871. * @param onError defines a callback triggered in case of error during load
  7872. * @param format defines the internal format to use for the texture once loaded
  7873. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7874. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7875. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7876. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7877. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7878. * @return the cube texture
  7879. */
  7880. constructor(rootUrl: string, sceneOrEngine: Scene | ThinEngine, extensions?: Nullable<string[]>, noMipmap?: boolean, files?: Nullable<string[]>, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number, prefiltered?: boolean, forcedExtension?: any, createPolynomials?: boolean, lodScale?: number, lodOffset?: number);
  7881. /**
  7882. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  7883. */
  7884. get isPrefiltered(): boolean;
  7885. /**
  7886. * Get the current class name of the texture useful for serialization or dynamic coding.
  7887. * @returns "CubeTexture"
  7888. */
  7889. getClassName(): string;
  7890. /**
  7891. * Update the url (and optional buffer) of this texture if url was null during construction.
  7892. * @param url the url of the texture
  7893. * @param forcedExtension defines the extension to use
  7894. * @param onLoad callback called when the texture is loaded (defaults to null)
  7895. * @param prefiltered Defines whether the updated texture is prefiltered or not
  7896. */
  7897. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  7898. /**
  7899. * Delays loading of the cube texture
  7900. * @param forcedExtension defines the extension to use
  7901. */
  7902. delayLoad(forcedExtension?: string): void;
  7903. /**
  7904. * Returns the reflection texture matrix
  7905. * @returns the reflection texture matrix
  7906. */
  7907. getReflectionTextureMatrix(): Matrix;
  7908. /**
  7909. * Sets the reflection texture matrix
  7910. * @param value Reflection texture matrix
  7911. */
  7912. setReflectionTextureMatrix(value: Matrix): void;
  7913. /**
  7914. * Parses text to create a cube texture
  7915. * @param parsedTexture define the serialized text to read from
  7916. * @param scene defines the hosting scene
  7917. * @param rootUrl defines the root url of the cube texture
  7918. * @returns a cube texture
  7919. */
  7920. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7921. /**
  7922. * Makes a clone, or deep copy, of the cube texture
  7923. * @returns a new cube texture
  7924. */
  7925. clone(): CubeTexture;
  7926. }
  7927. }
  7928. declare module "babylonjs/Materials/materialDefines" {
  7929. /**
  7930. * Manages the defines for the Material
  7931. */
  7932. export class MaterialDefines {
  7933. /** @hidden */
  7934. protected _keys: string[];
  7935. private _isDirty;
  7936. /** @hidden */
  7937. _renderId: number;
  7938. /** @hidden */
  7939. _areLightsDirty: boolean;
  7940. /** @hidden */
  7941. _areLightsDisposed: boolean;
  7942. /** @hidden */
  7943. _areAttributesDirty: boolean;
  7944. /** @hidden */
  7945. _areTexturesDirty: boolean;
  7946. /** @hidden */
  7947. _areFresnelDirty: boolean;
  7948. /** @hidden */
  7949. _areMiscDirty: boolean;
  7950. /** @hidden */
  7951. _areImageProcessingDirty: boolean;
  7952. /** @hidden */
  7953. _normals: boolean;
  7954. /** @hidden */
  7955. _uvs: boolean;
  7956. /** @hidden */
  7957. _needNormals: boolean;
  7958. /** @hidden */
  7959. _needUVs: boolean;
  7960. [id: string]: any;
  7961. /**
  7962. * Specifies if the material needs to be re-calculated
  7963. */
  7964. get isDirty(): boolean;
  7965. /**
  7966. * Marks the material to indicate that it has been re-calculated
  7967. */
  7968. markAsProcessed(): void;
  7969. /**
  7970. * Marks the material to indicate that it needs to be re-calculated
  7971. */
  7972. markAsUnprocessed(): void;
  7973. /**
  7974. * Marks the material to indicate all of its defines need to be re-calculated
  7975. */
  7976. markAllAsDirty(): void;
  7977. /**
  7978. * Marks the material to indicate that image processing needs to be re-calculated
  7979. */
  7980. markAsImageProcessingDirty(): void;
  7981. /**
  7982. * Marks the material to indicate the lights need to be re-calculated
  7983. * @param disposed Defines whether the light is dirty due to dispose or not
  7984. */
  7985. markAsLightDirty(disposed?: boolean): void;
  7986. /**
  7987. * Marks the attribute state as changed
  7988. */
  7989. markAsAttributesDirty(): void;
  7990. /**
  7991. * Marks the texture state as changed
  7992. */
  7993. markAsTexturesDirty(): void;
  7994. /**
  7995. * Marks the fresnel state as changed
  7996. */
  7997. markAsFresnelDirty(): void;
  7998. /**
  7999. * Marks the misc state as changed
  8000. */
  8001. markAsMiscDirty(): void;
  8002. /**
  8003. * Rebuilds the material defines
  8004. */
  8005. rebuild(): void;
  8006. /**
  8007. * Specifies if two material defines are equal
  8008. * @param other - A material define instance to compare to
  8009. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  8010. */
  8011. isEqual(other: MaterialDefines): boolean;
  8012. /**
  8013. * Clones this instance's defines to another instance
  8014. * @param other - material defines to clone values to
  8015. */
  8016. cloneTo(other: MaterialDefines): void;
  8017. /**
  8018. * Resets the material define values
  8019. */
  8020. reset(): void;
  8021. /**
  8022. * Converts the material define values to a string
  8023. * @returns - String of material define information
  8024. */
  8025. toString(): string;
  8026. }
  8027. }
  8028. declare module "babylonjs/Materials/colorCurves" {
  8029. import { Effect } from "babylonjs/Materials/effect";
  8030. /**
  8031. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  8032. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  8033. * These are similar to controls found in many professional imaging or colorist software. The global controls are applied to the entire image. For advanced tuning, extra controls are provided to adjust the shadow, midtone and highlight areas of the image;
  8034. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  8035. */
  8036. export class ColorCurves {
  8037. private _dirty;
  8038. private _tempColor;
  8039. private _globalCurve;
  8040. private _highlightsCurve;
  8041. private _midtonesCurve;
  8042. private _shadowsCurve;
  8043. private _positiveCurve;
  8044. private _negativeCurve;
  8045. private _globalHue;
  8046. private _globalDensity;
  8047. private _globalSaturation;
  8048. private _globalExposure;
  8049. /**
  8050. * Gets the global Hue value.
  8051. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8052. */
  8053. get globalHue(): number;
  8054. /**
  8055. * Sets the global Hue value.
  8056. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8057. */
  8058. set globalHue(value: number);
  8059. /**
  8060. * Gets the global Density value.
  8061. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8062. * Values less than zero provide a filter of opposite hue.
  8063. */
  8064. get globalDensity(): number;
  8065. /**
  8066. * Sets the global Density value.
  8067. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8068. * Values less than zero provide a filter of opposite hue.
  8069. */
  8070. set globalDensity(value: number);
  8071. /**
  8072. * Gets the global Saturation value.
  8073. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8074. */
  8075. get globalSaturation(): number;
  8076. /**
  8077. * Sets the global Saturation value.
  8078. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8079. */
  8080. set globalSaturation(value: number);
  8081. /**
  8082. * Gets the global Exposure value.
  8083. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8084. */
  8085. get globalExposure(): number;
  8086. /**
  8087. * Sets the global Exposure value.
  8088. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8089. */
  8090. set globalExposure(value: number);
  8091. private _highlightsHue;
  8092. private _highlightsDensity;
  8093. private _highlightsSaturation;
  8094. private _highlightsExposure;
  8095. /**
  8096. * Gets the highlights Hue value.
  8097. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8098. */
  8099. get highlightsHue(): number;
  8100. /**
  8101. * Sets the highlights Hue value.
  8102. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8103. */
  8104. set highlightsHue(value: number);
  8105. /**
  8106. * Gets the highlights Density value.
  8107. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8108. * Values less than zero provide a filter of opposite hue.
  8109. */
  8110. get highlightsDensity(): number;
  8111. /**
  8112. * Sets the highlights Density value.
  8113. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8114. * Values less than zero provide a filter of opposite hue.
  8115. */
  8116. set highlightsDensity(value: number);
  8117. /**
  8118. * Gets the highlights Saturation value.
  8119. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8120. */
  8121. get highlightsSaturation(): number;
  8122. /**
  8123. * Sets the highlights Saturation value.
  8124. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8125. */
  8126. set highlightsSaturation(value: number);
  8127. /**
  8128. * Gets the highlights Exposure value.
  8129. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8130. */
  8131. get highlightsExposure(): number;
  8132. /**
  8133. * Sets the highlights Exposure value.
  8134. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8135. */
  8136. set highlightsExposure(value: number);
  8137. private _midtonesHue;
  8138. private _midtonesDensity;
  8139. private _midtonesSaturation;
  8140. private _midtonesExposure;
  8141. /**
  8142. * Gets the midtones Hue value.
  8143. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8144. */
  8145. get midtonesHue(): number;
  8146. /**
  8147. * Sets the midtones Hue value.
  8148. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8149. */
  8150. set midtonesHue(value: number);
  8151. /**
  8152. * Gets the midtones Density value.
  8153. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8154. * Values less than zero provide a filter of opposite hue.
  8155. */
  8156. get midtonesDensity(): number;
  8157. /**
  8158. * Sets the midtones Density value.
  8159. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8160. * Values less than zero provide a filter of opposite hue.
  8161. */
  8162. set midtonesDensity(value: number);
  8163. /**
  8164. * Gets the midtones Saturation value.
  8165. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8166. */
  8167. get midtonesSaturation(): number;
  8168. /**
  8169. * Sets the midtones Saturation value.
  8170. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8171. */
  8172. set midtonesSaturation(value: number);
  8173. /**
  8174. * Gets the midtones Exposure value.
  8175. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8176. */
  8177. get midtonesExposure(): number;
  8178. /**
  8179. * Sets the midtones Exposure value.
  8180. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8181. */
  8182. set midtonesExposure(value: number);
  8183. private _shadowsHue;
  8184. private _shadowsDensity;
  8185. private _shadowsSaturation;
  8186. private _shadowsExposure;
  8187. /**
  8188. * Gets the shadows Hue value.
  8189. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8190. */
  8191. get shadowsHue(): number;
  8192. /**
  8193. * Sets the shadows Hue value.
  8194. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8195. */
  8196. set shadowsHue(value: number);
  8197. /**
  8198. * Gets the shadows Density value.
  8199. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8200. * Values less than zero provide a filter of opposite hue.
  8201. */
  8202. get shadowsDensity(): number;
  8203. /**
  8204. * Sets the shadows Density value.
  8205. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8206. * Values less than zero provide a filter of opposite hue.
  8207. */
  8208. set shadowsDensity(value: number);
  8209. /**
  8210. * Gets the shadows Saturation value.
  8211. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8212. */
  8213. get shadowsSaturation(): number;
  8214. /**
  8215. * Sets the shadows Saturation value.
  8216. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8217. */
  8218. set shadowsSaturation(value: number);
  8219. /**
  8220. * Gets the shadows Exposure value.
  8221. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8222. */
  8223. get shadowsExposure(): number;
  8224. /**
  8225. * Sets the shadows Exposure value.
  8226. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8227. */
  8228. set shadowsExposure(value: number);
  8229. /**
  8230. * Returns the class name
  8231. * @returns The class name
  8232. */
  8233. getClassName(): string;
  8234. /**
  8235. * Binds the color curves to the shader.
  8236. * @param colorCurves The color curve to bind
  8237. * @param effect The effect to bind to
  8238. * @param positiveUniform The positive uniform shader parameter
  8239. * @param neutralUniform The neutral uniform shader parameter
  8240. * @param negativeUniform The negative uniform shader parameter
  8241. */
  8242. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  8243. /**
  8244. * Prepare the list of uniforms associated with the ColorCurves effects.
  8245. * @param uniformsList The list of uniforms used in the effect
  8246. */
  8247. static PrepareUniforms(uniformsList: string[]): void;
  8248. /**
  8249. * Returns color grading data based on a hue, density, saturation and exposure value.
  8250. * @param filterHue The hue of the color filter.
  8251. * @param filterDensity The density of the color filter.
  8252. * @param saturation The saturation.
  8253. * @param exposure The exposure.
  8254. * @param result The result data container.
  8255. */
  8256. private getColorGradingDataToRef;
  8257. /**
  8258. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  8259. * @param value The input slider value in range [-100,100].
  8260. * @returns Adjusted value.
  8261. */
  8262. private static applyColorGradingSliderNonlinear;
  8263. /**
  8264. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  8265. * @param hue The hue (H) input.
  8266. * @param saturation The saturation (S) input.
  8267. * @param brightness The brightness (B) input.
  8268. * @result An RGBA color represented as Vector4.
  8269. */
  8270. private static fromHSBToRef;
  8271. /**
  8272. * Returns a value clamped between min and max
  8273. * @param value The value to clamp
  8274. * @param min The minimum of value
  8275. * @param max The maximum of value
  8276. * @returns The clamped value.
  8277. */
  8278. private static clamp;
  8279. /**
  8280. * Clones the current color curve instance.
  8281. * @return The cloned curves
  8282. */
  8283. clone(): ColorCurves;
  8284. /**
  8285. * Serializes the current color curve instance to a json representation.
  8286. * @return a JSON representation
  8287. */
  8288. serialize(): any;
  8289. /**
  8290. * Parses the color curve from a json representation.
  8291. * @param source the JSON source to parse
  8292. * @return The parsed curves
  8293. */
  8294. static Parse(source: any): ColorCurves;
  8295. }
  8296. }
  8297. declare module "babylonjs/Materials/imageProcessingConfiguration" {
  8298. import { Observable } from "babylonjs/Misc/observable";
  8299. import { Nullable } from "babylonjs/types";
  8300. import { Color4 } from "babylonjs/Maths/math.color";
  8301. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  8302. import { Effect } from "babylonjs/Materials/effect";
  8303. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8304. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  8305. /**
  8306. * Interface to follow in your material defines to integrate easily the
  8307. * Image proccessing functions.
  8308. * @hidden
  8309. */
  8310. export interface IImageProcessingConfigurationDefines {
  8311. IMAGEPROCESSING: boolean;
  8312. VIGNETTE: boolean;
  8313. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8314. VIGNETTEBLENDMODEOPAQUE: boolean;
  8315. TONEMAPPING: boolean;
  8316. TONEMAPPING_ACES: boolean;
  8317. CONTRAST: boolean;
  8318. EXPOSURE: boolean;
  8319. COLORCURVES: boolean;
  8320. COLORGRADING: boolean;
  8321. COLORGRADING3D: boolean;
  8322. SAMPLER3DGREENDEPTH: boolean;
  8323. SAMPLER3DBGRMAP: boolean;
  8324. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8325. }
  8326. /**
  8327. * @hidden
  8328. */
  8329. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8330. IMAGEPROCESSING: boolean;
  8331. VIGNETTE: boolean;
  8332. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8333. VIGNETTEBLENDMODEOPAQUE: boolean;
  8334. TONEMAPPING: boolean;
  8335. TONEMAPPING_ACES: boolean;
  8336. CONTRAST: boolean;
  8337. COLORCURVES: boolean;
  8338. COLORGRADING: boolean;
  8339. COLORGRADING3D: boolean;
  8340. SAMPLER3DGREENDEPTH: boolean;
  8341. SAMPLER3DBGRMAP: boolean;
  8342. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8343. EXPOSURE: boolean;
  8344. constructor();
  8345. }
  8346. /**
  8347. * This groups together the common properties used for image processing either in direct forward pass
  8348. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8349. * or not.
  8350. */
  8351. export class ImageProcessingConfiguration {
  8352. /**
  8353. * Default tone mapping applied in BabylonJS.
  8354. */
  8355. static readonly TONEMAPPING_STANDARD: number;
  8356. /**
  8357. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8358. * to other engines rendering to increase portability.
  8359. */
  8360. static readonly TONEMAPPING_ACES: number;
  8361. /**
  8362. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8363. */
  8364. colorCurves: Nullable<ColorCurves>;
  8365. private _colorCurvesEnabled;
  8366. /**
  8367. * Gets wether the color curves effect is enabled.
  8368. */
  8369. get colorCurvesEnabled(): boolean;
  8370. /**
  8371. * Sets wether the color curves effect is enabled.
  8372. */
  8373. set colorCurvesEnabled(value: boolean);
  8374. private _colorGradingTexture;
  8375. /**
  8376. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8377. */
  8378. get colorGradingTexture(): Nullable<BaseTexture>;
  8379. /**
  8380. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8381. */
  8382. set colorGradingTexture(value: Nullable<BaseTexture>);
  8383. private _colorGradingEnabled;
  8384. /**
  8385. * Gets wether the color grading effect is enabled.
  8386. */
  8387. get colorGradingEnabled(): boolean;
  8388. /**
  8389. * Sets wether the color grading effect is enabled.
  8390. */
  8391. set colorGradingEnabled(value: boolean);
  8392. private _colorGradingWithGreenDepth;
  8393. /**
  8394. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8395. */
  8396. get colorGradingWithGreenDepth(): boolean;
  8397. /**
  8398. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8399. */
  8400. set colorGradingWithGreenDepth(value: boolean);
  8401. private _colorGradingBGR;
  8402. /**
  8403. * Gets wether the color grading texture contains BGR values.
  8404. */
  8405. get colorGradingBGR(): boolean;
  8406. /**
  8407. * Sets wether the color grading texture contains BGR values.
  8408. */
  8409. set colorGradingBGR(value: boolean);
  8410. /** @hidden */
  8411. _exposure: number;
  8412. /**
  8413. * Gets the Exposure used in the effect.
  8414. */
  8415. get exposure(): number;
  8416. /**
  8417. * Sets the Exposure used in the effect.
  8418. */
  8419. set exposure(value: number);
  8420. private _toneMappingEnabled;
  8421. /**
  8422. * Gets wether the tone mapping effect is enabled.
  8423. */
  8424. get toneMappingEnabled(): boolean;
  8425. /**
  8426. * Sets wether the tone mapping effect is enabled.
  8427. */
  8428. set toneMappingEnabled(value: boolean);
  8429. private _toneMappingType;
  8430. /**
  8431. * Gets the type of tone mapping effect.
  8432. */
  8433. get toneMappingType(): number;
  8434. /**
  8435. * Sets the type of tone mapping effect used in BabylonJS.
  8436. */
  8437. set toneMappingType(value: number);
  8438. protected _contrast: number;
  8439. /**
  8440. * Gets the contrast used in the effect.
  8441. */
  8442. get contrast(): number;
  8443. /**
  8444. * Sets the contrast used in the effect.
  8445. */
  8446. set contrast(value: number);
  8447. /**
  8448. * Vignette stretch size.
  8449. */
  8450. vignetteStretch: number;
  8451. /**
  8452. * Vignette centre X Offset.
  8453. */
  8454. vignetteCentreX: number;
  8455. /**
  8456. * Vignette centre Y Offset.
  8457. */
  8458. vignetteCentreY: number;
  8459. /**
  8460. * Vignette weight or intensity of the vignette effect.
  8461. */
  8462. vignetteWeight: number;
  8463. /**
  8464. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8465. * if vignetteEnabled is set to true.
  8466. */
  8467. vignetteColor: Color4;
  8468. /**
  8469. * Camera field of view used by the Vignette effect.
  8470. */
  8471. vignetteCameraFov: number;
  8472. private _vignetteBlendMode;
  8473. /**
  8474. * Gets the vignette blend mode allowing different kind of effect.
  8475. */
  8476. get vignetteBlendMode(): number;
  8477. /**
  8478. * Sets the vignette blend mode allowing different kind of effect.
  8479. */
  8480. set vignetteBlendMode(value: number);
  8481. private _vignetteEnabled;
  8482. /**
  8483. * Gets wether the vignette effect is enabled.
  8484. */
  8485. get vignetteEnabled(): boolean;
  8486. /**
  8487. * Sets wether the vignette effect is enabled.
  8488. */
  8489. set vignetteEnabled(value: boolean);
  8490. private _applyByPostProcess;
  8491. /**
  8492. * Gets wether the image processing is applied through a post process or not.
  8493. */
  8494. get applyByPostProcess(): boolean;
  8495. /**
  8496. * Sets wether the image processing is applied through a post process or not.
  8497. */
  8498. set applyByPostProcess(value: boolean);
  8499. private _isEnabled;
  8500. /**
  8501. * Gets wether the image processing is enabled or not.
  8502. */
  8503. get isEnabled(): boolean;
  8504. /**
  8505. * Sets wether the image processing is enabled or not.
  8506. */
  8507. set isEnabled(value: boolean);
  8508. /**
  8509. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8510. */
  8511. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8512. /**
  8513. * Method called each time the image processing information changes requires to recompile the effect.
  8514. */
  8515. protected _updateParameters(): void;
  8516. /**
  8517. * Gets the current class name.
  8518. * @return "ImageProcessingConfiguration"
  8519. */
  8520. getClassName(): string;
  8521. /**
  8522. * Prepare the list of uniforms associated with the Image Processing effects.
  8523. * @param uniforms The list of uniforms used in the effect
  8524. * @param defines the list of defines currently in use
  8525. */
  8526. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8527. /**
  8528. * Prepare the list of samplers associated with the Image Processing effects.
  8529. * @param samplersList The list of uniforms used in the effect
  8530. * @param defines the list of defines currently in use
  8531. */
  8532. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8533. /**
  8534. * Prepare the list of defines associated to the shader.
  8535. * @param defines the list of defines to complete
  8536. * @param forPostProcess Define if we are currently in post process mode or not
  8537. */
  8538. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8539. /**
  8540. * Returns true if all the image processing information are ready.
  8541. * @returns True if ready, otherwise, false
  8542. */
  8543. isReady(): boolean;
  8544. /**
  8545. * Binds the image processing to the shader.
  8546. * @param effect The effect to bind to
  8547. * @param overrideAspectRatio Override the aspect ratio of the effect
  8548. */
  8549. bind(effect: Effect, overrideAspectRatio?: number): void;
  8550. /**
  8551. * Clones the current image processing instance.
  8552. * @return The cloned image processing
  8553. */
  8554. clone(): ImageProcessingConfiguration;
  8555. /**
  8556. * Serializes the current image processing instance to a json representation.
  8557. * @return a JSON representation
  8558. */
  8559. serialize(): any;
  8560. /**
  8561. * Parses the image processing from a json representation.
  8562. * @param source the JSON source to parse
  8563. * @return The parsed image processing
  8564. */
  8565. static Parse(source: any): ImageProcessingConfiguration;
  8566. private static _VIGNETTEMODE_MULTIPLY;
  8567. private static _VIGNETTEMODE_OPAQUE;
  8568. /**
  8569. * Used to apply the vignette as a mix with the pixel color.
  8570. */
  8571. static get VIGNETTEMODE_MULTIPLY(): number;
  8572. /**
  8573. * Used to apply the vignette as a replacement of the pixel color.
  8574. */
  8575. static get VIGNETTEMODE_OPAQUE(): number;
  8576. }
  8577. }
  8578. declare module "babylonjs/Shaders/postprocess.vertex" {
  8579. /** @hidden */
  8580. export var postprocessVertexShader: {
  8581. name: string;
  8582. shader: string;
  8583. };
  8584. }
  8585. declare module "babylonjs/Engines/Extensions/engine.renderTarget" {
  8586. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  8587. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  8588. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  8589. module "babylonjs/Engines/thinEngine" {
  8590. interface ThinEngine {
  8591. /**
  8592. * Creates a new render target texture
  8593. * @param size defines the size of the texture
  8594. * @param options defines the options used to create the texture
  8595. * @returns a new render target texture stored in an InternalTexture
  8596. */
  8597. createRenderTargetTexture(size: number | {
  8598. width: number;
  8599. height: number;
  8600. layers?: number;
  8601. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8602. /**
  8603. * Creates a depth stencil texture.
  8604. * This is only available in WebGL 2 or with the depth texture extension available.
  8605. * @param size The size of face edge in the texture.
  8606. * @param options The options defining the texture.
  8607. * @returns The texture
  8608. */
  8609. createDepthStencilTexture(size: number | {
  8610. width: number;
  8611. height: number;
  8612. layers?: number;
  8613. }, options: DepthTextureCreationOptions): InternalTexture;
  8614. /** @hidden */
  8615. _createDepthStencilTexture(size: number | {
  8616. width: number;
  8617. height: number;
  8618. layers?: number;
  8619. }, options: DepthTextureCreationOptions): InternalTexture;
  8620. }
  8621. }
  8622. }
  8623. declare module "babylonjs/Maths/math.axis" {
  8624. import { Vector3 } from "babylonjs/Maths/math.vector";
  8625. /** Defines supported spaces */
  8626. export enum Space {
  8627. /** Local (object) space */
  8628. LOCAL = 0,
  8629. /** World space */
  8630. WORLD = 1,
  8631. /** Bone space */
  8632. BONE = 2
  8633. }
  8634. /** Defines the 3 main axes */
  8635. export class Axis {
  8636. /** X axis */
  8637. static X: Vector3;
  8638. /** Y axis */
  8639. static Y: Vector3;
  8640. /** Z axis */
  8641. static Z: Vector3;
  8642. }
  8643. }
  8644. declare module "babylonjs/Cameras/targetCamera" {
  8645. import { Nullable } from "babylonjs/types";
  8646. import { Camera } from "babylonjs/Cameras/camera";
  8647. import { Scene } from "babylonjs/scene";
  8648. import { Quaternion, Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  8649. /**
  8650. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8651. * This is the base of the follow, arc rotate cameras and Free camera
  8652. * @see http://doc.babylonjs.com/features/cameras
  8653. */
  8654. export class TargetCamera extends Camera {
  8655. private static _RigCamTransformMatrix;
  8656. private static _TargetTransformMatrix;
  8657. private static _TargetFocalPoint;
  8658. /**
  8659. * Define the current direction the camera is moving to
  8660. */
  8661. cameraDirection: Vector3;
  8662. /**
  8663. * Define the current rotation the camera is rotating to
  8664. */
  8665. cameraRotation: Vector2;
  8666. /**
  8667. * When set, the up vector of the camera will be updated by the rotation of the camera
  8668. */
  8669. updateUpVectorFromRotation: boolean;
  8670. private _tmpQuaternion;
  8671. /**
  8672. * Define the current rotation of the camera
  8673. */
  8674. rotation: Vector3;
  8675. /**
  8676. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8677. */
  8678. rotationQuaternion: Quaternion;
  8679. /**
  8680. * Define the current speed of the camera
  8681. */
  8682. speed: number;
  8683. /**
  8684. * Add constraint to the camera to prevent it to move freely in all directions and
  8685. * around all axis.
  8686. */
  8687. noRotationConstraint: boolean;
  8688. /**
  8689. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  8690. * panning
  8691. */
  8692. invertRotation: boolean;
  8693. /**
  8694. * Speed multiplier for inverse camera panning
  8695. */
  8696. inverseRotationSpeed: number;
  8697. /**
  8698. * Define the current target of the camera as an object or a position.
  8699. */
  8700. lockedTarget: any;
  8701. /** @hidden */
  8702. _currentTarget: Vector3;
  8703. /** @hidden */
  8704. _initialFocalDistance: number;
  8705. /** @hidden */
  8706. _viewMatrix: Matrix;
  8707. /** @hidden */
  8708. _camMatrix: Matrix;
  8709. /** @hidden */
  8710. _cameraTransformMatrix: Matrix;
  8711. /** @hidden */
  8712. _cameraRotationMatrix: Matrix;
  8713. /** @hidden */
  8714. _referencePoint: Vector3;
  8715. /** @hidden */
  8716. _transformedReferencePoint: Vector3;
  8717. protected _globalCurrentTarget: Vector3;
  8718. protected _globalCurrentUpVector: Vector3;
  8719. /** @hidden */
  8720. _reset: () => void;
  8721. private _defaultUp;
  8722. /**
  8723. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  8724. * This is the base of the follow, arc rotate cameras and Free camera
  8725. * @see http://doc.babylonjs.com/features/cameras
  8726. * @param name Defines the name of the camera in the scene
  8727. * @param position Defines the start position of the camera in the scene
  8728. * @param scene Defines the scene the camera belongs to
  8729. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8730. */
  8731. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8732. /**
  8733. * Gets the position in front of the camera at a given distance.
  8734. * @param distance The distance from the camera we want the position to be
  8735. * @returns the position
  8736. */
  8737. getFrontPosition(distance: number): Vector3;
  8738. /** @hidden */
  8739. _getLockedTargetPosition(): Nullable<Vector3>;
  8740. private _storedPosition;
  8741. private _storedRotation;
  8742. private _storedRotationQuaternion;
  8743. /**
  8744. * Store current camera state of the camera (fov, position, rotation, etc..)
  8745. * @returns the camera
  8746. */
  8747. storeState(): Camera;
  8748. /**
  8749. * Restored camera state. You must call storeState() first
  8750. * @returns whether it was successful or not
  8751. * @hidden
  8752. */
  8753. _restoreStateValues(): boolean;
  8754. /** @hidden */
  8755. _initCache(): void;
  8756. /** @hidden */
  8757. _updateCache(ignoreParentClass?: boolean): void;
  8758. /** @hidden */
  8759. _isSynchronizedViewMatrix(): boolean;
  8760. /** @hidden */
  8761. _computeLocalCameraSpeed(): number;
  8762. /**
  8763. * Defines the target the camera should look at.
  8764. * @param target Defines the new target as a Vector or a mesh
  8765. */
  8766. setTarget(target: Vector3): void;
  8767. /**
  8768. * Return the current target position of the camera. This value is expressed in local space.
  8769. * @returns the target position
  8770. */
  8771. getTarget(): Vector3;
  8772. /** @hidden */
  8773. _decideIfNeedsToMove(): boolean;
  8774. /** @hidden */
  8775. _updatePosition(): void;
  8776. /** @hidden */
  8777. _checkInputs(): void;
  8778. protected _updateCameraRotationMatrix(): void;
  8779. /**
  8780. * Update the up vector to apply the rotation of the camera (So if you changed the camera rotation.z this will let you update the up vector as well)
  8781. * @returns the current camera
  8782. */
  8783. private _rotateUpVectorWithCameraRotationMatrix;
  8784. private _cachedRotationZ;
  8785. private _cachedQuaternionRotationZ;
  8786. /** @hidden */
  8787. _getViewMatrix(): Matrix;
  8788. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8789. /**
  8790. * @hidden
  8791. */
  8792. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8793. /**
  8794. * @hidden
  8795. */
  8796. _updateRigCameras(): void;
  8797. private _getRigCamPositionAndTarget;
  8798. /**
  8799. * Gets the current object class name.
  8800. * @return the class name
  8801. */
  8802. getClassName(): string;
  8803. }
  8804. }
  8805. declare module "babylonjs/Events/keyboardEvents" {
  8806. /**
  8807. * Gather the list of keyboard event types as constants.
  8808. */
  8809. export class KeyboardEventTypes {
  8810. /**
  8811. * The keydown event is fired when a key becomes active (pressed).
  8812. */
  8813. static readonly KEYDOWN: number;
  8814. /**
  8815. * The keyup event is fired when a key has been released.
  8816. */
  8817. static readonly KEYUP: number;
  8818. }
  8819. /**
  8820. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8821. */
  8822. export class KeyboardInfo {
  8823. /**
  8824. * Defines the type of event (KeyboardEventTypes)
  8825. */
  8826. type: number;
  8827. /**
  8828. * Defines the related dom event
  8829. */
  8830. event: KeyboardEvent;
  8831. /**
  8832. * Instantiates a new keyboard info.
  8833. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8834. * @param type Defines the type of event (KeyboardEventTypes)
  8835. * @param event Defines the related dom event
  8836. */
  8837. constructor(
  8838. /**
  8839. * Defines the type of event (KeyboardEventTypes)
  8840. */
  8841. type: number,
  8842. /**
  8843. * Defines the related dom event
  8844. */
  8845. event: KeyboardEvent);
  8846. }
  8847. /**
  8848. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8849. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8850. */
  8851. export class KeyboardInfoPre extends KeyboardInfo {
  8852. /**
  8853. * Defines the type of event (KeyboardEventTypes)
  8854. */
  8855. type: number;
  8856. /**
  8857. * Defines the related dom event
  8858. */
  8859. event: KeyboardEvent;
  8860. /**
  8861. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8862. */
  8863. skipOnPointerObservable: boolean;
  8864. /**
  8865. * Instantiates a new keyboard pre info.
  8866. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8867. * @param type Defines the type of event (KeyboardEventTypes)
  8868. * @param event Defines the related dom event
  8869. */
  8870. constructor(
  8871. /**
  8872. * Defines the type of event (KeyboardEventTypes)
  8873. */
  8874. type: number,
  8875. /**
  8876. * Defines the related dom event
  8877. */
  8878. event: KeyboardEvent);
  8879. }
  8880. }
  8881. declare module "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput" {
  8882. import { Nullable } from "babylonjs/types";
  8883. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  8884. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  8885. /**
  8886. * Manage the keyboard inputs to control the movement of a free camera.
  8887. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8888. */
  8889. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8890. /**
  8891. * Defines the camera the input is attached to.
  8892. */
  8893. camera: FreeCamera;
  8894. /**
  8895. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8896. */
  8897. keysUp: number[];
  8898. /**
  8899. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  8900. */
  8901. keysUpward: number[];
  8902. /**
  8903. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8904. */
  8905. keysDown: number[];
  8906. /**
  8907. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  8908. */
  8909. keysDownward: number[];
  8910. /**
  8911. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8912. */
  8913. keysLeft: number[];
  8914. /**
  8915. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8916. */
  8917. keysRight: number[];
  8918. private _keys;
  8919. private _onCanvasBlurObserver;
  8920. private _onKeyboardObserver;
  8921. private _engine;
  8922. private _scene;
  8923. /**
  8924. * Attach the input controls to a specific dom element to get the input from.
  8925. * @param element Defines the element the controls should be listened from
  8926. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8927. */
  8928. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8929. /**
  8930. * Detach the current controls from the specified dom element.
  8931. * @param element Defines the element to stop listening the inputs from
  8932. */
  8933. detachControl(element: Nullable<HTMLElement>): void;
  8934. /**
  8935. * Update the current camera state depending on the inputs that have been used this frame.
  8936. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8937. */
  8938. checkInputs(): void;
  8939. /**
  8940. * Gets the class name of the current intput.
  8941. * @returns the class name
  8942. */
  8943. getClassName(): string;
  8944. /** @hidden */
  8945. _onLostFocus(): void;
  8946. /**
  8947. * Get the friendly name associated with the input class.
  8948. * @returns the input friendly name
  8949. */
  8950. getSimpleName(): string;
  8951. }
  8952. }
  8953. declare module "babylonjs/Lights/shadowLight" {
  8954. import { Camera } from "babylonjs/Cameras/camera";
  8955. import { Scene } from "babylonjs/scene";
  8956. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  8957. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8958. import { Light } from "babylonjs/Lights/light";
  8959. /**
  8960. * Interface describing all the common properties and methods a shadow light needs to implement.
  8961. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8962. * as well as binding the different shadow properties to the effects.
  8963. */
  8964. export interface IShadowLight extends Light {
  8965. /**
  8966. * The light id in the scene (used in scene.findLighById for instance)
  8967. */
  8968. id: string;
  8969. /**
  8970. * The position the shdow will be casted from.
  8971. */
  8972. position: Vector3;
  8973. /**
  8974. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8975. */
  8976. direction: Vector3;
  8977. /**
  8978. * The transformed position. Position of the light in world space taking parenting in account.
  8979. */
  8980. transformedPosition: Vector3;
  8981. /**
  8982. * The transformed direction. Direction of the light in world space taking parenting in account.
  8983. */
  8984. transformedDirection: Vector3;
  8985. /**
  8986. * The friendly name of the light in the scene.
  8987. */
  8988. name: string;
  8989. /**
  8990. * Defines the shadow projection clipping minimum z value.
  8991. */
  8992. shadowMinZ: number;
  8993. /**
  8994. * Defines the shadow projection clipping maximum z value.
  8995. */
  8996. shadowMaxZ: number;
  8997. /**
  8998. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8999. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9000. */
  9001. computeTransformedInformation(): boolean;
  9002. /**
  9003. * Gets the scene the light belongs to.
  9004. * @returns The scene
  9005. */
  9006. getScene(): Scene;
  9007. /**
  9008. * Callback defining a custom Projection Matrix Builder.
  9009. * This can be used to override the default projection matrix computation.
  9010. */
  9011. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9012. /**
  9013. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9014. * @param matrix The materix to updated with the projection information
  9015. * @param viewMatrix The transform matrix of the light
  9016. * @param renderList The list of mesh to render in the map
  9017. * @returns The current light
  9018. */
  9019. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9020. /**
  9021. * Gets the current depth scale used in ESM.
  9022. * @returns The scale
  9023. */
  9024. getDepthScale(): number;
  9025. /**
  9026. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9027. * @returns true if a cube texture needs to be use
  9028. */
  9029. needCube(): boolean;
  9030. /**
  9031. * Detects if the projection matrix requires to be recomputed this frame.
  9032. * @returns true if it requires to be recomputed otherwise, false.
  9033. */
  9034. needProjectionMatrixCompute(): boolean;
  9035. /**
  9036. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9037. */
  9038. forceProjectionMatrixCompute(): void;
  9039. /**
  9040. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9041. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9042. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9043. */
  9044. getShadowDirection(faceIndex?: number): Vector3;
  9045. /**
  9046. * Gets the minZ used for shadow according to both the scene and the light.
  9047. * @param activeCamera The camera we are returning the min for
  9048. * @returns the depth min z
  9049. */
  9050. getDepthMinZ(activeCamera: Camera): number;
  9051. /**
  9052. * Gets the maxZ used for shadow according to both the scene and the light.
  9053. * @param activeCamera The camera we are returning the max for
  9054. * @returns the depth max z
  9055. */
  9056. getDepthMaxZ(activeCamera: Camera): number;
  9057. }
  9058. /**
  9059. * Base implementation IShadowLight
  9060. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  9061. */
  9062. export abstract class ShadowLight extends Light implements IShadowLight {
  9063. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  9064. protected _position: Vector3;
  9065. protected _setPosition(value: Vector3): void;
  9066. /**
  9067. * Sets the position the shadow will be casted from. Also use as the light position for both
  9068. * point and spot lights.
  9069. */
  9070. get position(): Vector3;
  9071. /**
  9072. * Sets the position the shadow will be casted from. Also use as the light position for both
  9073. * point and spot lights.
  9074. */
  9075. set position(value: Vector3);
  9076. protected _direction: Vector3;
  9077. protected _setDirection(value: Vector3): void;
  9078. /**
  9079. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  9080. * Also use as the light direction on spot and directional lights.
  9081. */
  9082. get direction(): Vector3;
  9083. /**
  9084. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  9085. * Also use as the light direction on spot and directional lights.
  9086. */
  9087. set direction(value: Vector3);
  9088. protected _shadowMinZ: number;
  9089. /**
  9090. * Gets the shadow projection clipping minimum z value.
  9091. */
  9092. get shadowMinZ(): number;
  9093. /**
  9094. * Sets the shadow projection clipping minimum z value.
  9095. */
  9096. set shadowMinZ(value: number);
  9097. protected _shadowMaxZ: number;
  9098. /**
  9099. * Sets the shadow projection clipping maximum z value.
  9100. */
  9101. get shadowMaxZ(): number;
  9102. /**
  9103. * Gets the shadow projection clipping maximum z value.
  9104. */
  9105. set shadowMaxZ(value: number);
  9106. /**
  9107. * Callback defining a custom Projection Matrix Builder.
  9108. * This can be used to override the default projection matrix computation.
  9109. */
  9110. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9111. /**
  9112. * The transformed position. Position of the light in world space taking parenting in account.
  9113. */
  9114. transformedPosition: Vector3;
  9115. /**
  9116. * The transformed direction. Direction of the light in world space taking parenting in account.
  9117. */
  9118. transformedDirection: Vector3;
  9119. private _needProjectionMatrixCompute;
  9120. /**
  9121. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9122. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9123. */
  9124. computeTransformedInformation(): boolean;
  9125. /**
  9126. * Return the depth scale used for the shadow map.
  9127. * @returns the depth scale.
  9128. */
  9129. getDepthScale(): number;
  9130. /**
  9131. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9132. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9133. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9134. */
  9135. getShadowDirection(faceIndex?: number): Vector3;
  9136. /**
  9137. * Returns the ShadowLight absolute position in the World.
  9138. * @returns the position vector in world space
  9139. */
  9140. getAbsolutePosition(): Vector3;
  9141. /**
  9142. * Sets the ShadowLight direction toward the passed target.
  9143. * @param target The point to target in local space
  9144. * @returns the updated ShadowLight direction
  9145. */
  9146. setDirectionToTarget(target: Vector3): Vector3;
  9147. /**
  9148. * Returns the light rotation in euler definition.
  9149. * @returns the x y z rotation in local space.
  9150. */
  9151. getRotation(): Vector3;
  9152. /**
  9153. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9154. * @returns true if a cube texture needs to be use
  9155. */
  9156. needCube(): boolean;
  9157. /**
  9158. * Detects if the projection matrix requires to be recomputed this frame.
  9159. * @returns true if it requires to be recomputed otherwise, false.
  9160. */
  9161. needProjectionMatrixCompute(): boolean;
  9162. /**
  9163. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9164. */
  9165. forceProjectionMatrixCompute(): void;
  9166. /** @hidden */
  9167. _initCache(): void;
  9168. /** @hidden */
  9169. _isSynchronized(): boolean;
  9170. /**
  9171. * Computes the world matrix of the node
  9172. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9173. * @returns the world matrix
  9174. */
  9175. computeWorldMatrix(force?: boolean): Matrix;
  9176. /**
  9177. * Gets the minZ used for shadow according to both the scene and the light.
  9178. * @param activeCamera The camera we are returning the min for
  9179. * @returns the depth min z
  9180. */
  9181. getDepthMinZ(activeCamera: Camera): number;
  9182. /**
  9183. * Gets the maxZ used for shadow according to both the scene and the light.
  9184. * @param activeCamera The camera we are returning the max for
  9185. * @returns the depth max z
  9186. */
  9187. getDepthMaxZ(activeCamera: Camera): number;
  9188. /**
  9189. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9190. * @param matrix The materix to updated with the projection information
  9191. * @param viewMatrix The transform matrix of the light
  9192. * @param renderList The list of mesh to render in the map
  9193. * @returns The current light
  9194. */
  9195. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9196. }
  9197. }
  9198. declare module "babylonjs/Materials/effectFallbacks" {
  9199. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  9200. import { Effect } from "babylonjs/Materials/effect";
  9201. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9202. /**
  9203. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  9204. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  9205. */
  9206. export class EffectFallbacks implements IEffectFallbacks {
  9207. private _defines;
  9208. private _currentRank;
  9209. private _maxRank;
  9210. private _mesh;
  9211. /**
  9212. * Removes the fallback from the bound mesh.
  9213. */
  9214. unBindMesh(): void;
  9215. /**
  9216. * Adds a fallback on the specified property.
  9217. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9218. * @param define The name of the define in the shader
  9219. */
  9220. addFallback(rank: number, define: string): void;
  9221. /**
  9222. * Sets the mesh to use CPU skinning when needing to fallback.
  9223. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9224. * @param mesh The mesh to use the fallbacks.
  9225. */
  9226. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  9227. /**
  9228. * Checks to see if more fallbacks are still availible.
  9229. */
  9230. get hasMoreFallbacks(): boolean;
  9231. /**
  9232. * Removes the defines that should be removed when falling back.
  9233. * @param currentDefines defines the current define statements for the shader.
  9234. * @param effect defines the current effect we try to compile
  9235. * @returns The resulting defines with defines of the current rank removed.
  9236. */
  9237. reduce(currentDefines: string, effect: Effect): string;
  9238. }
  9239. }
  9240. declare module "babylonjs/Materials/materialHelper" {
  9241. import { Nullable } from "babylonjs/types";
  9242. import { Scene } from "babylonjs/scene";
  9243. import { Engine } from "babylonjs/Engines/engine";
  9244. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9245. import { Light } from "babylonjs/Lights/light";
  9246. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  9247. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  9248. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  9249. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  9250. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  9251. /**
  9252. * "Static Class" containing the most commonly used helper while dealing with material for
  9253. * rendering purpose.
  9254. *
  9255. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  9256. *
  9257. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  9258. */
  9259. export class MaterialHelper {
  9260. /**
  9261. * Bind the current view position to an effect.
  9262. * @param effect The effect to be bound
  9263. * @param scene The scene the eyes position is used from
  9264. * @param variableName name of the shader variable that will hold the eye position
  9265. */
  9266. static BindEyePosition(effect: Effect, scene: Scene, variableName?: string): void;
  9267. /**
  9268. * Helps preparing the defines values about the UVs in used in the effect.
  9269. * UVs are shared as much as we can accross channels in the shaders.
  9270. * @param texture The texture we are preparing the UVs for
  9271. * @param defines The defines to update
  9272. * @param key The channel key "diffuse", "specular"... used in the shader
  9273. */
  9274. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  9275. /**
  9276. * Binds a texture matrix value to its corrsponding uniform
  9277. * @param texture The texture to bind the matrix for
  9278. * @param uniformBuffer The uniform buffer receivin the data
  9279. * @param key The channel key "diffuse", "specular"... used in the shader
  9280. */
  9281. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  9282. /**
  9283. * Gets the current status of the fog (should it be enabled?)
  9284. * @param mesh defines the mesh to evaluate for fog support
  9285. * @param scene defines the hosting scene
  9286. * @returns true if fog must be enabled
  9287. */
  9288. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  9289. /**
  9290. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  9291. * @param mesh defines the current mesh
  9292. * @param scene defines the current scene
  9293. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  9294. * @param pointsCloud defines if point cloud rendering has to be turned on
  9295. * @param fogEnabled defines if fog has to be turned on
  9296. * @param alphaTest defines if alpha testing has to be turned on
  9297. * @param defines defines the current list of defines
  9298. */
  9299. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  9300. /**
  9301. * Helper used to prepare the list of defines associated with frame values for shader compilation
  9302. * @param scene defines the current scene
  9303. * @param engine defines the current engine
  9304. * @param defines specifies the list of active defines
  9305. * @param useInstances defines if instances have to be turned on
  9306. * @param useClipPlane defines if clip plane have to be turned on
  9307. */
  9308. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  9309. /**
  9310. * Prepares the defines for bones
  9311. * @param mesh The mesh containing the geometry data we will draw
  9312. * @param defines The defines to update
  9313. */
  9314. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  9315. /**
  9316. * Prepares the defines for morph targets
  9317. * @param mesh The mesh containing the geometry data we will draw
  9318. * @param defines The defines to update
  9319. */
  9320. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  9321. /**
  9322. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  9323. * @param mesh The mesh containing the geometry data we will draw
  9324. * @param defines The defines to update
  9325. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  9326. * @param useBones Precise whether bones should be used or not (override mesh info)
  9327. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  9328. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  9329. * @returns false if defines are considered not dirty and have not been checked
  9330. */
  9331. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  9332. /**
  9333. * Prepares the defines related to multiview
  9334. * @param scene The scene we are intending to draw
  9335. * @param defines The defines to update
  9336. */
  9337. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  9338. /**
  9339. * Prepares the defines related to the light information passed in parameter
  9340. * @param scene The scene we are intending to draw
  9341. * @param mesh The mesh the effect is compiling for
  9342. * @param light The light the effect is compiling for
  9343. * @param lightIndex The index of the light
  9344. * @param defines The defines to update
  9345. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9346. * @param state Defines the current state regarding what is needed (normals, etc...)
  9347. */
  9348. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  9349. needNormals: boolean;
  9350. needRebuild: boolean;
  9351. shadowEnabled: boolean;
  9352. specularEnabled: boolean;
  9353. lightmapMode: boolean;
  9354. }): void;
  9355. /**
  9356. * Prepares the defines related to the light information passed in parameter
  9357. * @param scene The scene we are intending to draw
  9358. * @param mesh The mesh the effect is compiling for
  9359. * @param defines The defines to update
  9360. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9361. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  9362. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  9363. * @returns true if normals will be required for the rest of the effect
  9364. */
  9365. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  9366. /**
  9367. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  9368. * @param lightIndex defines the light index
  9369. * @param uniformsList The uniform list
  9370. * @param samplersList The sampler list
  9371. * @param projectedLightTexture defines if projected texture must be used
  9372. * @param uniformBuffersList defines an optional list of uniform buffers
  9373. */
  9374. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  9375. /**
  9376. * Prepares the uniforms and samplers list to be used in the effect
  9377. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  9378. * @param samplersList The sampler list
  9379. * @param defines The defines helping in the list generation
  9380. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  9381. */
  9382. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  9383. /**
  9384. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  9385. * @param defines The defines to update while falling back
  9386. * @param fallbacks The authorized effect fallbacks
  9387. * @param maxSimultaneousLights The maximum number of lights allowed
  9388. * @param rank the current rank of the Effect
  9389. * @returns The newly affected rank
  9390. */
  9391. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  9392. private static _TmpMorphInfluencers;
  9393. /**
  9394. * Prepares the list of attributes required for morph targets according to the effect defines.
  9395. * @param attribs The current list of supported attribs
  9396. * @param mesh The mesh to prepare the morph targets attributes for
  9397. * @param influencers The number of influencers
  9398. */
  9399. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  9400. /**
  9401. * Prepares the list of attributes required for morph targets according to the effect defines.
  9402. * @param attribs The current list of supported attribs
  9403. * @param mesh The mesh to prepare the morph targets attributes for
  9404. * @param defines The current Defines of the effect
  9405. */
  9406. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  9407. /**
  9408. * Prepares the list of attributes required for bones according to the effect defines.
  9409. * @param attribs The current list of supported attribs
  9410. * @param mesh The mesh to prepare the bones attributes for
  9411. * @param defines The current Defines of the effect
  9412. * @param fallbacks The current efffect fallback strategy
  9413. */
  9414. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  9415. /**
  9416. * Check and prepare the list of attributes required for instances according to the effect defines.
  9417. * @param attribs The current list of supported attribs
  9418. * @param defines The current MaterialDefines of the effect
  9419. */
  9420. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  9421. /**
  9422. * Add the list of attributes required for instances to the attribs array.
  9423. * @param attribs The current list of supported attribs
  9424. */
  9425. static PushAttributesForInstances(attribs: string[]): void;
  9426. /**
  9427. * Binds the light information to the effect.
  9428. * @param light The light containing the generator
  9429. * @param effect The effect we are binding the data to
  9430. * @param lightIndex The light index in the effect used to render
  9431. */
  9432. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9433. /**
  9434. * Binds the lights information from the scene to the effect for the given mesh.
  9435. * @param light Light to bind
  9436. * @param lightIndex Light index
  9437. * @param scene The scene where the light belongs to
  9438. * @param effect The effect we are binding the data to
  9439. * @param useSpecular Defines if specular is supported
  9440. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9441. */
  9442. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  9443. /**
  9444. * Binds the lights information from the scene to the effect for the given mesh.
  9445. * @param scene The scene the lights belongs to
  9446. * @param mesh The mesh we are binding the information to render
  9447. * @param effect The effect we are binding the data to
  9448. * @param defines The generated defines for the effect
  9449. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9450. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9451. */
  9452. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  9453. private static _tempFogColor;
  9454. /**
  9455. * Binds the fog information from the scene to the effect for the given mesh.
  9456. * @param scene The scene the lights belongs to
  9457. * @param mesh The mesh we are binding the information to render
  9458. * @param effect The effect we are binding the data to
  9459. * @param linearSpace Defines if the fog effect is applied in linear space
  9460. */
  9461. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9462. /**
  9463. * Binds the bones information from the mesh to the effect.
  9464. * @param mesh The mesh we are binding the information to render
  9465. * @param effect The effect we are binding the data to
  9466. */
  9467. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9468. /**
  9469. * Binds the morph targets information from the mesh to the effect.
  9470. * @param abstractMesh The mesh we are binding the information to render
  9471. * @param effect The effect we are binding the data to
  9472. */
  9473. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9474. /**
  9475. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9476. * @param defines The generated defines used in the effect
  9477. * @param effect The effect we are binding the data to
  9478. * @param scene The scene we are willing to render with logarithmic scale for
  9479. */
  9480. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9481. /**
  9482. * Binds the clip plane information from the scene to the effect.
  9483. * @param scene The scene the clip plane information are extracted from
  9484. * @param effect The effect we are binding the data to
  9485. */
  9486. static BindClipPlane(effect: Effect, scene: Scene): void;
  9487. }
  9488. }
  9489. declare module "babylonjs/Shaders/ShadersInclude/packingFunctions" {
  9490. /** @hidden */
  9491. export var packingFunctions: {
  9492. name: string;
  9493. shader: string;
  9494. };
  9495. }
  9496. declare module "babylonjs/Shaders/ShadersInclude/bayerDitherFunctions" {
  9497. /** @hidden */
  9498. export var bayerDitherFunctions: {
  9499. name: string;
  9500. shader: string;
  9501. };
  9502. }
  9503. declare module "babylonjs/Shaders/ShadersInclude/shadowMapFragmentDeclaration" {
  9504. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  9505. import "babylonjs/Shaders/ShadersInclude/bayerDitherFunctions";
  9506. /** @hidden */
  9507. export var shadowMapFragmentDeclaration: {
  9508. name: string;
  9509. shader: string;
  9510. };
  9511. }
  9512. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration" {
  9513. /** @hidden */
  9514. export var clipPlaneFragmentDeclaration: {
  9515. name: string;
  9516. shader: string;
  9517. };
  9518. }
  9519. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragment" {
  9520. /** @hidden */
  9521. export var clipPlaneFragment: {
  9522. name: string;
  9523. shader: string;
  9524. };
  9525. }
  9526. declare module "babylonjs/Shaders/ShadersInclude/shadowMapFragment" {
  9527. /** @hidden */
  9528. export var shadowMapFragment: {
  9529. name: string;
  9530. shader: string;
  9531. };
  9532. }
  9533. declare module "babylonjs/Shaders/shadowMap.fragment" {
  9534. import "babylonjs/Shaders/ShadersInclude/shadowMapFragmentDeclaration";
  9535. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  9536. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  9537. import "babylonjs/Shaders/ShadersInclude/shadowMapFragment";
  9538. /** @hidden */
  9539. export var shadowMapPixelShader: {
  9540. name: string;
  9541. shader: string;
  9542. };
  9543. }
  9544. declare module "babylonjs/Shaders/ShadersInclude/bonesDeclaration" {
  9545. /** @hidden */
  9546. export var bonesDeclaration: {
  9547. name: string;
  9548. shader: string;
  9549. };
  9550. }
  9551. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration" {
  9552. /** @hidden */
  9553. export var morphTargetsVertexGlobalDeclaration: {
  9554. name: string;
  9555. shader: string;
  9556. };
  9557. }
  9558. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration" {
  9559. /** @hidden */
  9560. export var morphTargetsVertexDeclaration: {
  9561. name: string;
  9562. shader: string;
  9563. };
  9564. }
  9565. declare module "babylonjs/Shaders/ShadersInclude/instancesDeclaration" {
  9566. /** @hidden */
  9567. export var instancesDeclaration: {
  9568. name: string;
  9569. shader: string;
  9570. };
  9571. }
  9572. declare module "babylonjs/Shaders/ShadersInclude/helperFunctions" {
  9573. /** @hidden */
  9574. export var helperFunctions: {
  9575. name: string;
  9576. shader: string;
  9577. };
  9578. }
  9579. declare module "babylonjs/Shaders/ShadersInclude/shadowMapVertexDeclaration" {
  9580. /** @hidden */
  9581. export var shadowMapVertexDeclaration: {
  9582. name: string;
  9583. shader: string;
  9584. };
  9585. }
  9586. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration" {
  9587. /** @hidden */
  9588. export var clipPlaneVertexDeclaration: {
  9589. name: string;
  9590. shader: string;
  9591. };
  9592. }
  9593. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertex" {
  9594. /** @hidden */
  9595. export var morphTargetsVertex: {
  9596. name: string;
  9597. shader: string;
  9598. };
  9599. }
  9600. declare module "babylonjs/Shaders/ShadersInclude/instancesVertex" {
  9601. /** @hidden */
  9602. export var instancesVertex: {
  9603. name: string;
  9604. shader: string;
  9605. };
  9606. }
  9607. declare module "babylonjs/Shaders/ShadersInclude/bonesVertex" {
  9608. /** @hidden */
  9609. export var bonesVertex: {
  9610. name: string;
  9611. shader: string;
  9612. };
  9613. }
  9614. declare module "babylonjs/Shaders/ShadersInclude/shadowMapVertexNormalBias" {
  9615. /** @hidden */
  9616. export var shadowMapVertexNormalBias: {
  9617. name: string;
  9618. shader: string;
  9619. };
  9620. }
  9621. declare module "babylonjs/Shaders/ShadersInclude/shadowMapVertexMetric" {
  9622. /** @hidden */
  9623. export var shadowMapVertexMetric: {
  9624. name: string;
  9625. shader: string;
  9626. };
  9627. }
  9628. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertex" {
  9629. /** @hidden */
  9630. export var clipPlaneVertex: {
  9631. name: string;
  9632. shader: string;
  9633. };
  9634. }
  9635. declare module "babylonjs/Shaders/shadowMap.vertex" {
  9636. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  9637. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  9638. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  9639. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  9640. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  9641. import "babylonjs/Shaders/ShadersInclude/shadowMapVertexDeclaration";
  9642. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  9643. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  9644. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  9645. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  9646. import "babylonjs/Shaders/ShadersInclude/shadowMapVertexNormalBias";
  9647. import "babylonjs/Shaders/ShadersInclude/shadowMapVertexMetric";
  9648. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  9649. /** @hidden */
  9650. export var shadowMapVertexShader: {
  9651. name: string;
  9652. shader: string;
  9653. };
  9654. }
  9655. declare module "babylonjs/Shaders/depthBoxBlur.fragment" {
  9656. /** @hidden */
  9657. export var depthBoxBlurPixelShader: {
  9658. name: string;
  9659. shader: string;
  9660. };
  9661. }
  9662. declare module "babylonjs/Shaders/ShadersInclude/shadowMapFragmentSoftTransparentShadow" {
  9663. /** @hidden */
  9664. export var shadowMapFragmentSoftTransparentShadow: {
  9665. name: string;
  9666. shader: string;
  9667. };
  9668. }
  9669. declare module "babylonjs/Culling/ray" {
  9670. import { DeepImmutable, Nullable, float } from "babylonjs/types";
  9671. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  9672. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9673. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  9674. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  9675. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  9676. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  9677. import { Plane } from "babylonjs/Maths/math.plane";
  9678. /**
  9679. * Class representing a ray with position and direction
  9680. */
  9681. export class Ray {
  9682. /** origin point */
  9683. origin: Vector3;
  9684. /** direction */
  9685. direction: Vector3;
  9686. /** length of the ray */
  9687. length: number;
  9688. private static readonly TmpVector3;
  9689. private _tmpRay;
  9690. /**
  9691. * Creates a new ray
  9692. * @param origin origin point
  9693. * @param direction direction
  9694. * @param length length of the ray
  9695. */
  9696. constructor(
  9697. /** origin point */
  9698. origin: Vector3,
  9699. /** direction */
  9700. direction: Vector3,
  9701. /** length of the ray */
  9702. length?: number);
  9703. /**
  9704. * Checks if the ray intersects a box
  9705. * This does not account for the ray lenght by design to improve perfs.
  9706. * @param minimum bound of the box
  9707. * @param maximum bound of the box
  9708. * @param intersectionTreshold extra extend to be added to the box in all direction
  9709. * @returns if the box was hit
  9710. */
  9711. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  9712. /**
  9713. * Checks if the ray intersects a box
  9714. * This does not account for the ray lenght by design to improve perfs.
  9715. * @param box the bounding box to check
  9716. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  9717. * @returns if the box was hit
  9718. */
  9719. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  9720. /**
  9721. * If the ray hits a sphere
  9722. * @param sphere the bounding sphere to check
  9723. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  9724. * @returns true if it hits the sphere
  9725. */
  9726. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  9727. /**
  9728. * If the ray hits a triange
  9729. * @param vertex0 triangle vertex
  9730. * @param vertex1 triangle vertex
  9731. * @param vertex2 triangle vertex
  9732. * @returns intersection information if hit
  9733. */
  9734. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  9735. /**
  9736. * Checks if ray intersects a plane
  9737. * @param plane the plane to check
  9738. * @returns the distance away it was hit
  9739. */
  9740. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  9741. /**
  9742. * Calculate the intercept of a ray on a given axis
  9743. * @param axis to check 'x' | 'y' | 'z'
  9744. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  9745. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  9746. */
  9747. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  9748. /**
  9749. * Checks if ray intersects a mesh
  9750. * @param mesh the mesh to check
  9751. * @param fastCheck defines if the first intersection will be used (and not the closest)
  9752. * @returns picking info of the intersecton
  9753. */
  9754. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  9755. /**
  9756. * Checks if ray intersects a mesh
  9757. * @param meshes the meshes to check
  9758. * @param fastCheck defines if the first intersection will be used (and not the closest)
  9759. * @param results array to store result in
  9760. * @returns Array of picking infos
  9761. */
  9762. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  9763. private _comparePickingInfo;
  9764. private static smallnum;
  9765. private static rayl;
  9766. /**
  9767. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  9768. * @param sega the first point of the segment to test the intersection against
  9769. * @param segb the second point of the segment to test the intersection against
  9770. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  9771. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  9772. */
  9773. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  9774. /**
  9775. * Update the ray from viewport position
  9776. * @param x position
  9777. * @param y y position
  9778. * @param viewportWidth viewport width
  9779. * @param viewportHeight viewport height
  9780. * @param world world matrix
  9781. * @param view view matrix
  9782. * @param projection projection matrix
  9783. * @returns this ray updated
  9784. */
  9785. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  9786. /**
  9787. * Creates a ray with origin and direction of 0,0,0
  9788. * @returns the new ray
  9789. */
  9790. static Zero(): Ray;
  9791. /**
  9792. * Creates a new ray from screen space and viewport
  9793. * @param x position
  9794. * @param y y position
  9795. * @param viewportWidth viewport width
  9796. * @param viewportHeight viewport height
  9797. * @param world world matrix
  9798. * @param view view matrix
  9799. * @param projection projection matrix
  9800. * @returns new ray
  9801. */
  9802. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  9803. /**
  9804. * Function will create a new transformed ray starting from origin and ending at the end point. Ray's length will be set, and ray will be
  9805. * transformed to the given world matrix.
  9806. * @param origin The origin point
  9807. * @param end The end point
  9808. * @param world a matrix to transform the ray to. Default is the identity matrix.
  9809. * @returns the new ray
  9810. */
  9811. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  9812. /**
  9813. * Transforms a ray by a matrix
  9814. * @param ray ray to transform
  9815. * @param matrix matrix to apply
  9816. * @returns the resulting new ray
  9817. */
  9818. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  9819. /**
  9820. * Transforms a ray by a matrix
  9821. * @param ray ray to transform
  9822. * @param matrix matrix to apply
  9823. * @param result ray to store result in
  9824. */
  9825. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  9826. /**
  9827. * Unproject a ray from screen space to object space
  9828. * @param sourceX defines the screen space x coordinate to use
  9829. * @param sourceY defines the screen space y coordinate to use
  9830. * @param viewportWidth defines the current width of the viewport
  9831. * @param viewportHeight defines the current height of the viewport
  9832. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  9833. * @param view defines the view matrix to use
  9834. * @param projection defines the projection matrix to use
  9835. */
  9836. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  9837. }
  9838. /**
  9839. * Type used to define predicate used to select faces when a mesh intersection is detected
  9840. */
  9841. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  9842. module "babylonjs/scene" {
  9843. interface Scene {
  9844. /** @hidden */
  9845. _tempPickingRay: Nullable<Ray>;
  9846. /** @hidden */
  9847. _cachedRayForTransform: Ray;
  9848. /** @hidden */
  9849. _pickWithRayInverseMatrix: Matrix;
  9850. /** @hidden */
  9851. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  9852. /** @hidden */
  9853. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  9854. }
  9855. }
  9856. }
  9857. declare module "babylonjs/sceneComponent" {
  9858. import { Scene } from "babylonjs/scene";
  9859. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9860. import { SubMesh } from "babylonjs/Meshes/subMesh";
  9861. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  9862. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  9863. import { Nullable } from "babylonjs/types";
  9864. import { Camera } from "babylonjs/Cameras/camera";
  9865. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  9866. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  9867. import { AbstractScene } from "babylonjs/abstractScene";
  9868. import { Mesh } from "babylonjs/Meshes/mesh";
  9869. /**
  9870. * Groups all the scene component constants in one place to ease maintenance.
  9871. * @hidden
  9872. */
  9873. export class SceneComponentConstants {
  9874. static readonly NAME_EFFECTLAYER: string;
  9875. static readonly NAME_LAYER: string;
  9876. static readonly NAME_LENSFLARESYSTEM: string;
  9877. static readonly NAME_BOUNDINGBOXRENDERER: string;
  9878. static readonly NAME_PARTICLESYSTEM: string;
  9879. static readonly NAME_GAMEPAD: string;
  9880. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  9881. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  9882. static readonly NAME_DEPTHRENDERER: string;
  9883. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  9884. static readonly NAME_SPRITE: string;
  9885. static readonly NAME_OUTLINERENDERER: string;
  9886. static readonly NAME_PROCEDURALTEXTURE: string;
  9887. static readonly NAME_SHADOWGENERATOR: string;
  9888. static readonly NAME_OCTREE: string;
  9889. static readonly NAME_PHYSICSENGINE: string;
  9890. static readonly NAME_AUDIO: string;
  9891. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  9892. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  9893. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  9894. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  9895. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  9896. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  9897. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  9898. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  9899. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  9900. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  9901. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  9902. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  9903. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  9904. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  9905. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  9906. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  9907. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  9908. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  9909. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  9910. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  9911. static readonly STEP_AFTERRENDER_AUDIO: number;
  9912. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  9913. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  9914. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  9915. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  9916. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  9917. static readonly STEP_POINTERMOVE_SPRITE: number;
  9918. static readonly STEP_POINTERDOWN_SPRITE: number;
  9919. static readonly STEP_POINTERUP_SPRITE: number;
  9920. }
  9921. /**
  9922. * This represents a scene component.
  9923. *
  9924. * This is used to decouple the dependency the scene is having on the different workloads like
  9925. * layers, post processes...
  9926. */
  9927. export interface ISceneComponent {
  9928. /**
  9929. * The name of the component. Each component must have a unique name.
  9930. */
  9931. name: string;
  9932. /**
  9933. * The scene the component belongs to.
  9934. */
  9935. scene: Scene;
  9936. /**
  9937. * Register the component to one instance of a scene.
  9938. */
  9939. register(): void;
  9940. /**
  9941. * Rebuilds the elements related to this component in case of
  9942. * context lost for instance.
  9943. */
  9944. rebuild(): void;
  9945. /**
  9946. * Disposes the component and the associated ressources.
  9947. */
  9948. dispose(): void;
  9949. }
  9950. /**
  9951. * This represents a SERIALIZABLE scene component.
  9952. *
  9953. * This extends Scene Component to add Serialization methods on top.
  9954. */
  9955. export interface ISceneSerializableComponent extends ISceneComponent {
  9956. /**
  9957. * Adds all the elements from the container to the scene
  9958. * @param container the container holding the elements
  9959. */
  9960. addFromContainer(container: AbstractScene): void;
  9961. /**
  9962. * Removes all the elements in the container from the scene
  9963. * @param container contains the elements to remove
  9964. * @param dispose if the removed element should be disposed (default: false)
  9965. */
  9966. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  9967. /**
  9968. * Serializes the component data to the specified json object
  9969. * @param serializationObject The object to serialize to
  9970. */
  9971. serialize(serializationObject: any): void;
  9972. }
  9973. /**
  9974. * Strong typing of a Mesh related stage step action
  9975. */
  9976. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  9977. /**
  9978. * Strong typing of a Evaluate Sub Mesh related stage step action
  9979. */
  9980. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  9981. /**
  9982. * Strong typing of a Active Mesh related stage step action
  9983. */
  9984. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  9985. /**
  9986. * Strong typing of a Camera related stage step action
  9987. */
  9988. export type CameraStageAction = (camera: Camera) => void;
  9989. /**
  9990. * Strong typing of a Camera Frame buffer related stage step action
  9991. */
  9992. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  9993. /**
  9994. * Strong typing of a Render Target related stage step action
  9995. */
  9996. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  9997. /**
  9998. * Strong typing of a RenderingGroup related stage step action
  9999. */
  10000. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  10001. /**
  10002. * Strong typing of a Mesh Render related stage step action
  10003. */
  10004. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  10005. /**
  10006. * Strong typing of a simple stage step action
  10007. */
  10008. export type SimpleStageAction = () => void;
  10009. /**
  10010. * Strong typing of a render target action.
  10011. */
  10012. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  10013. /**
  10014. * Strong typing of a pointer move action.
  10015. */
  10016. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  10017. /**
  10018. * Strong typing of a pointer up/down action.
  10019. */
  10020. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  10021. /**
  10022. * Representation of a stage in the scene (Basically a list of ordered steps)
  10023. * @hidden
  10024. */
  10025. export class Stage<T extends Function> extends Array<{
  10026. index: number;
  10027. component: ISceneComponent;
  10028. action: T;
  10029. }> {
  10030. /**
  10031. * Hide ctor from the rest of the world.
  10032. * @param items The items to add.
  10033. */
  10034. private constructor();
  10035. /**
  10036. * Creates a new Stage.
  10037. * @returns A new instance of a Stage
  10038. */
  10039. static Create<T extends Function>(): Stage<T>;
  10040. /**
  10041. * Registers a step in an ordered way in the targeted stage.
  10042. * @param index Defines the position to register the step in
  10043. * @param component Defines the component attached to the step
  10044. * @param action Defines the action to launch during the step
  10045. */
  10046. registerStep(index: number, component: ISceneComponent, action: T): void;
  10047. /**
  10048. * Clears all the steps from the stage.
  10049. */
  10050. clear(): void;
  10051. }
  10052. }
  10053. declare module "babylonjs/Sprites/spriteSceneComponent" {
  10054. import { Nullable } from "babylonjs/types";
  10055. import { Observable } from "babylonjs/Misc/observable";
  10056. import { Scene } from "babylonjs/scene";
  10057. import { Sprite } from "babylonjs/Sprites/sprite";
  10058. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  10059. import { Ray } from "babylonjs/Culling/ray";
  10060. import { Camera } from "babylonjs/Cameras/camera";
  10061. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  10062. import { ISceneComponent } from "babylonjs/sceneComponent";
  10063. module "babylonjs/scene" {
  10064. interface Scene {
  10065. /** @hidden */
  10066. _pointerOverSprite: Nullable<Sprite>;
  10067. /** @hidden */
  10068. _pickedDownSprite: Nullable<Sprite>;
  10069. /** @hidden */
  10070. _tempSpritePickingRay: Nullable<Ray>;
  10071. /**
  10072. * All of the sprite managers added to this scene
  10073. * @see http://doc.babylonjs.com/babylon101/sprites
  10074. */
  10075. spriteManagers: Array<ISpriteManager>;
  10076. /**
  10077. * An event triggered when sprites rendering is about to start
  10078. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  10079. */
  10080. onBeforeSpritesRenderingObservable: Observable<Scene>;
  10081. /**
  10082. * An event triggered when sprites rendering is done
  10083. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  10084. */
  10085. onAfterSpritesRenderingObservable: Observable<Scene>;
  10086. /** @hidden */
  10087. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10088. /** Launch a ray to try to pick a sprite in the scene
  10089. * @param x position on screen
  10090. * @param y position on screen
  10091. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  10092. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10093. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  10094. * @returns a PickingInfo
  10095. */
  10096. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10097. /** Use the given ray to pick a sprite in the scene
  10098. * @param ray The ray (in world space) to use to pick meshes
  10099. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  10100. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10101. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  10102. * @returns a PickingInfo
  10103. */
  10104. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10105. /** @hidden */
  10106. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10107. /** Launch a ray to try to pick sprites in the scene
  10108. * @param x position on screen
  10109. * @param y position on screen
  10110. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  10111. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  10112. * @returns a PickingInfo array
  10113. */
  10114. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10115. /** Use the given ray to pick sprites in the scene
  10116. * @param ray The ray (in world space) to use to pick meshes
  10117. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  10118. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  10119. * @returns a PickingInfo array
  10120. */
  10121. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10122. /**
  10123. * Force the sprite under the pointer
  10124. * @param sprite defines the sprite to use
  10125. */
  10126. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  10127. /**
  10128. * Gets the sprite under the pointer
  10129. * @returns a Sprite or null if no sprite is under the pointer
  10130. */
  10131. getPointerOverSprite(): Nullable<Sprite>;
  10132. }
  10133. }
  10134. /**
  10135. * Defines the sprite scene component responsible to manage sprites
  10136. * in a given scene.
  10137. */
  10138. export class SpriteSceneComponent implements ISceneComponent {
  10139. /**
  10140. * The component name helpfull to identify the component in the list of scene components.
  10141. */
  10142. readonly name: string;
  10143. /**
  10144. * The scene the component belongs to.
  10145. */
  10146. scene: Scene;
  10147. /** @hidden */
  10148. private _spritePredicate;
  10149. /**
  10150. * Creates a new instance of the component for the given scene
  10151. * @param scene Defines the scene to register the component in
  10152. */
  10153. constructor(scene: Scene);
  10154. /**
  10155. * Registers the component in a given scene
  10156. */
  10157. register(): void;
  10158. /**
  10159. * Rebuilds the elements related to this component in case of
  10160. * context lost for instance.
  10161. */
  10162. rebuild(): void;
  10163. /**
  10164. * Disposes the component and the associated ressources.
  10165. */
  10166. dispose(): void;
  10167. private _pickSpriteButKeepRay;
  10168. private _pointerMove;
  10169. private _pointerDown;
  10170. private _pointerUp;
  10171. }
  10172. }
  10173. declare module "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration" {
  10174. /** @hidden */
  10175. export var fogFragmentDeclaration: {
  10176. name: string;
  10177. shader: string;
  10178. };
  10179. }
  10180. declare module "babylonjs/Shaders/ShadersInclude/fogFragment" {
  10181. /** @hidden */
  10182. export var fogFragment: {
  10183. name: string;
  10184. shader: string;
  10185. };
  10186. }
  10187. declare module "babylonjs/Shaders/sprites.fragment" {
  10188. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  10189. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  10190. /** @hidden */
  10191. export var spritesPixelShader: {
  10192. name: string;
  10193. shader: string;
  10194. };
  10195. }
  10196. declare module "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration" {
  10197. /** @hidden */
  10198. export var fogVertexDeclaration: {
  10199. name: string;
  10200. shader: string;
  10201. };
  10202. }
  10203. declare module "babylonjs/Shaders/sprites.vertex" {
  10204. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  10205. /** @hidden */
  10206. export var spritesVertexShader: {
  10207. name: string;
  10208. shader: string;
  10209. };
  10210. }
  10211. declare module "babylonjs/Sprites/spriteManager" {
  10212. import { IDisposable, Scene } from "babylonjs/scene";
  10213. import { Nullable } from "babylonjs/types";
  10214. import { Observable } from "babylonjs/Misc/observable";
  10215. import { Sprite } from "babylonjs/Sprites/sprite";
  10216. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  10217. import { Camera } from "babylonjs/Cameras/camera";
  10218. import { Texture } from "babylonjs/Materials/Textures/texture";
  10219. import "babylonjs/Shaders/sprites.fragment";
  10220. import "babylonjs/Shaders/sprites.vertex";
  10221. import { Ray } from "babylonjs/Culling/ray";
  10222. /**
  10223. * Defines the minimum interface to fullfil in order to be a sprite manager.
  10224. */
  10225. export interface ISpriteManager extends IDisposable {
  10226. /**
  10227. * Restricts the camera to viewing objects with the same layerMask.
  10228. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  10229. */
  10230. layerMask: number;
  10231. /**
  10232. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  10233. */
  10234. isPickable: boolean;
  10235. /**
  10236. * Specifies the rendering group id for this mesh (0 by default)
  10237. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  10238. */
  10239. renderingGroupId: number;
  10240. /**
  10241. * Defines the list of sprites managed by the manager.
  10242. */
  10243. sprites: Array<Sprite>;
  10244. /**
  10245. * Tests the intersection of a sprite with a specific ray.
  10246. * @param ray The ray we are sending to test the collision
  10247. * @param camera The camera space we are sending rays in
  10248. * @param predicate A predicate allowing excluding sprites from the list of object to test
  10249. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10250. * @returns picking info or null.
  10251. */
  10252. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  10253. /**
  10254. * Intersects the sprites with a ray
  10255. * @param ray defines the ray to intersect with
  10256. * @param camera defines the current active camera
  10257. * @param predicate defines a predicate used to select candidate sprites
  10258. * @returns null if no hit or a PickingInfo array
  10259. */
  10260. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  10261. /**
  10262. * Renders the list of sprites on screen.
  10263. */
  10264. render(): void;
  10265. }
  10266. /**
  10267. * Class used to manage multiple sprites on the same spritesheet
  10268. * @see http://doc.babylonjs.com/babylon101/sprites
  10269. */
  10270. export class SpriteManager implements ISpriteManager {
  10271. /** defines the manager's name */
  10272. name: string;
  10273. /** Gets the list of sprites */
  10274. sprites: Sprite[];
  10275. /** Gets or sets the rendering group id (0 by default) */
  10276. renderingGroupId: number;
  10277. /** Gets or sets camera layer mask */
  10278. layerMask: number;
  10279. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  10280. fogEnabled: boolean;
  10281. /** Gets or sets a boolean indicating if the sprites are pickable */
  10282. isPickable: boolean;
  10283. /** Defines the default width of a cell in the spritesheet */
  10284. cellWidth: number;
  10285. /** Defines the default height of a cell in the spritesheet */
  10286. cellHeight: number;
  10287. /** Associative array from JSON sprite data file */
  10288. private _cellData;
  10289. /** Array of sprite names from JSON sprite data file */
  10290. private _spriteMap;
  10291. /** True when packed cell data from JSON file is ready*/
  10292. private _packedAndReady;
  10293. private _textureContent;
  10294. /**
  10295. * An event triggered when the manager is disposed.
  10296. */
  10297. onDisposeObservable: Observable<SpriteManager>;
  10298. private _onDisposeObserver;
  10299. /**
  10300. * Callback called when the manager is disposed
  10301. */
  10302. set onDispose(callback: () => void);
  10303. private _capacity;
  10304. private _fromPacked;
  10305. private _spriteTexture;
  10306. private _epsilon;
  10307. private _scene;
  10308. private _vertexData;
  10309. private _buffer;
  10310. private _vertexBuffers;
  10311. private _indexBuffer;
  10312. private _effectBase;
  10313. private _effectFog;
  10314. /**
  10315. * Gets or sets the spritesheet texture
  10316. */
  10317. get texture(): Texture;
  10318. set texture(value: Texture);
  10319. private _blendMode;
  10320. /**
  10321. * Blend mode use to render the particle, it can be any of
  10322. * the static Constants.ALPHA_x properties provided in this class.
  10323. * Default value is Constants.ALPHA_COMBINE
  10324. */
  10325. get blendMode(): number;
  10326. set blendMode(blendMode: number);
  10327. /** Disables writing to the depth buffer when rendering the sprites.
  10328. * It can be handy to disable depth writing when using textures without alpha channel
  10329. * and setting some specific blend modes.
  10330. */
  10331. disableDepthWrite: boolean;
  10332. /**
  10333. * Creates a new sprite manager
  10334. * @param name defines the manager's name
  10335. * @param imgUrl defines the sprite sheet url
  10336. * @param capacity defines the maximum allowed number of sprites
  10337. * @param cellSize defines the size of a sprite cell
  10338. * @param scene defines the hosting scene
  10339. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  10340. * @param samplingMode defines the smapling mode to use with spritesheet
  10341. * @param fromPacked set to false; do not alter
  10342. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  10343. */
  10344. constructor(
  10345. /** defines the manager's name */
  10346. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  10347. private _makePacked;
  10348. private _appendSpriteVertex;
  10349. private _checkTextureAlpha;
  10350. /**
  10351. * Intersects the sprites with a ray
  10352. * @param ray defines the ray to intersect with
  10353. * @param camera defines the current active camera
  10354. * @param predicate defines a predicate used to select candidate sprites
  10355. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  10356. * @returns null if no hit or a PickingInfo
  10357. */
  10358. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  10359. /**
  10360. * Intersects the sprites with a ray
  10361. * @param ray defines the ray to intersect with
  10362. * @param camera defines the current active camera
  10363. * @param predicate defines a predicate used to select candidate sprites
  10364. * @returns null if no hit or a PickingInfo array
  10365. */
  10366. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  10367. /**
  10368. * Render all child sprites
  10369. */
  10370. render(): void;
  10371. /**
  10372. * Release associated resources
  10373. */
  10374. dispose(): void;
  10375. }
  10376. }
  10377. declare module "babylonjs/Misc/gradients" {
  10378. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  10379. /** Interface used by value gradients (color, factor, ...) */
  10380. export interface IValueGradient {
  10381. /**
  10382. * Gets or sets the gradient value (between 0 and 1)
  10383. */
  10384. gradient: number;
  10385. }
  10386. /** Class used to store color4 gradient */
  10387. export class ColorGradient implements IValueGradient {
  10388. /**
  10389. * Gets or sets the gradient value (between 0 and 1)
  10390. */
  10391. gradient: number;
  10392. /**
  10393. * Gets or sets first associated color
  10394. */
  10395. color1: Color4;
  10396. /**
  10397. * Gets or sets second associated color
  10398. */
  10399. color2?: Color4 | undefined;
  10400. /**
  10401. * Creates a new color4 gradient
  10402. * @param gradient gets or sets the gradient value (between 0 and 1)
  10403. * @param color1 gets or sets first associated color
  10404. * @param color2 gets or sets first second color
  10405. */
  10406. constructor(
  10407. /**
  10408. * Gets or sets the gradient value (between 0 and 1)
  10409. */
  10410. gradient: number,
  10411. /**
  10412. * Gets or sets first associated color
  10413. */
  10414. color1: Color4,
  10415. /**
  10416. * Gets or sets second associated color
  10417. */
  10418. color2?: Color4 | undefined);
  10419. /**
  10420. * Will get a color picked randomly between color1 and color2.
  10421. * If color2 is undefined then color1 will be used
  10422. * @param result defines the target Color4 to store the result in
  10423. */
  10424. getColorToRef(result: Color4): void;
  10425. }
  10426. /** Class used to store color 3 gradient */
  10427. export class Color3Gradient implements IValueGradient {
  10428. /**
  10429. * Gets or sets the gradient value (between 0 and 1)
  10430. */
  10431. gradient: number;
  10432. /**
  10433. * Gets or sets the associated color
  10434. */
  10435. color: Color3;
  10436. /**
  10437. * Creates a new color3 gradient
  10438. * @param gradient gets or sets the gradient value (between 0 and 1)
  10439. * @param color gets or sets associated color
  10440. */
  10441. constructor(
  10442. /**
  10443. * Gets or sets the gradient value (between 0 and 1)
  10444. */
  10445. gradient: number,
  10446. /**
  10447. * Gets or sets the associated color
  10448. */
  10449. color: Color3);
  10450. }
  10451. /** Class used to store factor gradient */
  10452. export class FactorGradient implements IValueGradient {
  10453. /**
  10454. * Gets or sets the gradient value (between 0 and 1)
  10455. */
  10456. gradient: number;
  10457. /**
  10458. * Gets or sets first associated factor
  10459. */
  10460. factor1: number;
  10461. /**
  10462. * Gets or sets second associated factor
  10463. */
  10464. factor2?: number | undefined;
  10465. /**
  10466. * Creates a new factor gradient
  10467. * @param gradient gets or sets the gradient value (between 0 and 1)
  10468. * @param factor1 gets or sets first associated factor
  10469. * @param factor2 gets or sets second associated factor
  10470. */
  10471. constructor(
  10472. /**
  10473. * Gets or sets the gradient value (between 0 and 1)
  10474. */
  10475. gradient: number,
  10476. /**
  10477. * Gets or sets first associated factor
  10478. */
  10479. factor1: number,
  10480. /**
  10481. * Gets or sets second associated factor
  10482. */
  10483. factor2?: number | undefined);
  10484. /**
  10485. * Will get a number picked randomly between factor1 and factor2.
  10486. * If factor2 is undefined then factor1 will be used
  10487. * @returns the picked number
  10488. */
  10489. getFactor(): number;
  10490. }
  10491. /**
  10492. * Helper used to simplify some generic gradient tasks
  10493. */
  10494. export class GradientHelper {
  10495. /**
  10496. * Gets the current gradient from an array of IValueGradient
  10497. * @param ratio defines the current ratio to get
  10498. * @param gradients defines the array of IValueGradient
  10499. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  10500. */
  10501. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  10502. }
  10503. }
  10504. declare module "babylonjs/Maths/math.size" {
  10505. /**
  10506. * Interface for the size containing width and height
  10507. */
  10508. export interface ISize {
  10509. /**
  10510. * Width
  10511. */
  10512. width: number;
  10513. /**
  10514. * Heighht
  10515. */
  10516. height: number;
  10517. }
  10518. /**
  10519. * Size containing widht and height
  10520. */
  10521. export class Size implements ISize {
  10522. /**
  10523. * Width
  10524. */
  10525. width: number;
  10526. /**
  10527. * Height
  10528. */
  10529. height: number;
  10530. /**
  10531. * Creates a Size object from the given width and height (floats).
  10532. * @param width width of the new size
  10533. * @param height height of the new size
  10534. */
  10535. constructor(width: number, height: number);
  10536. /**
  10537. * Returns a string with the Size width and height
  10538. * @returns a string with the Size width and height
  10539. */
  10540. toString(): string;
  10541. /**
  10542. * "Size"
  10543. * @returns the string "Size"
  10544. */
  10545. getClassName(): string;
  10546. /**
  10547. * Returns the Size hash code.
  10548. * @returns a hash code for a unique width and height
  10549. */
  10550. getHashCode(): number;
  10551. /**
  10552. * Updates the current size from the given one.
  10553. * @param src the given size
  10554. */
  10555. copyFrom(src: Size): void;
  10556. /**
  10557. * Updates in place the current Size from the given floats.
  10558. * @param width width of the new size
  10559. * @param height height of the new size
  10560. * @returns the updated Size.
  10561. */
  10562. copyFromFloats(width: number, height: number): Size;
  10563. /**
  10564. * Updates in place the current Size from the given floats.
  10565. * @param width width to set
  10566. * @param height height to set
  10567. * @returns the updated Size.
  10568. */
  10569. set(width: number, height: number): Size;
  10570. /**
  10571. * Multiplies the width and height by numbers
  10572. * @param w factor to multiple the width by
  10573. * @param h factor to multiple the height by
  10574. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  10575. */
  10576. multiplyByFloats(w: number, h: number): Size;
  10577. /**
  10578. * Clones the size
  10579. * @returns a new Size copied from the given one.
  10580. */
  10581. clone(): Size;
  10582. /**
  10583. * True if the current Size and the given one width and height are strictly equal.
  10584. * @param other the other size to compare against
  10585. * @returns True if the current Size and the given one width and height are strictly equal.
  10586. */
  10587. equals(other: Size): boolean;
  10588. /**
  10589. * The surface of the Size : width * height (float).
  10590. */
  10591. get surface(): number;
  10592. /**
  10593. * Create a new size of zero
  10594. * @returns a new Size set to (0.0, 0.0)
  10595. */
  10596. static Zero(): Size;
  10597. /**
  10598. * Sums the width and height of two sizes
  10599. * @param otherSize size to add to this size
  10600. * @returns a new Size set as the addition result of the current Size and the given one.
  10601. */
  10602. add(otherSize: Size): Size;
  10603. /**
  10604. * Subtracts the width and height of two
  10605. * @param otherSize size to subtract to this size
  10606. * @returns a new Size set as the subtraction result of the given one from the current Size.
  10607. */
  10608. subtract(otherSize: Size): Size;
  10609. /**
  10610. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  10611. * @param start starting size to lerp between
  10612. * @param end end size to lerp between
  10613. * @param amount amount to lerp between the start and end values
  10614. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  10615. */
  10616. static Lerp(start: Size, end: Size, amount: number): Size;
  10617. }
  10618. }
  10619. declare module "babylonjs/Engines/Extensions/engine.dynamicTexture" {
  10620. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  10621. import { Nullable } from "babylonjs/types";
  10622. module "babylonjs/Engines/thinEngine" {
  10623. interface ThinEngine {
  10624. /**
  10625. * Creates a dynamic texture
  10626. * @param width defines the width of the texture
  10627. * @param height defines the height of the texture
  10628. * @param generateMipMaps defines if the engine should generate the mip levels
  10629. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  10630. * @returns the dynamic texture inside an InternalTexture
  10631. */
  10632. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  10633. /**
  10634. * Update the content of a dynamic texture
  10635. * @param texture defines the texture to update
  10636. * @param canvas defines the canvas containing the source
  10637. * @param invertY defines if data must be stored with Y axis inverted
  10638. * @param premulAlpha defines if alpha is stored as premultiplied
  10639. * @param format defines the format of the data
  10640. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  10641. */
  10642. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  10643. }
  10644. }
  10645. }
  10646. declare module "babylonjs/Misc/canvasGenerator" {
  10647. /**
  10648. * Helper class used to generate a canvas to manipulate images
  10649. */
  10650. export class CanvasGenerator {
  10651. /**
  10652. * Create a new canvas (or offscreen canvas depending on the context)
  10653. * @param width defines the expected width
  10654. * @param height defines the expected height
  10655. * @return a new canvas or offscreen canvas
  10656. */
  10657. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  10658. }
  10659. }
  10660. declare module "babylonjs/Materials/Textures/dynamicTexture" {
  10661. import { Scene } from "babylonjs/scene";
  10662. import { Texture } from "babylonjs/Materials/Textures/texture";
  10663. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  10664. /**
  10665. * A class extending Texture allowing drawing on a texture
  10666. * @see http://doc.babylonjs.com/how_to/dynamictexture
  10667. */
  10668. export class DynamicTexture extends Texture {
  10669. private _generateMipMaps;
  10670. private _canvas;
  10671. private _context;
  10672. /**
  10673. * Creates a DynamicTexture
  10674. * @param name defines the name of the texture
  10675. * @param options provides 3 alternatives for width and height of texture, a canvas, object with width and height properties, number for both width and height
  10676. * @param scene defines the scene where you want the texture
  10677. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  10678. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  10679. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  10680. */
  10681. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  10682. /**
  10683. * Get the current class name of the texture useful for serialization or dynamic coding.
  10684. * @returns "DynamicTexture"
  10685. */
  10686. getClassName(): string;
  10687. /**
  10688. * Gets the current state of canRescale
  10689. */
  10690. get canRescale(): boolean;
  10691. private _recreate;
  10692. /**
  10693. * Scales the texture
  10694. * @param ratio the scale factor to apply to both width and height
  10695. */
  10696. scale(ratio: number): void;
  10697. /**
  10698. * Resizes the texture
  10699. * @param width the new width
  10700. * @param height the new height
  10701. */
  10702. scaleTo(width: number, height: number): void;
  10703. /**
  10704. * Gets the context of the canvas used by the texture
  10705. * @returns the canvas context of the dynamic texture
  10706. */
  10707. getContext(): CanvasRenderingContext2D;
  10708. /**
  10709. * Clears the texture
  10710. */
  10711. clear(): void;
  10712. /**
  10713. * Updates the texture
  10714. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  10715. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  10716. */
  10717. update(invertY?: boolean, premulAlpha?: boolean): void;
  10718. /**
  10719. * Draws text onto the texture
  10720. * @param text defines the text to be drawn
  10721. * @param x defines the placement of the text from the left
  10722. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  10723. * @param font defines the font to be used with font-style, font-size, font-name
  10724. * @param color defines the color used for the text
  10725. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  10726. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  10727. * @param update defines whether texture is immediately update (default is true)
  10728. */
  10729. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, clearColor: string, invertY?: boolean, update?: boolean): void;
  10730. /**
  10731. * Clones the texture
  10732. * @returns the clone of the texture.
  10733. */
  10734. clone(): DynamicTexture;
  10735. /**
  10736. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  10737. * @returns a serialized dynamic texture object
  10738. */
  10739. serialize(): any;
  10740. /** @hidden */
  10741. _rebuild(): void;
  10742. }
  10743. }
  10744. declare module "babylonjs/Engines/Extensions/engine.rawTexture" {
  10745. import { Nullable } from "babylonjs/types";
  10746. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  10747. import { Scene } from "babylonjs/scene";
  10748. module "babylonjs/Engines/thinEngine" {
  10749. interface ThinEngine {
  10750. /**
  10751. * Creates a raw texture
  10752. * @param data defines the data to store in the texture
  10753. * @param width defines the width of the texture
  10754. * @param height defines the height of the texture
  10755. * @param format defines the format of the data
  10756. * @param generateMipMaps defines if the engine should generate the mip levels
  10757. * @param invertY defines if data must be stored with Y axis inverted
  10758. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  10759. * @param compression defines the compression used (null by default)
  10760. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10761. * @returns the raw texture inside an InternalTexture
  10762. */
  10763. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  10764. /**
  10765. * Update a raw texture
  10766. * @param texture defines the texture to update
  10767. * @param data defines the data to store in the texture
  10768. * @param format defines the format of the data
  10769. * @param invertY defines if data must be stored with Y axis inverted
  10770. */
  10771. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  10772. /**
  10773. * Update a raw texture
  10774. * @param texture defines the texture to update
  10775. * @param data defines the data to store in the texture
  10776. * @param format defines the format of the data
  10777. * @param invertY defines if data must be stored with Y axis inverted
  10778. * @param compression defines the compression used (null by default)
  10779. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10780. */
  10781. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  10782. /**
  10783. * Creates a new raw cube texture
  10784. * @param data defines the array of data to use to create each face
  10785. * @param size defines the size of the textures
  10786. * @param format defines the format of the data
  10787. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  10788. * @param generateMipMaps defines if the engine should generate the mip levels
  10789. * @param invertY defines if data must be stored with Y axis inverted
  10790. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  10791. * @param compression defines the compression used (null by default)
  10792. * @returns the cube texture as an InternalTexture
  10793. */
  10794. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  10795. /**
  10796. * Update a raw cube texture
  10797. * @param texture defines the texture to udpdate
  10798. * @param data defines the data to store
  10799. * @param format defines the data format
  10800. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10801. * @param invertY defines if data must be stored with Y axis inverted
  10802. */
  10803. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  10804. /**
  10805. * Update a raw cube texture
  10806. * @param texture defines the texture to udpdate
  10807. * @param data defines the data to store
  10808. * @param format defines the data format
  10809. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10810. * @param invertY defines if data must be stored with Y axis inverted
  10811. * @param compression defines the compression used (null by default)
  10812. */
  10813. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  10814. /**
  10815. * Update a raw cube texture
  10816. * @param texture defines the texture to udpdate
  10817. * @param data defines the data to store
  10818. * @param format defines the data format
  10819. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10820. * @param invertY defines if data must be stored with Y axis inverted
  10821. * @param compression defines the compression used (null by default)
  10822. * @param level defines which level of the texture to update
  10823. */
  10824. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  10825. /**
  10826. * Creates a new raw cube texture from a specified url
  10827. * @param url defines the url where the data is located
  10828. * @param scene defines the current scene
  10829. * @param size defines the size of the textures
  10830. * @param format defines the format of the data
  10831. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  10832. * @param noMipmap defines if the engine should avoid generating the mip levels
  10833. * @param callback defines a callback used to extract texture data from loaded data
  10834. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  10835. * @param onLoad defines a callback called when texture is loaded
  10836. * @param onError defines a callback called if there is an error
  10837. * @returns the cube texture as an InternalTexture
  10838. */
  10839. createRawCubeTextureFromUrl(url: string, scene: Nullable<Scene>, size: number, format: number, type: number, noMipmap: boolean, callback: (ArrayBuffer: ArrayBuffer) => Nullable<ArrayBufferView[]>, mipmapGenerator: Nullable<((faces: ArrayBufferView[]) => ArrayBufferView[][])>, onLoad: Nullable<() => void>, onError: Nullable<(message?: string, exception?: any) => void>): InternalTexture;
  10840. /**
  10841. * Creates a new raw cube texture from a specified url
  10842. * @param url defines the url where the data is located
  10843. * @param scene defines the current scene
  10844. * @param size defines the size of the textures
  10845. * @param format defines the format of the data
  10846. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  10847. * @param noMipmap defines if the engine should avoid generating the mip levels
  10848. * @param callback defines a callback used to extract texture data from loaded data
  10849. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  10850. * @param onLoad defines a callback called when texture is loaded
  10851. * @param onError defines a callback called if there is an error
  10852. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  10853. * @param invertY defines if data must be stored with Y axis inverted
  10854. * @returns the cube texture as an InternalTexture
  10855. */
  10856. createRawCubeTextureFromUrl(url: string, scene: Nullable<Scene>, size: number, format: number, type: number, noMipmap: boolean, callback: (ArrayBuffer: ArrayBuffer) => Nullable<ArrayBufferView[]>, mipmapGenerator: Nullable<((faces: ArrayBufferView[]) => ArrayBufferView[][])>, onLoad: Nullable<() => void>, onError: Nullable<(message?: string, exception?: any) => void>, samplingMode: number, invertY: boolean): InternalTexture;
  10857. /**
  10858. * Creates a new raw 3D texture
  10859. * @param data defines the data used to create the texture
  10860. * @param width defines the width of the texture
  10861. * @param height defines the height of the texture
  10862. * @param depth defines the depth of the texture
  10863. * @param format defines the format of the texture
  10864. * @param generateMipMaps defines if the engine must generate mip levels
  10865. * @param invertY defines if data must be stored with Y axis inverted
  10866. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  10867. * @param compression defines the compressed used (can be null)
  10868. * @param textureType defines the compressed used (can be null)
  10869. * @returns a new raw 3D texture (stored in an InternalTexture)
  10870. */
  10871. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  10872. /**
  10873. * Update a raw 3D texture
  10874. * @param texture defines the texture to update
  10875. * @param data defines the data to store
  10876. * @param format defines the data format
  10877. * @param invertY defines if data must be stored with Y axis inverted
  10878. */
  10879. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  10880. /**
  10881. * Update a raw 3D texture
  10882. * @param texture defines the texture to update
  10883. * @param data defines the data to store
  10884. * @param format defines the data format
  10885. * @param invertY defines if data must be stored with Y axis inverted
  10886. * @param compression defines the used compression (can be null)
  10887. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  10888. */
  10889. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  10890. /**
  10891. * Creates a new raw 2D array texture
  10892. * @param data defines the data used to create the texture
  10893. * @param width defines the width of the texture
  10894. * @param height defines the height of the texture
  10895. * @param depth defines the number of layers of the texture
  10896. * @param format defines the format of the texture
  10897. * @param generateMipMaps defines if the engine must generate mip levels
  10898. * @param invertY defines if data must be stored with Y axis inverted
  10899. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  10900. * @param compression defines the compressed used (can be null)
  10901. * @param textureType defines the compressed used (can be null)
  10902. * @returns a new raw 2D array texture (stored in an InternalTexture)
  10903. */
  10904. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  10905. /**
  10906. * Update a raw 2D array texture
  10907. * @param texture defines the texture to update
  10908. * @param data defines the data to store
  10909. * @param format defines the data format
  10910. * @param invertY defines if data must be stored with Y axis inverted
  10911. */
  10912. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  10913. /**
  10914. * Update a raw 2D array texture
  10915. * @param texture defines the texture to update
  10916. * @param data defines the data to store
  10917. * @param format defines the data format
  10918. * @param invertY defines if data must be stored with Y axis inverted
  10919. * @param compression defines the used compression (can be null)
  10920. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  10921. */
  10922. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  10923. }
  10924. }
  10925. }
  10926. declare module "babylonjs/Materials/Textures/rawTexture" {
  10927. import { Scene } from "babylonjs/scene";
  10928. import { Texture } from "babylonjs/Materials/Textures/texture";
  10929. import "babylonjs/Engines/Extensions/engine.rawTexture";
  10930. /**
  10931. * Raw texture can help creating a texture directly from an array of data.
  10932. * This can be super useful if you either get the data from an uncompressed source or
  10933. * if you wish to create your texture pixel by pixel.
  10934. */
  10935. export class RawTexture extends Texture {
  10936. /**
  10937. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  10938. */
  10939. format: number;
  10940. /**
  10941. * Instantiates a new RawTexture.
  10942. * Raw texture can help creating a texture directly from an array of data.
  10943. * This can be super useful if you either get the data from an uncompressed source or
  10944. * if you wish to create your texture pixel by pixel.
  10945. * @param data define the array of data to use to create the texture
  10946. * @param width define the width of the texture
  10947. * @param height define the height of the texture
  10948. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  10949. * @param scene define the scene the texture belongs to
  10950. * @param generateMipMaps define whether mip maps should be generated or not
  10951. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10952. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10953. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  10954. */
  10955. constructor(data: ArrayBufferView, width: number, height: number,
  10956. /**
  10957. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  10958. */
  10959. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  10960. /**
  10961. * Updates the texture underlying data.
  10962. * @param data Define the new data of the texture
  10963. */
  10964. update(data: ArrayBufferView): void;
  10965. /**
  10966. * Creates a luminance texture from some data.
  10967. * @param data Define the texture data
  10968. * @param width Define the width of the texture
  10969. * @param height Define the height of the texture
  10970. * @param scene Define the scene the texture belongs to
  10971. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10972. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10973. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10974. * @returns the luminance texture
  10975. */
  10976. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  10977. /**
  10978. * Creates a luminance alpha texture from some data.
  10979. * @param data Define the texture data
  10980. * @param width Define the width of the texture
  10981. * @param height Define the height of the texture
  10982. * @param scene Define the scene the texture belongs to
  10983. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10984. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10985. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10986. * @returns the luminance alpha texture
  10987. */
  10988. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  10989. /**
  10990. * Creates an alpha texture from some data.
  10991. * @param data Define the texture data
  10992. * @param width Define the width of the texture
  10993. * @param height Define the height of the texture
  10994. * @param scene Define the scene the texture belongs to
  10995. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10996. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10997. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10998. * @returns the alpha texture
  10999. */
  11000. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11001. /**
  11002. * Creates a RGB texture from some data.
  11003. * @param data Define the texture data
  11004. * @param width Define the width of the texture
  11005. * @param height Define the height of the texture
  11006. * @param scene Define the scene the texture belongs to
  11007. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11008. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11009. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11010. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11011. * @returns the RGB alpha texture
  11012. */
  11013. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11014. /**
  11015. * Creates a RGBA texture from some data.
  11016. * @param data Define the texture data
  11017. * @param width Define the width of the texture
  11018. * @param height Define the height of the texture
  11019. * @param scene Define the scene the texture belongs to
  11020. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11021. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11022. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11023. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11024. * @returns the RGBA texture
  11025. */
  11026. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11027. /**
  11028. * Creates a R texture from some data.
  11029. * @param data Define the texture data
  11030. * @param width Define the width of the texture
  11031. * @param height Define the height of the texture
  11032. * @param scene Define the scene the texture belongs to
  11033. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11034. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11035. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11036. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11037. * @returns the R texture
  11038. */
  11039. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11040. }
  11041. }
  11042. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent" {
  11043. import { Scene } from "babylonjs/scene";
  11044. import { ISceneComponent } from "babylonjs/sceneComponent";
  11045. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  11046. module "babylonjs/abstractScene" {
  11047. interface AbstractScene {
  11048. /**
  11049. * The list of procedural textures added to the scene
  11050. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11051. */
  11052. proceduralTextures: Array<ProceduralTexture>;
  11053. }
  11054. }
  11055. /**
  11056. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  11057. * in a given scene.
  11058. */
  11059. export class ProceduralTextureSceneComponent implements ISceneComponent {
  11060. /**
  11061. * The component name helpfull to identify the component in the list of scene components.
  11062. */
  11063. readonly name: string;
  11064. /**
  11065. * The scene the component belongs to.
  11066. */
  11067. scene: Scene;
  11068. /**
  11069. * Creates a new instance of the component for the given scene
  11070. * @param scene Defines the scene to register the component in
  11071. */
  11072. constructor(scene: Scene);
  11073. /**
  11074. * Registers the component in a given scene
  11075. */
  11076. register(): void;
  11077. /**
  11078. * Rebuilds the elements related to this component in case of
  11079. * context lost for instance.
  11080. */
  11081. rebuild(): void;
  11082. /**
  11083. * Disposes the component and the associated ressources.
  11084. */
  11085. dispose(): void;
  11086. private _beforeClear;
  11087. }
  11088. }
  11089. declare module "babylonjs/Engines/Extensions/engine.renderTargetCube" {
  11090. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  11091. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  11092. module "babylonjs/Engines/thinEngine" {
  11093. interface ThinEngine {
  11094. /**
  11095. * Creates a new render target cube texture
  11096. * @param size defines the size of the texture
  11097. * @param options defines the options used to create the texture
  11098. * @returns a new render target cube texture stored in an InternalTexture
  11099. */
  11100. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  11101. }
  11102. }
  11103. }
  11104. declare module "babylonjs/Shaders/procedural.vertex" {
  11105. /** @hidden */
  11106. export var proceduralVertexShader: {
  11107. name: string;
  11108. shader: string;
  11109. };
  11110. }
  11111. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTexture" {
  11112. import { Observable } from "babylonjs/Misc/observable";
  11113. import { Nullable } from "babylonjs/types";
  11114. import { Scene } from "babylonjs/scene";
  11115. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  11116. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  11117. import { Effect } from "babylonjs/Materials/effect";
  11118. import { Texture } from "babylonjs/Materials/Textures/texture";
  11119. import "babylonjs/Engines/Extensions/engine.renderTarget";
  11120. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  11121. import "babylonjs/Shaders/procedural.vertex";
  11122. /**
  11123. * Procedural texturing is a way to programmatically create a texture. There are 2 types of procedural textures: code-only, and code that references some classic 2D images, sometimes calmpler' images.
  11124. * This is the base class of any Procedural texture and contains most of the shareable code.
  11125. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11126. */
  11127. export class ProceduralTexture extends Texture {
  11128. isCube: boolean;
  11129. /**
  11130. * Define if the texture is enabled or not (disabled texture will not render)
  11131. */
  11132. isEnabled: boolean;
  11133. /**
  11134. * Define if the texture must be cleared before rendering (default is true)
  11135. */
  11136. autoClear: boolean;
  11137. /**
  11138. * Callback called when the texture is generated
  11139. */
  11140. onGenerated: () => void;
  11141. /**
  11142. * Event raised when the texture is generated
  11143. */
  11144. onGeneratedObservable: Observable<ProceduralTexture>;
  11145. /** @hidden */
  11146. _generateMipMaps: boolean;
  11147. /** @hidden **/
  11148. _effect: Effect;
  11149. /** @hidden */
  11150. _textures: {
  11151. [key: string]: Texture;
  11152. };
  11153. /** @hidden */
  11154. protected _fallbackTexture: Nullable<Texture>;
  11155. private _size;
  11156. private _currentRefreshId;
  11157. private _frameId;
  11158. private _refreshRate;
  11159. private _vertexBuffers;
  11160. private _indexBuffer;
  11161. private _uniforms;
  11162. private _samplers;
  11163. private _fragment;
  11164. private _floats;
  11165. private _ints;
  11166. private _floatsArrays;
  11167. private _colors3;
  11168. private _colors4;
  11169. private _vectors2;
  11170. private _vectors3;
  11171. private _matrices;
  11172. private _fallbackTextureUsed;
  11173. private _fullEngine;
  11174. private _cachedDefines;
  11175. private _contentUpdateId;
  11176. private _contentData;
  11177. /**
  11178. * Instantiates a new procedural texture.
  11179. * Procedural texturing is a way to programmatically create a texture. There are 2 types of procedural textures: code-only, and code that references some classic 2D images, sometimes called 'refMaps' or 'sampler' images.
  11180. * This is the base class of any Procedural texture and contains most of the shareable code.
  11181. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11182. * @param name Define the name of the texture
  11183. * @param size Define the size of the texture to create
  11184. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  11185. * @param scene Define the scene the texture belongs to
  11186. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  11187. * @param generateMipMaps Define if the texture should creates mip maps or not
  11188. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  11189. */
  11190. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  11191. /**
  11192. * The effect that is created when initializing the post process.
  11193. * @returns The created effect corresponding the the postprocess.
  11194. */
  11195. getEffect(): Effect;
  11196. /**
  11197. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  11198. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  11199. */
  11200. getContent(): Nullable<ArrayBufferView>;
  11201. private _createIndexBuffer;
  11202. /** @hidden */
  11203. _rebuild(): void;
  11204. /**
  11205. * Resets the texture in order to recreate its associated resources.
  11206. * This can be called in case of context loss
  11207. */
  11208. reset(): void;
  11209. protected _getDefines(): string;
  11210. /**
  11211. * Is the texture ready to be used ? (rendered at least once)
  11212. * @returns true if ready, otherwise, false.
  11213. */
  11214. isReady(): boolean;
  11215. /**
  11216. * Resets the refresh counter of the texture and start bak from scratch.
  11217. * Could be useful to regenerate the texture if it is setup to render only once.
  11218. */
  11219. resetRefreshCounter(): void;
  11220. /**
  11221. * Set the fragment shader to use in order to render the texture.
  11222. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  11223. */
  11224. setFragment(fragment: any): void;
  11225. /**
  11226. * Define the refresh rate of the texture or the rendering frequency.
  11227. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  11228. */
  11229. get refreshRate(): number;
  11230. set refreshRate(value: number);
  11231. /** @hidden */
  11232. _shouldRender(): boolean;
  11233. /**
  11234. * Get the size the texture is rendering at.
  11235. * @returns the size (texture is always squared)
  11236. */
  11237. getRenderSize(): number;
  11238. /**
  11239. * Resize the texture to new value.
  11240. * @param size Define the new size the texture should have
  11241. * @param generateMipMaps Define whether the new texture should create mip maps
  11242. */
  11243. resize(size: number, generateMipMaps: boolean): void;
  11244. private _checkUniform;
  11245. /**
  11246. * Set a texture in the shader program used to render.
  11247. * @param name Define the name of the uniform samplers as defined in the shader
  11248. * @param texture Define the texture to bind to this sampler
  11249. * @return the texture itself allowing "fluent" like uniform updates
  11250. */
  11251. setTexture(name: string, texture: Texture): ProceduralTexture;
  11252. /**
  11253. * Set a float in the shader.
  11254. * @param name Define the name of the uniform as defined in the shader
  11255. * @param value Define the value to give to the uniform
  11256. * @return the texture itself allowing "fluent" like uniform updates
  11257. */
  11258. setFloat(name: string, value: number): ProceduralTexture;
  11259. /**
  11260. * Set a int in the shader.
  11261. * @param name Define the name of the uniform as defined in the shader
  11262. * @param value Define the value to give to the uniform
  11263. * @return the texture itself allowing "fluent" like uniform updates
  11264. */
  11265. setInt(name: string, value: number): ProceduralTexture;
  11266. /**
  11267. * Set an array of floats in the shader.
  11268. * @param name Define the name of the uniform as defined in the shader
  11269. * @param value Define the value to give to the uniform
  11270. * @return the texture itself allowing "fluent" like uniform updates
  11271. */
  11272. setFloats(name: string, value: number[]): ProceduralTexture;
  11273. /**
  11274. * Set a vec3 in the shader from a Color3.
  11275. * @param name Define the name of the uniform as defined in the shader
  11276. * @param value Define the value to give to the uniform
  11277. * @return the texture itself allowing "fluent" like uniform updates
  11278. */
  11279. setColor3(name: string, value: Color3): ProceduralTexture;
  11280. /**
  11281. * Set a vec4 in the shader from a Color4.
  11282. * @param name Define the name of the uniform as defined in the shader
  11283. * @param value Define the value to give to the uniform
  11284. * @return the texture itself allowing "fluent" like uniform updates
  11285. */
  11286. setColor4(name: string, value: Color4): ProceduralTexture;
  11287. /**
  11288. * Set a vec2 in the shader from a Vector2.
  11289. * @param name Define the name of the uniform as defined in the shader
  11290. * @param value Define the value to give to the uniform
  11291. * @return the texture itself allowing "fluent" like uniform updates
  11292. */
  11293. setVector2(name: string, value: Vector2): ProceduralTexture;
  11294. /**
  11295. * Set a vec3 in the shader from a Vector3.
  11296. * @param name Define the name of the uniform as defined in the shader
  11297. * @param value Define the value to give to the uniform
  11298. * @return the texture itself allowing "fluent" like uniform updates
  11299. */
  11300. setVector3(name: string, value: Vector3): ProceduralTexture;
  11301. /**
  11302. * Set a mat4 in the shader from a MAtrix.
  11303. * @param name Define the name of the uniform as defined in the shader
  11304. * @param value Define the value to give to the uniform
  11305. * @return the texture itself allowing "fluent" like uniform updates
  11306. */
  11307. setMatrix(name: string, value: Matrix): ProceduralTexture;
  11308. /**
  11309. * Render the texture to its associated render target.
  11310. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  11311. */
  11312. render(useCameraPostProcess?: boolean): void;
  11313. /**
  11314. * Clone the texture.
  11315. * @returns the cloned texture
  11316. */
  11317. clone(): ProceduralTexture;
  11318. /**
  11319. * Dispose the texture and release its asoociated resources.
  11320. */
  11321. dispose(): void;
  11322. }
  11323. }
  11324. declare module "babylonjs/Particles/baseParticleSystem" {
  11325. import { Nullable } from "babylonjs/types";
  11326. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  11327. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11328. import { ImageProcessingConfiguration, ImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  11329. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  11330. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  11331. import { Scene } from "babylonjs/scene";
  11332. import { ColorGradient, FactorGradient, Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  11333. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  11334. import { Texture } from "babylonjs/Materials/Textures/texture";
  11335. import { Color4 } from "babylonjs/Maths/math.color";
  11336. import { Animation } from "babylonjs/Animations/animation";
  11337. /**
  11338. * This represents the base class for particle system in Babylon.
  11339. * Particles are often small sprites used to simulate hard-to-reproduce phenomena like fire, smoke, water, or abstract visual effects like magic glitter and faery dust.
  11340. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  11341. * @example https://doc.babylonjs.com/babylon101/particles
  11342. */
  11343. export class BaseParticleSystem {
  11344. /**
  11345. * Source color is added to the destination color without alpha affecting the result
  11346. */
  11347. static BLENDMODE_ONEONE: number;
  11348. /**
  11349. * Blend current color and particle color using particle’s alpha
  11350. */
  11351. static BLENDMODE_STANDARD: number;
  11352. /**
  11353. * Add current color and particle color multiplied by particle’s alpha
  11354. */
  11355. static BLENDMODE_ADD: number;
  11356. /**
  11357. * Multiply current color with particle color
  11358. */
  11359. static BLENDMODE_MULTIPLY: number;
  11360. /**
  11361. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  11362. */
  11363. static BLENDMODE_MULTIPLYADD: number;
  11364. /**
  11365. * List of animations used by the particle system.
  11366. */
  11367. animations: Animation[];
  11368. /**
  11369. * Gets or sets the unique id of the particle system
  11370. */
  11371. uniqueId: number;
  11372. /**
  11373. * The id of the Particle system.
  11374. */
  11375. id: string;
  11376. /**
  11377. * The friendly name of the Particle system.
  11378. */
  11379. name: string;
  11380. /**
  11381. * Snippet ID if the particle system was created from the snippet server
  11382. */
  11383. snippetId: string;
  11384. /**
  11385. * The rendering group used by the Particle system to chose when to render.
  11386. */
  11387. renderingGroupId: number;
  11388. /**
  11389. * The emitter represents the Mesh or position we are attaching the particle system to.
  11390. */
  11391. emitter: Nullable<AbstractMesh | Vector3>;
  11392. /**
  11393. * The maximum number of particles to emit per frame
  11394. */
  11395. emitRate: number;
  11396. /**
  11397. * If you want to launch only a few particles at once, that can be done, as well.
  11398. */
  11399. manualEmitCount: number;
  11400. /**
  11401. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  11402. */
  11403. updateSpeed: number;
  11404. /**
  11405. * The amount of time the particle system is running (depends of the overall update speed).
  11406. */
  11407. targetStopDuration: number;
  11408. /**
  11409. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  11410. */
  11411. disposeOnStop: boolean;
  11412. /**
  11413. * Minimum power of emitting particles.
  11414. */
  11415. minEmitPower: number;
  11416. /**
  11417. * Maximum power of emitting particles.
  11418. */
  11419. maxEmitPower: number;
  11420. /**
  11421. * Minimum life time of emitting particles.
  11422. */
  11423. minLifeTime: number;
  11424. /**
  11425. * Maximum life time of emitting particles.
  11426. */
  11427. maxLifeTime: number;
  11428. /**
  11429. * Minimum Size of emitting particles.
  11430. */
  11431. minSize: number;
  11432. /**
  11433. * Maximum Size of emitting particles.
  11434. */
  11435. maxSize: number;
  11436. /**
  11437. * Minimum scale of emitting particles on X axis.
  11438. */
  11439. minScaleX: number;
  11440. /**
  11441. * Maximum scale of emitting particles on X axis.
  11442. */
  11443. maxScaleX: number;
  11444. /**
  11445. * Minimum scale of emitting particles on Y axis.
  11446. */
  11447. minScaleY: number;
  11448. /**
  11449. * Maximum scale of emitting particles on Y axis.
  11450. */
  11451. maxScaleY: number;
  11452. /**
  11453. * Gets or sets the minimal initial rotation in radians.
  11454. */
  11455. minInitialRotation: number;
  11456. /**
  11457. * Gets or sets the maximal initial rotation in radians.
  11458. */
  11459. maxInitialRotation: number;
  11460. /**
  11461. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  11462. */
  11463. minAngularSpeed: number;
  11464. /**
  11465. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  11466. */
  11467. maxAngularSpeed: number;
  11468. /**
  11469. * The texture used to render each particle. (this can be a spritesheet)
  11470. */
  11471. particleTexture: Nullable<Texture>;
  11472. /**
  11473. * The layer mask we are rendering the particles through.
  11474. */
  11475. layerMask: number;
  11476. /**
  11477. * This can help using your own shader to render the particle system.
  11478. * The according effect will be created
  11479. */
  11480. customShader: any;
  11481. /**
  11482. * By default particle system starts as soon as they are created. This prevents the
  11483. * automatic start to happen and let you decide when to start emitting particles.
  11484. */
  11485. preventAutoStart: boolean;
  11486. private _noiseTexture;
  11487. /**
  11488. * Gets or sets a texture used to add random noise to particle positions
  11489. */
  11490. get noiseTexture(): Nullable<ProceduralTexture>;
  11491. set noiseTexture(value: Nullable<ProceduralTexture>);
  11492. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  11493. noiseStrength: Vector3;
  11494. /**
  11495. * Callback triggered when the particle animation is ending.
  11496. */
  11497. onAnimationEnd: Nullable<() => void>;
  11498. /**
  11499. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  11500. */
  11501. blendMode: number;
  11502. /**
  11503. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  11504. * to override the particles.
  11505. */
  11506. forceDepthWrite: boolean;
  11507. /** Gets or sets a value indicating how many cycles (or frames) must be executed before first rendering (this value has to be set before starting the system). Default is 0 */
  11508. preWarmCycles: number;
  11509. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  11510. preWarmStepOffset: number;
  11511. /**
  11512. * If using a spritesheet (isAnimationSheetEnabled) defines the speed of the sprite loop (default is 1 meaning the animation will play once during the entire particle lifetime)
  11513. */
  11514. spriteCellChangeSpeed: number;
  11515. /**
  11516. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  11517. */
  11518. startSpriteCellID: number;
  11519. /**
  11520. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  11521. */
  11522. endSpriteCellID: number;
  11523. /**
  11524. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  11525. */
  11526. spriteCellWidth: number;
  11527. /**
  11528. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  11529. */
  11530. spriteCellHeight: number;
  11531. /**
  11532. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  11533. */
  11534. spriteRandomStartCell: boolean;
  11535. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  11536. translationPivot: Vector2;
  11537. /** @hidden */
  11538. protected _isAnimationSheetEnabled: boolean;
  11539. /**
  11540. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  11541. */
  11542. beginAnimationOnStart: boolean;
  11543. /**
  11544. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  11545. */
  11546. beginAnimationFrom: number;
  11547. /**
  11548. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  11549. */
  11550. beginAnimationTo: number;
  11551. /**
  11552. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  11553. */
  11554. beginAnimationLoop: boolean;
  11555. /**
  11556. * Gets or sets a world offset applied to all particles
  11557. */
  11558. worldOffset: Vector3;
  11559. /**
  11560. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  11561. */
  11562. get isAnimationSheetEnabled(): boolean;
  11563. set isAnimationSheetEnabled(value: boolean);
  11564. /**
  11565. * Get hosting scene
  11566. * @returns the scene
  11567. */
  11568. getScene(): Scene;
  11569. /**
  11570. * You can use gravity if you want to give an orientation to your particles.
  11571. */
  11572. gravity: Vector3;
  11573. protected _colorGradients: Nullable<Array<ColorGradient>>;
  11574. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  11575. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  11576. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  11577. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  11578. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  11579. protected _dragGradients: Nullable<Array<FactorGradient>>;
  11580. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  11581. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  11582. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  11583. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  11584. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  11585. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  11586. /**
  11587. * Defines the delay in milliseconds before starting the system (0 by default)
  11588. */
  11589. startDelay: number;
  11590. /**
  11591. * Gets the current list of drag gradients.
  11592. * You must use addDragGradient and removeDragGradient to udpate this list
  11593. * @returns the list of drag gradients
  11594. */
  11595. getDragGradients(): Nullable<Array<FactorGradient>>;
  11596. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  11597. limitVelocityDamping: number;
  11598. /**
  11599. * Gets the current list of limit velocity gradients.
  11600. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  11601. * @returns the list of limit velocity gradients
  11602. */
  11603. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  11604. /**
  11605. * Gets the current list of color gradients.
  11606. * You must use addColorGradient and removeColorGradient to udpate this list
  11607. * @returns the list of color gradients
  11608. */
  11609. getColorGradients(): Nullable<Array<ColorGradient>>;
  11610. /**
  11611. * Gets the current list of size gradients.
  11612. * You must use addSizeGradient and removeSizeGradient to udpate this list
  11613. * @returns the list of size gradients
  11614. */
  11615. getSizeGradients(): Nullable<Array<FactorGradient>>;
  11616. /**
  11617. * Gets the current list of color remap gradients.
  11618. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  11619. * @returns the list of color remap gradients
  11620. */
  11621. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  11622. /**
  11623. * Gets the current list of alpha remap gradients.
  11624. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  11625. * @returns the list of alpha remap gradients
  11626. */
  11627. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  11628. /**
  11629. * Gets the current list of life time gradients.
  11630. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  11631. * @returns the list of life time gradients
  11632. */
  11633. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  11634. /**
  11635. * Gets the current list of angular speed gradients.
  11636. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  11637. * @returns the list of angular speed gradients
  11638. */
  11639. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  11640. /**
  11641. * Gets the current list of velocity gradients.
  11642. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  11643. * @returns the list of velocity gradients
  11644. */
  11645. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  11646. /**
  11647. * Gets the current list of start size gradients.
  11648. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  11649. * @returns the list of start size gradients
  11650. */
  11651. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  11652. /**
  11653. * Gets the current list of emit rate gradients.
  11654. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  11655. * @returns the list of emit rate gradients
  11656. */
  11657. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  11658. /**
  11659. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  11660. * This only works when particleEmitterTyps is a BoxParticleEmitter
  11661. */
  11662. get direction1(): Vector3;
  11663. set direction1(value: Vector3);
  11664. /**
  11665. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  11666. * This only works when particleEmitterTyps is a BoxParticleEmitter
  11667. */
  11668. get direction2(): Vector3;
  11669. set direction2(value: Vector3);
  11670. /**
  11671. * Minimum box point around our emitter. Our emitter is the center of particles source, but if you want your particles to emit from more than one point, then you can tell it to do so.
  11672. * This only works when particleEmitterTyps is a BoxParticleEmitter
  11673. */
  11674. get minEmitBox(): Vector3;
  11675. set minEmitBox(value: Vector3);
  11676. /**
  11677. * Maximum box point around our emitter. Our emitter is the center of particles source, but if you want your particles to emit from more than one point, then you can tell it to do so.
  11678. * This only works when particleEmitterTyps is a BoxParticleEmitter
  11679. */
  11680. get maxEmitBox(): Vector3;
  11681. set maxEmitBox(value: Vector3);
  11682. /**
  11683. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  11684. */
  11685. color1: Color4;
  11686. /**
  11687. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  11688. */
  11689. color2: Color4;
  11690. /**
  11691. * Color the particle will have at the end of its lifetime
  11692. */
  11693. colorDead: Color4;
  11694. /**
  11695. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  11696. */
  11697. textureMask: Color4;
  11698. /**
  11699. * The particle emitter type defines the emitter used by the particle system.
  11700. * It can be for example box, sphere, or cone...
  11701. */
  11702. particleEmitterType: IParticleEmitterType;
  11703. /** @hidden */
  11704. _isSubEmitter: boolean;
  11705. /**
  11706. * Gets or sets the billboard mode to use when isBillboardBased = true.
  11707. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  11708. */
  11709. billboardMode: number;
  11710. protected _isBillboardBased: boolean;
  11711. /**
  11712. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  11713. */
  11714. get isBillboardBased(): boolean;
  11715. set isBillboardBased(value: boolean);
  11716. /**
  11717. * The scene the particle system belongs to.
  11718. */
  11719. protected _scene: Scene;
  11720. /**
  11721. * Local cache of defines for image processing.
  11722. */
  11723. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  11724. /**
  11725. * Default configuration related to image processing available in the standard Material.
  11726. */
  11727. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  11728. /**
  11729. * Gets the image processing configuration used either in this material.
  11730. */
  11731. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  11732. /**
  11733. * Sets the Default image processing configuration used either in the this material.
  11734. *
  11735. * If sets to null, the scene one is in use.
  11736. */
  11737. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  11738. /**
  11739. * Attaches a new image processing configuration to the Standard Material.
  11740. * @param configuration
  11741. */
  11742. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  11743. /** @hidden */
  11744. protected _reset(): void;
  11745. /** @hidden */
  11746. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  11747. /**
  11748. * Instantiates a particle system.
  11749. * Particles are often small sprites used to simulate hard-to-reproduce phenomena like fire, smoke, water, or abstract visual effects like magic glitter and faery dust.
  11750. * @param name The name of the particle system
  11751. */
  11752. constructor(name: string);
  11753. /**
  11754. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  11755. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  11756. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  11757. * @returns the emitter
  11758. */
  11759. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  11760. /**
  11761. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  11762. * @param radius The radius of the hemisphere to emit from
  11763. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  11764. * @returns the emitter
  11765. */
  11766. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  11767. /**
  11768. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  11769. * @param radius The radius of the sphere to emit from
  11770. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  11771. * @returns the emitter
  11772. */
  11773. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  11774. /**
  11775. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  11776. * @param radius The radius of the sphere to emit from
  11777. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  11778. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  11779. * @returns the emitter
  11780. */
  11781. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  11782. /**
  11783. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  11784. * @param radius The radius of the emission cylinder
  11785. * @param height The height of the emission cylinder
  11786. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  11787. * @param directionRandomizer How much to randomize the particle direction [0-1]
  11788. * @returns the emitter
  11789. */
  11790. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  11791. /**
  11792. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  11793. * @param radius The radius of the cylinder to emit from
  11794. * @param height The height of the emission cylinder
  11795. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  11796. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  11797. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  11798. * @returns the emitter
  11799. */
  11800. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  11801. /**
  11802. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  11803. * @param radius The radius of the cone to emit from
  11804. * @param angle The base angle of the cone
  11805. * @returns the emitter
  11806. */
  11807. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  11808. /**
  11809. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  11810. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  11811. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  11812. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  11813. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  11814. * @returns the emitter
  11815. */
  11816. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  11817. }
  11818. }
  11819. declare module "babylonjs/Particles/subEmitter" {
  11820. import { Scene } from "babylonjs/scene";
  11821. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  11822. /**
  11823. * Type of sub emitter
  11824. */
  11825. export enum SubEmitterType {
  11826. /**
  11827. * Attached to the particle over it's lifetime
  11828. */
  11829. ATTACHED = 0,
  11830. /**
  11831. * Created when the particle dies
  11832. */
  11833. END = 1
  11834. }
  11835. /**
  11836. * Sub emitter class used to emit particles from an existing particle
  11837. */
  11838. export class SubEmitter {
  11839. /**
  11840. * the particle system to be used by the sub emitter
  11841. */
  11842. particleSystem: ParticleSystem;
  11843. /**
  11844. * Type of the submitter (Default: END)
  11845. */
  11846. type: SubEmitterType;
  11847. /**
  11848. * If the particle should inherit the direction from the particle it's attached to. (+Y will face the direction the particle is moving) (Default: false)
  11849. * Note: This only is supported when using an emitter of type Mesh
  11850. */
  11851. inheritDirection: boolean;
  11852. /**
  11853. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  11854. */
  11855. inheritedVelocityAmount: number;
  11856. /**
  11857. * Creates a sub emitter
  11858. * @param particleSystem the particle system to be used by the sub emitter
  11859. */
  11860. constructor(
  11861. /**
  11862. * the particle system to be used by the sub emitter
  11863. */
  11864. particleSystem: ParticleSystem);
  11865. /**
  11866. * Clones the sub emitter
  11867. * @returns the cloned sub emitter
  11868. */
  11869. clone(): SubEmitter;
  11870. /**
  11871. * Serialize current object to a JSON object
  11872. * @returns the serialized object
  11873. */
  11874. serialize(): any;
  11875. /** @hidden */
  11876. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  11877. /**
  11878. * Creates a new SubEmitter from a serialized JSON version
  11879. * @param serializationObject defines the JSON object to read from
  11880. * @param scene defines the hosting scene
  11881. * @param rootUrl defines the rootUrl for data loading
  11882. * @returns a new SubEmitter
  11883. */
  11884. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  11885. /** Release associated resources */
  11886. dispose(): void;
  11887. }
  11888. }
  11889. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration" {
  11890. /** @hidden */
  11891. export var imageProcessingDeclaration: {
  11892. name: string;
  11893. shader: string;
  11894. };
  11895. }
  11896. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions" {
  11897. /** @hidden */
  11898. export var imageProcessingFunctions: {
  11899. name: string;
  11900. shader: string;
  11901. };
  11902. }
  11903. declare module "babylonjs/Shaders/particles.fragment" {
  11904. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  11905. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  11906. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  11907. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  11908. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  11909. /** @hidden */
  11910. export var particlesPixelShader: {
  11911. name: string;
  11912. shader: string;
  11913. };
  11914. }
  11915. declare module "babylonjs/Shaders/particles.vertex" {
  11916. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  11917. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  11918. /** @hidden */
  11919. export var particlesVertexShader: {
  11920. name: string;
  11921. shader: string;
  11922. };
  11923. }
  11924. declare module "babylonjs/Particles/particleSystem" {
  11925. import { Nullable } from "babylonjs/types";
  11926. import { FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  11927. import { Observable } from "babylonjs/Misc/observable";
  11928. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  11929. import { Effect } from "babylonjs/Materials/effect";
  11930. import { Scene, IDisposable } from "babylonjs/scene";
  11931. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  11932. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  11933. import { Particle } from "babylonjs/Particles/particle";
  11934. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  11935. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  11936. import "babylonjs/Shaders/particles.fragment";
  11937. import "babylonjs/Shaders/particles.vertex";
  11938. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  11939. /**
  11940. * This represents a particle system in Babylon.
  11941. * Particles are often small sprites used to simulate hard-to-reproduce phenomena like fire, smoke, water, or abstract visual effects like magic glitter and faery dust.
  11942. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  11943. * @example https://doc.babylonjs.com/babylon101/particles
  11944. */
  11945. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  11946. /**
  11947. * Billboard mode will only apply to Y axis
  11948. */
  11949. static readonly BILLBOARDMODE_Y: number;
  11950. /**
  11951. * Billboard mode will apply to all axes
  11952. */
  11953. static readonly BILLBOARDMODE_ALL: number;
  11954. /**
  11955. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  11956. */
  11957. static readonly BILLBOARDMODE_STRETCHED: number;
  11958. /**
  11959. * This function can be defined to provide custom update for active particles.
  11960. * This function will be called instead of regular update (age, position, color, etc.).
  11961. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  11962. */
  11963. updateFunction: (particles: Particle[]) => void;
  11964. private _emitterWorldMatrix;
  11965. /**
  11966. * This function can be defined to specify initial direction for every new particle.
  11967. * It by default use the emitterType defined function
  11968. */
  11969. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  11970. /**
  11971. * This function can be defined to specify initial position for every new particle.
  11972. * It by default use the emitterType defined function
  11973. */
  11974. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  11975. /**
  11976. * @hidden
  11977. */
  11978. _inheritedVelocityOffset: Vector3;
  11979. /**
  11980. * An event triggered when the system is disposed
  11981. */
  11982. onDisposeObservable: Observable<ParticleSystem>;
  11983. private _onDisposeObserver;
  11984. /**
  11985. * Sets a callback that will be triggered when the system is disposed
  11986. */
  11987. set onDispose(callback: () => void);
  11988. private _particles;
  11989. private _epsilon;
  11990. private _capacity;
  11991. private _stockParticles;
  11992. private _newPartsExcess;
  11993. private _vertexData;
  11994. private _vertexBuffer;
  11995. private _vertexBuffers;
  11996. private _spriteBuffer;
  11997. private _indexBuffer;
  11998. private _effect;
  11999. private _customEffect;
  12000. private _cachedDefines;
  12001. private _scaledColorStep;
  12002. private _colorDiff;
  12003. private _scaledDirection;
  12004. private _scaledGravity;
  12005. private _currentRenderId;
  12006. private _alive;
  12007. private _useInstancing;
  12008. private _started;
  12009. private _stopped;
  12010. private _actualFrame;
  12011. private _scaledUpdateSpeed;
  12012. private _vertexBufferSize;
  12013. /** @hidden */
  12014. _currentEmitRateGradient: Nullable<FactorGradient>;
  12015. /** @hidden */
  12016. _currentEmitRate1: number;
  12017. /** @hidden */
  12018. _currentEmitRate2: number;
  12019. /** @hidden */
  12020. _currentStartSizeGradient: Nullable<FactorGradient>;
  12021. /** @hidden */
  12022. _currentStartSize1: number;
  12023. /** @hidden */
  12024. _currentStartSize2: number;
  12025. private readonly _rawTextureWidth;
  12026. private _rampGradientsTexture;
  12027. private _useRampGradients;
  12028. /** Gets or sets a boolean indicating that ramp gradients must be used
  12029. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  12030. */
  12031. get useRampGradients(): boolean;
  12032. set useRampGradients(value: boolean);
  12033. /**
  12034. * The Sub-emitters templates that will be used to generate the sub particle system to be associated with the system, this property is used by the root particle system only.
  12035. * When a particle is spawned, an array will be chosen at random and all the emitters in that array will be attached to the particle. (Default: [])
  12036. */
  12037. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  12038. private _subEmitters;
  12039. /**
  12040. * @hidden
  12041. * If the particle systems emitter should be disposed when the particle system is disposed
  12042. */
  12043. _disposeEmitterOnDispose: boolean;
  12044. /**
  12045. * The current active Sub-systems, this property is used by the root particle system only.
  12046. */
  12047. activeSubSystems: Array<ParticleSystem>;
  12048. /**
  12049. * Specifies if the particles are updated in emitter local space or world space
  12050. */
  12051. isLocal: boolean;
  12052. private _rootParticleSystem;
  12053. /**
  12054. * Gets the current list of active particles
  12055. */
  12056. get particles(): Particle[];
  12057. /**
  12058. * Gets the number of particles active at the same time.
  12059. * @returns The number of active particles.
  12060. */
  12061. getActiveCount(): number;
  12062. /**
  12063. * Returns the string "ParticleSystem"
  12064. * @returns a string containing the class name
  12065. */
  12066. getClassName(): string;
  12067. /**
  12068. * Gets a boolean indicating that the system is stopping
  12069. * @returns true if the system is currently stopping
  12070. */
  12071. isStopping(): boolean;
  12072. /**
  12073. * Instantiates a particle system.
  12074. * Particles are often small sprites used to simulate hard-to-reproduce phenomena like fire, smoke, water, or abstract visual effects like magic glitter and faery dust.
  12075. * @param name The name of the particle system
  12076. * @param capacity The max number of particles alive at the same time
  12077. * @param scene The scene the particle system belongs to
  12078. * @param customEffect a custom effect used to change the way particles are rendered by default
  12079. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  12080. * @param epsilon Offset used to render the particles
  12081. */
  12082. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  12083. private _addFactorGradient;
  12084. private _removeFactorGradient;
  12085. /**
  12086. * Adds a new life time gradient
  12087. * @param gradient defines the gradient to use (between 0 and 1)
  12088. * @param factor defines the life time factor to affect to the specified gradient
  12089. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12090. * @returns the current particle system
  12091. */
  12092. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12093. /**
  12094. * Remove a specific life time gradient
  12095. * @param gradient defines the gradient to remove
  12096. * @returns the current particle system
  12097. */
  12098. removeLifeTimeGradient(gradient: number): IParticleSystem;
  12099. /**
  12100. * Adds a new size gradient
  12101. * @param gradient defines the gradient to use (between 0 and 1)
  12102. * @param factor defines the size factor to affect to the specified gradient
  12103. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12104. * @returns the current particle system
  12105. */
  12106. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12107. /**
  12108. * Remove a specific size gradient
  12109. * @param gradient defines the gradient to remove
  12110. * @returns the current particle system
  12111. */
  12112. removeSizeGradient(gradient: number): IParticleSystem;
  12113. /**
  12114. * Adds a new color remap gradient
  12115. * @param gradient defines the gradient to use (between 0 and 1)
  12116. * @param min defines the color remap minimal range
  12117. * @param max defines the color remap maximal range
  12118. * @returns the current particle system
  12119. */
  12120. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  12121. /**
  12122. * Remove a specific color remap gradient
  12123. * @param gradient defines the gradient to remove
  12124. * @returns the current particle system
  12125. */
  12126. removeColorRemapGradient(gradient: number): IParticleSystem;
  12127. /**
  12128. * Adds a new alpha remap gradient
  12129. * @param gradient defines the gradient to use (between 0 and 1)
  12130. * @param min defines the alpha remap minimal range
  12131. * @param max defines the alpha remap maximal range
  12132. * @returns the current particle system
  12133. */
  12134. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  12135. /**
  12136. * Remove a specific alpha remap gradient
  12137. * @param gradient defines the gradient to remove
  12138. * @returns the current particle system
  12139. */
  12140. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  12141. /**
  12142. * Adds a new angular speed gradient
  12143. * @param gradient defines the gradient to use (between 0 and 1)
  12144. * @param factor defines the angular speed to affect to the specified gradient
  12145. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12146. * @returns the current particle system
  12147. */
  12148. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12149. /**
  12150. * Remove a specific angular speed gradient
  12151. * @param gradient defines the gradient to remove
  12152. * @returns the current particle system
  12153. */
  12154. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  12155. /**
  12156. * Adds a new velocity gradient
  12157. * @param gradient defines the gradient to use (between 0 and 1)
  12158. * @param factor defines the velocity to affect to the specified gradient
  12159. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12160. * @returns the current particle system
  12161. */
  12162. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12163. /**
  12164. * Remove a specific velocity gradient
  12165. * @param gradient defines the gradient to remove
  12166. * @returns the current particle system
  12167. */
  12168. removeVelocityGradient(gradient: number): IParticleSystem;
  12169. /**
  12170. * Adds a new limit velocity gradient
  12171. * @param gradient defines the gradient to use (between 0 and 1)
  12172. * @param factor defines the limit velocity value to affect to the specified gradient
  12173. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12174. * @returns the current particle system
  12175. */
  12176. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12177. /**
  12178. * Remove a specific limit velocity gradient
  12179. * @param gradient defines the gradient to remove
  12180. * @returns the current particle system
  12181. */
  12182. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  12183. /**
  12184. * Adds a new drag gradient
  12185. * @param gradient defines the gradient to use (between 0 and 1)
  12186. * @param factor defines the drag value to affect to the specified gradient
  12187. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12188. * @returns the current particle system
  12189. */
  12190. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12191. /**
  12192. * Remove a specific drag gradient
  12193. * @param gradient defines the gradient to remove
  12194. * @returns the current particle system
  12195. */
  12196. removeDragGradient(gradient: number): IParticleSystem;
  12197. /**
  12198. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  12199. * @param gradient defines the gradient to use (between 0 and 1)
  12200. * @param factor defines the emit rate value to affect to the specified gradient
  12201. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12202. * @returns the current particle system
  12203. */
  12204. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12205. /**
  12206. * Remove a specific emit rate gradient
  12207. * @param gradient defines the gradient to remove
  12208. * @returns the current particle system
  12209. */
  12210. removeEmitRateGradient(gradient: number): IParticleSystem;
  12211. /**
  12212. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  12213. * @param gradient defines the gradient to use (between 0 and 1)
  12214. * @param factor defines the start size value to affect to the specified gradient
  12215. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12216. * @returns the current particle system
  12217. */
  12218. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12219. /**
  12220. * Remove a specific start size gradient
  12221. * @param gradient defines the gradient to remove
  12222. * @returns the current particle system
  12223. */
  12224. removeStartSizeGradient(gradient: number): IParticleSystem;
  12225. private _createRampGradientTexture;
  12226. /**
  12227. * Gets the current list of ramp gradients.
  12228. * You must use addRampGradient and removeRampGradient to udpate this list
  12229. * @returns the list of ramp gradients
  12230. */
  12231. getRampGradients(): Nullable<Array<Color3Gradient>>;
  12232. /** Force the system to rebuild all gradients that need to be resync */
  12233. forceRefreshGradients(): void;
  12234. private _syncRampGradientTexture;
  12235. /**
  12236. * Adds a new ramp gradient used to remap particle colors
  12237. * @param gradient defines the gradient to use (between 0 and 1)
  12238. * @param color defines the color to affect to the specified gradient
  12239. * @returns the current particle system
  12240. */
  12241. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  12242. /**
  12243. * Remove a specific ramp gradient
  12244. * @param gradient defines the gradient to remove
  12245. * @returns the current particle system
  12246. */
  12247. removeRampGradient(gradient: number): ParticleSystem;
  12248. /**
  12249. * Adds a new color gradient
  12250. * @param gradient defines the gradient to use (between 0 and 1)
  12251. * @param color1 defines the color to affect to the specified gradient
  12252. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  12253. * @returns this particle system
  12254. */
  12255. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  12256. /**
  12257. * Remove a specific color gradient
  12258. * @param gradient defines the gradient to remove
  12259. * @returns this particle system
  12260. */
  12261. removeColorGradient(gradient: number): IParticleSystem;
  12262. private _fetchR;
  12263. protected _reset(): void;
  12264. private _resetEffect;
  12265. private _createVertexBuffers;
  12266. private _createIndexBuffer;
  12267. /**
  12268. * Gets the maximum number of particles active at the same time.
  12269. * @returns The max number of active particles.
  12270. */
  12271. getCapacity(): number;
  12272. /**
  12273. * Gets whether there are still active particles in the system.
  12274. * @returns True if it is alive, otherwise false.
  12275. */
  12276. isAlive(): boolean;
  12277. /**
  12278. * Gets if the system has been started. (Note: this will still be true after stop is called)
  12279. * @returns True if it has been started, otherwise false.
  12280. */
  12281. isStarted(): boolean;
  12282. private _prepareSubEmitterInternalArray;
  12283. /**
  12284. * Starts the particle system and begins to emit
  12285. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  12286. */
  12287. start(delay?: number): void;
  12288. /**
  12289. * Stops the particle system.
  12290. * @param stopSubEmitters if true it will stop the current system and all created sub-Systems if false it will stop the current root system only, this param is used by the root particle system only. the default value is true.
  12291. */
  12292. stop(stopSubEmitters?: boolean): void;
  12293. /**
  12294. * Remove all active particles
  12295. */
  12296. reset(): void;
  12297. /**
  12298. * @hidden (for internal use only)
  12299. */
  12300. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  12301. /**
  12302. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  12303. * Its lifetime will start back at 0.
  12304. */
  12305. recycleParticle: (particle: Particle) => void;
  12306. private _stopSubEmitters;
  12307. private _createParticle;
  12308. private _removeFromRoot;
  12309. private _emitFromParticle;
  12310. private _update;
  12311. /** @hidden */
  12312. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  12313. /** @hidden */
  12314. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  12315. /** @hidden */
  12316. private _getEffect;
  12317. /**
  12318. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  12319. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  12320. */
  12321. animate(preWarmOnly?: boolean): void;
  12322. private _appendParticleVertices;
  12323. /**
  12324. * Rebuilds the particle system.
  12325. */
  12326. rebuild(): void;
  12327. /**
  12328. * Is this system ready to be used/rendered
  12329. * @return true if the system is ready
  12330. */
  12331. isReady(): boolean;
  12332. private _render;
  12333. /**
  12334. * Renders the particle system in its current state.
  12335. * @returns the current number of particles
  12336. */
  12337. render(): number;
  12338. /**
  12339. * Disposes the particle system and free the associated resources
  12340. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  12341. */
  12342. dispose(disposeTexture?: boolean): void;
  12343. /**
  12344. * Clones the particle system.
  12345. * @param name The name of the cloned object
  12346. * @param newEmitter The new emitter to use
  12347. * @returns the cloned particle system
  12348. */
  12349. clone(name: string, newEmitter: any): ParticleSystem;
  12350. /**
  12351. * Serializes the particle system to a JSON object
  12352. * @param serializeTexture defines if the texture must be serialized as well
  12353. * @returns the JSON object
  12354. */
  12355. serialize(serializeTexture?: boolean): any;
  12356. /** @hidden */
  12357. static _Serialize(serializationObject: any, particleSystem: IParticleSystem, serializeTexture: boolean): void;
  12358. /** @hidden */
  12359. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  12360. /**
  12361. * Parses a JSON object to create a particle system.
  12362. * @param parsedParticleSystem The JSON object to parse
  12363. * @param scene The scene to create the particle system in
  12364. * @param rootUrl The root url to use to load external dependencies like texture
  12365. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  12366. * @returns the Parsed particle system
  12367. */
  12368. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  12369. }
  12370. }
  12371. declare module "babylonjs/Particles/particle" {
  12372. import { Nullable } from "babylonjs/types";
  12373. import { Vector2, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  12374. import { Color4 } from "babylonjs/Maths/math.color";
  12375. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  12376. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  12377. import { ColorGradient, FactorGradient } from "babylonjs/Misc/gradients";
  12378. /**
  12379. * A particle represents one of the element emitted by a particle system.
  12380. * This is mainly define by its coordinates, direction, velocity and age.
  12381. */
  12382. export class Particle {
  12383. /**
  12384. * The particle system the particle belongs to.
  12385. */
  12386. particleSystem: ParticleSystem;
  12387. private static _Count;
  12388. /**
  12389. * Unique ID of the particle
  12390. */
  12391. id: number;
  12392. /**
  12393. * The world position of the particle in the scene.
  12394. */
  12395. position: Vector3;
  12396. /**
  12397. * The world direction of the particle in the scene.
  12398. */
  12399. direction: Vector3;
  12400. /**
  12401. * The color of the particle.
  12402. */
  12403. color: Color4;
  12404. /**
  12405. * The color change of the particle per step.
  12406. */
  12407. colorStep: Color4;
  12408. /**
  12409. * Defines how long will the life of the particle be.
  12410. */
  12411. lifeTime: number;
  12412. /**
  12413. * The current age of the particle.
  12414. */
  12415. age: number;
  12416. /**
  12417. * The current size of the particle.
  12418. */
  12419. size: number;
  12420. /**
  12421. * The current scale of the particle.
  12422. */
  12423. scale: Vector2;
  12424. /**
  12425. * The current angle of the particle.
  12426. */
  12427. angle: number;
  12428. /**
  12429. * Defines how fast is the angle changing.
  12430. */
  12431. angularSpeed: number;
  12432. /**
  12433. * Defines the cell index used by the particle to be rendered from a sprite.
  12434. */
  12435. cellIndex: number;
  12436. /**
  12437. * The information required to support color remapping
  12438. */
  12439. remapData: Vector4;
  12440. /** @hidden */
  12441. _randomCellOffset?: number;
  12442. /** @hidden */
  12443. _initialDirection: Nullable<Vector3>;
  12444. /** @hidden */
  12445. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  12446. /** @hidden */
  12447. _initialStartSpriteCellID: number;
  12448. /** @hidden */
  12449. _initialEndSpriteCellID: number;
  12450. /** @hidden */
  12451. _currentColorGradient: Nullable<ColorGradient>;
  12452. /** @hidden */
  12453. _currentColor1: Color4;
  12454. /** @hidden */
  12455. _currentColor2: Color4;
  12456. /** @hidden */
  12457. _currentSizeGradient: Nullable<FactorGradient>;
  12458. /** @hidden */
  12459. _currentSize1: number;
  12460. /** @hidden */
  12461. _currentSize2: number;
  12462. /** @hidden */
  12463. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  12464. /** @hidden */
  12465. _currentAngularSpeed1: number;
  12466. /** @hidden */
  12467. _currentAngularSpeed2: number;
  12468. /** @hidden */
  12469. _currentVelocityGradient: Nullable<FactorGradient>;
  12470. /** @hidden */
  12471. _currentVelocity1: number;
  12472. /** @hidden */
  12473. _currentVelocity2: number;
  12474. /** @hidden */
  12475. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  12476. /** @hidden */
  12477. _currentLimitVelocity1: number;
  12478. /** @hidden */
  12479. _currentLimitVelocity2: number;
  12480. /** @hidden */
  12481. _currentDragGradient: Nullable<FactorGradient>;
  12482. /** @hidden */
  12483. _currentDrag1: number;
  12484. /** @hidden */
  12485. _currentDrag2: number;
  12486. /** @hidden */
  12487. _randomNoiseCoordinates1: Vector3;
  12488. /** @hidden */
  12489. _randomNoiseCoordinates2: Vector3;
  12490. /** @hidden */
  12491. _localPosition?: Vector3;
  12492. /**
  12493. * Creates a new instance Particle
  12494. * @param particleSystem the particle system the particle belongs to
  12495. */
  12496. constructor(
  12497. /**
  12498. * The particle system the particle belongs to.
  12499. */
  12500. particleSystem: ParticleSystem);
  12501. private updateCellInfoFromSystem;
  12502. /**
  12503. * Defines how the sprite cell index is updated for the particle
  12504. */
  12505. updateCellIndex(): void;
  12506. /** @hidden */
  12507. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  12508. /** @hidden */
  12509. _inheritParticleInfoToSubEmitters(): void;
  12510. /** @hidden */
  12511. _reset(): void;
  12512. /**
  12513. * Copy the properties of particle to another one.
  12514. * @param other the particle to copy the information to.
  12515. */
  12516. copyTo(other: Particle): void;
  12517. }
  12518. }
  12519. declare module "babylonjs/Particles/EmitterTypes/IParticleEmitterType" {
  12520. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  12521. import { Effect } from "babylonjs/Materials/effect";
  12522. import { Particle } from "babylonjs/Particles/particle";
  12523. import { Scene } from "babylonjs/scene";
  12524. /**
  12525. * Particle emitter represents a volume emitting particles.
  12526. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  12527. */
  12528. export interface IParticleEmitterType {
  12529. /**
  12530. * Called by the particle System when the direction is computed for the created particle.
  12531. * @param worldMatrix is the world matrix of the particle system
  12532. * @param directionToUpdate is the direction vector to update with the result
  12533. * @param particle is the particle we are computed the direction for
  12534. * @param isLocal defines if the direction should be set in local space
  12535. */
  12536. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12537. /**
  12538. * Called by the particle System when the position is computed for the created particle.
  12539. * @param worldMatrix is the world matrix of the particle system
  12540. * @param positionToUpdate is the position vector to update with the result
  12541. * @param particle is the particle we are computed the position for
  12542. * @param isLocal defines if the position should be set in local space
  12543. */
  12544. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12545. /**
  12546. * Clones the current emitter and returns a copy of it
  12547. * @returns the new emitter
  12548. */
  12549. clone(): IParticleEmitterType;
  12550. /**
  12551. * Called by the GPUParticleSystem to setup the update shader
  12552. * @param effect defines the update shader
  12553. */
  12554. applyToShader(effect: Effect): void;
  12555. /**
  12556. * Returns a string to use to update the GPU particles update shader
  12557. * @returns the effect defines string
  12558. */
  12559. getEffectDefines(): string;
  12560. /**
  12561. * Returns a string representing the class name
  12562. * @returns a string containing the class name
  12563. */
  12564. getClassName(): string;
  12565. /**
  12566. * Serializes the particle system to a JSON object.
  12567. * @returns the JSON object
  12568. */
  12569. serialize(): any;
  12570. /**
  12571. * Parse properties from a JSON object
  12572. * @param serializationObject defines the JSON object
  12573. * @param scene defines the hosting scene
  12574. */
  12575. parse(serializationObject: any, scene: Scene): void;
  12576. }
  12577. }
  12578. declare module "babylonjs/Particles/EmitterTypes/boxParticleEmitter" {
  12579. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  12580. import { Effect } from "babylonjs/Materials/effect";
  12581. import { Particle } from "babylonjs/Particles/particle";
  12582. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  12583. /**
  12584. * Particle emitter emitting particles from the inside of a box.
  12585. * It emits the particles randomly between 2 given directions.
  12586. */
  12587. export class BoxParticleEmitter implements IParticleEmitterType {
  12588. /**
  12589. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12590. */
  12591. direction1: Vector3;
  12592. /**
  12593. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12594. */
  12595. direction2: Vector3;
  12596. /**
  12597. * Minimum box point around our emitter. Our emitter is the center of particles source, but if you want your particles to emit from more than one point, then you can tell it to do so.
  12598. */
  12599. minEmitBox: Vector3;
  12600. /**
  12601. * Maximum box point around our emitter. Our emitter is the center of particles source, but if you want your particles to emit from more than one point, then you can tell it to do so.
  12602. */
  12603. maxEmitBox: Vector3;
  12604. /**
  12605. * Creates a new instance BoxParticleEmitter
  12606. */
  12607. constructor();
  12608. /**
  12609. * Called by the particle System when the direction is computed for the created particle.
  12610. * @param worldMatrix is the world matrix of the particle system
  12611. * @param directionToUpdate is the direction vector to update with the result
  12612. * @param particle is the particle we are computed the direction for
  12613. * @param isLocal defines if the direction should be set in local space
  12614. */
  12615. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12616. /**
  12617. * Called by the particle System when the position is computed for the created particle.
  12618. * @param worldMatrix is the world matrix of the particle system
  12619. * @param positionToUpdate is the position vector to update with the result
  12620. * @param particle is the particle we are computed the position for
  12621. * @param isLocal defines if the position should be set in local space
  12622. */
  12623. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12624. /**
  12625. * Clones the current emitter and returns a copy of it
  12626. * @returns the new emitter
  12627. */
  12628. clone(): BoxParticleEmitter;
  12629. /**
  12630. * Called by the GPUParticleSystem to setup the update shader
  12631. * @param effect defines the update shader
  12632. */
  12633. applyToShader(effect: Effect): void;
  12634. /**
  12635. * Returns a string to use to update the GPU particles update shader
  12636. * @returns a string containng the defines string
  12637. */
  12638. getEffectDefines(): string;
  12639. /**
  12640. * Returns the string "BoxParticleEmitter"
  12641. * @returns a string containing the class name
  12642. */
  12643. getClassName(): string;
  12644. /**
  12645. * Serializes the particle system to a JSON object.
  12646. * @returns the JSON object
  12647. */
  12648. serialize(): any;
  12649. /**
  12650. * Parse properties from a JSON object
  12651. * @param serializationObject defines the JSON object
  12652. */
  12653. parse(serializationObject: any): void;
  12654. }
  12655. }
  12656. declare module "babylonjs/Particles/EmitterTypes/coneParticleEmitter" {
  12657. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  12658. import { Effect } from "babylonjs/Materials/effect";
  12659. import { Particle } from "babylonjs/Particles/particle";
  12660. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  12661. /**
  12662. * Particle emitter emitting particles from the inside of a cone.
  12663. * It emits the particles alongside the cone volume from the base to the particle.
  12664. * The emission direction might be randomized.
  12665. */
  12666. export class ConeParticleEmitter implements IParticleEmitterType {
  12667. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  12668. directionRandomizer: number;
  12669. private _radius;
  12670. private _angle;
  12671. private _height;
  12672. /**
  12673. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  12674. */
  12675. radiusRange: number;
  12676. /**
  12677. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  12678. */
  12679. heightRange: number;
  12680. /**
  12681. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  12682. */
  12683. emitFromSpawnPointOnly: boolean;
  12684. /**
  12685. * Gets or sets the radius of the emission cone
  12686. */
  12687. get radius(): number;
  12688. set radius(value: number);
  12689. /**
  12690. * Gets or sets the angle of the emission cone
  12691. */
  12692. get angle(): number;
  12693. set angle(value: number);
  12694. private _buildHeight;
  12695. /**
  12696. * Creates a new instance ConeParticleEmitter
  12697. * @param radius the radius of the emission cone (1 by default)
  12698. * @param angle the cone base angle (PI by default)
  12699. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  12700. */
  12701. constructor(radius?: number, angle?: number,
  12702. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  12703. directionRandomizer?: number);
  12704. /**
  12705. * Called by the particle System when the direction is computed for the created particle.
  12706. * @param worldMatrix is the world matrix of the particle system
  12707. * @param directionToUpdate is the direction vector to update with the result
  12708. * @param particle is the particle we are computed the direction for
  12709. * @param isLocal defines if the direction should be set in local space
  12710. */
  12711. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12712. /**
  12713. * Called by the particle System when the position is computed for the created particle.
  12714. * @param worldMatrix is the world matrix of the particle system
  12715. * @param positionToUpdate is the position vector to update with the result
  12716. * @param particle is the particle we are computed the position for
  12717. * @param isLocal defines if the position should be set in local space
  12718. */
  12719. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12720. /**
  12721. * Clones the current emitter and returns a copy of it
  12722. * @returns the new emitter
  12723. */
  12724. clone(): ConeParticleEmitter;
  12725. /**
  12726. * Called by the GPUParticleSystem to setup the update shader
  12727. * @param effect defines the update shader
  12728. */
  12729. applyToShader(effect: Effect): void;
  12730. /**
  12731. * Returns a string to use to update the GPU particles update shader
  12732. * @returns a string containng the defines string
  12733. */
  12734. getEffectDefines(): string;
  12735. /**
  12736. * Returns the string "ConeParticleEmitter"
  12737. * @returns a string containing the class name
  12738. */
  12739. getClassName(): string;
  12740. /**
  12741. * Serializes the particle system to a JSON object.
  12742. * @returns the JSON object
  12743. */
  12744. serialize(): any;
  12745. /**
  12746. * Parse properties from a JSON object
  12747. * @param serializationObject defines the JSON object
  12748. */
  12749. parse(serializationObject: any): void;
  12750. }
  12751. }
  12752. declare module "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter" {
  12753. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  12754. import { Effect } from "babylonjs/Materials/effect";
  12755. import { Particle } from "babylonjs/Particles/particle";
  12756. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  12757. /**
  12758. * Particle emitter emitting particles from the inside of a cylinder.
  12759. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  12760. */
  12761. export class CylinderParticleEmitter implements IParticleEmitterType {
  12762. /**
  12763. * The radius of the emission cylinder.
  12764. */
  12765. radius: number;
  12766. /**
  12767. * The height of the emission cylinder.
  12768. */
  12769. height: number;
  12770. /**
  12771. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12772. */
  12773. radiusRange: number;
  12774. /**
  12775. * How much to randomize the particle direction [0-1].
  12776. */
  12777. directionRandomizer: number;
  12778. /**
  12779. * Creates a new instance CylinderParticleEmitter
  12780. * @param radius the radius of the emission cylinder (1 by default)
  12781. * @param height the height of the emission cylinder (1 by default)
  12782. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12783. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  12784. */
  12785. constructor(
  12786. /**
  12787. * The radius of the emission cylinder.
  12788. */
  12789. radius?: number,
  12790. /**
  12791. * The height of the emission cylinder.
  12792. */
  12793. height?: number,
  12794. /**
  12795. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12796. */
  12797. radiusRange?: number,
  12798. /**
  12799. * How much to randomize the particle direction [0-1].
  12800. */
  12801. directionRandomizer?: number);
  12802. /**
  12803. * Called by the particle System when the direction is computed for the created particle.
  12804. * @param worldMatrix is the world matrix of the particle system
  12805. * @param directionToUpdate is the direction vector to update with the result
  12806. * @param particle is the particle we are computed the direction for
  12807. * @param isLocal defines if the direction should be set in local space
  12808. */
  12809. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12810. /**
  12811. * Called by the particle System when the position is computed for the created particle.
  12812. * @param worldMatrix is the world matrix of the particle system
  12813. * @param positionToUpdate is the position vector to update with the result
  12814. * @param particle is the particle we are computed the position for
  12815. * @param isLocal defines if the position should be set in local space
  12816. */
  12817. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12818. /**
  12819. * Clones the current emitter and returns a copy of it
  12820. * @returns the new emitter
  12821. */
  12822. clone(): CylinderParticleEmitter;
  12823. /**
  12824. * Called by the GPUParticleSystem to setup the update shader
  12825. * @param effect defines the update shader
  12826. */
  12827. applyToShader(effect: Effect): void;
  12828. /**
  12829. * Returns a string to use to update the GPU particles update shader
  12830. * @returns a string containng the defines string
  12831. */
  12832. getEffectDefines(): string;
  12833. /**
  12834. * Returns the string "CylinderParticleEmitter"
  12835. * @returns a string containing the class name
  12836. */
  12837. getClassName(): string;
  12838. /**
  12839. * Serializes the particle system to a JSON object.
  12840. * @returns the JSON object
  12841. */
  12842. serialize(): any;
  12843. /**
  12844. * Parse properties from a JSON object
  12845. * @param serializationObject defines the JSON object
  12846. */
  12847. parse(serializationObject: any): void;
  12848. }
  12849. /**
  12850. * Particle emitter emitting particles from the inside of a cylinder.
  12851. * It emits the particles randomly between two vectors.
  12852. */
  12853. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  12854. /**
  12855. * The min limit of the emission direction.
  12856. */
  12857. direction1: Vector3;
  12858. /**
  12859. * The max limit of the emission direction.
  12860. */
  12861. direction2: Vector3;
  12862. /**
  12863. * Creates a new instance CylinderDirectedParticleEmitter
  12864. * @param radius the radius of the emission cylinder (1 by default)
  12865. * @param height the height of the emission cylinder (1 by default)
  12866. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12867. * @param direction1 the min limit of the emission direction (up vector by default)
  12868. * @param direction2 the max limit of the emission direction (up vector by default)
  12869. */
  12870. constructor(radius?: number, height?: number, radiusRange?: number,
  12871. /**
  12872. * The min limit of the emission direction.
  12873. */
  12874. direction1?: Vector3,
  12875. /**
  12876. * The max limit of the emission direction.
  12877. */
  12878. direction2?: Vector3);
  12879. /**
  12880. * Called by the particle System when the direction is computed for the created particle.
  12881. * @param worldMatrix is the world matrix of the particle system
  12882. * @param directionToUpdate is the direction vector to update with the result
  12883. * @param particle is the particle we are computed the direction for
  12884. */
  12885. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  12886. /**
  12887. * Clones the current emitter and returns a copy of it
  12888. * @returns the new emitter
  12889. */
  12890. clone(): CylinderDirectedParticleEmitter;
  12891. /**
  12892. * Called by the GPUParticleSystem to setup the update shader
  12893. * @param effect defines the update shader
  12894. */
  12895. applyToShader(effect: Effect): void;
  12896. /**
  12897. * Returns a string to use to update the GPU particles update shader
  12898. * @returns a string containng the defines string
  12899. */
  12900. getEffectDefines(): string;
  12901. /**
  12902. * Returns the string "CylinderDirectedParticleEmitter"
  12903. * @returns a string containing the class name
  12904. */
  12905. getClassName(): string;
  12906. /**
  12907. * Serializes the particle system to a JSON object.
  12908. * @returns the JSON object
  12909. */
  12910. serialize(): any;
  12911. /**
  12912. * Parse properties from a JSON object
  12913. * @param serializationObject defines the JSON object
  12914. */
  12915. parse(serializationObject: any): void;
  12916. }
  12917. }
  12918. declare module "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter" {
  12919. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  12920. import { Effect } from "babylonjs/Materials/effect";
  12921. import { Particle } from "babylonjs/Particles/particle";
  12922. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  12923. /**
  12924. * Particle emitter emitting particles from the inside of a hemisphere.
  12925. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  12926. */
  12927. export class HemisphericParticleEmitter implements IParticleEmitterType {
  12928. /**
  12929. * The radius of the emission hemisphere.
  12930. */
  12931. radius: number;
  12932. /**
  12933. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12934. */
  12935. radiusRange: number;
  12936. /**
  12937. * How much to randomize the particle direction [0-1].
  12938. */
  12939. directionRandomizer: number;
  12940. /**
  12941. * Creates a new instance HemisphericParticleEmitter
  12942. * @param radius the radius of the emission hemisphere (1 by default)
  12943. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12944. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  12945. */
  12946. constructor(
  12947. /**
  12948. * The radius of the emission hemisphere.
  12949. */
  12950. radius?: number,
  12951. /**
  12952. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12953. */
  12954. radiusRange?: number,
  12955. /**
  12956. * How much to randomize the particle direction [0-1].
  12957. */
  12958. directionRandomizer?: number);
  12959. /**
  12960. * Called by the particle System when the direction is computed for the created particle.
  12961. * @param worldMatrix is the world matrix of the particle system
  12962. * @param directionToUpdate is the direction vector to update with the result
  12963. * @param particle is the particle we are computed the direction for
  12964. * @param isLocal defines if the direction should be set in local space
  12965. */
  12966. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12967. /**
  12968. * Called by the particle System when the position is computed for the created particle.
  12969. * @param worldMatrix is the world matrix of the particle system
  12970. * @param positionToUpdate is the position vector to update with the result
  12971. * @param particle is the particle we are computed the position for
  12972. * @param isLocal defines if the position should be set in local space
  12973. */
  12974. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12975. /**
  12976. * Clones the current emitter and returns a copy of it
  12977. * @returns the new emitter
  12978. */
  12979. clone(): HemisphericParticleEmitter;
  12980. /**
  12981. * Called by the GPUParticleSystem to setup the update shader
  12982. * @param effect defines the update shader
  12983. */
  12984. applyToShader(effect: Effect): void;
  12985. /**
  12986. * Returns a string to use to update the GPU particles update shader
  12987. * @returns a string containng the defines string
  12988. */
  12989. getEffectDefines(): string;
  12990. /**
  12991. * Returns the string "HemisphericParticleEmitter"
  12992. * @returns a string containing the class name
  12993. */
  12994. getClassName(): string;
  12995. /**
  12996. * Serializes the particle system to a JSON object.
  12997. * @returns the JSON object
  12998. */
  12999. serialize(): any;
  13000. /**
  13001. * Parse properties from a JSON object
  13002. * @param serializationObject defines the JSON object
  13003. */
  13004. parse(serializationObject: any): void;
  13005. }
  13006. }
  13007. declare module "babylonjs/Particles/EmitterTypes/pointParticleEmitter" {
  13008. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13009. import { Effect } from "babylonjs/Materials/effect";
  13010. import { Particle } from "babylonjs/Particles/particle";
  13011. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13012. /**
  13013. * Particle emitter emitting particles from a point.
  13014. * It emits the particles randomly between 2 given directions.
  13015. */
  13016. export class PointParticleEmitter implements IParticleEmitterType {
  13017. /**
  13018. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13019. */
  13020. direction1: Vector3;
  13021. /**
  13022. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13023. */
  13024. direction2: Vector3;
  13025. /**
  13026. * Creates a new instance PointParticleEmitter
  13027. */
  13028. constructor();
  13029. /**
  13030. * Called by the particle System when the direction is computed for the created particle.
  13031. * @param worldMatrix is the world matrix of the particle system
  13032. * @param directionToUpdate is the direction vector to update with the result
  13033. * @param particle is the particle we are computed the direction for
  13034. * @param isLocal defines if the direction should be set in local space
  13035. */
  13036. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13037. /**
  13038. * Called by the particle System when the position is computed for the created particle.
  13039. * @param worldMatrix is the world matrix of the particle system
  13040. * @param positionToUpdate is the position vector to update with the result
  13041. * @param particle is the particle we are computed the position for
  13042. * @param isLocal defines if the position should be set in local space
  13043. */
  13044. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13045. /**
  13046. * Clones the current emitter and returns a copy of it
  13047. * @returns the new emitter
  13048. */
  13049. clone(): PointParticleEmitter;
  13050. /**
  13051. * Called by the GPUParticleSystem to setup the update shader
  13052. * @param effect defines the update shader
  13053. */
  13054. applyToShader(effect: Effect): void;
  13055. /**
  13056. * Returns a string to use to update the GPU particles update shader
  13057. * @returns a string containng the defines string
  13058. */
  13059. getEffectDefines(): string;
  13060. /**
  13061. * Returns the string "PointParticleEmitter"
  13062. * @returns a string containing the class name
  13063. */
  13064. getClassName(): string;
  13065. /**
  13066. * Serializes the particle system to a JSON object.
  13067. * @returns the JSON object
  13068. */
  13069. serialize(): any;
  13070. /**
  13071. * Parse properties from a JSON object
  13072. * @param serializationObject defines the JSON object
  13073. */
  13074. parse(serializationObject: any): void;
  13075. }
  13076. }
  13077. declare module "babylonjs/Particles/EmitterTypes/sphereParticleEmitter" {
  13078. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13079. import { Effect } from "babylonjs/Materials/effect";
  13080. import { Particle } from "babylonjs/Particles/particle";
  13081. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13082. /**
  13083. * Particle emitter emitting particles from the inside of a sphere.
  13084. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  13085. */
  13086. export class SphereParticleEmitter implements IParticleEmitterType {
  13087. /**
  13088. * The radius of the emission sphere.
  13089. */
  13090. radius: number;
  13091. /**
  13092. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13093. */
  13094. radiusRange: number;
  13095. /**
  13096. * How much to randomize the particle direction [0-1].
  13097. */
  13098. directionRandomizer: number;
  13099. /**
  13100. * Creates a new instance SphereParticleEmitter
  13101. * @param radius the radius of the emission sphere (1 by default)
  13102. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13103. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13104. */
  13105. constructor(
  13106. /**
  13107. * The radius of the emission sphere.
  13108. */
  13109. radius?: number,
  13110. /**
  13111. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13112. */
  13113. radiusRange?: number,
  13114. /**
  13115. * How much to randomize the particle direction [0-1].
  13116. */
  13117. directionRandomizer?: number);
  13118. /**
  13119. * Called by the particle System when the direction is computed for the created particle.
  13120. * @param worldMatrix is the world matrix of the particle system
  13121. * @param directionToUpdate is the direction vector to update with the result
  13122. * @param particle is the particle we are computed the direction for
  13123. * @param isLocal defines if the direction should be set in local space
  13124. */
  13125. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13126. /**
  13127. * Called by the particle System when the position is computed for the created particle.
  13128. * @param worldMatrix is the world matrix of the particle system
  13129. * @param positionToUpdate is the position vector to update with the result
  13130. * @param particle is the particle we are computed the position for
  13131. * @param isLocal defines if the position should be set in local space
  13132. */
  13133. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13134. /**
  13135. * Clones the current emitter and returns a copy of it
  13136. * @returns the new emitter
  13137. */
  13138. clone(): SphereParticleEmitter;
  13139. /**
  13140. * Called by the GPUParticleSystem to setup the update shader
  13141. * @param effect defines the update shader
  13142. */
  13143. applyToShader(effect: Effect): void;
  13144. /**
  13145. * Returns a string to use to update the GPU particles update shader
  13146. * @returns a string containng the defines string
  13147. */
  13148. getEffectDefines(): string;
  13149. /**
  13150. * Returns the string "SphereParticleEmitter"
  13151. * @returns a string containing the class name
  13152. */
  13153. getClassName(): string;
  13154. /**
  13155. * Serializes the particle system to a JSON object.
  13156. * @returns the JSON object
  13157. */
  13158. serialize(): any;
  13159. /**
  13160. * Parse properties from a JSON object
  13161. * @param serializationObject defines the JSON object
  13162. */
  13163. parse(serializationObject: any): void;
  13164. }
  13165. /**
  13166. * Particle emitter emitting particles from the inside of a sphere.
  13167. * It emits the particles randomly between two vectors.
  13168. */
  13169. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  13170. /**
  13171. * The min limit of the emission direction.
  13172. */
  13173. direction1: Vector3;
  13174. /**
  13175. * The max limit of the emission direction.
  13176. */
  13177. direction2: Vector3;
  13178. /**
  13179. * Creates a new instance SphereDirectedParticleEmitter
  13180. * @param radius the radius of the emission sphere (1 by default)
  13181. * @param direction1 the min limit of the emission direction (up vector by default)
  13182. * @param direction2 the max limit of the emission direction (up vector by default)
  13183. */
  13184. constructor(radius?: number,
  13185. /**
  13186. * The min limit of the emission direction.
  13187. */
  13188. direction1?: Vector3,
  13189. /**
  13190. * The max limit of the emission direction.
  13191. */
  13192. direction2?: Vector3);
  13193. /**
  13194. * Called by the particle System when the direction is computed for the created particle.
  13195. * @param worldMatrix is the world matrix of the particle system
  13196. * @param directionToUpdate is the direction vector to update with the result
  13197. * @param particle is the particle we are computed the direction for
  13198. */
  13199. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  13200. /**
  13201. * Clones the current emitter and returns a copy of it
  13202. * @returns the new emitter
  13203. */
  13204. clone(): SphereDirectedParticleEmitter;
  13205. /**
  13206. * Called by the GPUParticleSystem to setup the update shader
  13207. * @param effect defines the update shader
  13208. */
  13209. applyToShader(effect: Effect): void;
  13210. /**
  13211. * Returns a string to use to update the GPU particles update shader
  13212. * @returns a string containng the defines string
  13213. */
  13214. getEffectDefines(): string;
  13215. /**
  13216. * Returns the string "SphereDirectedParticleEmitter"
  13217. * @returns a string containing the class name
  13218. */
  13219. getClassName(): string;
  13220. /**
  13221. * Serializes the particle system to a JSON object.
  13222. * @returns the JSON object
  13223. */
  13224. serialize(): any;
  13225. /**
  13226. * Parse properties from a JSON object
  13227. * @param serializationObject defines the JSON object
  13228. */
  13229. parse(serializationObject: any): void;
  13230. }
  13231. }
  13232. declare module "babylonjs/Particles/EmitterTypes/customParticleEmitter" {
  13233. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13234. import { Effect } from "babylonjs/Materials/effect";
  13235. import { Particle } from "babylonjs/Particles/particle";
  13236. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13237. import { Nullable } from "babylonjs/types";
  13238. /**
  13239. * Particle emitter emitting particles from a custom list of positions.
  13240. */
  13241. export class CustomParticleEmitter implements IParticleEmitterType {
  13242. /**
  13243. * Gets or sets the position generator that will create the inital position of each particle.
  13244. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  13245. */
  13246. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  13247. /**
  13248. * Gets or sets the destination generator that will create the final destination of each particle.
  13249. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  13250. */
  13251. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  13252. /**
  13253. * Creates a new instance CustomParticleEmitter
  13254. */
  13255. constructor();
  13256. /**
  13257. * Called by the particle System when the direction is computed for the created particle.
  13258. * @param worldMatrix is the world matrix of the particle system
  13259. * @param directionToUpdate is the direction vector to update with the result
  13260. * @param particle is the particle we are computed the direction for
  13261. * @param isLocal defines if the direction should be set in local space
  13262. */
  13263. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13264. /**
  13265. * Called by the particle System when the position is computed for the created particle.
  13266. * @param worldMatrix is the world matrix of the particle system
  13267. * @param positionToUpdate is the position vector to update with the result
  13268. * @param particle is the particle we are computed the position for
  13269. * @param isLocal defines if the position should be set in local space
  13270. */
  13271. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13272. /**
  13273. * Clones the current emitter and returns a copy of it
  13274. * @returns the new emitter
  13275. */
  13276. clone(): CustomParticleEmitter;
  13277. /**
  13278. * Called by the GPUParticleSystem to setup the update shader
  13279. * @param effect defines the update shader
  13280. */
  13281. applyToShader(effect: Effect): void;
  13282. /**
  13283. * Returns a string to use to update the GPU particles update shader
  13284. * @returns a string containng the defines string
  13285. */
  13286. getEffectDefines(): string;
  13287. /**
  13288. * Returns the string "PointParticleEmitter"
  13289. * @returns a string containing the class name
  13290. */
  13291. getClassName(): string;
  13292. /**
  13293. * Serializes the particle system to a JSON object.
  13294. * @returns the JSON object
  13295. */
  13296. serialize(): any;
  13297. /**
  13298. * Parse properties from a JSON object
  13299. * @param serializationObject defines the JSON object
  13300. */
  13301. parse(serializationObject: any): void;
  13302. }
  13303. }
  13304. declare module "babylonjs/Particles/EmitterTypes/meshParticleEmitter" {
  13305. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13306. import { Effect } from "babylonjs/Materials/effect";
  13307. import { Particle } from "babylonjs/Particles/particle";
  13308. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13309. import { Nullable } from "babylonjs/types";
  13310. import { Scene } from "babylonjs/scene";
  13311. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13312. /**
  13313. * Particle emitter emitting particles from the inside of a box.
  13314. * It emits the particles randomly between 2 given directions.
  13315. */
  13316. export class MeshParticleEmitter implements IParticleEmitterType {
  13317. private _indices;
  13318. private _positions;
  13319. private _normals;
  13320. private _storedNormal;
  13321. private _mesh;
  13322. /**
  13323. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13324. */
  13325. direction1: Vector3;
  13326. /**
  13327. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13328. */
  13329. direction2: Vector3;
  13330. /**
  13331. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  13332. */
  13333. useMeshNormalsForDirection: boolean;
  13334. /** Defines the mesh to use as source */
  13335. get mesh(): Nullable<AbstractMesh>;
  13336. set mesh(value: Nullable<AbstractMesh>);
  13337. /**
  13338. * Creates a new instance MeshParticleEmitter
  13339. * @param mesh defines the mesh to use as source
  13340. */
  13341. constructor(mesh?: Nullable<AbstractMesh>);
  13342. /**
  13343. * Called by the particle System when the direction is computed for the created particle.
  13344. * @param worldMatrix is the world matrix of the particle system
  13345. * @param directionToUpdate is the direction vector to update with the result
  13346. * @param particle is the particle we are computed the direction for
  13347. * @param isLocal defines if the direction should be set in local space
  13348. */
  13349. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13350. /**
  13351. * Called by the particle System when the position is computed for the created particle.
  13352. * @param worldMatrix is the world matrix of the particle system
  13353. * @param positionToUpdate is the position vector to update with the result
  13354. * @param particle is the particle we are computed the position for
  13355. * @param isLocal defines if the position should be set in local space
  13356. */
  13357. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13358. /**
  13359. * Clones the current emitter and returns a copy of it
  13360. * @returns the new emitter
  13361. */
  13362. clone(): MeshParticleEmitter;
  13363. /**
  13364. * Called by the GPUParticleSystem to setup the update shader
  13365. * @param effect defines the update shader
  13366. */
  13367. applyToShader(effect: Effect): void;
  13368. /**
  13369. * Returns a string to use to update the GPU particles update shader
  13370. * @returns a string containng the defines string
  13371. */
  13372. getEffectDefines(): string;
  13373. /**
  13374. * Returns the string "BoxParticleEmitter"
  13375. * @returns a string containing the class name
  13376. */
  13377. getClassName(): string;
  13378. /**
  13379. * Serializes the particle system to a JSON object.
  13380. * @returns the JSON object
  13381. */
  13382. serialize(): any;
  13383. /**
  13384. * Parse properties from a JSON object
  13385. * @param serializationObject defines the JSON object
  13386. * @param scene defines the hosting scene
  13387. */
  13388. parse(serializationObject: any, scene: Scene): void;
  13389. }
  13390. }
  13391. declare module "babylonjs/Particles/EmitterTypes/index" {
  13392. export * from "babylonjs/Particles/EmitterTypes/boxParticleEmitter";
  13393. export * from "babylonjs/Particles/EmitterTypes/coneParticleEmitter";
  13394. export * from "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter";
  13395. export * from "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter";
  13396. export * from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13397. export * from "babylonjs/Particles/EmitterTypes/pointParticleEmitter";
  13398. export * from "babylonjs/Particles/EmitterTypes/sphereParticleEmitter";
  13399. export * from "babylonjs/Particles/EmitterTypes/customParticleEmitter";
  13400. export * from "babylonjs/Particles/EmitterTypes/meshParticleEmitter";
  13401. }
  13402. declare module "babylonjs/Particles/IParticleSystem" {
  13403. import { Nullable } from "babylonjs/types";
  13404. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  13405. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  13406. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13407. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  13408. import { Texture } from "babylonjs/Materials/Textures/texture";
  13409. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  13410. import { Scene } from "babylonjs/scene";
  13411. import { ColorGradient, FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  13412. import { Animation } from "babylonjs/Animations/animation";
  13413. /**
  13414. * Interface representing a particle system in Babylon.js.
  13415. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  13416. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  13417. */
  13418. export interface IParticleSystem {
  13419. /**
  13420. * List of animations used by the particle system.
  13421. */
  13422. animations: Animation[];
  13423. /**
  13424. * The id of the Particle system.
  13425. */
  13426. id: string;
  13427. /**
  13428. * The name of the Particle system.
  13429. */
  13430. name: string;
  13431. /**
  13432. * The emitter represents the Mesh or position we are attaching the particle system to.
  13433. */
  13434. emitter: Nullable<AbstractMesh | Vector3>;
  13435. /**
  13436. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  13437. */
  13438. isBillboardBased: boolean;
  13439. /**
  13440. * The rendering group used by the Particle system to chose when to render.
  13441. */
  13442. renderingGroupId: number;
  13443. /**
  13444. * The layer mask we are rendering the particles through.
  13445. */
  13446. layerMask: number;
  13447. /**
  13448. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  13449. */
  13450. updateSpeed: number;
  13451. /**
  13452. * The amount of time the particle system is running (depends of the overall update speed).
  13453. */
  13454. targetStopDuration: number;
  13455. /**
  13456. * The texture used to render each particle. (this can be a spritesheet)
  13457. */
  13458. particleTexture: Nullable<Texture>;
  13459. /**
  13460. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  13461. */
  13462. blendMode: number;
  13463. /**
  13464. * Minimum life time of emitting particles.
  13465. */
  13466. minLifeTime: number;
  13467. /**
  13468. * Maximum life time of emitting particles.
  13469. */
  13470. maxLifeTime: number;
  13471. /**
  13472. * Minimum Size of emitting particles.
  13473. */
  13474. minSize: number;
  13475. /**
  13476. * Maximum Size of emitting particles.
  13477. */
  13478. maxSize: number;
  13479. /**
  13480. * Minimum scale of emitting particles on X axis.
  13481. */
  13482. minScaleX: number;
  13483. /**
  13484. * Maximum scale of emitting particles on X axis.
  13485. */
  13486. maxScaleX: number;
  13487. /**
  13488. * Minimum scale of emitting particles on Y axis.
  13489. */
  13490. minScaleY: number;
  13491. /**
  13492. * Maximum scale of emitting particles on Y axis.
  13493. */
  13494. maxScaleY: number;
  13495. /**
  13496. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  13497. */
  13498. color1: Color4;
  13499. /**
  13500. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  13501. */
  13502. color2: Color4;
  13503. /**
  13504. * Color the particle will have at the end of its lifetime.
  13505. */
  13506. colorDead: Color4;
  13507. /**
  13508. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  13509. */
  13510. emitRate: number;
  13511. /**
  13512. * You can use gravity if you want to give an orientation to your particles.
  13513. */
  13514. gravity: Vector3;
  13515. /**
  13516. * Minimum power of emitting particles.
  13517. */
  13518. minEmitPower: number;
  13519. /**
  13520. * Maximum power of emitting particles.
  13521. */
  13522. maxEmitPower: number;
  13523. /**
  13524. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  13525. */
  13526. minAngularSpeed: number;
  13527. /**
  13528. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  13529. */
  13530. maxAngularSpeed: number;
  13531. /**
  13532. * Gets or sets the minimal initial rotation in radians.
  13533. */
  13534. minInitialRotation: number;
  13535. /**
  13536. * Gets or sets the maximal initial rotation in radians.
  13537. */
  13538. maxInitialRotation: number;
  13539. /**
  13540. * The particle emitter type defines the emitter used by the particle system.
  13541. * It can be for example box, sphere, or cone...
  13542. */
  13543. particleEmitterType: Nullable<IParticleEmitterType>;
  13544. /**
  13545. * Defines the delay in milliseconds before starting the system (0 by default)
  13546. */
  13547. startDelay: number;
  13548. /**
  13549. * Gets or sets a value indicating how many cycles (or frames) must be executed before first rendering (this value has to be set before starting the system). Default is 0
  13550. */
  13551. preWarmCycles: number;
  13552. /**
  13553. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  13554. */
  13555. preWarmStepOffset: number;
  13556. /**
  13557. * If using a spritesheet (isAnimationSheetEnabled) defines the speed of the sprite loop (default is 1 meaning the animation will play once during the entire particle lifetime)
  13558. */
  13559. spriteCellChangeSpeed: number;
  13560. /**
  13561. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  13562. */
  13563. startSpriteCellID: number;
  13564. /**
  13565. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  13566. */
  13567. endSpriteCellID: number;
  13568. /**
  13569. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  13570. */
  13571. spriteCellWidth: number;
  13572. /**
  13573. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  13574. */
  13575. spriteCellHeight: number;
  13576. /**
  13577. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  13578. */
  13579. spriteRandomStartCell: boolean;
  13580. /**
  13581. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  13582. */
  13583. isAnimationSheetEnabled: boolean;
  13584. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  13585. translationPivot: Vector2;
  13586. /**
  13587. * Gets or sets a texture used to add random noise to particle positions
  13588. */
  13589. noiseTexture: Nullable<BaseTexture>;
  13590. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  13591. noiseStrength: Vector3;
  13592. /**
  13593. * Gets or sets the billboard mode to use when isBillboardBased = true.
  13594. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  13595. */
  13596. billboardMode: number;
  13597. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  13598. limitVelocityDamping: number;
  13599. /**
  13600. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  13601. */
  13602. beginAnimationOnStart: boolean;
  13603. /**
  13604. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  13605. */
  13606. beginAnimationFrom: number;
  13607. /**
  13608. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  13609. */
  13610. beginAnimationTo: number;
  13611. /**
  13612. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  13613. */
  13614. beginAnimationLoop: boolean;
  13615. /**
  13616. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  13617. */
  13618. disposeOnStop: boolean;
  13619. /**
  13620. * Specifies if the particles are updated in emitter local space or world space
  13621. */
  13622. isLocal: boolean;
  13623. /** Snippet ID if the particle system was created from the snippet server */
  13624. snippetId: string;
  13625. /**
  13626. * Gets the maximum number of particles active at the same time.
  13627. * @returns The max number of active particles.
  13628. */
  13629. getCapacity(): number;
  13630. /**
  13631. * Gets the number of particles active at the same time.
  13632. * @returns The number of active particles.
  13633. */
  13634. getActiveCount(): number;
  13635. /**
  13636. * Gets if the system has been started. (Note: this will still be true after stop is called)
  13637. * @returns True if it has been started, otherwise false.
  13638. */
  13639. isStarted(): boolean;
  13640. /**
  13641. * Animates the particle system for this frame.
  13642. */
  13643. animate(): void;
  13644. /**
  13645. * Renders the particle system in its current state.
  13646. * @returns the current number of particles
  13647. */
  13648. render(): number;
  13649. /**
  13650. * Dispose the particle system and frees its associated resources.
  13651. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  13652. */
  13653. dispose(disposeTexture?: boolean): void;
  13654. /**
  13655. * Clones the particle system.
  13656. * @param name The name of the cloned object
  13657. * @param newEmitter The new emitter to use
  13658. * @returns the cloned particle system
  13659. */
  13660. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  13661. /**
  13662. * Serializes the particle system to a JSON object
  13663. * @param serializeTexture defines if the texture must be serialized as well
  13664. * @returns the JSON object
  13665. */
  13666. serialize(serializeTexture: boolean): any;
  13667. /**
  13668. * Rebuild the particle system
  13669. */
  13670. rebuild(): void;
  13671. /** Force the system to rebuild all gradients that need to be resync */
  13672. forceRefreshGradients(): void;
  13673. /**
  13674. * Starts the particle system and begins to emit
  13675. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  13676. */
  13677. start(delay?: number): void;
  13678. /**
  13679. * Stops the particle system.
  13680. */
  13681. stop(): void;
  13682. /**
  13683. * Remove all active particles
  13684. */
  13685. reset(): void;
  13686. /**
  13687. * Gets a boolean indicating that the system is stopping
  13688. * @returns true if the system is currently stopping
  13689. */
  13690. isStopping(): boolean;
  13691. /**
  13692. * Is this system ready to be used/rendered
  13693. * @return true if the system is ready
  13694. */
  13695. isReady(): boolean;
  13696. /**
  13697. * Returns the string "ParticleSystem"
  13698. * @returns a string containing the class name
  13699. */
  13700. getClassName(): string;
  13701. /**
  13702. * Adds a new color gradient
  13703. * @param gradient defines the gradient to use (between 0 and 1)
  13704. * @param color1 defines the color to affect to the specified gradient
  13705. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  13706. * @returns the current particle system
  13707. */
  13708. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  13709. /**
  13710. * Remove a specific color gradient
  13711. * @param gradient defines the gradient to remove
  13712. * @returns the current particle system
  13713. */
  13714. removeColorGradient(gradient: number): IParticleSystem;
  13715. /**
  13716. * Adds a new size gradient
  13717. * @param gradient defines the gradient to use (between 0 and 1)
  13718. * @param factor defines the size factor to affect to the specified gradient
  13719. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13720. * @returns the current particle system
  13721. */
  13722. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13723. /**
  13724. * Remove a specific size gradient
  13725. * @param gradient defines the gradient to remove
  13726. * @returns the current particle system
  13727. */
  13728. removeSizeGradient(gradient: number): IParticleSystem;
  13729. /**
  13730. * Gets the current list of color gradients.
  13731. * You must use addColorGradient and removeColorGradient to udpate this list
  13732. * @returns the list of color gradients
  13733. */
  13734. getColorGradients(): Nullable<Array<ColorGradient>>;
  13735. /**
  13736. * Gets the current list of size gradients.
  13737. * You must use addSizeGradient and removeSizeGradient to udpate this list
  13738. * @returns the list of size gradients
  13739. */
  13740. getSizeGradients(): Nullable<Array<FactorGradient>>;
  13741. /**
  13742. * Gets the current list of angular speed gradients.
  13743. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  13744. * @returns the list of angular speed gradients
  13745. */
  13746. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  13747. /**
  13748. * Adds a new angular speed gradient
  13749. * @param gradient defines the gradient to use (between 0 and 1)
  13750. * @param factor defines the angular speed to affect to the specified gradient
  13751. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13752. * @returns the current particle system
  13753. */
  13754. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13755. /**
  13756. * Remove a specific angular speed gradient
  13757. * @param gradient defines the gradient to remove
  13758. * @returns the current particle system
  13759. */
  13760. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  13761. /**
  13762. * Gets the current list of velocity gradients.
  13763. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  13764. * @returns the list of velocity gradients
  13765. */
  13766. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  13767. /**
  13768. * Adds a new velocity gradient
  13769. * @param gradient defines the gradient to use (between 0 and 1)
  13770. * @param factor defines the velocity to affect to the specified gradient
  13771. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13772. * @returns the current particle system
  13773. */
  13774. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13775. /**
  13776. * Remove a specific velocity gradient
  13777. * @param gradient defines the gradient to remove
  13778. * @returns the current particle system
  13779. */
  13780. removeVelocityGradient(gradient: number): IParticleSystem;
  13781. /**
  13782. * Gets the current list of limit velocity gradients.
  13783. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  13784. * @returns the list of limit velocity gradients
  13785. */
  13786. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  13787. /**
  13788. * Adds a new limit velocity gradient
  13789. * @param gradient defines the gradient to use (between 0 and 1)
  13790. * @param factor defines the limit velocity to affect to the specified gradient
  13791. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13792. * @returns the current particle system
  13793. */
  13794. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13795. /**
  13796. * Remove a specific limit velocity gradient
  13797. * @param gradient defines the gradient to remove
  13798. * @returns the current particle system
  13799. */
  13800. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  13801. /**
  13802. * Adds a new drag gradient
  13803. * @param gradient defines the gradient to use (between 0 and 1)
  13804. * @param factor defines the drag to affect to the specified gradient
  13805. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13806. * @returns the current particle system
  13807. */
  13808. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13809. /**
  13810. * Remove a specific drag gradient
  13811. * @param gradient defines the gradient to remove
  13812. * @returns the current particle system
  13813. */
  13814. removeDragGradient(gradient: number): IParticleSystem;
  13815. /**
  13816. * Gets the current list of drag gradients.
  13817. * You must use addDragGradient and removeDragGradient to udpate this list
  13818. * @returns the list of drag gradients
  13819. */
  13820. getDragGradients(): Nullable<Array<FactorGradient>>;
  13821. /**
  13822. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  13823. * @param gradient defines the gradient to use (between 0 and 1)
  13824. * @param factor defines the emit rate to affect to the specified gradient
  13825. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13826. * @returns the current particle system
  13827. */
  13828. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13829. /**
  13830. * Remove a specific emit rate gradient
  13831. * @param gradient defines the gradient to remove
  13832. * @returns the current particle system
  13833. */
  13834. removeEmitRateGradient(gradient: number): IParticleSystem;
  13835. /**
  13836. * Gets the current list of emit rate gradients.
  13837. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  13838. * @returns the list of emit rate gradients
  13839. */
  13840. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  13841. /**
  13842. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  13843. * @param gradient defines the gradient to use (between 0 and 1)
  13844. * @param factor defines the start size to affect to the specified gradient
  13845. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13846. * @returns the current particle system
  13847. */
  13848. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13849. /**
  13850. * Remove a specific start size gradient
  13851. * @param gradient defines the gradient to remove
  13852. * @returns the current particle system
  13853. */
  13854. removeStartSizeGradient(gradient: number): IParticleSystem;
  13855. /**
  13856. * Gets the current list of start size gradients.
  13857. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  13858. * @returns the list of start size gradients
  13859. */
  13860. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  13861. /**
  13862. * Adds a new life time gradient
  13863. * @param gradient defines the gradient to use (between 0 and 1)
  13864. * @param factor defines the life time factor to affect to the specified gradient
  13865. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13866. * @returns the current particle system
  13867. */
  13868. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13869. /**
  13870. * Remove a specific life time gradient
  13871. * @param gradient defines the gradient to remove
  13872. * @returns the current particle system
  13873. */
  13874. removeLifeTimeGradient(gradient: number): IParticleSystem;
  13875. /**
  13876. * Gets the current list of life time gradients.
  13877. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  13878. * @returns the list of life time gradients
  13879. */
  13880. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  13881. /**
  13882. * Gets the current list of color gradients.
  13883. * You must use addColorGradient and removeColorGradient to udpate this list
  13884. * @returns the list of color gradients
  13885. */
  13886. getColorGradients(): Nullable<Array<ColorGradient>>;
  13887. /**
  13888. * Adds a new ramp gradient used to remap particle colors
  13889. * @param gradient defines the gradient to use (between 0 and 1)
  13890. * @param color defines the color to affect to the specified gradient
  13891. * @returns the current particle system
  13892. */
  13893. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  13894. /**
  13895. * Gets the current list of ramp gradients.
  13896. * You must use addRampGradient and removeRampGradient to udpate this list
  13897. * @returns the list of ramp gradients
  13898. */
  13899. getRampGradients(): Nullable<Array<Color3Gradient>>;
  13900. /** Gets or sets a boolean indicating that ramp gradients must be used
  13901. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  13902. */
  13903. useRampGradients: boolean;
  13904. /**
  13905. * Adds a new color remap gradient
  13906. * @param gradient defines the gradient to use (between 0 and 1)
  13907. * @param min defines the color remap minimal range
  13908. * @param max defines the color remap maximal range
  13909. * @returns the current particle system
  13910. */
  13911. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  13912. /**
  13913. * Gets the current list of color remap gradients.
  13914. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  13915. * @returns the list of color remap gradients
  13916. */
  13917. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  13918. /**
  13919. * Adds a new alpha remap gradient
  13920. * @param gradient defines the gradient to use (between 0 and 1)
  13921. * @param min defines the alpha remap minimal range
  13922. * @param max defines the alpha remap maximal range
  13923. * @returns the current particle system
  13924. */
  13925. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  13926. /**
  13927. * Gets the current list of alpha remap gradients.
  13928. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  13929. * @returns the list of alpha remap gradients
  13930. */
  13931. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  13932. /**
  13933. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  13934. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  13935. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  13936. * @returns the emitter
  13937. */
  13938. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  13939. /**
  13940. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  13941. * @param radius The radius of the hemisphere to emit from
  13942. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  13943. * @returns the emitter
  13944. */
  13945. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  13946. /**
  13947. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  13948. * @param radius The radius of the sphere to emit from
  13949. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  13950. * @returns the emitter
  13951. */
  13952. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  13953. /**
  13954. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  13955. * @param radius The radius of the sphere to emit from
  13956. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  13957. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  13958. * @returns the emitter
  13959. */
  13960. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  13961. /**
  13962. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  13963. * @param radius The radius of the emission cylinder
  13964. * @param height The height of the emission cylinder
  13965. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  13966. * @param directionRandomizer How much to randomize the particle direction [0-1]
  13967. * @returns the emitter
  13968. */
  13969. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  13970. /**
  13971. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  13972. * @param radius The radius of the cylinder to emit from
  13973. * @param height The height of the emission cylinder
  13974. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13975. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  13976. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  13977. * @returns the emitter
  13978. */
  13979. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  13980. /**
  13981. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  13982. * @param radius The radius of the cone to emit from
  13983. * @param angle The base angle of the cone
  13984. * @returns the emitter
  13985. */
  13986. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  13987. /**
  13988. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  13989. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  13990. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  13991. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  13992. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  13993. * @returns the emitter
  13994. */
  13995. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  13996. /**
  13997. * Get hosting scene
  13998. * @returns the scene
  13999. */
  14000. getScene(): Scene;
  14001. }
  14002. }
  14003. declare module "babylonjs/Meshes/transformNode" {
  14004. import { DeepImmutable } from "babylonjs/types";
  14005. import { Observable } from "babylonjs/Misc/observable";
  14006. import { Nullable } from "babylonjs/types";
  14007. import { Camera } from "babylonjs/Cameras/camera";
  14008. import { Scene } from "babylonjs/scene";
  14009. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  14010. import { Node } from "babylonjs/node";
  14011. import { Bone } from "babylonjs/Bones/bone";
  14012. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14013. import { Space } from "babylonjs/Maths/math.axis";
  14014. /**
  14015. * A TransformNode is an object that is not rendered but can be used as a center of transformation. This can decrease memory usage and increase rendering speed compared to using an empty mesh as a parent and is less complicated than using a pivot matrix.
  14016. * @see https://doc.babylonjs.com/how_to/transformnode
  14017. */
  14018. export class TransformNode extends Node {
  14019. /**
  14020. * Object will not rotate to face the camera
  14021. */
  14022. static BILLBOARDMODE_NONE: number;
  14023. /**
  14024. * Object will rotate to face the camera but only on the x axis
  14025. */
  14026. static BILLBOARDMODE_X: number;
  14027. /**
  14028. * Object will rotate to face the camera but only on the y axis
  14029. */
  14030. static BILLBOARDMODE_Y: number;
  14031. /**
  14032. * Object will rotate to face the camera but only on the z axis
  14033. */
  14034. static BILLBOARDMODE_Z: number;
  14035. /**
  14036. * Object will rotate to face the camera
  14037. */
  14038. static BILLBOARDMODE_ALL: number;
  14039. /**
  14040. * Object will rotate to face the camera's position instead of orientation
  14041. */
  14042. static BILLBOARDMODE_USE_POSITION: number;
  14043. private _forward;
  14044. private _forwardInverted;
  14045. private _up;
  14046. private _right;
  14047. private _rightInverted;
  14048. private _position;
  14049. private _rotation;
  14050. private _rotationQuaternion;
  14051. protected _scaling: Vector3;
  14052. protected _isDirty: boolean;
  14053. private _transformToBoneReferal;
  14054. private _isAbsoluteSynced;
  14055. private _billboardMode;
  14056. /**
  14057. * Gets or sets the billboard mode. Default is 0.
  14058. *
  14059. * | Value | Type | Description |
  14060. * | --- | --- | --- |
  14061. * | 0 | BILLBOARDMODE_NONE | |
  14062. * | 1 | BILLBOARDMODE_X | |
  14063. * | 2 | BILLBOARDMODE_Y | |
  14064. * | 4 | BILLBOARDMODE_Z | |
  14065. * | 7 | BILLBOARDMODE_ALL | |
  14066. *
  14067. */
  14068. get billboardMode(): number;
  14069. set billboardMode(value: number);
  14070. private _preserveParentRotationForBillboard;
  14071. /**
  14072. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  14073. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  14074. */
  14075. get preserveParentRotationForBillboard(): boolean;
  14076. set preserveParentRotationForBillboard(value: boolean);
  14077. /**
  14078. * Multiplication factor on scale x/y/z when computing the world matrix. Eg. for a 1x1x1 cube setting this to 2 will make it a 2x2x2 cube
  14079. */
  14080. scalingDeterminant: number;
  14081. private _infiniteDistance;
  14082. /**
  14083. * Gets or sets the distance of the object to max, often used by skybox
  14084. */
  14085. get infiniteDistance(): boolean;
  14086. set infiniteDistance(value: boolean);
  14087. /**
  14088. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  14089. * By default the system will update normals to compensate
  14090. */
  14091. ignoreNonUniformScaling: boolean;
  14092. /**
  14093. * Gets or sets a boolean indicating that even if rotationQuaternion is defined, you can keep updating rotation property and Babylon.js will just mix both
  14094. */
  14095. reIntegrateRotationIntoRotationQuaternion: boolean;
  14096. /** @hidden */
  14097. _poseMatrix: Nullable<Matrix>;
  14098. /** @hidden */
  14099. _localMatrix: Matrix;
  14100. private _usePivotMatrix;
  14101. private _absolutePosition;
  14102. private _absoluteScaling;
  14103. private _absoluteRotationQuaternion;
  14104. private _pivotMatrix;
  14105. private _pivotMatrixInverse;
  14106. protected _postMultiplyPivotMatrix: boolean;
  14107. protected _isWorldMatrixFrozen: boolean;
  14108. /** @hidden */
  14109. _indexInSceneTransformNodesArray: number;
  14110. /**
  14111. * An event triggered after the world matrix is updated
  14112. */
  14113. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  14114. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  14115. /**
  14116. * Gets a string identifying the name of the class
  14117. * @returns "TransformNode" string
  14118. */
  14119. getClassName(): string;
  14120. /**
  14121. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  14122. */
  14123. get position(): Vector3;
  14124. set position(newPosition: Vector3);
  14125. /**
  14126. * Gets or sets the rotation property : a Vector3 defining the rotation value in radians around each local axis X, Y, Z (default is (0.0, 0.0, 0.0)).
  14127. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  14128. */
  14129. get rotation(): Vector3;
  14130. set rotation(newRotation: Vector3);
  14131. /**
  14132. * Gets or sets the scaling property : a Vector3 defining the node scaling along each local axis X, Y, Z (default is (0.0, 0.0, 0.0)).
  14133. */
  14134. get scaling(): Vector3;
  14135. set scaling(newScaling: Vector3);
  14136. /**
  14137. * Gets or sets the rotation Quaternion property : this a Quaternion object defining the node rotation by using a unit quaternion (undefined by default, but can be null).
  14138. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  14139. */
  14140. get rotationQuaternion(): Nullable<Quaternion>;
  14141. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  14142. /**
  14143. * The forward direction of that transform in world space.
  14144. */
  14145. get forward(): Vector3;
  14146. /**
  14147. * The up direction of that transform in world space.
  14148. */
  14149. get up(): Vector3;
  14150. /**
  14151. * The right direction of that transform in world space.
  14152. */
  14153. get right(): Vector3;
  14154. /**
  14155. * Copies the parameter passed Matrix into the mesh Pose matrix.
  14156. * @param matrix the matrix to copy the pose from
  14157. * @returns this TransformNode.
  14158. */
  14159. updatePoseMatrix(matrix: Matrix): TransformNode;
  14160. /**
  14161. * Returns the mesh Pose matrix.
  14162. * @returns the pose matrix
  14163. */
  14164. getPoseMatrix(): Matrix;
  14165. /** @hidden */
  14166. _isSynchronized(): boolean;
  14167. /** @hidden */
  14168. _initCache(): void;
  14169. /**
  14170. * Flag the transform node as dirty (Forcing it to update everything)
  14171. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  14172. * @returns this transform node
  14173. */
  14174. markAsDirty(property: string): TransformNode;
  14175. /**
  14176. * Returns the current mesh absolute position.
  14177. * Returns a Vector3.
  14178. */
  14179. get absolutePosition(): Vector3;
  14180. /**
  14181. * Returns the current mesh absolute scaling.
  14182. * Returns a Vector3.
  14183. */
  14184. get absoluteScaling(): Vector3;
  14185. /**
  14186. * Returns the current mesh absolute rotation.
  14187. * Returns a Quaternion.
  14188. */
  14189. get absoluteRotationQuaternion(): Quaternion;
  14190. /**
  14191. * Sets a new matrix to apply before all other transformation
  14192. * @param matrix defines the transform matrix
  14193. * @returns the current TransformNode
  14194. */
  14195. setPreTransformMatrix(matrix: Matrix): TransformNode;
  14196. /**
  14197. * Sets a new pivot matrix to the current node
  14198. * @param matrix defines the new pivot matrix to use
  14199. * @param postMultiplyPivotMatrix defines if the pivot matrix must be cancelled in the world matrix. When this parameter is set to true (default), the inverse of the pivot matrix is also applied at the end to cancel the transformation effect
  14200. * @returns the current TransformNode
  14201. */
  14202. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  14203. /**
  14204. * Returns the mesh pivot matrix.
  14205. * Default : Identity.
  14206. * @returns the matrix
  14207. */
  14208. getPivotMatrix(): Matrix;
  14209. /**
  14210. * Instantiate (when possible) or clone that node with its hierarchy
  14211. * @param newParent defines the new parent to use for the instance (or clone)
  14212. * @param options defines options to configure how copy is done
  14213. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  14214. * @returns an instance (or a clone) of the current node with its hiearchy
  14215. */
  14216. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  14217. doNotInstantiate: boolean;
  14218. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  14219. /**
  14220. * Prevents the World matrix to be computed any longer
  14221. * @param newWorldMatrix defines an optional matrix to use as world matrix
  14222. * @returns the TransformNode.
  14223. */
  14224. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  14225. /**
  14226. * Allows back the World matrix computation.
  14227. * @returns the TransformNode.
  14228. */
  14229. unfreezeWorldMatrix(): this;
  14230. /**
  14231. * True if the World matrix has been frozen.
  14232. */
  14233. get isWorldMatrixFrozen(): boolean;
  14234. /**
  14235. * Retuns the mesh absolute position in the World.
  14236. * @returns a Vector3.
  14237. */
  14238. getAbsolutePosition(): Vector3;
  14239. /**
  14240. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  14241. * @param absolutePosition the absolute position to set
  14242. * @returns the TransformNode.
  14243. */
  14244. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  14245. /**
  14246. * Sets the mesh position in its local space.
  14247. * @param vector3 the position to set in localspace
  14248. * @returns the TransformNode.
  14249. */
  14250. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  14251. /**
  14252. * Returns the mesh position in the local space from the current World matrix values.
  14253. * @returns a new Vector3.
  14254. */
  14255. getPositionExpressedInLocalSpace(): Vector3;
  14256. /**
  14257. * Translates the mesh along the passed Vector3 in its local space.
  14258. * @param vector3 the distance to translate in localspace
  14259. * @returns the TransformNode.
  14260. */
  14261. locallyTranslate(vector3: Vector3): TransformNode;
  14262. private static _lookAtVectorCache;
  14263. /**
  14264. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  14265. * @param targetPoint the position (must be in same space as current mesh) to look at
  14266. * @param yawCor optional yaw (y-axis) correction in radians
  14267. * @param pitchCor optional pitch (x-axis) correction in radians
  14268. * @param rollCor optional roll (z-axis) correction in radians
  14269. * @param space the choosen space of the target
  14270. * @returns the TransformNode.
  14271. */
  14272. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  14273. /**
  14274. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14275. * This Vector3 is expressed in the World space.
  14276. * @param localAxis axis to rotate
  14277. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14278. */
  14279. getDirection(localAxis: Vector3): Vector3;
  14280. /**
  14281. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  14282. * localAxis is expressed in the mesh local space.
  14283. * result is computed in the Wordl space from the mesh World matrix.
  14284. * @param localAxis axis to rotate
  14285. * @param result the resulting transformnode
  14286. * @returns this TransformNode.
  14287. */
  14288. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  14289. /**
  14290. * Sets this transform node rotation to the given local axis.
  14291. * @param localAxis the axis in local space
  14292. * @param yawCor optional yaw (y-axis) correction in radians
  14293. * @param pitchCor optional pitch (x-axis) correction in radians
  14294. * @param rollCor optional roll (z-axis) correction in radians
  14295. * @returns this TransformNode
  14296. */
  14297. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  14298. /**
  14299. * Sets a new pivot point to the current node
  14300. * @param point defines the new pivot point to use
  14301. * @param space defines if the point is in world or local space (local by default)
  14302. * @returns the current TransformNode
  14303. */
  14304. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  14305. /**
  14306. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  14307. * @returns the pivot point
  14308. */
  14309. getPivotPoint(): Vector3;
  14310. /**
  14311. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  14312. * @param result the vector3 to store the result
  14313. * @returns this TransformNode.
  14314. */
  14315. getPivotPointToRef(result: Vector3): TransformNode;
  14316. /**
  14317. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  14318. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  14319. */
  14320. getAbsolutePivotPoint(): Vector3;
  14321. /**
  14322. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  14323. * @param result vector3 to store the result
  14324. * @returns this TransformNode.
  14325. */
  14326. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  14327. /**
  14328. * Defines the passed node as the parent of the current node.
  14329. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  14330. * @see https://doc.babylonjs.com/how_to/parenting
  14331. * @param node the node ot set as the parent
  14332. * @returns this TransformNode.
  14333. */
  14334. setParent(node: Nullable<Node>): TransformNode;
  14335. private _nonUniformScaling;
  14336. /**
  14337. * True if the scaling property of this object is non uniform eg. (1,2,1)
  14338. */
  14339. get nonUniformScaling(): boolean;
  14340. /** @hidden */
  14341. _updateNonUniformScalingState(value: boolean): boolean;
  14342. /**
  14343. * Attach the current TransformNode to another TransformNode associated with a bone
  14344. * @param bone Bone affecting the TransformNode
  14345. * @param affectedTransformNode TransformNode associated with the bone
  14346. * @returns this object
  14347. */
  14348. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  14349. /**
  14350. * Detach the transform node if its associated with a bone
  14351. * @returns this object
  14352. */
  14353. detachFromBone(): TransformNode;
  14354. private static _rotationAxisCache;
  14355. /**
  14356. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  14357. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14358. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14359. * The passed axis is also normalized.
  14360. * @param axis the axis to rotate around
  14361. * @param amount the amount to rotate in radians
  14362. * @param space Space to rotate in (Default: local)
  14363. * @returns the TransformNode.
  14364. */
  14365. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  14366. /**
  14367. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  14368. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14369. * The passed axis is also normalized. .
  14370. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  14371. * @param point the point to rotate around
  14372. * @param axis the axis to rotate around
  14373. * @param amount the amount to rotate in radians
  14374. * @returns the TransformNode
  14375. */
  14376. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  14377. /**
  14378. * Translates the mesh along the axis vector for the passed distance in the given space.
  14379. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14380. * @param axis the axis to translate in
  14381. * @param distance the distance to translate
  14382. * @param space Space to rotate in (Default: local)
  14383. * @returns the TransformNode.
  14384. */
  14385. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  14386. /**
  14387. * Adds a rotation step to the mesh current rotation.
  14388. * x, y, z are Euler angles expressed in radians.
  14389. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  14390. * This means this rotation is made in the mesh local space only.
  14391. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  14392. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  14393. * ```javascript
  14394. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  14395. * ```
  14396. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  14397. * Under the hood, only quaternions are used. So it's a little faster is you use .rotationQuaternion because it doesn't need to translate them back to Euler angles.
  14398. * @param x Rotation to add
  14399. * @param y Rotation to add
  14400. * @param z Rotation to add
  14401. * @returns the TransformNode.
  14402. */
  14403. addRotation(x: number, y: number, z: number): TransformNode;
  14404. /**
  14405. * @hidden
  14406. */
  14407. protected _getEffectiveParent(): Nullable<Node>;
  14408. /**
  14409. * Computes the world matrix of the node
  14410. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14411. * @returns the world matrix
  14412. */
  14413. computeWorldMatrix(force?: boolean): Matrix;
  14414. /**
  14415. * Resets this nodeTransform's local matrix to Matrix.Identity().
  14416. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  14417. */
  14418. resetLocalMatrix(independentOfChildren?: boolean): void;
  14419. protected _afterComputeWorldMatrix(): void;
  14420. /**
  14421. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  14422. * @param func callback function to add
  14423. *
  14424. * @returns the TransformNode.
  14425. */
  14426. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14427. /**
  14428. * Removes a registered callback function.
  14429. * @param func callback function to remove
  14430. * @returns the TransformNode.
  14431. */
  14432. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14433. /**
  14434. * Gets the position of the current mesh in camera space
  14435. * @param camera defines the camera to use
  14436. * @returns a position
  14437. */
  14438. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  14439. /**
  14440. * Returns the distance from the mesh to the active camera
  14441. * @param camera defines the camera to use
  14442. * @returns the distance
  14443. */
  14444. getDistanceToCamera(camera?: Nullable<Camera>): number;
  14445. /**
  14446. * Clone the current transform node
  14447. * @param name Name of the new clone
  14448. * @param newParent New parent for the clone
  14449. * @param doNotCloneChildren Do not clone children hierarchy
  14450. * @returns the new transform node
  14451. */
  14452. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  14453. /**
  14454. * Serializes the objects information.
  14455. * @param currentSerializationObject defines the object to serialize in
  14456. * @returns the serialized object
  14457. */
  14458. serialize(currentSerializationObject?: any): any;
  14459. /**
  14460. * Returns a new TransformNode object parsed from the source provided.
  14461. * @param parsedTransformNode is the source.
  14462. * @param scene the scne the object belongs to
  14463. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  14464. * @returns a new TransformNode object parsed from the source provided.
  14465. */
  14466. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  14467. /**
  14468. * Get all child-transformNodes of this node
  14469. * @param directDescendantsOnly defines if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered
  14470. * @param predicate defines an optional predicate that will be called on every evaluated child, the predicate must return true for a given child to be part of the result, otherwise it will be ignored
  14471. * @returns an array of TransformNode
  14472. */
  14473. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  14474. /**
  14475. * Releases resources associated with this transform node.
  14476. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  14477. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  14478. */
  14479. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  14480. /**
  14481. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  14482. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  14483. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  14484. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  14485. * @returns the current mesh
  14486. */
  14487. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  14488. private _syncAbsoluteScalingAndRotation;
  14489. }
  14490. }
  14491. declare module "babylonjs/Animations/animationPropertiesOverride" {
  14492. /**
  14493. * Class used to override all child animations of a given target
  14494. */
  14495. export class AnimationPropertiesOverride {
  14496. /**
  14497. * Gets or sets a value indicating if animation blending must be used
  14498. */
  14499. enableBlending: boolean;
  14500. /**
  14501. * Gets or sets the blending speed to use when enableBlending is true
  14502. */
  14503. blendingSpeed: number;
  14504. /**
  14505. * Gets or sets the default loop mode to use
  14506. */
  14507. loopMode: number;
  14508. }
  14509. }
  14510. declare module "babylonjs/Bones/bone" {
  14511. import { Skeleton } from "babylonjs/Bones/skeleton";
  14512. import { Vector3, Quaternion, Matrix } from "babylonjs/Maths/math.vector";
  14513. import { Nullable } from "babylonjs/types";
  14514. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14515. import { TransformNode } from "babylonjs/Meshes/transformNode";
  14516. import { Node } from "babylonjs/node";
  14517. import { Space } from "babylonjs/Maths/math.axis";
  14518. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  14519. /**
  14520. * Class used to store bone information
  14521. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  14522. */
  14523. export class Bone extends Node {
  14524. /**
  14525. * defines the bone name
  14526. */
  14527. name: string;
  14528. private static _tmpVecs;
  14529. private static _tmpQuat;
  14530. private static _tmpMats;
  14531. /**
  14532. * Gets the list of child bones
  14533. */
  14534. children: Bone[];
  14535. /** Gets the animations associated with this bone */
  14536. animations: import("babylonjs/Animations/animation").Animation[];
  14537. /**
  14538. * Gets or sets bone length
  14539. */
  14540. length: number;
  14541. /**
  14542. * @hidden Internal only
  14543. * Set this value to map this bone to a different index in the transform matrices
  14544. * Set this value to -1 to exclude the bone from the transform matrices
  14545. */
  14546. _index: Nullable<number>;
  14547. private _skeleton;
  14548. private _localMatrix;
  14549. private _restPose;
  14550. private _baseMatrix;
  14551. private _absoluteTransform;
  14552. private _invertedAbsoluteTransform;
  14553. private _parent;
  14554. private _scalingDeterminant;
  14555. private _worldTransform;
  14556. private _localScaling;
  14557. private _localRotation;
  14558. private _localPosition;
  14559. private _needToDecompose;
  14560. private _needToCompose;
  14561. /** @hidden */
  14562. _linkedTransformNode: Nullable<TransformNode>;
  14563. /** @hidden */
  14564. _waitingTransformNodeId: Nullable<string>;
  14565. /** @hidden */
  14566. get _matrix(): Matrix;
  14567. /** @hidden */
  14568. set _matrix(value: Matrix);
  14569. /**
  14570. * Create a new bone
  14571. * @param name defines the bone name
  14572. * @param skeleton defines the parent skeleton
  14573. * @param parentBone defines the parent (can be null if the bone is the root)
  14574. * @param localMatrix defines the local matrix
  14575. * @param restPose defines the rest pose matrix
  14576. * @param baseMatrix defines the base matrix
  14577. * @param index defines index of the bone in the hiearchy
  14578. */
  14579. constructor(
  14580. /**
  14581. * defines the bone name
  14582. */
  14583. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  14584. /**
  14585. * Gets the current object class name.
  14586. * @return the class name
  14587. */
  14588. getClassName(): string;
  14589. /**
  14590. * Gets the parent skeleton
  14591. * @returns a skeleton
  14592. */
  14593. getSkeleton(): Skeleton;
  14594. /**
  14595. * Gets parent bone
  14596. * @returns a bone or null if the bone is the root of the bone hierarchy
  14597. */
  14598. getParent(): Nullable<Bone>;
  14599. /**
  14600. * Returns an array containing the root bones
  14601. * @returns an array containing the root bones
  14602. */
  14603. getChildren(): Array<Bone>;
  14604. /**
  14605. * Gets the node index in matrix array generated for rendering
  14606. * @returns the node index
  14607. */
  14608. getIndex(): number;
  14609. /**
  14610. * Sets the parent bone
  14611. * @param parent defines the parent (can be null if the bone is the root)
  14612. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  14613. */
  14614. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  14615. /**
  14616. * Gets the local matrix
  14617. * @returns a matrix
  14618. */
  14619. getLocalMatrix(): Matrix;
  14620. /**
  14621. * Gets the base matrix (initial matrix which remains unchanged)
  14622. * @returns a matrix
  14623. */
  14624. getBaseMatrix(): Matrix;
  14625. /**
  14626. * Gets the rest pose matrix
  14627. * @returns a matrix
  14628. */
  14629. getRestPose(): Matrix;
  14630. /**
  14631. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  14632. */
  14633. getWorldMatrix(): Matrix;
  14634. /**
  14635. * Sets the local matrix to rest pose matrix
  14636. */
  14637. returnToRest(): void;
  14638. /**
  14639. * Gets the inverse of the absolute transform matrix.
  14640. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  14641. * @returns a matrix
  14642. */
  14643. getInvertedAbsoluteTransform(): Matrix;
  14644. /**
  14645. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  14646. * @returns a matrix
  14647. */
  14648. getAbsoluteTransform(): Matrix;
  14649. /**
  14650. * Links with the given transform node.
  14651. * The local matrix of this bone is copied from the transform node every frame.
  14652. * @param transformNode defines the transform node to link to
  14653. */
  14654. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  14655. /**
  14656. * Gets the node used to drive the bone's transformation
  14657. * @returns a transform node or null
  14658. */
  14659. getTransformNode(): Nullable<TransformNode>;
  14660. /** Gets or sets current position (in local space) */
  14661. get position(): Vector3;
  14662. set position(newPosition: Vector3);
  14663. /** Gets or sets current rotation (in local space) */
  14664. get rotation(): Vector3;
  14665. set rotation(newRotation: Vector3);
  14666. /** Gets or sets current rotation quaternion (in local space) */
  14667. get rotationQuaternion(): Quaternion;
  14668. set rotationQuaternion(newRotation: Quaternion);
  14669. /** Gets or sets current scaling (in local space) */
  14670. get scaling(): Vector3;
  14671. set scaling(newScaling: Vector3);
  14672. /**
  14673. * Gets the animation properties override
  14674. */
  14675. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  14676. private _decompose;
  14677. private _compose;
  14678. /**
  14679. * Update the base and local matrices
  14680. * @param matrix defines the new base or local matrix
  14681. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  14682. * @param updateLocalMatrix defines if the local matrix should be updated
  14683. */
  14684. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  14685. /** @hidden */
  14686. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  14687. /**
  14688. * Flag the bone as dirty (Forcing it to update everything)
  14689. */
  14690. markAsDirty(): void;
  14691. /** @hidden */
  14692. _markAsDirtyAndCompose(): void;
  14693. private _markAsDirtyAndDecompose;
  14694. /**
  14695. * Translate the bone in local or world space
  14696. * @param vec The amount to translate the bone
  14697. * @param space The space that the translation is in
  14698. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14699. */
  14700. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14701. /**
  14702. * Set the postion of the bone in local or world space
  14703. * @param position The position to set the bone
  14704. * @param space The space that the position is in
  14705. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14706. */
  14707. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14708. /**
  14709. * Set the absolute position of the bone (world space)
  14710. * @param position The position to set the bone
  14711. * @param mesh The mesh that this bone is attached to
  14712. */
  14713. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  14714. /**
  14715. * Scale the bone on the x, y and z axes (in local space)
  14716. * @param x The amount to scale the bone on the x axis
  14717. * @param y The amount to scale the bone on the y axis
  14718. * @param z The amount to scale the bone on the z axis
  14719. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  14720. */
  14721. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  14722. /**
  14723. * Set the bone scaling in local space
  14724. * @param scale defines the scaling vector
  14725. */
  14726. setScale(scale: Vector3): void;
  14727. /**
  14728. * Gets the current scaling in local space
  14729. * @returns the current scaling vector
  14730. */
  14731. getScale(): Vector3;
  14732. /**
  14733. * Gets the current scaling in local space and stores it in a target vector
  14734. * @param result defines the target vector
  14735. */
  14736. getScaleToRef(result: Vector3): void;
  14737. /**
  14738. * Set the yaw, pitch, and roll of the bone in local or world space
  14739. * @param yaw The rotation of the bone on the y axis
  14740. * @param pitch The rotation of the bone on the x axis
  14741. * @param roll The rotation of the bone on the z axis
  14742. * @param space The space that the axes of rotation are in
  14743. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14744. */
  14745. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  14746. /**
  14747. * Add a rotation to the bone on an axis in local or world space
  14748. * @param axis The axis to rotate the bone on
  14749. * @param amount The amount to rotate the bone
  14750. * @param space The space that the axis is in
  14751. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14752. */
  14753. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  14754. /**
  14755. * Set the rotation of the bone to a particular axis angle in local or world space
  14756. * @param axis The axis to rotate the bone on
  14757. * @param angle The angle that the bone should be rotated to
  14758. * @param space The space that the axis is in
  14759. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14760. */
  14761. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  14762. /**
  14763. * Set the euler rotation of the bone in local of world space
  14764. * @param rotation The euler rotation that the bone should be set to
  14765. * @param space The space that the rotation is in
  14766. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14767. */
  14768. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14769. /**
  14770. * Set the quaternion rotation of the bone in local of world space
  14771. * @param quat The quaternion rotation that the bone should be set to
  14772. * @param space The space that the rotation is in
  14773. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14774. */
  14775. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  14776. /**
  14777. * Set the rotation matrix of the bone in local of world space
  14778. * @param rotMat The rotation matrix that the bone should be set to
  14779. * @param space The space that the rotation is in
  14780. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14781. */
  14782. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  14783. private _rotateWithMatrix;
  14784. private _getNegativeRotationToRef;
  14785. /**
  14786. * Get the position of the bone in local or world space
  14787. * @param space The space that the returned position is in
  14788. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14789. * @returns The position of the bone
  14790. */
  14791. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  14792. /**
  14793. * Copy the position of the bone to a vector3 in local or world space
  14794. * @param space The space that the returned position is in
  14795. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14796. * @param result The vector3 to copy the position to
  14797. */
  14798. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  14799. /**
  14800. * Get the absolute position of the bone (world space)
  14801. * @param mesh The mesh that this bone is attached to
  14802. * @returns The absolute position of the bone
  14803. */
  14804. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  14805. /**
  14806. * Copy the absolute position of the bone (world space) to the result param
  14807. * @param mesh The mesh that this bone is attached to
  14808. * @param result The vector3 to copy the absolute position to
  14809. */
  14810. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  14811. /**
  14812. * Compute the absolute transforms of this bone and its children
  14813. */
  14814. computeAbsoluteTransforms(): void;
  14815. /**
  14816. * Get the world direction from an axis that is in the local space of the bone
  14817. * @param localAxis The local direction that is used to compute the world direction
  14818. * @param mesh The mesh that this bone is attached to
  14819. * @returns The world direction
  14820. */
  14821. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14822. /**
  14823. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  14824. * @param localAxis The local direction that is used to compute the world direction
  14825. * @param mesh The mesh that this bone is attached to
  14826. * @param result The vector3 that the world direction will be copied to
  14827. */
  14828. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14829. /**
  14830. * Get the euler rotation of the bone in local or world space
  14831. * @param space The space that the rotation should be in
  14832. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14833. * @returns The euler rotation
  14834. */
  14835. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  14836. /**
  14837. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  14838. * @param space The space that the rotation should be in
  14839. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14840. * @param result The vector3 that the rotation should be copied to
  14841. */
  14842. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14843. /**
  14844. * Get the quaternion rotation of the bone in either local or world space
  14845. * @param space The space that the rotation should be in
  14846. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14847. * @returns The quaternion rotation
  14848. */
  14849. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  14850. /**
  14851. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  14852. * @param space The space that the rotation should be in
  14853. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14854. * @param result The quaternion that the rotation should be copied to
  14855. */
  14856. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  14857. /**
  14858. * Get the rotation matrix of the bone in local or world space
  14859. * @param space The space that the rotation should be in
  14860. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14861. * @returns The rotation matrix
  14862. */
  14863. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  14864. /**
  14865. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  14866. * @param space The space that the rotation should be in
  14867. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14868. * @param result The quaternion that the rotation should be copied to
  14869. */
  14870. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  14871. /**
  14872. * Get the world position of a point that is in the local space of the bone
  14873. * @param position The local position
  14874. * @param mesh The mesh that this bone is attached to
  14875. * @returns The world position
  14876. */
  14877. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14878. /**
  14879. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  14880. * @param position The local position
  14881. * @param mesh The mesh that this bone is attached to
  14882. * @param result The vector3 that the world position should be copied to
  14883. */
  14884. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14885. /**
  14886. * Get the local position of a point that is in world space
  14887. * @param position The world position
  14888. * @param mesh The mesh that this bone is attached to
  14889. * @returns The local position
  14890. */
  14891. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14892. /**
  14893. * Get the local position of a point that is in world space and copy it to the result param
  14894. * @param position The world position
  14895. * @param mesh The mesh that this bone is attached to
  14896. * @param result The vector3 that the local position should be copied to
  14897. */
  14898. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14899. }
  14900. }
  14901. declare module "babylonjs/Animations/runtimeAnimation" {
  14902. import { Animation, _IAnimationState } from "babylonjs/Animations/animation";
  14903. import { Animatable } from "babylonjs/Animations/animatable";
  14904. import { Scene } from "babylonjs/scene";
  14905. /**
  14906. * Defines a runtime animation
  14907. */
  14908. export class RuntimeAnimation {
  14909. private _events;
  14910. /**
  14911. * The current frame of the runtime animation
  14912. */
  14913. private _currentFrame;
  14914. /**
  14915. * The animation used by the runtime animation
  14916. */
  14917. private _animation;
  14918. /**
  14919. * The target of the runtime animation
  14920. */
  14921. private _target;
  14922. /**
  14923. * The initiating animatable
  14924. */
  14925. private _host;
  14926. /**
  14927. * The original value of the runtime animation
  14928. */
  14929. private _originalValue;
  14930. /**
  14931. * The original blend value of the runtime animation
  14932. */
  14933. private _originalBlendValue;
  14934. /**
  14935. * The offsets cache of the runtime animation
  14936. */
  14937. private _offsetsCache;
  14938. /**
  14939. * The high limits cache of the runtime animation
  14940. */
  14941. private _highLimitsCache;
  14942. /**
  14943. * Specifies if the runtime animation has been stopped
  14944. */
  14945. private _stopped;
  14946. /**
  14947. * The blending factor of the runtime animation
  14948. */
  14949. private _blendingFactor;
  14950. /**
  14951. * The BabylonJS scene
  14952. */
  14953. private _scene;
  14954. /**
  14955. * The current value of the runtime animation
  14956. */
  14957. private _currentValue;
  14958. /** @hidden */
  14959. _animationState: _IAnimationState;
  14960. /**
  14961. * The active target of the runtime animation
  14962. */
  14963. private _activeTargets;
  14964. private _currentActiveTarget;
  14965. private _directTarget;
  14966. /**
  14967. * The target path of the runtime animation
  14968. */
  14969. private _targetPath;
  14970. /**
  14971. * The weight of the runtime animation
  14972. */
  14973. private _weight;
  14974. /**
  14975. * The ratio offset of the runtime animation
  14976. */
  14977. private _ratioOffset;
  14978. /**
  14979. * The previous delay of the runtime animation
  14980. */
  14981. private _previousDelay;
  14982. /**
  14983. * The previous ratio of the runtime animation
  14984. */
  14985. private _previousRatio;
  14986. private _enableBlending;
  14987. private _keys;
  14988. private _minFrame;
  14989. private _maxFrame;
  14990. private _minValue;
  14991. private _maxValue;
  14992. private _targetIsArray;
  14993. /**
  14994. * Gets the current frame of the runtime animation
  14995. */
  14996. get currentFrame(): number;
  14997. /**
  14998. * Gets the weight of the runtime animation
  14999. */
  15000. get weight(): number;
  15001. /**
  15002. * Gets the current value of the runtime animation
  15003. */
  15004. get currentValue(): any;
  15005. /**
  15006. * Gets the target path of the runtime animation
  15007. */
  15008. get targetPath(): string;
  15009. /**
  15010. * Gets the actual target of the runtime animation
  15011. */
  15012. get target(): any;
  15013. /**
  15014. * Gets the additive state of the runtime animation
  15015. */
  15016. get isAdditive(): boolean;
  15017. /** @hidden */
  15018. _onLoop: () => void;
  15019. /**
  15020. * Create a new RuntimeAnimation object
  15021. * @param target defines the target of the animation
  15022. * @param animation defines the source animation object
  15023. * @param scene defines the hosting scene
  15024. * @param host defines the initiating Animatable
  15025. */
  15026. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  15027. private _preparePath;
  15028. /**
  15029. * Gets the animation from the runtime animation
  15030. */
  15031. get animation(): Animation;
  15032. /**
  15033. * Resets the runtime animation to the beginning
  15034. * @param restoreOriginal defines whether to restore the target property to the original value
  15035. */
  15036. reset(restoreOriginal?: boolean): void;
  15037. /**
  15038. * Specifies if the runtime animation is stopped
  15039. * @returns Boolean specifying if the runtime animation is stopped
  15040. */
  15041. isStopped(): boolean;
  15042. /**
  15043. * Disposes of the runtime animation
  15044. */
  15045. dispose(): void;
  15046. /**
  15047. * Apply the interpolated value to the target
  15048. * @param currentValue defines the value computed by the animation
  15049. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  15050. */
  15051. setValue(currentValue: any, weight: number): void;
  15052. private _getOriginalValues;
  15053. private _setValue;
  15054. /**
  15055. * Gets the loop pmode of the runtime animation
  15056. * @returns Loop Mode
  15057. */
  15058. private _getCorrectLoopMode;
  15059. /**
  15060. * Move the current animation to a given frame
  15061. * @param frame defines the frame to move to
  15062. */
  15063. goToFrame(frame: number): void;
  15064. /**
  15065. * @hidden Internal use only
  15066. */
  15067. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  15068. /**
  15069. * Execute the current animation
  15070. * @param delay defines the delay to add to the current frame
  15071. * @param from defines the lower bound of the animation range
  15072. * @param to defines the upper bound of the animation range
  15073. * @param loop defines if the current animation must loop
  15074. * @param speedRatio defines the current speed ratio
  15075. * @param weight defines the weight of the animation (default is -1 so no weight)
  15076. * @param onLoop optional callback called when animation loops
  15077. * @returns a boolean indicating if the animation is running
  15078. */
  15079. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  15080. }
  15081. }
  15082. declare module "babylonjs/Animations/animatable" {
  15083. import { Animation } from "babylonjs/Animations/animation";
  15084. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  15085. import { Nullable } from "babylonjs/types";
  15086. import { Observable } from "babylonjs/Misc/observable";
  15087. import { Scene } from "babylonjs/scene";
  15088. import { Matrix, Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  15089. import { Node } from "babylonjs/node";
  15090. /**
  15091. * Class used to store an actual running animation
  15092. */
  15093. export class Animatable {
  15094. /** defines the target object */
  15095. target: any;
  15096. /** defines the starting frame number (default is 0) */
  15097. fromFrame: number;
  15098. /** defines the ending frame number (default is 100) */
  15099. toFrame: number;
  15100. /** defines if the animation must loop (default is false) */
  15101. loopAnimation: boolean;
  15102. /** defines a callback to call when animation ends if it is not looping */
  15103. onAnimationEnd?: (() => void) | null | undefined;
  15104. /** defines a callback to call when animation loops */
  15105. onAnimationLoop?: (() => void) | null | undefined;
  15106. /** defines whether the animation should be evaluated additively */
  15107. isAdditive: boolean;
  15108. private _localDelayOffset;
  15109. private _pausedDelay;
  15110. private _runtimeAnimations;
  15111. private _paused;
  15112. private _scene;
  15113. private _speedRatio;
  15114. private _weight;
  15115. private _syncRoot;
  15116. /**
  15117. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  15118. * This will only apply for non looping animation (default is true)
  15119. */
  15120. disposeOnEnd: boolean;
  15121. /**
  15122. * Gets a boolean indicating if the animation has started
  15123. */
  15124. animationStarted: boolean;
  15125. /**
  15126. * Observer raised when the animation ends
  15127. */
  15128. onAnimationEndObservable: Observable<Animatable>;
  15129. /**
  15130. * Observer raised when the animation loops
  15131. */
  15132. onAnimationLoopObservable: Observable<Animatable>;
  15133. /**
  15134. * Gets the root Animatable used to synchronize and normalize animations
  15135. */
  15136. get syncRoot(): Nullable<Animatable>;
  15137. /**
  15138. * Gets the current frame of the first RuntimeAnimation
  15139. * Used to synchronize Animatables
  15140. */
  15141. get masterFrame(): number;
  15142. /**
  15143. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  15144. */
  15145. get weight(): number;
  15146. set weight(value: number);
  15147. /**
  15148. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  15149. */
  15150. get speedRatio(): number;
  15151. set speedRatio(value: number);
  15152. /**
  15153. * Creates a new Animatable
  15154. * @param scene defines the hosting scene
  15155. * @param target defines the target object
  15156. * @param fromFrame defines the starting frame number (default is 0)
  15157. * @param toFrame defines the ending frame number (default is 100)
  15158. * @param loopAnimation defines if the animation must loop (default is false)
  15159. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  15160. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  15161. * @param animations defines a group of animation to add to the new Animatable
  15162. * @param onAnimationLoop defines a callback to call when animation loops
  15163. * @param isAdditive defines whether the animation should be evaluated additively
  15164. */
  15165. constructor(scene: Scene,
  15166. /** defines the target object */
  15167. target: any,
  15168. /** defines the starting frame number (default is 0) */
  15169. fromFrame?: number,
  15170. /** defines the ending frame number (default is 100) */
  15171. toFrame?: number,
  15172. /** defines if the animation must loop (default is false) */
  15173. loopAnimation?: boolean, speedRatio?: number,
  15174. /** defines a callback to call when animation ends if it is not looping */
  15175. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  15176. /** defines a callback to call when animation loops */
  15177. onAnimationLoop?: (() => void) | null | undefined,
  15178. /** defines whether the animation should be evaluated additively */
  15179. isAdditive?: boolean);
  15180. /**
  15181. * Synchronize and normalize current Animatable with a source Animatable
  15182. * This is useful when using animation weights and when animations are not of the same length
  15183. * @param root defines the root Animatable to synchronize with
  15184. * @returns the current Animatable
  15185. */
  15186. syncWith(root: Animatable): Animatable;
  15187. /**
  15188. * Gets the list of runtime animations
  15189. * @returns an array of RuntimeAnimation
  15190. */
  15191. getAnimations(): RuntimeAnimation[];
  15192. /**
  15193. * Adds more animations to the current animatable
  15194. * @param target defines the target of the animations
  15195. * @param animations defines the new animations to add
  15196. */
  15197. appendAnimations(target: any, animations: Animation[]): void;
  15198. /**
  15199. * Gets the source animation for a specific property
  15200. * @param property defines the propertyu to look for
  15201. * @returns null or the source animation for the given property
  15202. */
  15203. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  15204. /**
  15205. * Gets the runtime animation for a specific property
  15206. * @param property defines the propertyu to look for
  15207. * @returns null or the runtime animation for the given property
  15208. */
  15209. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  15210. /**
  15211. * Resets the animatable to its original state
  15212. */
  15213. reset(): void;
  15214. /**
  15215. * Allows the animatable to blend with current running animations
  15216. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  15217. * @param blendingSpeed defines the blending speed to use
  15218. */
  15219. enableBlending(blendingSpeed: number): void;
  15220. /**
  15221. * Disable animation blending
  15222. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  15223. */
  15224. disableBlending(): void;
  15225. /**
  15226. * Jump directly to a given frame
  15227. * @param frame defines the frame to jump to
  15228. */
  15229. goToFrame(frame: number): void;
  15230. /**
  15231. * Pause the animation
  15232. */
  15233. pause(): void;
  15234. /**
  15235. * Restart the animation
  15236. */
  15237. restart(): void;
  15238. private _raiseOnAnimationEnd;
  15239. /**
  15240. * Stop and delete the current animation
  15241. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  15242. * @param targetMask - a function that determines if the animation should be stopped based on its target (all animations will be stopped if both this and animationName are empty)
  15243. */
  15244. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  15245. /**
  15246. * Wait asynchronously for the animation to end
  15247. * @returns a promise which will be fullfilled when the animation ends
  15248. */
  15249. waitAsync(): Promise<Animatable>;
  15250. /** @hidden */
  15251. _animate(delay: number): boolean;
  15252. }
  15253. module "babylonjs/scene" {
  15254. interface Scene {
  15255. /** @hidden */
  15256. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  15257. /** @hidden */
  15258. _processLateAnimationBindingsForMatrices(holder: {
  15259. totalWeight: number;
  15260. totalAdditiveWeight: number;
  15261. animations: RuntimeAnimation[];
  15262. additiveAnimations: RuntimeAnimation[];
  15263. originalValue: Matrix;
  15264. }): any;
  15265. /** @hidden */
  15266. _processLateAnimationBindingsForQuaternions(holder: {
  15267. totalWeight: number;
  15268. totalAdditiveWeight: number;
  15269. animations: RuntimeAnimation[];
  15270. additiveAnimations: RuntimeAnimation[];
  15271. originalValue: Quaternion;
  15272. }, refQuaternion: Quaternion): Quaternion;
  15273. /** @hidden */
  15274. _processLateAnimationBindings(): void;
  15275. /**
  15276. * Will start the animation sequence of a given target
  15277. * @param target defines the target
  15278. * @param from defines from which frame should animation start
  15279. * @param to defines until which frame should animation run.
  15280. * @param weight defines the weight to apply to the animation (1.0 by default)
  15281. * @param loop defines if the animation loops
  15282. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  15283. * @param onAnimationEnd defines the function to be executed when the animation ends
  15284. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  15285. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  15286. * @param onAnimationLoop defines the callback to call when an animation loops
  15287. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15288. * @returns the animatable object created for this animation
  15289. */
  15290. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  15291. /**
  15292. * Will start the animation sequence of a given target
  15293. * @param target defines the target
  15294. * @param from defines from which frame should animation start
  15295. * @param to defines until which frame should animation run.
  15296. * @param loop defines if the animation loops
  15297. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  15298. * @param onAnimationEnd defines the function to be executed when the animation ends
  15299. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  15300. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  15301. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  15302. * @param onAnimationLoop defines the callback to call when an animation loops
  15303. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15304. * @returns the animatable object created for this animation
  15305. */
  15306. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  15307. /**
  15308. * Will start the animation sequence of a given target and its hierarchy
  15309. * @param target defines the target
  15310. * @param directDescendantsOnly if true only direct descendants will be used, if false direct and also indirect (children of children, an so on in a recursive manner) descendants will be used.
  15311. * @param from defines from which frame should animation start
  15312. * @param to defines until which frame should animation run.
  15313. * @param loop defines if the animation loops
  15314. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  15315. * @param onAnimationEnd defines the function to be executed when the animation ends
  15316. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  15317. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  15318. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  15319. * @param onAnimationLoop defines the callback to call when an animation loops
  15320. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15321. * @returns the list of created animatables
  15322. */
  15323. beginHierarchyAnimation(target: any, directDescendantsOnly: boolean, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  15324. /**
  15325. * Begin a new animation on a given node
  15326. * @param target defines the target where the animation will take place
  15327. * @param animations defines the list of animations to start
  15328. * @param from defines the initial value
  15329. * @param to defines the final value
  15330. * @param loop defines if you want animation to loop (off by default)
  15331. * @param speedRatio defines the speed ratio to apply to all animations
  15332. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  15333. * @param onAnimationLoop defines the callback to call when an animation loops
  15334. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15335. * @returns the list of created animatables
  15336. */
  15337. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  15338. /**
  15339. * Begin a new animation on a given node and its hierarchy
  15340. * @param target defines the root node where the animation will take place
  15341. * @param directDescendantsOnly if true only direct descendants will be used, if false direct and also indirect (children of children, an so on in a recursive manner) descendants will be used.
  15342. * @param animations defines the list of animations to start
  15343. * @param from defines the initial value
  15344. * @param to defines the final value
  15345. * @param loop defines if you want animation to loop (off by default)
  15346. * @param speedRatio defines the speed ratio to apply to all animations
  15347. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  15348. * @param onAnimationLoop defines the callback to call when an animation loops
  15349. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15350. * @returns the list of animatables created for all nodes
  15351. */
  15352. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  15353. /**
  15354. * Gets the animatable associated with a specific target
  15355. * @param target defines the target of the animatable
  15356. * @returns the required animatable if found
  15357. */
  15358. getAnimatableByTarget(target: any): Nullable<Animatable>;
  15359. /**
  15360. * Gets all animatables associated with a given target
  15361. * @param target defines the target to look animatables for
  15362. * @returns an array of Animatables
  15363. */
  15364. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  15365. /**
  15366. * Stops and removes all animations that have been applied to the scene
  15367. */
  15368. stopAllAnimations(): void;
  15369. /**
  15370. * Gets the current delta time used by animation engine
  15371. */
  15372. deltaTime: number;
  15373. }
  15374. }
  15375. module "babylonjs/Bones/bone" {
  15376. interface Bone {
  15377. /**
  15378. * Copy an animation range from another bone
  15379. * @param source defines the source bone
  15380. * @param rangeName defines the range name to copy
  15381. * @param frameOffset defines the frame offset
  15382. * @param rescaleAsRequired defines if rescaling must be applied if required
  15383. * @param skelDimensionsRatio defines the scaling ratio
  15384. * @returns true if operation was successful
  15385. */
  15386. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  15387. }
  15388. }
  15389. }
  15390. declare module "babylonjs/Bones/skeleton" {
  15391. import { Bone } from "babylonjs/Bones/bone";
  15392. import { Observable } from "babylonjs/Misc/observable";
  15393. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  15394. import { Scene } from "babylonjs/scene";
  15395. import { Nullable } from "babylonjs/types";
  15396. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  15397. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  15398. import { Animatable } from "babylonjs/Animations/animatable";
  15399. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  15400. import { Animation } from "babylonjs/Animations/animation";
  15401. import { AnimationRange } from "babylonjs/Animations/animationRange";
  15402. import { IInspectable } from "babylonjs/Misc/iInspectable";
  15403. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  15404. /**
  15405. * Class used to handle skinning animations
  15406. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  15407. */
  15408. export class Skeleton implements IAnimatable {
  15409. /** defines the skeleton name */
  15410. name: string;
  15411. /** defines the skeleton Id */
  15412. id: string;
  15413. /**
  15414. * Defines the list of child bones
  15415. */
  15416. bones: Bone[];
  15417. /**
  15418. * Defines an estimate of the dimension of the skeleton at rest
  15419. */
  15420. dimensionsAtRest: Vector3;
  15421. /**
  15422. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  15423. */
  15424. needInitialSkinMatrix: boolean;
  15425. /**
  15426. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  15427. */
  15428. overrideMesh: Nullable<AbstractMesh>;
  15429. /**
  15430. * Gets the list of animations attached to this skeleton
  15431. */
  15432. animations: Array<Animation>;
  15433. private _scene;
  15434. private _isDirty;
  15435. private _transformMatrices;
  15436. private _transformMatrixTexture;
  15437. private _meshesWithPoseMatrix;
  15438. private _animatables;
  15439. private _identity;
  15440. private _synchronizedWithMesh;
  15441. private _ranges;
  15442. private _lastAbsoluteTransformsUpdateId;
  15443. private _canUseTextureForBones;
  15444. private _uniqueId;
  15445. /** @hidden */
  15446. _numBonesWithLinkedTransformNode: number;
  15447. /** @hidden */
  15448. _hasWaitingData: Nullable<boolean>;
  15449. /**
  15450. * Specifies if the skeleton should be serialized
  15451. */
  15452. doNotSerialize: boolean;
  15453. private _useTextureToStoreBoneMatrices;
  15454. /**
  15455. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  15456. * Please note that this option is not available if the hardware does not support it
  15457. */
  15458. get useTextureToStoreBoneMatrices(): boolean;
  15459. set useTextureToStoreBoneMatrices(value: boolean);
  15460. private _animationPropertiesOverride;
  15461. /**
  15462. * Gets or sets the animation properties override
  15463. */
  15464. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  15465. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  15466. /**
  15467. * List of inspectable custom properties (used by the Inspector)
  15468. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15469. */
  15470. inspectableCustomProperties: IInspectable[];
  15471. /**
  15472. * An observable triggered before computing the skeleton's matrices
  15473. */
  15474. onBeforeComputeObservable: Observable<Skeleton>;
  15475. /**
  15476. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  15477. */
  15478. get isUsingTextureForMatrices(): boolean;
  15479. /**
  15480. * Gets the unique ID of this skeleton
  15481. */
  15482. get uniqueId(): number;
  15483. /**
  15484. * Creates a new skeleton
  15485. * @param name defines the skeleton name
  15486. * @param id defines the skeleton Id
  15487. * @param scene defines the hosting scene
  15488. */
  15489. constructor(
  15490. /** defines the skeleton name */
  15491. name: string,
  15492. /** defines the skeleton Id */
  15493. id: string, scene: Scene);
  15494. /**
  15495. * Gets the current object class name.
  15496. * @return the class name
  15497. */
  15498. getClassName(): string;
  15499. /**
  15500. * Returns an array containing the root bones
  15501. * @returns an array containing the root bones
  15502. */
  15503. getChildren(): Array<Bone>;
  15504. /**
  15505. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  15506. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  15507. * @returns a Float32Array containing matrices data
  15508. */
  15509. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  15510. /**
  15511. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  15512. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  15513. * @returns a raw texture containing the data
  15514. */
  15515. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  15516. /**
  15517. * Gets the current hosting scene
  15518. * @returns a scene object
  15519. */
  15520. getScene(): Scene;
  15521. /**
  15522. * Gets a string representing the current skeleton data
  15523. * @param fullDetails defines a boolean indicating if we want a verbose version
  15524. * @returns a string representing the current skeleton data
  15525. */
  15526. toString(fullDetails?: boolean): string;
  15527. /**
  15528. * Get bone's index searching by name
  15529. * @param name defines bone's name to search for
  15530. * @return the indice of the bone. Returns -1 if not found
  15531. */
  15532. getBoneIndexByName(name: string): number;
  15533. /**
  15534. * Creater a new animation range
  15535. * @param name defines the name of the range
  15536. * @param from defines the start key
  15537. * @param to defines the end key
  15538. */
  15539. createAnimationRange(name: string, from: number, to: number): void;
  15540. /**
  15541. * Delete a specific animation range
  15542. * @param name defines the name of the range
  15543. * @param deleteFrames defines if frames must be removed as well
  15544. */
  15545. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  15546. /**
  15547. * Gets a specific animation range
  15548. * @param name defines the name of the range to look for
  15549. * @returns the requested animation range or null if not found
  15550. */
  15551. getAnimationRange(name: string): Nullable<AnimationRange>;
  15552. /**
  15553. * Gets the list of all animation ranges defined on this skeleton
  15554. * @returns an array
  15555. */
  15556. getAnimationRanges(): Nullable<AnimationRange>[];
  15557. /**
  15558. * Copy animation range from a source skeleton.
  15559. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  15560. * @param source defines the source skeleton
  15561. * @param name defines the name of the range to copy
  15562. * @param rescaleAsRequired defines if rescaling must be applied if required
  15563. * @returns true if operation was successful
  15564. */
  15565. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  15566. /**
  15567. * Forces the skeleton to go to rest pose
  15568. */
  15569. returnToRest(): void;
  15570. private _getHighestAnimationFrame;
  15571. /**
  15572. * Begin a specific animation range
  15573. * @param name defines the name of the range to start
  15574. * @param loop defines if looping must be turned on (false by default)
  15575. * @param speedRatio defines the speed ratio to apply (1 by default)
  15576. * @param onAnimationEnd defines a callback which will be called when animation will end
  15577. * @returns a new animatable
  15578. */
  15579. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  15580. /**
  15581. * Convert the keyframes for a range of animation on a skeleton to be relative to a given reference frame.
  15582. * @param skeleton defines the Skeleton containing the animation range to convert
  15583. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  15584. * @param range defines the name of the AnimationRange belonging to the Skeleton to convert
  15585. * @returns the original skeleton
  15586. */
  15587. static MakeAnimationAdditive(skeleton: Skeleton, referenceFrame: number | undefined, range: string): Nullable<Skeleton>;
  15588. /** @hidden */
  15589. _markAsDirty(): void;
  15590. /** @hidden */
  15591. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  15592. /** @hidden */
  15593. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  15594. private _computeTransformMatrices;
  15595. /**
  15596. * Build all resources required to render a skeleton
  15597. */
  15598. prepare(): void;
  15599. /**
  15600. * Gets the list of animatables currently running for this skeleton
  15601. * @returns an array of animatables
  15602. */
  15603. getAnimatables(): IAnimatable[];
  15604. /**
  15605. * Clone the current skeleton
  15606. * @param name defines the name of the new skeleton
  15607. * @param id defines the id of the new skeleton
  15608. * @returns the new skeleton
  15609. */
  15610. clone(name: string, id?: string): Skeleton;
  15611. /**
  15612. * Enable animation blending for this skeleton
  15613. * @param blendingSpeed defines the blending speed to apply
  15614. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  15615. */
  15616. enableBlending(blendingSpeed?: number): void;
  15617. /**
  15618. * Releases all resources associated with the current skeleton
  15619. */
  15620. dispose(): void;
  15621. /**
  15622. * Serialize the skeleton in a JSON object
  15623. * @returns a JSON object
  15624. */
  15625. serialize(): any;
  15626. /**
  15627. * Creates a new skeleton from serialized data
  15628. * @param parsedSkeleton defines the serialized data
  15629. * @param scene defines the hosting scene
  15630. * @returns a new skeleton
  15631. */
  15632. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  15633. /**
  15634. * Compute all node absolute transforms
  15635. * @param forceUpdate defines if computation must be done even if cache is up to date
  15636. */
  15637. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  15638. /**
  15639. * Gets the root pose matrix
  15640. * @returns a matrix
  15641. */
  15642. getPoseMatrix(): Nullable<Matrix>;
  15643. /**
  15644. * Sorts bones per internal index
  15645. */
  15646. sortBones(): void;
  15647. private _sortBones;
  15648. }
  15649. }
  15650. declare module "babylonjs/Meshes/instancedMesh" {
  15651. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  15652. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  15653. import { Camera } from "babylonjs/Cameras/camera";
  15654. import { Node } from "babylonjs/node";
  15655. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  15656. import { Mesh } from "babylonjs/Meshes/mesh";
  15657. import { Material } from "babylonjs/Materials/material";
  15658. import { Skeleton } from "babylonjs/Bones/skeleton";
  15659. import { Light } from "babylonjs/Lights/light";
  15660. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  15661. /**
  15662. * Creates an instance based on a source mesh.
  15663. */
  15664. export class InstancedMesh extends AbstractMesh {
  15665. private _sourceMesh;
  15666. private _currentLOD;
  15667. /** @hidden */
  15668. _indexInSourceMeshInstanceArray: number;
  15669. constructor(name: string, source: Mesh);
  15670. /**
  15671. * Returns the string "InstancedMesh".
  15672. */
  15673. getClassName(): string;
  15674. /** Gets the list of lights affecting that mesh */
  15675. get lightSources(): Light[];
  15676. _resyncLightSources(): void;
  15677. _resyncLightSource(light: Light): void;
  15678. _removeLightSource(light: Light, dispose: boolean): void;
  15679. /**
  15680. * If the source mesh receives shadows
  15681. */
  15682. get receiveShadows(): boolean;
  15683. /**
  15684. * The material of the source mesh
  15685. */
  15686. get material(): Nullable<Material>;
  15687. /**
  15688. * Visibility of the source mesh
  15689. */
  15690. get visibility(): number;
  15691. /**
  15692. * Skeleton of the source mesh
  15693. */
  15694. get skeleton(): Nullable<Skeleton>;
  15695. /**
  15696. * Rendering ground id of the source mesh
  15697. */
  15698. get renderingGroupId(): number;
  15699. set renderingGroupId(value: number);
  15700. /**
  15701. * Returns the total number of vertices (integer).
  15702. */
  15703. getTotalVertices(): number;
  15704. /**
  15705. * Returns a positive integer : the total number of indices in this mesh geometry.
  15706. * @returns the numner of indices or zero if the mesh has no geometry.
  15707. */
  15708. getTotalIndices(): number;
  15709. /**
  15710. * The source mesh of the instance
  15711. */
  15712. get sourceMesh(): Mesh;
  15713. /**
  15714. * Is this node ready to be used/rendered
  15715. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  15716. * @return {boolean} is it ready
  15717. */
  15718. isReady(completeCheck?: boolean): boolean;
  15719. /**
  15720. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  15721. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  15722. * @param copyWhenShared If true (default false) and and if the mesh geometry is shared among some other meshes, the returned array is a copy of the internal one.
  15723. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  15724. */
  15725. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  15726. /**
  15727. * Sets the vertex data of the mesh geometry for the requested `kind`.
  15728. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  15729. * The `data` are either a numeric array either a Float32Array.
  15730. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  15731. * The parameter `stride` is an optional positive integer, it is usually automatically deducted from the `kind` (3 for positions or normals, 2 for UV, etc).
  15732. * Note that a new underlying VertexBuffer object is created each call.
  15733. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  15734. *
  15735. * Possible `kind` values :
  15736. * - VertexBuffer.PositionKind
  15737. * - VertexBuffer.UVKind
  15738. * - VertexBuffer.UV2Kind
  15739. * - VertexBuffer.UV3Kind
  15740. * - VertexBuffer.UV4Kind
  15741. * - VertexBuffer.UV5Kind
  15742. * - VertexBuffer.UV6Kind
  15743. * - VertexBuffer.ColorKind
  15744. * - VertexBuffer.MatricesIndicesKind
  15745. * - VertexBuffer.MatricesIndicesExtraKind
  15746. * - VertexBuffer.MatricesWeightsKind
  15747. * - VertexBuffer.MatricesWeightsExtraKind
  15748. *
  15749. * Returns the Mesh.
  15750. */
  15751. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  15752. /**
  15753. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  15754. * If the mesh has no geometry, it is simply returned as it is.
  15755. * The `data` are either a numeric array either a Float32Array.
  15756. * No new underlying VertexBuffer object is created.
  15757. * If the `kind` is the `PositionKind` and if `updateExtends` is true, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  15758. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  15759. *
  15760. * Possible `kind` values :
  15761. * - VertexBuffer.PositionKind
  15762. * - VertexBuffer.UVKind
  15763. * - VertexBuffer.UV2Kind
  15764. * - VertexBuffer.UV3Kind
  15765. * - VertexBuffer.UV4Kind
  15766. * - VertexBuffer.UV5Kind
  15767. * - VertexBuffer.UV6Kind
  15768. * - VertexBuffer.ColorKind
  15769. * - VertexBuffer.MatricesIndicesKind
  15770. * - VertexBuffer.MatricesIndicesExtraKind
  15771. * - VertexBuffer.MatricesWeightsKind
  15772. * - VertexBuffer.MatricesWeightsExtraKind
  15773. *
  15774. * Returns the Mesh.
  15775. */
  15776. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  15777. /**
  15778. * Sets the mesh indices.
  15779. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  15780. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  15781. * This method creates a new index buffer each call.
  15782. * Returns the Mesh.
  15783. */
  15784. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  15785. /**
  15786. * Boolean : True if the mesh owns the requested kind of data.
  15787. */
  15788. isVerticesDataPresent(kind: string): boolean;
  15789. /**
  15790. * Returns an array of indices (IndicesArray).
  15791. */
  15792. getIndices(): Nullable<IndicesArray>;
  15793. get _positions(): Nullable<Vector3[]>;
  15794. /**
  15795. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  15796. * This means the mesh underlying bounding box and sphere are recomputed.
  15797. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  15798. * @returns the current mesh
  15799. */
  15800. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  15801. /** @hidden */
  15802. _preActivate(): InstancedMesh;
  15803. /** @hidden */
  15804. _activate(renderId: number, intermediateRendering: boolean): boolean;
  15805. /** @hidden */
  15806. _postActivate(): void;
  15807. getWorldMatrix(): Matrix;
  15808. get isAnInstance(): boolean;
  15809. /**
  15810. * Returns the current associated LOD AbstractMesh.
  15811. */
  15812. getLOD(camera: Camera): AbstractMesh;
  15813. /** @hidden */
  15814. _preActivateForIntermediateRendering(renderId: number): Mesh;
  15815. /** @hidden */
  15816. _syncSubMeshes(): InstancedMesh;
  15817. /** @hidden */
  15818. _generatePointsArray(): boolean;
  15819. /**
  15820. * Creates a new InstancedMesh from the current mesh.
  15821. * - name (string) : the cloned mesh name
  15822. * - newParent (optional Node) : the optional Node to parent the clone to.
  15823. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  15824. *
  15825. * Returns the clone.
  15826. */
  15827. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  15828. /**
  15829. * Disposes the InstancedMesh.
  15830. * Returns nothing.
  15831. */
  15832. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  15833. }
  15834. module "babylonjs/Meshes/mesh" {
  15835. interface Mesh {
  15836. /**
  15837. * Register a custom buffer that will be instanced
  15838. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  15839. * @param kind defines the buffer kind
  15840. * @param stride defines the stride in floats
  15841. */
  15842. registerInstancedBuffer(kind: string, stride: number): void;
  15843. /** @hidden */
  15844. _userInstancedBuffersStorage: {
  15845. data: {
  15846. [key: string]: Float32Array;
  15847. };
  15848. sizes: {
  15849. [key: string]: number;
  15850. };
  15851. vertexBuffers: {
  15852. [key: string]: Nullable<VertexBuffer>;
  15853. };
  15854. strides: {
  15855. [key: string]: number;
  15856. };
  15857. };
  15858. }
  15859. }
  15860. module "babylonjs/Meshes/abstractMesh" {
  15861. interface AbstractMesh {
  15862. /**
  15863. * Object used to store instanced buffers defined by user
  15864. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  15865. */
  15866. instancedBuffers: {
  15867. [key: string]: any;
  15868. };
  15869. }
  15870. }
  15871. }
  15872. declare module "babylonjs/Materials/shaderMaterial" {
  15873. import { Nullable } from "babylonjs/types";
  15874. import { Scene } from "babylonjs/scene";
  15875. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  15876. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  15877. import { Mesh } from "babylonjs/Meshes/mesh";
  15878. import { SubMesh, BaseSubMesh } from "babylonjs/Meshes/subMesh";
  15879. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  15880. import { Effect } from "babylonjs/Materials/effect";
  15881. import { Material } from "babylonjs/Materials/material";
  15882. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  15883. /**
  15884. * Defines the options associated with the creation of a shader material.
  15885. */
  15886. export interface IShaderMaterialOptions {
  15887. /**
  15888. * Does the material work in alpha blend mode
  15889. */
  15890. needAlphaBlending: boolean;
  15891. /**
  15892. * Does the material work in alpha test mode
  15893. */
  15894. needAlphaTesting: boolean;
  15895. /**
  15896. * The list of attribute names used in the shader
  15897. */
  15898. attributes: string[];
  15899. /**
  15900. * The list of unifrom names used in the shader
  15901. */
  15902. uniforms: string[];
  15903. /**
  15904. * The list of UBO names used in the shader
  15905. */
  15906. uniformBuffers: string[];
  15907. /**
  15908. * The list of sampler names used in the shader
  15909. */
  15910. samplers: string[];
  15911. /**
  15912. * The list of defines used in the shader
  15913. */
  15914. defines: string[];
  15915. }
  15916. /**
  15917. * The ShaderMaterial object has the necessary methods to pass data from your scene to the Vertex and Fragment Shaders and returns a material that can be applied to any mesh.
  15918. *
  15919. * This returned material effects how the mesh will look based on the code in the shaders.
  15920. *
  15921. * @see http://doc.babylonjs.com/how_to/shader_material
  15922. */
  15923. export class ShaderMaterial extends Material {
  15924. private _shaderPath;
  15925. private _options;
  15926. private _textures;
  15927. private _textureArrays;
  15928. private _floats;
  15929. private _ints;
  15930. private _floatsArrays;
  15931. private _colors3;
  15932. private _colors3Arrays;
  15933. private _colors4;
  15934. private _colors4Arrays;
  15935. private _vectors2;
  15936. private _vectors3;
  15937. private _vectors4;
  15938. private _matrices;
  15939. private _matrixArrays;
  15940. private _matrices3x3;
  15941. private _matrices2x2;
  15942. private _vectors2Arrays;
  15943. private _vectors3Arrays;
  15944. private _vectors4Arrays;
  15945. private _cachedWorldViewMatrix;
  15946. private _cachedWorldViewProjectionMatrix;
  15947. private _renderId;
  15948. private _multiview;
  15949. private _cachedDefines;
  15950. /**
  15951. * Instantiate a new shader material.
  15952. * The ShaderMaterial object has the necessary methods to pass data from your scene to the Vertex and Fragment Shaders and returns a material that can be applied to any mesh.
  15953. * This returned material effects how the mesh will look based on the code in the shaders.
  15954. * @see http://doc.babylonjs.com/how_to/shader_material
  15955. * @param name Define the name of the material in the scene
  15956. * @param scene Define the scene the material belongs to
  15957. * @param shaderPath Defines the route to the shader code in one of three ways:
  15958. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  15959. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  15960. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  15961. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  15962. * @param options Define the options used to create the shader
  15963. */
  15964. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  15965. /**
  15966. * Gets the shader path used to define the shader code
  15967. * It can be modified to trigger a new compilation
  15968. */
  15969. get shaderPath(): any;
  15970. /**
  15971. * Sets the shader path used to define the shader code
  15972. * It can be modified to trigger a new compilation
  15973. */
  15974. set shaderPath(shaderPath: any);
  15975. /**
  15976. * Gets the options used to compile the shader.
  15977. * They can be modified to trigger a new compilation
  15978. */
  15979. get options(): IShaderMaterialOptions;
  15980. /**
  15981. * Gets the current class name of the material e.g. "ShaderMaterial"
  15982. * Mainly use in serialization.
  15983. * @returns the class name
  15984. */
  15985. getClassName(): string;
  15986. /**
  15987. * Specifies if the material will require alpha blending
  15988. * @returns a boolean specifying if alpha blending is needed
  15989. */
  15990. needAlphaBlending(): boolean;
  15991. /**
  15992. * Specifies if this material should be rendered in alpha test mode
  15993. * @returns a boolean specifying if an alpha test is needed.
  15994. */
  15995. needAlphaTesting(): boolean;
  15996. private _checkUniform;
  15997. /**
  15998. * Set a texture in the shader.
  15999. * @param name Define the name of the uniform samplers as defined in the shader
  16000. * @param texture Define the texture to bind to this sampler
  16001. * @return the material itself allowing "fluent" like uniform updates
  16002. */
  16003. setTexture(name: string, texture: BaseTexture): ShaderMaterial;
  16004. /**
  16005. * Set a texture array in the shader.
  16006. * @param name Define the name of the uniform sampler array as defined in the shader
  16007. * @param textures Define the list of textures to bind to this sampler
  16008. * @return the material itself allowing "fluent" like uniform updates
  16009. */
  16010. setTextureArray(name: string, textures: BaseTexture[]): ShaderMaterial;
  16011. /**
  16012. * Set a float in the shader.
  16013. * @param name Define the name of the uniform as defined in the shader
  16014. * @param value Define the value to give to the uniform
  16015. * @return the material itself allowing "fluent" like uniform updates
  16016. */
  16017. setFloat(name: string, value: number): ShaderMaterial;
  16018. /**
  16019. * Set a int in the shader.
  16020. * @param name Define the name of the uniform as defined in the shader
  16021. * @param value Define the value to give to the uniform
  16022. * @return the material itself allowing "fluent" like uniform updates
  16023. */
  16024. setInt(name: string, value: number): ShaderMaterial;
  16025. /**
  16026. * Set an array of floats in the shader.
  16027. * @param name Define the name of the uniform as defined in the shader
  16028. * @param value Define the value to give to the uniform
  16029. * @return the material itself allowing "fluent" like uniform updates
  16030. */
  16031. setFloats(name: string, value: number[]): ShaderMaterial;
  16032. /**
  16033. * Set a vec3 in the shader from a Color3.
  16034. * @param name Define the name of the uniform as defined in the shader
  16035. * @param value Define the value to give to the uniform
  16036. * @return the material itself allowing "fluent" like uniform updates
  16037. */
  16038. setColor3(name: string, value: Color3): ShaderMaterial;
  16039. /**
  16040. * Set a vec3 array in the shader from a Color3 array.
  16041. * @param name Define the name of the uniform as defined in the shader
  16042. * @param value Define the value to give to the uniform
  16043. * @return the material itself allowing "fluent" like uniform updates
  16044. */
  16045. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  16046. /**
  16047. * Set a vec4 in the shader from a Color4.
  16048. * @param name Define the name of the uniform as defined in the shader
  16049. * @param value Define the value to give to the uniform
  16050. * @return the material itself allowing "fluent" like uniform updates
  16051. */
  16052. setColor4(name: string, value: Color4): ShaderMaterial;
  16053. /**
  16054. * Set a vec4 array in the shader from a Color4 array.
  16055. * @param name Define the name of the uniform as defined in the shader
  16056. * @param value Define the value to give to the uniform
  16057. * @return the material itself allowing "fluent" like uniform updates
  16058. */
  16059. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  16060. /**
  16061. * Set a vec2 in the shader from a Vector2.
  16062. * @param name Define the name of the uniform as defined in the shader
  16063. * @param value Define the value to give to the uniform
  16064. * @return the material itself allowing "fluent" like uniform updates
  16065. */
  16066. setVector2(name: string, value: Vector2): ShaderMaterial;
  16067. /**
  16068. * Set a vec3 in the shader from a Vector3.
  16069. * @param name Define the name of the uniform as defined in the shader
  16070. * @param value Define the value to give to the uniform
  16071. * @return the material itself allowing "fluent" like uniform updates
  16072. */
  16073. setVector3(name: string, value: Vector3): ShaderMaterial;
  16074. /**
  16075. * Set a vec4 in the shader from a Vector4.
  16076. * @param name Define the name of the uniform as defined in the shader
  16077. * @param value Define the value to give to the uniform
  16078. * @return the material itself allowing "fluent" like uniform updates
  16079. */
  16080. setVector4(name: string, value: Vector4): ShaderMaterial;
  16081. /**
  16082. * Set a mat4 in the shader from a Matrix.
  16083. * @param name Define the name of the uniform as defined in the shader
  16084. * @param value Define the value to give to the uniform
  16085. * @return the material itself allowing "fluent" like uniform updates
  16086. */
  16087. setMatrix(name: string, value: Matrix): ShaderMaterial;
  16088. /**
  16089. * Set a float32Array in the shader from a matrix array.
  16090. * @param name Define the name of the uniform as defined in the shader
  16091. * @param value Define the value to give to the uniform
  16092. * @return the material itself allowing "fluent" like uniform updates
  16093. */
  16094. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  16095. /**
  16096. * Set a mat3 in the shader from a Float32Array.
  16097. * @param name Define the name of the uniform as defined in the shader
  16098. * @param value Define the value to give to the uniform
  16099. * @return the material itself allowing "fluent" like uniform updates
  16100. */
  16101. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  16102. /**
  16103. * Set a mat2 in the shader from a Float32Array.
  16104. * @param name Define the name of the uniform as defined in the shader
  16105. * @param value Define the value to give to the uniform
  16106. * @return the material itself allowing "fluent" like uniform updates
  16107. */
  16108. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  16109. /**
  16110. * Set a vec2 array in the shader from a number array.
  16111. * @param name Define the name of the uniform as defined in the shader
  16112. * @param value Define the value to give to the uniform
  16113. * @return the material itself allowing "fluent" like uniform updates
  16114. */
  16115. setArray2(name: string, value: number[]): ShaderMaterial;
  16116. /**
  16117. * Set a vec3 array in the shader from a number array.
  16118. * @param name Define the name of the uniform as defined in the shader
  16119. * @param value Define the value to give to the uniform
  16120. * @return the material itself allowing "fluent" like uniform updates
  16121. */
  16122. setArray3(name: string, value: number[]): ShaderMaterial;
  16123. /**
  16124. * Set a vec4 array in the shader from a number array.
  16125. * @param name Define the name of the uniform as defined in the shader
  16126. * @param value Define the value to give to the uniform
  16127. * @return the material itself allowing "fluent" like uniform updates
  16128. */
  16129. setArray4(name: string, value: number[]): ShaderMaterial;
  16130. private _checkCache;
  16131. /**
  16132. * Specifies that the submesh is ready to be used
  16133. * @param mesh defines the mesh to check
  16134. * @param subMesh defines which submesh to check
  16135. * @param useInstances specifies that instances should be used
  16136. * @returns a boolean indicating that the submesh is ready or not
  16137. */
  16138. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  16139. /**
  16140. * Checks if the material is ready to render the requested mesh
  16141. * @param mesh Define the mesh to render
  16142. * @param useInstances Define whether or not the material is used with instances
  16143. * @returns true if ready, otherwise false
  16144. */
  16145. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  16146. /**
  16147. * Binds the world matrix to the material
  16148. * @param world defines the world transformation matrix
  16149. * @param effectOverride - If provided, use this effect instead of internal effect
  16150. */
  16151. bindOnlyWorldMatrix(world: Matrix, effectOverride?: Nullable<Effect>): void;
  16152. /**
  16153. * Binds the submesh to this material by preparing the effect and shader to draw
  16154. * @param world defines the world transformation matrix
  16155. * @param mesh defines the mesh containing the submesh
  16156. * @param subMesh defines the submesh to bind the material to
  16157. */
  16158. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  16159. /**
  16160. * Binds the material to the mesh
  16161. * @param world defines the world transformation matrix
  16162. * @param mesh defines the mesh to bind the material to
  16163. * @param effectOverride - If provided, use this effect instead of internal effect
  16164. */
  16165. bind(world: Matrix, mesh?: Mesh, effectOverride?: Nullable<Effect>): void;
  16166. protected _afterBind(mesh?: Mesh): void;
  16167. /**
  16168. * Gets the active textures from the material
  16169. * @returns an array of textures
  16170. */
  16171. getActiveTextures(): BaseTexture[];
  16172. /**
  16173. * Specifies if the material uses a texture
  16174. * @param texture defines the texture to check against the material
  16175. * @returns a boolean specifying if the material uses the texture
  16176. */
  16177. hasTexture(texture: BaseTexture): boolean;
  16178. /**
  16179. * Makes a duplicate of the material, and gives it a new name
  16180. * @param name defines the new name for the duplicated material
  16181. * @returns the cloned material
  16182. */
  16183. clone(name: string): ShaderMaterial;
  16184. /**
  16185. * Disposes the material
  16186. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  16187. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  16188. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  16189. */
  16190. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  16191. /**
  16192. * Serializes this material in a JSON representation
  16193. * @returns the serialized material object
  16194. */
  16195. serialize(): any;
  16196. /**
  16197. * Creates a shader material from parsed shader material data
  16198. * @param source defines the JSON represnetation of the material
  16199. * @param scene defines the hosting scene
  16200. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  16201. * @returns a new material
  16202. */
  16203. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  16204. }
  16205. }
  16206. declare module "babylonjs/Shaders/color.fragment" {
  16207. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  16208. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  16209. /** @hidden */
  16210. export var colorPixelShader: {
  16211. name: string;
  16212. shader: string;
  16213. };
  16214. }
  16215. declare module "babylonjs/Shaders/color.vertex" {
  16216. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  16217. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  16218. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  16219. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  16220. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  16221. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  16222. /** @hidden */
  16223. export var colorVertexShader: {
  16224. name: string;
  16225. shader: string;
  16226. };
  16227. }
  16228. declare module "babylonjs/Meshes/linesMesh" {
  16229. import { Nullable } from "babylonjs/types";
  16230. import { Scene } from "babylonjs/scene";
  16231. import { Color3 } from "babylonjs/Maths/math.color";
  16232. import { Node } from "babylonjs/node";
  16233. import { SubMesh } from "babylonjs/Meshes/subMesh";
  16234. import { Mesh } from "babylonjs/Meshes/mesh";
  16235. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  16236. import { Effect } from "babylonjs/Materials/effect";
  16237. import { Material } from "babylonjs/Materials/material";
  16238. import "babylonjs/Shaders/color.fragment";
  16239. import "babylonjs/Shaders/color.vertex";
  16240. /**
  16241. * Line mesh
  16242. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  16243. */
  16244. export class LinesMesh extends Mesh {
  16245. /**
  16246. * If vertex color should be applied to the mesh
  16247. */
  16248. readonly useVertexColor?: boolean | undefined;
  16249. /**
  16250. * If vertex alpha should be applied to the mesh
  16251. */
  16252. readonly useVertexAlpha?: boolean | undefined;
  16253. /**
  16254. * Color of the line (Default: White)
  16255. */
  16256. color: Color3;
  16257. /**
  16258. * Alpha of the line (Default: 1)
  16259. */
  16260. alpha: number;
  16261. /**
  16262. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  16263. * This margin is expressed in world space coordinates, so its value may vary.
  16264. * Default value is 0.1
  16265. */
  16266. intersectionThreshold: number;
  16267. private _colorShader;
  16268. private color4;
  16269. /**
  16270. * Creates a new LinesMesh
  16271. * @param name defines the name
  16272. * @param scene defines the hosting scene
  16273. * @param parent defines the parent mesh if any
  16274. * @param source defines the optional source LinesMesh used to clone data from
  16275. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  16276. * When false, achieved by calling a clone(), also passing False.
  16277. * This will make creation of children, recursive.
  16278. * @param useVertexColor defines if this LinesMesh supports vertex color
  16279. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  16280. */
  16281. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  16282. /**
  16283. * If vertex color should be applied to the mesh
  16284. */
  16285. useVertexColor?: boolean | undefined,
  16286. /**
  16287. * If vertex alpha should be applied to the mesh
  16288. */
  16289. useVertexAlpha?: boolean | undefined);
  16290. private _addClipPlaneDefine;
  16291. private _removeClipPlaneDefine;
  16292. isReady(): boolean;
  16293. /**
  16294. * Returns the string "LineMesh"
  16295. */
  16296. getClassName(): string;
  16297. /**
  16298. * @hidden
  16299. */
  16300. get material(): Material;
  16301. /**
  16302. * @hidden
  16303. */
  16304. set material(value: Material);
  16305. /**
  16306. * @hidden
  16307. */
  16308. get checkCollisions(): boolean;
  16309. /** @hidden */
  16310. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  16311. /** @hidden */
  16312. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  16313. /**
  16314. * Disposes of the line mesh
  16315. * @param doNotRecurse If children should be disposed
  16316. */
  16317. dispose(doNotRecurse?: boolean): void;
  16318. /**
  16319. * Returns a new LineMesh object cloned from the current one.
  16320. */
  16321. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  16322. /**
  16323. * Creates a new InstancedLinesMesh object from the mesh model.
  16324. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  16325. * @param name defines the name of the new instance
  16326. * @returns a new InstancedLinesMesh
  16327. */
  16328. createInstance(name: string): InstancedLinesMesh;
  16329. }
  16330. /**
  16331. * Creates an instance based on a source LinesMesh
  16332. */
  16333. export class InstancedLinesMesh extends InstancedMesh {
  16334. /**
  16335. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  16336. * This margin is expressed in world space coordinates, so its value may vary.
  16337. * Initilized with the intersectionThreshold value of the source LinesMesh
  16338. */
  16339. intersectionThreshold: number;
  16340. constructor(name: string, source: LinesMesh);
  16341. /**
  16342. * Returns the string "InstancedLinesMesh".
  16343. */
  16344. getClassName(): string;
  16345. }
  16346. }
  16347. declare module "babylonjs/Shaders/line.fragment" {
  16348. /** @hidden */
  16349. export var linePixelShader: {
  16350. name: string;
  16351. shader: string;
  16352. };
  16353. }
  16354. declare module "babylonjs/Shaders/line.vertex" {
  16355. /** @hidden */
  16356. export var lineVertexShader: {
  16357. name: string;
  16358. shader: string;
  16359. };
  16360. }
  16361. declare module "babylonjs/Rendering/edgesRenderer" {
  16362. import { Nullable } from "babylonjs/types";
  16363. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  16364. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16365. import { Vector3 } from "babylonjs/Maths/math.vector";
  16366. import { IDisposable } from "babylonjs/scene";
  16367. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  16368. import "babylonjs/Shaders/line.fragment";
  16369. import "babylonjs/Shaders/line.vertex";
  16370. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  16371. module "babylonjs/Meshes/abstractMesh" {
  16372. interface AbstractMesh {
  16373. /**
  16374. * Gets the edgesRenderer associated with the mesh
  16375. */
  16376. edgesRenderer: Nullable<EdgesRenderer>;
  16377. }
  16378. }
  16379. module "babylonjs/Meshes/linesMesh" {
  16380. interface LinesMesh {
  16381. /**
  16382. * Enables the edge rendering mode on the mesh.
  16383. * This mode makes the mesh edges visible
  16384. * @param epsilon defines the maximal distance between two angles to detect a face
  16385. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  16386. * @returns the currentAbstractMesh
  16387. * @see https://www.babylonjs-playground.com/#19O9TU#0
  16388. */
  16389. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  16390. }
  16391. }
  16392. module "babylonjs/Meshes/linesMesh" {
  16393. interface InstancedLinesMesh {
  16394. /**
  16395. * Enables the edge rendering mode on the mesh.
  16396. * This mode makes the mesh edges visible
  16397. * @param epsilon defines the maximal distance between two angles to detect a face
  16398. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  16399. * @returns the current InstancedLinesMesh
  16400. * @see https://www.babylonjs-playground.com/#19O9TU#0
  16401. */
  16402. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  16403. }
  16404. }
  16405. /**
  16406. * Defines the minimum contract an Edges renderer should follow.
  16407. */
  16408. export interface IEdgesRenderer extends IDisposable {
  16409. /**
  16410. * Gets or sets a boolean indicating if the edgesRenderer is active
  16411. */
  16412. isEnabled: boolean;
  16413. /**
  16414. * Renders the edges of the attached mesh,
  16415. */
  16416. render(): void;
  16417. /**
  16418. * Checks wether or not the edges renderer is ready to render.
  16419. * @return true if ready, otherwise false.
  16420. */
  16421. isReady(): boolean;
  16422. }
  16423. /**
  16424. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  16425. */
  16426. export class EdgesRenderer implements IEdgesRenderer {
  16427. /**
  16428. * Define the size of the edges with an orthographic camera
  16429. */
  16430. edgesWidthScalerForOrthographic: number;
  16431. /**
  16432. * Define the size of the edges with a perspective camera
  16433. */
  16434. edgesWidthScalerForPerspective: number;
  16435. protected _source: AbstractMesh;
  16436. protected _linesPositions: number[];
  16437. protected _linesNormals: number[];
  16438. protected _linesIndices: number[];
  16439. protected _epsilon: number;
  16440. protected _indicesCount: number;
  16441. protected _lineShader: ShaderMaterial;
  16442. protected _ib: DataBuffer;
  16443. protected _buffers: {
  16444. [key: string]: Nullable<VertexBuffer>;
  16445. };
  16446. protected _checkVerticesInsteadOfIndices: boolean;
  16447. private _meshRebuildObserver;
  16448. private _meshDisposeObserver;
  16449. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  16450. isEnabled: boolean;
  16451. /**
  16452. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  16453. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  16454. * @param source Mesh used to create edges
  16455. * @param epsilon sum of angles in adjacency to check for edge
  16456. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  16457. * @param generateEdgesLines - should generate Lines or only prepare resources.
  16458. */
  16459. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  16460. protected _prepareRessources(): void;
  16461. /** @hidden */
  16462. _rebuild(): void;
  16463. /**
  16464. * Releases the required resources for the edges renderer
  16465. */
  16466. dispose(): void;
  16467. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  16468. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  16469. /**
  16470. * Checks if the pair of p0 and p1 is en edge
  16471. * @param faceIndex
  16472. * @param edge
  16473. * @param faceNormals
  16474. * @param p0
  16475. * @param p1
  16476. * @private
  16477. */
  16478. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  16479. /**
  16480. * push line into the position, normal and index buffer
  16481. * @protected
  16482. */
  16483. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  16484. /**
  16485. * Generates lines edges from adjacencjes
  16486. * @private
  16487. */
  16488. _generateEdgesLines(): void;
  16489. /**
  16490. * Checks wether or not the edges renderer is ready to render.
  16491. * @return true if ready, otherwise false.
  16492. */
  16493. isReady(): boolean;
  16494. /**
  16495. * Renders the edges of the attached mesh,
  16496. */
  16497. render(): void;
  16498. }
  16499. /**
  16500. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  16501. */
  16502. export class LineEdgesRenderer extends EdgesRenderer {
  16503. /**
  16504. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  16505. * @param source LineMesh used to generate edges
  16506. * @param epsilon not important (specified angle for edge detection)
  16507. * @param checkVerticesInsteadOfIndices not important for LineMesh
  16508. */
  16509. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  16510. /**
  16511. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  16512. */
  16513. _generateEdgesLines(): void;
  16514. }
  16515. }
  16516. declare module "babylonjs/Rendering/renderingGroup" {
  16517. import { SmartArray } from "babylonjs/Misc/smartArray";
  16518. import { SubMesh } from "babylonjs/Meshes/subMesh";
  16519. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16520. import { Nullable } from "babylonjs/types";
  16521. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  16522. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  16523. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  16524. import { Material } from "babylonjs/Materials/material";
  16525. import { Scene } from "babylonjs/scene";
  16526. /**
  16527. * This represents the object necessary to create a rendering group.
  16528. * This is exclusively used and created by the rendering manager.
  16529. * To modify the behavior, you use the available helpers in your scene or meshes.
  16530. * @hidden
  16531. */
  16532. export class RenderingGroup {
  16533. index: number;
  16534. private static _zeroVector;
  16535. private _scene;
  16536. private _opaqueSubMeshes;
  16537. private _transparentSubMeshes;
  16538. private _alphaTestSubMeshes;
  16539. private _depthOnlySubMeshes;
  16540. private _particleSystems;
  16541. private _spriteManagers;
  16542. private _opaqueSortCompareFn;
  16543. private _alphaTestSortCompareFn;
  16544. private _transparentSortCompareFn;
  16545. private _renderOpaque;
  16546. private _renderAlphaTest;
  16547. private _renderTransparent;
  16548. /** @hidden */
  16549. _edgesRenderers: SmartArray<IEdgesRenderer>;
  16550. onBeforeTransparentRendering: () => void;
  16551. /**
  16552. * Set the opaque sort comparison function.
  16553. * If null the sub meshes will be render in the order they were created
  16554. */
  16555. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  16556. /**
  16557. * Set the alpha test sort comparison function.
  16558. * If null the sub meshes will be render in the order they were created
  16559. */
  16560. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  16561. /**
  16562. * Set the transparent sort comparison function.
  16563. * If null the sub meshes will be render in the order they were created
  16564. */
  16565. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  16566. /**
  16567. * Creates a new rendering group.
  16568. * @param index The rendering group index
  16569. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  16570. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  16571. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  16572. */
  16573. constructor(index: number, scene: Scene, opaqueSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>, alphaTestSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>, transparentSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>);
  16574. /**
  16575. * Render all the sub meshes contained in the group.
  16576. * @param customRenderFunction Used to override the default render behaviour of the group.
  16577. * @returns true if rendered some submeshes.
  16578. */
  16579. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  16580. /**
  16581. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  16582. * @param subMeshes The submeshes to render
  16583. */
  16584. private renderOpaqueSorted;
  16585. /**
  16586. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  16587. * @param subMeshes The submeshes to render
  16588. */
  16589. private renderAlphaTestSorted;
  16590. /**
  16591. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  16592. * @param subMeshes The submeshes to render
  16593. */
  16594. private renderTransparentSorted;
  16595. /**
  16596. * Renders the submeshes in a specified order.
  16597. * @param subMeshes The submeshes to sort before render
  16598. * @param sortCompareFn The comparison function use to sort
  16599. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  16600. * @param transparent Specifies to activate blending if true
  16601. */
  16602. private static renderSorted;
  16603. /**
  16604. * Renders the submeshes in the order they were dispatched (no sort applied).
  16605. * @param subMeshes The submeshes to render
  16606. */
  16607. private static renderUnsorted;
  16608. /**
  16609. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  16610. * are rendered back to front if in the same alpha index.
  16611. *
  16612. * @param a The first submesh
  16613. * @param b The second submesh
  16614. * @returns The result of the comparison
  16615. */
  16616. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  16617. /**
  16618. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  16619. * are rendered back to front.
  16620. *
  16621. * @param a The first submesh
  16622. * @param b The second submesh
  16623. * @returns The result of the comparison
  16624. */
  16625. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  16626. /**
  16627. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  16628. * are rendered front to back (prevent overdraw).
  16629. *
  16630. * @param a The first submesh
  16631. * @param b The second submesh
  16632. * @returns The result of the comparison
  16633. */
  16634. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  16635. /**
  16636. * Resets the different lists of submeshes to prepare a new frame.
  16637. */
  16638. prepare(): void;
  16639. dispose(): void;
  16640. /**
  16641. * Inserts the submesh in its correct queue depending on its material.
  16642. * @param subMesh The submesh to dispatch
  16643. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  16644. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  16645. */
  16646. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  16647. dispatchSprites(spriteManager: ISpriteManager): void;
  16648. dispatchParticles(particleSystem: IParticleSystem): void;
  16649. private _renderParticles;
  16650. private _renderSprites;
  16651. }
  16652. }
  16653. declare module "babylonjs/Rendering/renderingManager" {
  16654. import { Nullable } from "babylonjs/types";
  16655. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16656. import { SubMesh } from "babylonjs/Meshes/subMesh";
  16657. import { SmartArray } from "babylonjs/Misc/smartArray";
  16658. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  16659. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  16660. import { Material } from "babylonjs/Materials/material";
  16661. import { Scene } from "babylonjs/scene";
  16662. import { Camera } from "babylonjs/Cameras/camera";
  16663. /**
  16664. * Interface describing the different options available in the rendering manager
  16665. * regarding Auto Clear between groups.
  16666. */
  16667. export interface IRenderingManagerAutoClearSetup {
  16668. /**
  16669. * Defines whether or not autoclear is enable.
  16670. */
  16671. autoClear: boolean;
  16672. /**
  16673. * Defines whether or not to autoclear the depth buffer.
  16674. */
  16675. depth: boolean;
  16676. /**
  16677. * Defines whether or not to autoclear the stencil buffer.
  16678. */
  16679. stencil: boolean;
  16680. }
  16681. /**
  16682. * This class is used by the onRenderingGroupObservable
  16683. */
  16684. export class RenderingGroupInfo {
  16685. /**
  16686. * The Scene that being rendered
  16687. */
  16688. scene: Scene;
  16689. /**
  16690. * The camera currently used for the rendering pass
  16691. */
  16692. camera: Nullable<Camera>;
  16693. /**
  16694. * The ID of the renderingGroup being processed
  16695. */
  16696. renderingGroupId: number;
  16697. }
  16698. /**
  16699. * This is the manager responsible of all the rendering for meshes sprites and particles.
  16700. * It is enable to manage the different groups as well as the different necessary sort functions.
  16701. * This should not be used directly aside of the few static configurations
  16702. */
  16703. export class RenderingManager {
  16704. /**
  16705. * The max id used for rendering groups (not included)
  16706. */
  16707. static MAX_RENDERINGGROUPS: number;
  16708. /**
  16709. * The min id used for rendering groups (included)
  16710. */
  16711. static MIN_RENDERINGGROUPS: number;
  16712. /**
  16713. * Used to globally prevent autoclearing scenes.
  16714. */
  16715. static AUTOCLEAR: boolean;
  16716. /**
  16717. * @hidden
  16718. */
  16719. _useSceneAutoClearSetup: boolean;
  16720. private _scene;
  16721. private _renderingGroups;
  16722. private _depthStencilBufferAlreadyCleaned;
  16723. private _autoClearDepthStencil;
  16724. private _customOpaqueSortCompareFn;
  16725. private _customAlphaTestSortCompareFn;
  16726. private _customTransparentSortCompareFn;
  16727. private _renderingGroupInfo;
  16728. /**
  16729. * Instantiates a new rendering group for a particular scene
  16730. * @param scene Defines the scene the groups belongs to
  16731. */
  16732. constructor(scene: Scene);
  16733. private _clearDepthStencilBuffer;
  16734. /**
  16735. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  16736. * @hidden
  16737. */
  16738. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  16739. /**
  16740. * Resets the different information of the group to prepare a new frame
  16741. * @hidden
  16742. */
  16743. reset(): void;
  16744. /**
  16745. * Dispose and release the group and its associated resources.
  16746. * @hidden
  16747. */
  16748. dispose(): void;
  16749. /**
  16750. * Clear the info related to rendering groups preventing retention points during dispose.
  16751. */
  16752. freeRenderingGroups(): void;
  16753. private _prepareRenderingGroup;
  16754. /**
  16755. * Add a sprite manager to the rendering manager in order to render it this frame.
  16756. * @param spriteManager Define the sprite manager to render
  16757. */
  16758. dispatchSprites(spriteManager: ISpriteManager): void;
  16759. /**
  16760. * Add a particle system to the rendering manager in order to render it this frame.
  16761. * @param particleSystem Define the particle system to render
  16762. */
  16763. dispatchParticles(particleSystem: IParticleSystem): void;
  16764. /**
  16765. * Add a submesh to the manager in order to render it this frame
  16766. * @param subMesh The submesh to dispatch
  16767. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  16768. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  16769. */
  16770. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  16771. /**
  16772. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  16773. * This allowed control for front to back rendering or reversly depending of the special needs.
  16774. *
  16775. * @param renderingGroupId The rendering group id corresponding to its index
  16776. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  16777. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  16778. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  16779. */
  16780. setRenderingOrder(renderingGroupId: number, opaqueSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>, alphaTestSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>, transparentSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>): void;
  16781. /**
  16782. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  16783. *
  16784. * @param renderingGroupId The rendering group id corresponding to its index
  16785. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  16786. * @param depth Automatically clears depth between groups if true and autoClear is true.
  16787. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  16788. */
  16789. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  16790. /**
  16791. * Gets the current auto clear configuration for one rendering group of the rendering
  16792. * manager.
  16793. * @param index the rendering group index to get the information for
  16794. * @returns The auto clear setup for the requested rendering group
  16795. */
  16796. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  16797. }
  16798. }
  16799. declare module "babylonjs/Lights/Shadows/shadowGenerator" {
  16800. import { SmartArray } from "babylonjs/Misc/smartArray";
  16801. import { Nullable } from "babylonjs/types";
  16802. import { Scene } from "babylonjs/scene";
  16803. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  16804. import { SubMesh } from "babylonjs/Meshes/subMesh";
  16805. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16806. import { Mesh } from "babylonjs/Meshes/mesh";
  16807. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  16808. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  16809. import { Effect } from "babylonjs/Materials/effect";
  16810. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  16811. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  16812. import "babylonjs/Shaders/shadowMap.fragment";
  16813. import "babylonjs/Shaders/shadowMap.vertex";
  16814. import "babylonjs/Shaders/depthBoxBlur.fragment";
  16815. import "babylonjs/Shaders/ShadersInclude/shadowMapFragmentSoftTransparentShadow";
  16816. import { Observable } from "babylonjs/Misc/observable";
  16817. /**
  16818. * Defines the options associated with the creation of a custom shader for a shadow generator.
  16819. */
  16820. export interface ICustomShaderOptions {
  16821. /**
  16822. * Gets or sets the custom shader name to use
  16823. */
  16824. shaderName: string;
  16825. /**
  16826. * The list of attribute names used in the shader
  16827. */
  16828. attributes?: string[];
  16829. /**
  16830. * The list of unifrom names used in the shader
  16831. */
  16832. uniforms?: string[];
  16833. /**
  16834. * The list of sampler names used in the shader
  16835. */
  16836. samplers?: string[];
  16837. /**
  16838. * The list of defines used in the shader
  16839. */
  16840. defines?: string[];
  16841. }
  16842. /**
  16843. * Interface to implement to create a shadow generator compatible with BJS.
  16844. */
  16845. export interface IShadowGenerator {
  16846. /**
  16847. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  16848. * @returns The render target texture if present otherwise, null
  16849. */
  16850. getShadowMap(): Nullable<RenderTargetTexture>;
  16851. /**
  16852. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  16853. * @param subMesh The submesh we want to render in the shadow map
  16854. * @param useInstances Defines wether will draw in the map using instances
  16855. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  16856. * @returns true if ready otherwise, false
  16857. */
  16858. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  16859. /**
  16860. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  16861. * @param defines Defines of the material we want to update
  16862. * @param lightIndex Index of the light in the enabled light list of the material
  16863. */
  16864. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  16865. /**
  16866. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  16867. * defined in the generator but impacting the effect).
  16868. * It implies the unifroms available on the materials are the standard BJS ones.
  16869. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  16870. * @param effect The effect we are binfing the information for
  16871. */
  16872. bindShadowLight(lightIndex: string, effect: Effect): void;
  16873. /**
  16874. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  16875. * (eq to shadow prjection matrix * light transform matrix)
  16876. * @returns The transform matrix used to create the shadow map
  16877. */
  16878. getTransformMatrix(): Matrix;
  16879. /**
  16880. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  16881. * Cube and 2D textures for instance.
  16882. */
  16883. recreateShadowMap(): void;
  16884. /**
  16885. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  16886. * @param onCompiled Callback triggered at the and of the effects compilation
  16887. * @param options Sets of optional options forcing the compilation with different modes
  16888. */
  16889. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  16890. useInstances: boolean;
  16891. }>): void;
  16892. /**
  16893. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  16894. * @param options Sets of optional options forcing the compilation with different modes
  16895. * @returns A promise that resolves when the compilation completes
  16896. */
  16897. forceCompilationAsync(options?: Partial<{
  16898. useInstances: boolean;
  16899. }>): Promise<void>;
  16900. /**
  16901. * Serializes the shadow generator setup to a json object.
  16902. * @returns The serialized JSON object
  16903. */
  16904. serialize(): any;
  16905. /**
  16906. * Disposes the Shadow map and related Textures and effects.
  16907. */
  16908. dispose(): void;
  16909. }
  16910. /**
  16911. * Default implementation IShadowGenerator.
  16912. * This is the main object responsible of generating shadows in the framework.
  16913. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  16914. */
  16915. export class ShadowGenerator implements IShadowGenerator {
  16916. /**
  16917. * Name of the shadow generator class
  16918. */
  16919. static CLASSNAME: string;
  16920. /**
  16921. * Shadow generator mode None: no filtering applied.
  16922. */
  16923. static readonly FILTER_NONE: number;
  16924. /**
  16925. * Shadow generator mode ESM: Exponential Shadow Mapping.
  16926. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  16927. */
  16928. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  16929. /**
  16930. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  16931. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  16932. */
  16933. static readonly FILTER_POISSONSAMPLING: number;
  16934. /**
  16935. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  16936. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  16937. */
  16938. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  16939. /**
  16940. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  16941. * edge artifacts on steep falloff.
  16942. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  16943. */
  16944. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  16945. /**
  16946. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  16947. * edge artifacts on steep falloff.
  16948. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  16949. */
  16950. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  16951. /**
  16952. * Shadow generator mode PCF: Percentage Closer Filtering
  16953. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  16954. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  16955. */
  16956. static readonly FILTER_PCF: number;
  16957. /**
  16958. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  16959. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  16960. * Contact Hardening
  16961. */
  16962. static readonly FILTER_PCSS: number;
  16963. /**
  16964. * Reserved for PCF and PCSS
  16965. * Highest Quality.
  16966. *
  16967. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  16968. *
  16969. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  16970. */
  16971. static readonly QUALITY_HIGH: number;
  16972. /**
  16973. * Reserved for PCF and PCSS
  16974. * Good tradeoff for quality/perf cross devices
  16975. *
  16976. * Execute PCF on a 3*3 kernel.
  16977. *
  16978. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  16979. */
  16980. static readonly QUALITY_MEDIUM: number;
  16981. /**
  16982. * Reserved for PCF and PCSS
  16983. * The lowest quality but the fastest.
  16984. *
  16985. * Execute PCF on a 1*1 kernel.
  16986. *
  16987. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  16988. */
  16989. static readonly QUALITY_LOW: number;
  16990. /** Gets or sets the custom shader name to use */
  16991. customShaderOptions: ICustomShaderOptions;
  16992. /**
  16993. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  16994. */
  16995. onBeforeShadowMapRenderObservable: Observable<Effect>;
  16996. /**
  16997. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  16998. */
  16999. onAfterShadowMapRenderObservable: Observable<Effect>;
  17000. /**
  17001. * Observable triggered before a mesh is rendered in the shadow map.
  17002. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  17003. */
  17004. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  17005. /**
  17006. * Observable triggered after a mesh is rendered in the shadow map.
  17007. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  17008. */
  17009. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  17010. protected _bias: number;
  17011. /**
  17012. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  17013. */
  17014. get bias(): number;
  17015. /**
  17016. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  17017. */
  17018. set bias(bias: number);
  17019. protected _normalBias: number;
  17020. /**
  17021. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  17022. */
  17023. get normalBias(): number;
  17024. /**
  17025. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  17026. */
  17027. set normalBias(normalBias: number);
  17028. protected _blurBoxOffset: number;
  17029. /**
  17030. * Gets the blur box offset: offset applied during the blur pass.
  17031. * Only useful if useKernelBlur = false
  17032. */
  17033. get blurBoxOffset(): number;
  17034. /**
  17035. * Sets the blur box offset: offset applied during the blur pass.
  17036. * Only useful if useKernelBlur = false
  17037. */
  17038. set blurBoxOffset(value: number);
  17039. protected _blurScale: number;
  17040. /**
  17041. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  17042. * 2 means half of the size.
  17043. */
  17044. get blurScale(): number;
  17045. /**
  17046. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  17047. * 2 means half of the size.
  17048. */
  17049. set blurScale(value: number);
  17050. protected _blurKernel: number;
  17051. /**
  17052. * Gets the blur kernel: kernel size of the blur pass.
  17053. * Only useful if useKernelBlur = true
  17054. */
  17055. get blurKernel(): number;
  17056. /**
  17057. * Sets the blur kernel: kernel size of the blur pass.
  17058. * Only useful if useKernelBlur = true
  17059. */
  17060. set blurKernel(value: number);
  17061. protected _useKernelBlur: boolean;
  17062. /**
  17063. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  17064. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  17065. */
  17066. get useKernelBlur(): boolean;
  17067. /**
  17068. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  17069. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  17070. */
  17071. set useKernelBlur(value: boolean);
  17072. protected _depthScale: number;
  17073. /**
  17074. * Gets the depth scale used in ESM mode.
  17075. */
  17076. get depthScale(): number;
  17077. /**
  17078. * Sets the depth scale used in ESM mode.
  17079. * This can override the scale stored on the light.
  17080. */
  17081. set depthScale(value: number);
  17082. protected _validateFilter(filter: number): number;
  17083. protected _filter: number;
  17084. /**
  17085. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  17086. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  17087. */
  17088. get filter(): number;
  17089. /**
  17090. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  17091. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  17092. */
  17093. set filter(value: number);
  17094. /**
  17095. * Gets if the current filter is set to Poisson Sampling.
  17096. */
  17097. get usePoissonSampling(): boolean;
  17098. /**
  17099. * Sets the current filter to Poisson Sampling.
  17100. */
  17101. set usePoissonSampling(value: boolean);
  17102. /**
  17103. * Gets if the current filter is set to ESM.
  17104. */
  17105. get useExponentialShadowMap(): boolean;
  17106. /**
  17107. * Sets the current filter is to ESM.
  17108. */
  17109. set useExponentialShadowMap(value: boolean);
  17110. /**
  17111. * Gets if the current filter is set to filtered ESM.
  17112. */
  17113. get useBlurExponentialShadowMap(): boolean;
  17114. /**
  17115. * Gets if the current filter is set to filtered ESM.
  17116. */
  17117. set useBlurExponentialShadowMap(value: boolean);
  17118. /**
  17119. * Gets if the current filter is set to "close ESM" (using the inverse of the
  17120. * exponential to prevent steep falloff artifacts).
  17121. */
  17122. get useCloseExponentialShadowMap(): boolean;
  17123. /**
  17124. * Sets the current filter to "close ESM" (using the inverse of the
  17125. * exponential to prevent steep falloff artifacts).
  17126. */
  17127. set useCloseExponentialShadowMap(value: boolean);
  17128. /**
  17129. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  17130. * exponential to prevent steep falloff artifacts).
  17131. */
  17132. get useBlurCloseExponentialShadowMap(): boolean;
  17133. /**
  17134. * Sets the current filter to filtered "close ESM" (using the inverse of the
  17135. * exponential to prevent steep falloff artifacts).
  17136. */
  17137. set useBlurCloseExponentialShadowMap(value: boolean);
  17138. /**
  17139. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  17140. */
  17141. get usePercentageCloserFiltering(): boolean;
  17142. /**
  17143. * Sets the current filter to "PCF" (percentage closer filtering).
  17144. */
  17145. set usePercentageCloserFiltering(value: boolean);
  17146. protected _filteringQuality: number;
  17147. /**
  17148. * Gets the PCF or PCSS Quality.
  17149. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  17150. */
  17151. get filteringQuality(): number;
  17152. /**
  17153. * Sets the PCF or PCSS Quality.
  17154. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  17155. */
  17156. set filteringQuality(filteringQuality: number);
  17157. /**
  17158. * Gets if the current filter is set to "PCSS" (contact hardening).
  17159. */
  17160. get useContactHardeningShadow(): boolean;
  17161. /**
  17162. * Sets the current filter to "PCSS" (contact hardening).
  17163. */
  17164. set useContactHardeningShadow(value: boolean);
  17165. protected _contactHardeningLightSizeUVRatio: number;
  17166. /**
  17167. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  17168. * Using a ratio helps keeping shape stability independently of the map size.
  17169. *
  17170. * It does not account for the light projection as it was having too much
  17171. * instability during the light setup or during light position changes.
  17172. *
  17173. * Only valid if useContactHardeningShadow is true.
  17174. */
  17175. get contactHardeningLightSizeUVRatio(): number;
  17176. /**
  17177. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  17178. * Using a ratio helps keeping shape stability independently of the map size.
  17179. *
  17180. * It does not account for the light projection as it was having too much
  17181. * instability during the light setup or during light position changes.
  17182. *
  17183. * Only valid if useContactHardeningShadow is true.
  17184. */
  17185. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  17186. protected _darkness: number;
  17187. /** Gets or sets the actual darkness of a shadow */
  17188. get darkness(): number;
  17189. set darkness(value: number);
  17190. /**
  17191. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  17192. * 0 means strongest and 1 would means no shadow.
  17193. * @returns the darkness.
  17194. */
  17195. getDarkness(): number;
  17196. /**
  17197. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  17198. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  17199. * @returns the shadow generator allowing fluent coding.
  17200. */
  17201. setDarkness(darkness: number): ShadowGenerator;
  17202. protected _transparencyShadow: boolean;
  17203. /** Gets or sets the ability to have transparent shadow */
  17204. get transparencyShadow(): boolean;
  17205. set transparencyShadow(value: boolean);
  17206. /**
  17207. * Sets the ability to have transparent shadow (boolean).
  17208. * @param transparent True if transparent else False
  17209. * @returns the shadow generator allowing fluent coding
  17210. */
  17211. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  17212. /**
  17213. * Enables or disables shadows with varying strength based on the transparency
  17214. * When it is enabled, the strength of the shadow is taken equal to mesh.visibility
  17215. * If you enabled an alpha texture on your material, the alpha value red from the texture is also combined to compute the strength:
  17216. * mesh.visibility * alphaTexture.a
  17217. * Note that by definition transparencyShadow must be set to true for enableSoftTransparentShadow to work!
  17218. */
  17219. enableSoftTransparentShadow: boolean;
  17220. protected _shadowMap: Nullable<RenderTargetTexture>;
  17221. protected _shadowMap2: Nullable<RenderTargetTexture>;
  17222. /**
  17223. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  17224. * @returns The render target texture if present otherwise, null
  17225. */
  17226. getShadowMap(): Nullable<RenderTargetTexture>;
  17227. /**
  17228. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  17229. * @returns The render target texture if the shadow map is present otherwise, null
  17230. */
  17231. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  17232. /**
  17233. * Gets the class name of that object
  17234. * @returns "ShadowGenerator"
  17235. */
  17236. getClassName(): string;
  17237. /**
  17238. * Helper function to add a mesh and its descendants to the list of shadow casters.
  17239. * @param mesh Mesh to add
  17240. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  17241. * @returns the Shadow Generator itself
  17242. */
  17243. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  17244. /**
  17245. * Helper function to remove a mesh and its descendants from the list of shadow casters
  17246. * @param mesh Mesh to remove
  17247. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  17248. * @returns the Shadow Generator itself
  17249. */
  17250. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  17251. /**
  17252. * Controls the extent to which the shadows fade out at the edge of the frustum
  17253. */
  17254. frustumEdgeFalloff: number;
  17255. protected _light: IShadowLight;
  17256. /**
  17257. * Returns the associated light object.
  17258. * @returns the light generating the shadow
  17259. */
  17260. getLight(): IShadowLight;
  17261. /**
  17262. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  17263. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  17264. * It might on the other hand introduce peter panning.
  17265. */
  17266. forceBackFacesOnly: boolean;
  17267. protected _scene: Scene;
  17268. protected _lightDirection: Vector3;
  17269. protected _effect: Effect;
  17270. protected _viewMatrix: Matrix;
  17271. protected _projectionMatrix: Matrix;
  17272. protected _transformMatrix: Matrix;
  17273. protected _cachedPosition: Vector3;
  17274. protected _cachedDirection: Vector3;
  17275. protected _cachedDefines: string;
  17276. protected _currentRenderID: number;
  17277. protected _boxBlurPostprocess: Nullable<PostProcess>;
  17278. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  17279. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  17280. protected _blurPostProcesses: PostProcess[];
  17281. protected _mapSize: number;
  17282. protected _currentFaceIndex: number;
  17283. protected _currentFaceIndexCache: number;
  17284. protected _textureType: number;
  17285. protected _defaultTextureMatrix: Matrix;
  17286. protected _storedUniqueId: Nullable<number>;
  17287. /** @hidden */
  17288. static _SceneComponentInitialization: (scene: Scene) => void;
  17289. /**
  17290. * Creates a ShadowGenerator object.
  17291. * A ShadowGenerator is the required tool to use the shadows.
  17292. * Each light casting shadows needs to use its own ShadowGenerator.
  17293. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  17294. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  17295. * @param light The light object generating the shadows.
  17296. * @param usefulFloatFirst By default the generator will try to use half float textures but if you need precision (for self shadowing for instance), you can use this option to enforce full float texture.
  17297. */
  17298. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  17299. protected _initializeGenerator(): void;
  17300. protected _createTargetRenderTexture(): void;
  17301. protected _initializeShadowMap(): void;
  17302. protected _initializeBlurRTTAndPostProcesses(): void;
  17303. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  17304. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  17305. protected _renderSubMeshForShadowMap(subMesh: SubMesh, isTransparent?: boolean): void;
  17306. protected _applyFilterValues(): void;
  17307. /**
  17308. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17309. * @param onCompiled Callback triggered at the and of the effects compilation
  17310. * @param options Sets of optional options forcing the compilation with different modes
  17311. */
  17312. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  17313. useInstances: boolean;
  17314. }>): void;
  17315. /**
  17316. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17317. * @param options Sets of optional options forcing the compilation with different modes
  17318. * @returns A promise that resolves when the compilation completes
  17319. */
  17320. forceCompilationAsync(options?: Partial<{
  17321. useInstances: boolean;
  17322. }>): Promise<void>;
  17323. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  17324. private _prepareShadowDefines;
  17325. /**
  17326. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  17327. * @param subMesh The submesh we want to render in the shadow map
  17328. * @param useInstances Defines wether will draw in the map using instances
  17329. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  17330. * @returns true if ready otherwise, false
  17331. */
  17332. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  17333. /**
  17334. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  17335. * @param defines Defines of the material we want to update
  17336. * @param lightIndex Index of the light in the enabled light list of the material
  17337. */
  17338. prepareDefines(defines: any, lightIndex: number): void;
  17339. /**
  17340. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  17341. * defined in the generator but impacting the effect).
  17342. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  17343. * @param effect The effect we are binfing the information for
  17344. */
  17345. bindShadowLight(lightIndex: string, effect: Effect): void;
  17346. /**
  17347. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  17348. * (eq to shadow prjection matrix * light transform matrix)
  17349. * @returns The transform matrix used to create the shadow map
  17350. */
  17351. getTransformMatrix(): Matrix;
  17352. /**
  17353. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  17354. * Cube and 2D textures for instance.
  17355. */
  17356. recreateShadowMap(): void;
  17357. protected _disposeBlurPostProcesses(): void;
  17358. protected _disposeRTTandPostProcesses(): void;
  17359. /**
  17360. * Disposes the ShadowGenerator.
  17361. * Returns nothing.
  17362. */
  17363. dispose(): void;
  17364. /**
  17365. * Serializes the shadow generator setup to a json object.
  17366. * @returns The serialized JSON object
  17367. */
  17368. serialize(): any;
  17369. /**
  17370. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  17371. * @param parsedShadowGenerator The JSON object to parse
  17372. * @param scene The scene to create the shadow map for
  17373. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  17374. * @returns The parsed shadow generator
  17375. */
  17376. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  17377. }
  17378. }
  17379. declare module "babylonjs/Lights/light" {
  17380. import { Nullable } from "babylonjs/types";
  17381. import { Scene } from "babylonjs/scene";
  17382. import { Vector3 } from "babylonjs/Maths/math.vector";
  17383. import { Color3 } from "babylonjs/Maths/math.color";
  17384. import { Node } from "babylonjs/node";
  17385. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17386. import { Effect } from "babylonjs/Materials/effect";
  17387. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  17388. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  17389. /**
  17390. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  17391. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  17392. * All meshes allow light to pass through them unless shadow generation is activated. The default number of lights allowed is four but this can be increased.
  17393. */
  17394. export abstract class Light extends Node {
  17395. /**
  17396. * Falloff Default: light is falling off following the material specification:
  17397. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  17398. */
  17399. static readonly FALLOFF_DEFAULT: number;
  17400. /**
  17401. * Falloff Physical: light is falling off following the inverse squared distance law.
  17402. */
  17403. static readonly FALLOFF_PHYSICAL: number;
  17404. /**
  17405. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  17406. * to enhance interoperability with other engines.
  17407. */
  17408. static readonly FALLOFF_GLTF: number;
  17409. /**
  17410. * Falloff Standard: light is falling off like in the standard material
  17411. * to enhance interoperability with other materials.
  17412. */
  17413. static readonly FALLOFF_STANDARD: number;
  17414. /**
  17415. * If every light affecting the material is in this lightmapMode,
  17416. * material.lightmapTexture adds or multiplies
  17417. * (depends on material.useLightmapAsShadowmap)
  17418. * after every other light calculations.
  17419. */
  17420. static readonly LIGHTMAP_DEFAULT: number;
  17421. /**
  17422. * material.lightmapTexture as only diffuse lighting from this light
  17423. * adds only specular lighting from this light
  17424. * adds dynamic shadows
  17425. */
  17426. static readonly LIGHTMAP_SPECULAR: number;
  17427. /**
  17428. * material.lightmapTexture as only lighting
  17429. * no light calculation from this light
  17430. * only adds dynamic shadows from this light
  17431. */
  17432. static readonly LIGHTMAP_SHADOWSONLY: number;
  17433. /**
  17434. * Each light type uses the default quantity according to its type:
  17435. * point/spot lights use luminous intensity
  17436. * directional lights use illuminance
  17437. */
  17438. static readonly INTENSITYMODE_AUTOMATIC: number;
  17439. /**
  17440. * lumen (lm)
  17441. */
  17442. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  17443. /**
  17444. * candela (lm/sr)
  17445. */
  17446. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  17447. /**
  17448. * lux (lm/m^2)
  17449. */
  17450. static readonly INTENSITYMODE_ILLUMINANCE: number;
  17451. /**
  17452. * nit (cd/m^2)
  17453. */
  17454. static readonly INTENSITYMODE_LUMINANCE: number;
  17455. /**
  17456. * Light type const id of the point light.
  17457. */
  17458. static readonly LIGHTTYPEID_POINTLIGHT: number;
  17459. /**
  17460. * Light type const id of the directional light.
  17461. */
  17462. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  17463. /**
  17464. * Light type const id of the spot light.
  17465. */
  17466. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  17467. /**
  17468. * Light type const id of the hemispheric light.
  17469. */
  17470. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  17471. /**
  17472. * Diffuse gives the basic color to an object.
  17473. */
  17474. diffuse: Color3;
  17475. /**
  17476. * Specular produces a highlight color on an object.
  17477. * Note: This is note affecting PBR materials.
  17478. */
  17479. specular: Color3;
  17480. /**
  17481. * Defines the falloff type for this light. This lets overrriding how punctual light are
  17482. * falling off base on range or angle.
  17483. * This can be set to any values in Light.FALLOFF_x.
  17484. *
  17485. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  17486. * other types of materials.
  17487. */
  17488. falloffType: number;
  17489. /**
  17490. * Strength of the light.
  17491. * Note: By default it is define in the framework own unit.
  17492. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  17493. */
  17494. intensity: number;
  17495. private _range;
  17496. protected _inverseSquaredRange: number;
  17497. /**
  17498. * Defines how far from the source the light is impacting in scene units.
  17499. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  17500. */
  17501. get range(): number;
  17502. /**
  17503. * Defines how far from the source the light is impacting in scene units.
  17504. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  17505. */
  17506. set range(value: number);
  17507. /**
  17508. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  17509. * of light.
  17510. */
  17511. private _photometricScale;
  17512. private _intensityMode;
  17513. /**
  17514. * Gets the photometric scale used to interpret the intensity.
  17515. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  17516. */
  17517. get intensityMode(): number;
  17518. /**
  17519. * Sets the photometric scale used to interpret the intensity.
  17520. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  17521. */
  17522. set intensityMode(value: number);
  17523. private _radius;
  17524. /**
  17525. * Gets the light radius used by PBR Materials to simulate soft area lights.
  17526. */
  17527. get radius(): number;
  17528. /**
  17529. * sets the light radius used by PBR Materials to simulate soft area lights.
  17530. */
  17531. set radius(value: number);
  17532. private _renderPriority;
  17533. /**
  17534. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  17535. * exceeding the number allowed of the materials.
  17536. */
  17537. renderPriority: number;
  17538. private _shadowEnabled;
  17539. /**
  17540. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  17541. * the current shadow generator.
  17542. */
  17543. get shadowEnabled(): boolean;
  17544. /**
  17545. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  17546. * the current shadow generator.
  17547. */
  17548. set shadowEnabled(value: boolean);
  17549. private _includedOnlyMeshes;
  17550. /**
  17551. * Gets the only meshes impacted by this light.
  17552. */
  17553. get includedOnlyMeshes(): AbstractMesh[];
  17554. /**
  17555. * Sets the only meshes impacted by this light.
  17556. */
  17557. set includedOnlyMeshes(value: AbstractMesh[]);
  17558. private _excludedMeshes;
  17559. /**
  17560. * Gets the meshes not impacted by this light.
  17561. */
  17562. get excludedMeshes(): AbstractMesh[];
  17563. /**
  17564. * Sets the meshes not impacted by this light.
  17565. */
  17566. set excludedMeshes(value: AbstractMesh[]);
  17567. private _excludeWithLayerMask;
  17568. /**
  17569. * Gets the layer id use to find what meshes are not impacted by the light.
  17570. * Inactive if 0
  17571. */
  17572. get excludeWithLayerMask(): number;
  17573. /**
  17574. * Sets the layer id use to find what meshes are not impacted by the light.
  17575. * Inactive if 0
  17576. */
  17577. set excludeWithLayerMask(value: number);
  17578. private _includeOnlyWithLayerMask;
  17579. /**
  17580. * Gets the layer id use to find what meshes are impacted by the light.
  17581. * Inactive if 0
  17582. */
  17583. get includeOnlyWithLayerMask(): number;
  17584. /**
  17585. * Sets the layer id use to find what meshes are impacted by the light.
  17586. * Inactive if 0
  17587. */
  17588. set includeOnlyWithLayerMask(value: number);
  17589. private _lightmapMode;
  17590. /**
  17591. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  17592. */
  17593. get lightmapMode(): number;
  17594. /**
  17595. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  17596. */
  17597. set lightmapMode(value: number);
  17598. /**
  17599. * Shadow generator associted to the light.
  17600. * @hidden Internal use only.
  17601. */
  17602. _shadowGenerator: Nullable<IShadowGenerator>;
  17603. /**
  17604. * @hidden Internal use only.
  17605. */
  17606. _excludedMeshesIds: string[];
  17607. /**
  17608. * @hidden Internal use only.
  17609. */
  17610. _includedOnlyMeshesIds: string[];
  17611. /**
  17612. * The current light unifom buffer.
  17613. * @hidden Internal use only.
  17614. */
  17615. _uniformBuffer: UniformBuffer;
  17616. /** @hidden */
  17617. _renderId: number;
  17618. /**
  17619. * Creates a Light object in the scene.
  17620. * Documentation : https://doc.babylonjs.com/babylon101/lights
  17621. * @param name The firendly name of the light
  17622. * @param scene The scene the light belongs too
  17623. */
  17624. constructor(name: string, scene: Scene);
  17625. protected abstract _buildUniformLayout(): void;
  17626. /**
  17627. * Sets the passed Effect "effect" with the Light information.
  17628. * @param effect The effect to update
  17629. * @param lightIndex The index of the light in the effect to update
  17630. * @returns The light
  17631. */
  17632. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  17633. /**
  17634. * Sets the passed Effect "effect" with the Light textures.
  17635. * @param effect The effect to update
  17636. * @param lightIndex The index of the light in the effect to update
  17637. * @returns The light
  17638. */
  17639. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  17640. /**
  17641. * Binds the lights information from the scene to the effect for the given mesh.
  17642. * @param lightIndex Light index
  17643. * @param scene The scene where the light belongs to
  17644. * @param effect The effect we are binding the data to
  17645. * @param useSpecular Defines if specular is supported
  17646. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  17647. */
  17648. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  17649. /**
  17650. * Sets the passed Effect "effect" with the Light information.
  17651. * @param effect The effect to update
  17652. * @param lightDataUniformName The uniform used to store light data (position or direction)
  17653. * @returns The light
  17654. */
  17655. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  17656. /**
  17657. * Returns the string "Light".
  17658. * @returns the class name
  17659. */
  17660. getClassName(): string;
  17661. /** @hidden */
  17662. readonly _isLight: boolean;
  17663. /**
  17664. * Converts the light information to a readable string for debug purpose.
  17665. * @param fullDetails Supports for multiple levels of logging within scene loading
  17666. * @returns the human readable light info
  17667. */
  17668. toString(fullDetails?: boolean): string;
  17669. /** @hidden */
  17670. protected _syncParentEnabledState(): void;
  17671. /**
  17672. * Set the enabled state of this node.
  17673. * @param value - the new enabled state
  17674. */
  17675. setEnabled(value: boolean): void;
  17676. /**
  17677. * Returns the Light associated shadow generator if any.
  17678. * @return the associated shadow generator.
  17679. */
  17680. getShadowGenerator(): Nullable<IShadowGenerator>;
  17681. /**
  17682. * Returns a Vector3, the absolute light position in the World.
  17683. * @returns the world space position of the light
  17684. */
  17685. getAbsolutePosition(): Vector3;
  17686. /**
  17687. * Specifies if the light will affect the passed mesh.
  17688. * @param mesh The mesh to test against the light
  17689. * @return true the mesh is affected otherwise, false.
  17690. */
  17691. canAffectMesh(mesh: AbstractMesh): boolean;
  17692. /**
  17693. * Sort function to order lights for rendering.
  17694. * @param a First Light object to compare to second.
  17695. * @param b Second Light object to compare first.
  17696. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  17697. */
  17698. static CompareLightsPriority(a: Light, b: Light): number;
  17699. /**
  17700. * Releases resources associated with this node.
  17701. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  17702. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  17703. */
  17704. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  17705. /**
  17706. * Returns the light type ID (integer).
  17707. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  17708. */
  17709. getTypeID(): number;
  17710. /**
  17711. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  17712. * @returns the scaled intensity in intensity mode unit
  17713. */
  17714. getScaledIntensity(): number;
  17715. /**
  17716. * Returns a new Light object, named "name", from the current one.
  17717. * @param name The name of the cloned light
  17718. * @param newParent The parent of this light, if it has one
  17719. * @returns the new created light
  17720. */
  17721. clone(name: string, newParent?: Nullable<Node>): Nullable<Light>;
  17722. /**
  17723. * Serializes the current light into a Serialization object.
  17724. * @returns the serialized object.
  17725. */
  17726. serialize(): any;
  17727. /**
  17728. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  17729. * This new light is named "name" and added to the passed scene.
  17730. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  17731. * @param name The friendly name of the light
  17732. * @param scene The scene the new light will belong to
  17733. * @returns the constructor function
  17734. */
  17735. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  17736. /**
  17737. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  17738. * @param parsedLight The JSON representation of the light
  17739. * @param scene The scene to create the parsed light in
  17740. * @returns the created light after parsing
  17741. */
  17742. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  17743. private _hookArrayForExcluded;
  17744. private _hookArrayForIncludedOnly;
  17745. private _resyncMeshes;
  17746. /**
  17747. * Forces the meshes to update their light related information in their rendering used effects
  17748. * @hidden Internal Use Only
  17749. */
  17750. _markMeshesAsLightDirty(): void;
  17751. /**
  17752. * Recomputes the cached photometric scale if needed.
  17753. */
  17754. private _computePhotometricScale;
  17755. /**
  17756. * Returns the Photometric Scale according to the light type and intensity mode.
  17757. */
  17758. private _getPhotometricScale;
  17759. /**
  17760. * Reorder the light in the scene according to their defined priority.
  17761. * @hidden Internal Use Only
  17762. */
  17763. _reorderLightsInScene(): void;
  17764. /**
  17765. * Prepares the list of defines specific to the light type.
  17766. * @param defines the list of defines
  17767. * @param lightIndex defines the index of the light for the effect
  17768. */
  17769. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  17770. }
  17771. }
  17772. declare module "babylonjs/Actions/action" {
  17773. import { Observable } from "babylonjs/Misc/observable";
  17774. import { Condition } from "babylonjs/Actions/condition";
  17775. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  17776. import { ActionManager } from "babylonjs/Actions/actionManager";
  17777. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  17778. /**
  17779. * Interface used to define Action
  17780. */
  17781. export interface IAction {
  17782. /**
  17783. * Trigger for the action
  17784. */
  17785. trigger: number;
  17786. /** Options of the trigger */
  17787. triggerOptions: any;
  17788. /**
  17789. * Gets the trigger parameters
  17790. * @returns the trigger parameters
  17791. */
  17792. getTriggerParameter(): any;
  17793. /**
  17794. * Internal only - executes current action event
  17795. * @hidden
  17796. */
  17797. _executeCurrent(evt?: ActionEvent): void;
  17798. /**
  17799. * Serialize placeholder for child classes
  17800. * @param parent of child
  17801. * @returns the serialized object
  17802. */
  17803. serialize(parent: any): any;
  17804. /**
  17805. * Internal only
  17806. * @hidden
  17807. */
  17808. _prepare(): void;
  17809. /**
  17810. * Internal only - manager for action
  17811. * @hidden
  17812. */
  17813. _actionManager: AbstractActionManager;
  17814. /**
  17815. * Adds action to chain of actions, may be a DoNothingAction
  17816. * @param action defines the next action to execute
  17817. * @returns The action passed in
  17818. * @see https://www.babylonjs-playground.com/#1T30HR#0
  17819. */
  17820. then(action: IAction): IAction;
  17821. }
  17822. /**
  17823. * The action to be carried out following a trigger
  17824. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  17825. */
  17826. export class Action implements IAction {
  17827. /** the trigger, with or without parameters, for the action */
  17828. triggerOptions: any;
  17829. /**
  17830. * Trigger for the action
  17831. */
  17832. trigger: number;
  17833. /**
  17834. * Internal only - manager for action
  17835. * @hidden
  17836. */
  17837. _actionManager: ActionManager;
  17838. private _nextActiveAction;
  17839. private _child;
  17840. private _condition?;
  17841. private _triggerParameter;
  17842. /**
  17843. * An event triggered prior to action being executed.
  17844. */
  17845. onBeforeExecuteObservable: Observable<Action>;
  17846. /**
  17847. * Creates a new Action
  17848. * @param triggerOptions the trigger, with or without parameters, for the action
  17849. * @param condition an optional determinant of action
  17850. */
  17851. constructor(
  17852. /** the trigger, with or without parameters, for the action */
  17853. triggerOptions: any, condition?: Condition);
  17854. /**
  17855. * Internal only
  17856. * @hidden
  17857. */
  17858. _prepare(): void;
  17859. /**
  17860. * Gets the trigger parameters
  17861. * @returns the trigger parameters
  17862. */
  17863. getTriggerParameter(): any;
  17864. /**
  17865. * Internal only - executes current action event
  17866. * @hidden
  17867. */
  17868. _executeCurrent(evt?: ActionEvent): void;
  17869. /**
  17870. * Execute placeholder for child classes
  17871. * @param evt optional action event
  17872. */
  17873. execute(evt?: ActionEvent): void;
  17874. /**
  17875. * Skips to next active action
  17876. */
  17877. skipToNextActiveAction(): void;
  17878. /**
  17879. * Adds action to chain of actions, may be a DoNothingAction
  17880. * @param action defines the next action to execute
  17881. * @returns The action passed in
  17882. * @see https://www.babylonjs-playground.com/#1T30HR#0
  17883. */
  17884. then(action: Action): Action;
  17885. /**
  17886. * Internal only
  17887. * @hidden
  17888. */
  17889. _getProperty(propertyPath: string): string;
  17890. /**
  17891. * Internal only
  17892. * @hidden
  17893. */
  17894. _getEffectiveTarget(target: any, propertyPath: string): any;
  17895. /**
  17896. * Serialize placeholder for child classes
  17897. * @param parent of child
  17898. * @returns the serialized object
  17899. */
  17900. serialize(parent: any): any;
  17901. /**
  17902. * Internal only called by serialize
  17903. * @hidden
  17904. */
  17905. protected _serialize(serializedAction: any, parent?: any): any;
  17906. /**
  17907. * Internal only
  17908. * @hidden
  17909. */
  17910. static _SerializeValueAsString: (value: any) => string;
  17911. /**
  17912. * Internal only
  17913. * @hidden
  17914. */
  17915. static _GetTargetProperty: (target: import("babylonjs/node").Node | import("babylonjs/scene").Scene) => {
  17916. name: string;
  17917. targetType: string;
  17918. value: string;
  17919. };
  17920. }
  17921. }
  17922. declare module "babylonjs/Actions/condition" {
  17923. import { ActionManager } from "babylonjs/Actions/actionManager";
  17924. /**
  17925. * A Condition applied to an Action
  17926. */
  17927. export class Condition {
  17928. /**
  17929. * Internal only - manager for action
  17930. * @hidden
  17931. */
  17932. _actionManager: ActionManager;
  17933. /**
  17934. * Internal only
  17935. * @hidden
  17936. */
  17937. _evaluationId: number;
  17938. /**
  17939. * Internal only
  17940. * @hidden
  17941. */
  17942. _currentResult: boolean;
  17943. /**
  17944. * Creates a new Condition
  17945. * @param actionManager the manager of the action the condition is applied to
  17946. */
  17947. constructor(actionManager: ActionManager);
  17948. /**
  17949. * Check if the current condition is valid
  17950. * @returns a boolean
  17951. */
  17952. isValid(): boolean;
  17953. /**
  17954. * Internal only
  17955. * @hidden
  17956. */
  17957. _getProperty(propertyPath: string): string;
  17958. /**
  17959. * Internal only
  17960. * @hidden
  17961. */
  17962. _getEffectiveTarget(target: any, propertyPath: string): any;
  17963. /**
  17964. * Serialize placeholder for child classes
  17965. * @returns the serialized object
  17966. */
  17967. serialize(): any;
  17968. /**
  17969. * Internal only
  17970. * @hidden
  17971. */
  17972. protected _serialize(serializedCondition: any): any;
  17973. }
  17974. /**
  17975. * Defines specific conditional operators as extensions of Condition
  17976. */
  17977. export class ValueCondition extends Condition {
  17978. /** path to specify the property of the target the conditional operator uses */
  17979. propertyPath: string;
  17980. /** the value compared by the conditional operator against the current value of the property */
  17981. value: any;
  17982. /** the conditional operator, default ValueCondition.IsEqual */
  17983. operator: number;
  17984. /**
  17985. * Internal only
  17986. * @hidden
  17987. */
  17988. private static _IsEqual;
  17989. /**
  17990. * Internal only
  17991. * @hidden
  17992. */
  17993. private static _IsDifferent;
  17994. /**
  17995. * Internal only
  17996. * @hidden
  17997. */
  17998. private static _IsGreater;
  17999. /**
  18000. * Internal only
  18001. * @hidden
  18002. */
  18003. private static _IsLesser;
  18004. /**
  18005. * returns the number for IsEqual
  18006. */
  18007. static get IsEqual(): number;
  18008. /**
  18009. * Returns the number for IsDifferent
  18010. */
  18011. static get IsDifferent(): number;
  18012. /**
  18013. * Returns the number for IsGreater
  18014. */
  18015. static get IsGreater(): number;
  18016. /**
  18017. * Returns the number for IsLesser
  18018. */
  18019. static get IsLesser(): number;
  18020. /**
  18021. * Internal only The action manager for the condition
  18022. * @hidden
  18023. */
  18024. _actionManager: ActionManager;
  18025. /**
  18026. * Internal only
  18027. * @hidden
  18028. */
  18029. private _target;
  18030. /**
  18031. * Internal only
  18032. * @hidden
  18033. */
  18034. private _effectiveTarget;
  18035. /**
  18036. * Internal only
  18037. * @hidden
  18038. */
  18039. private _property;
  18040. /**
  18041. * Creates a new ValueCondition
  18042. * @param actionManager manager for the action the condition applies to
  18043. * @param target for the action
  18044. * @param propertyPath path to specify the property of the target the conditional operator uses
  18045. * @param value the value compared by the conditional operator against the current value of the property
  18046. * @param operator the conditional operator, default ValueCondition.IsEqual
  18047. */
  18048. constructor(actionManager: ActionManager, target: any,
  18049. /** path to specify the property of the target the conditional operator uses */
  18050. propertyPath: string,
  18051. /** the value compared by the conditional operator against the current value of the property */
  18052. value: any,
  18053. /** the conditional operator, default ValueCondition.IsEqual */
  18054. operator?: number);
  18055. /**
  18056. * Compares the given value with the property value for the specified conditional operator
  18057. * @returns the result of the comparison
  18058. */
  18059. isValid(): boolean;
  18060. /**
  18061. * Serialize the ValueCondition into a JSON compatible object
  18062. * @returns serialization object
  18063. */
  18064. serialize(): any;
  18065. /**
  18066. * Gets the name of the conditional operator for the ValueCondition
  18067. * @param operator the conditional operator
  18068. * @returns the name
  18069. */
  18070. static GetOperatorName(operator: number): string;
  18071. }
  18072. /**
  18073. * Defines a predicate condition as an extension of Condition
  18074. */
  18075. export class PredicateCondition extends Condition {
  18076. /** defines the predicate function used to validate the condition */
  18077. predicate: () => boolean;
  18078. /**
  18079. * Internal only - manager for action
  18080. * @hidden
  18081. */
  18082. _actionManager: ActionManager;
  18083. /**
  18084. * Creates a new PredicateCondition
  18085. * @param actionManager manager for the action the condition applies to
  18086. * @param predicate defines the predicate function used to validate the condition
  18087. */
  18088. constructor(actionManager: ActionManager,
  18089. /** defines the predicate function used to validate the condition */
  18090. predicate: () => boolean);
  18091. /**
  18092. * @returns the validity of the predicate condition
  18093. */
  18094. isValid(): boolean;
  18095. }
  18096. /**
  18097. * Defines a state condition as an extension of Condition
  18098. */
  18099. export class StateCondition extends Condition {
  18100. /** Value to compare with target state */
  18101. value: string;
  18102. /**
  18103. * Internal only - manager for action
  18104. * @hidden
  18105. */
  18106. _actionManager: ActionManager;
  18107. /**
  18108. * Internal only
  18109. * @hidden
  18110. */
  18111. private _target;
  18112. /**
  18113. * Creates a new StateCondition
  18114. * @param actionManager manager for the action the condition applies to
  18115. * @param target of the condition
  18116. * @param value to compare with target state
  18117. */
  18118. constructor(actionManager: ActionManager, target: any,
  18119. /** Value to compare with target state */
  18120. value: string);
  18121. /**
  18122. * Gets a boolean indicating if the current condition is met
  18123. * @returns the validity of the state
  18124. */
  18125. isValid(): boolean;
  18126. /**
  18127. * Serialize the StateCondition into a JSON compatible object
  18128. * @returns serialization object
  18129. */
  18130. serialize(): any;
  18131. }
  18132. }
  18133. declare module "babylonjs/Actions/directActions" {
  18134. import { Action } from "babylonjs/Actions/action";
  18135. import { Condition } from "babylonjs/Actions/condition";
  18136. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  18137. /**
  18138. * This defines an action responsible to toggle a boolean once triggered.
  18139. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  18140. */
  18141. export class SwitchBooleanAction extends Action {
  18142. /**
  18143. * The path to the boolean property in the target object
  18144. */
  18145. propertyPath: string;
  18146. private _target;
  18147. private _effectiveTarget;
  18148. private _property;
  18149. /**
  18150. * Instantiate the action
  18151. * @param triggerOptions defines the trigger options
  18152. * @param target defines the object containing the boolean
  18153. * @param propertyPath defines the path to the boolean property in the target object
  18154. * @param condition defines the trigger related conditions
  18155. */
  18156. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  18157. /** @hidden */
  18158. _prepare(): void;
  18159. /**
  18160. * Execute the action toggle the boolean value.
  18161. */
  18162. execute(): void;
  18163. /**
  18164. * Serializes the actions and its related information.
  18165. * @param parent defines the object to serialize in
  18166. * @returns the serialized object
  18167. */
  18168. serialize(parent: any): any;
  18169. }
  18170. /**
  18171. * This defines an action responsible to set a the state field of the target
  18172. * to a desired value once triggered.
  18173. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  18174. */
  18175. export class SetStateAction extends Action {
  18176. /**
  18177. * The value to store in the state field.
  18178. */
  18179. value: string;
  18180. private _target;
  18181. /**
  18182. * Instantiate the action
  18183. * @param triggerOptions defines the trigger options
  18184. * @param target defines the object containing the state property
  18185. * @param value defines the value to store in the state field
  18186. * @param condition defines the trigger related conditions
  18187. */
  18188. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  18189. /**
  18190. * Execute the action and store the value on the target state property.
  18191. */
  18192. execute(): void;
  18193. /**
  18194. * Serializes the actions and its related information.
  18195. * @param parent defines the object to serialize in
  18196. * @returns the serialized object
  18197. */
  18198. serialize(parent: any): any;
  18199. }
  18200. /**
  18201. * This defines an action responsible to set a property of the target
  18202. * to a desired value once triggered.
  18203. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  18204. */
  18205. export class SetValueAction extends Action {
  18206. /**
  18207. * The path of the property to set in the target.
  18208. */
  18209. propertyPath: string;
  18210. /**
  18211. * The value to set in the property
  18212. */
  18213. value: any;
  18214. private _target;
  18215. private _effectiveTarget;
  18216. private _property;
  18217. /**
  18218. * Instantiate the action
  18219. * @param triggerOptions defines the trigger options
  18220. * @param target defines the object containing the property
  18221. * @param propertyPath defines the path of the property to set in the target
  18222. * @param value defines the value to set in the property
  18223. * @param condition defines the trigger related conditions
  18224. */
  18225. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  18226. /** @hidden */
  18227. _prepare(): void;
  18228. /**
  18229. * Execute the action and set the targetted property to the desired value.
  18230. */
  18231. execute(): void;
  18232. /**
  18233. * Serializes the actions and its related information.
  18234. * @param parent defines the object to serialize in
  18235. * @returns the serialized object
  18236. */
  18237. serialize(parent: any): any;
  18238. }
  18239. /**
  18240. * This defines an action responsible to increment the target value
  18241. * to a desired value once triggered.
  18242. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  18243. */
  18244. export class IncrementValueAction extends Action {
  18245. /**
  18246. * The path of the property to increment in the target.
  18247. */
  18248. propertyPath: string;
  18249. /**
  18250. * The value we should increment the property by.
  18251. */
  18252. value: any;
  18253. private _target;
  18254. private _effectiveTarget;
  18255. private _property;
  18256. /**
  18257. * Instantiate the action
  18258. * @param triggerOptions defines the trigger options
  18259. * @param target defines the object containing the property
  18260. * @param propertyPath defines the path of the property to increment in the target
  18261. * @param value defines the value value we should increment the property by
  18262. * @param condition defines the trigger related conditions
  18263. */
  18264. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  18265. /** @hidden */
  18266. _prepare(): void;
  18267. /**
  18268. * Execute the action and increment the target of the value amount.
  18269. */
  18270. execute(): void;
  18271. /**
  18272. * Serializes the actions and its related information.
  18273. * @param parent defines the object to serialize in
  18274. * @returns the serialized object
  18275. */
  18276. serialize(parent: any): any;
  18277. }
  18278. /**
  18279. * This defines an action responsible to start an animation once triggered.
  18280. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  18281. */
  18282. export class PlayAnimationAction extends Action {
  18283. /**
  18284. * Where the animation should start (animation frame)
  18285. */
  18286. from: number;
  18287. /**
  18288. * Where the animation should stop (animation frame)
  18289. */
  18290. to: number;
  18291. /**
  18292. * Define if the animation should loop or stop after the first play.
  18293. */
  18294. loop?: boolean;
  18295. private _target;
  18296. /**
  18297. * Instantiate the action
  18298. * @param triggerOptions defines the trigger options
  18299. * @param target defines the target animation or animation name
  18300. * @param from defines from where the animation should start (animation frame)
  18301. * @param end defines where the animation should stop (animation frame)
  18302. * @param loop defines if the animation should loop or stop after the first play
  18303. * @param condition defines the trigger related conditions
  18304. */
  18305. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  18306. /** @hidden */
  18307. _prepare(): void;
  18308. /**
  18309. * Execute the action and play the animation.
  18310. */
  18311. execute(): void;
  18312. /**
  18313. * Serializes the actions and its related information.
  18314. * @param parent defines the object to serialize in
  18315. * @returns the serialized object
  18316. */
  18317. serialize(parent: any): any;
  18318. }
  18319. /**
  18320. * This defines an action responsible to stop an animation once triggered.
  18321. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  18322. */
  18323. export class StopAnimationAction extends Action {
  18324. private _target;
  18325. /**
  18326. * Instantiate the action
  18327. * @param triggerOptions defines the trigger options
  18328. * @param target defines the target animation or animation name
  18329. * @param condition defines the trigger related conditions
  18330. */
  18331. constructor(triggerOptions: any, target: any, condition?: Condition);
  18332. /** @hidden */
  18333. _prepare(): void;
  18334. /**
  18335. * Execute the action and stop the animation.
  18336. */
  18337. execute(): void;
  18338. /**
  18339. * Serializes the actions and its related information.
  18340. * @param parent defines the object to serialize in
  18341. * @returns the serialized object
  18342. */
  18343. serialize(parent: any): any;
  18344. }
  18345. /**
  18346. * This defines an action responsible that does nothing once triggered.
  18347. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  18348. */
  18349. export class DoNothingAction extends Action {
  18350. /**
  18351. * Instantiate the action
  18352. * @param triggerOptions defines the trigger options
  18353. * @param condition defines the trigger related conditions
  18354. */
  18355. constructor(triggerOptions?: any, condition?: Condition);
  18356. /**
  18357. * Execute the action and do nothing.
  18358. */
  18359. execute(): void;
  18360. /**
  18361. * Serializes the actions and its related information.
  18362. * @param parent defines the object to serialize in
  18363. * @returns the serialized object
  18364. */
  18365. serialize(parent: any): any;
  18366. }
  18367. /**
  18368. * This defines an action responsible to trigger several actions once triggered.
  18369. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  18370. */
  18371. export class CombineAction extends Action {
  18372. /**
  18373. * The list of aggregated animations to run.
  18374. */
  18375. children: Action[];
  18376. /**
  18377. * Instantiate the action
  18378. * @param triggerOptions defines the trigger options
  18379. * @param children defines the list of aggregated animations to run
  18380. * @param condition defines the trigger related conditions
  18381. */
  18382. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  18383. /** @hidden */
  18384. _prepare(): void;
  18385. /**
  18386. * Execute the action and executes all the aggregated actions.
  18387. */
  18388. execute(evt: ActionEvent): void;
  18389. /**
  18390. * Serializes the actions and its related information.
  18391. * @param parent defines the object to serialize in
  18392. * @returns the serialized object
  18393. */
  18394. serialize(parent: any): any;
  18395. }
  18396. /**
  18397. * This defines an action responsible to run code (external event) once triggered.
  18398. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  18399. */
  18400. export class ExecuteCodeAction extends Action {
  18401. /**
  18402. * The callback function to run.
  18403. */
  18404. func: (evt: ActionEvent) => void;
  18405. /**
  18406. * Instantiate the action
  18407. * @param triggerOptions defines the trigger options
  18408. * @param func defines the callback function to run
  18409. * @param condition defines the trigger related conditions
  18410. */
  18411. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  18412. /**
  18413. * Execute the action and run the attached code.
  18414. */
  18415. execute(evt: ActionEvent): void;
  18416. }
  18417. /**
  18418. * This defines an action responsible to set the parent property of the target once triggered.
  18419. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  18420. */
  18421. export class SetParentAction extends Action {
  18422. private _parent;
  18423. private _target;
  18424. /**
  18425. * Instantiate the action
  18426. * @param triggerOptions defines the trigger options
  18427. * @param target defines the target containing the parent property
  18428. * @param parent defines from where the animation should start (animation frame)
  18429. * @param condition defines the trigger related conditions
  18430. */
  18431. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  18432. /** @hidden */
  18433. _prepare(): void;
  18434. /**
  18435. * Execute the action and set the parent property.
  18436. */
  18437. execute(): void;
  18438. /**
  18439. * Serializes the actions and its related information.
  18440. * @param parent defines the object to serialize in
  18441. * @returns the serialized object
  18442. */
  18443. serialize(parent: any): any;
  18444. }
  18445. }
  18446. declare module "babylonjs/Actions/actionManager" {
  18447. import { Nullable } from "babylonjs/types";
  18448. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18449. import { Scene } from "babylonjs/scene";
  18450. import { IAction } from "babylonjs/Actions/action";
  18451. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  18452. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  18453. /**
  18454. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  18455. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  18456. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  18457. */
  18458. export class ActionManager extends AbstractActionManager {
  18459. /**
  18460. * Nothing
  18461. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18462. */
  18463. static readonly NothingTrigger: number;
  18464. /**
  18465. * On pick
  18466. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18467. */
  18468. static readonly OnPickTrigger: number;
  18469. /**
  18470. * On left pick
  18471. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18472. */
  18473. static readonly OnLeftPickTrigger: number;
  18474. /**
  18475. * On right pick
  18476. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18477. */
  18478. static readonly OnRightPickTrigger: number;
  18479. /**
  18480. * On center pick
  18481. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18482. */
  18483. static readonly OnCenterPickTrigger: number;
  18484. /**
  18485. * On pick down
  18486. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18487. */
  18488. static readonly OnPickDownTrigger: number;
  18489. /**
  18490. * On double pick
  18491. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18492. */
  18493. static readonly OnDoublePickTrigger: number;
  18494. /**
  18495. * On pick up
  18496. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18497. */
  18498. static readonly OnPickUpTrigger: number;
  18499. /**
  18500. * On pick out.
  18501. * This trigger will only be raised if you also declared a OnPickDown
  18502. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18503. */
  18504. static readonly OnPickOutTrigger: number;
  18505. /**
  18506. * On long press
  18507. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18508. */
  18509. static readonly OnLongPressTrigger: number;
  18510. /**
  18511. * On pointer over
  18512. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18513. */
  18514. static readonly OnPointerOverTrigger: number;
  18515. /**
  18516. * On pointer out
  18517. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18518. */
  18519. static readonly OnPointerOutTrigger: number;
  18520. /**
  18521. * On every frame
  18522. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18523. */
  18524. static readonly OnEveryFrameTrigger: number;
  18525. /**
  18526. * On intersection enter
  18527. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18528. */
  18529. static readonly OnIntersectionEnterTrigger: number;
  18530. /**
  18531. * On intersection exit
  18532. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18533. */
  18534. static readonly OnIntersectionExitTrigger: number;
  18535. /**
  18536. * On key down
  18537. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18538. */
  18539. static readonly OnKeyDownTrigger: number;
  18540. /**
  18541. * On key up
  18542. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18543. */
  18544. static readonly OnKeyUpTrigger: number;
  18545. private _scene;
  18546. /**
  18547. * Creates a new action manager
  18548. * @param scene defines the hosting scene
  18549. */
  18550. constructor(scene: Scene);
  18551. /**
  18552. * Releases all associated resources
  18553. */
  18554. dispose(): void;
  18555. /**
  18556. * Gets hosting scene
  18557. * @returns the hosting scene
  18558. */
  18559. getScene(): Scene;
  18560. /**
  18561. * Does this action manager handles actions of any of the given triggers
  18562. * @param triggers defines the triggers to be tested
  18563. * @return a boolean indicating whether one (or more) of the triggers is handled
  18564. */
  18565. hasSpecificTriggers(triggers: number[]): boolean;
  18566. /**
  18567. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  18568. * speed.
  18569. * @param triggerA defines the trigger to be tested
  18570. * @param triggerB defines the trigger to be tested
  18571. * @return a boolean indicating whether one (or more) of the triggers is handled
  18572. */
  18573. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  18574. /**
  18575. * Does this action manager handles actions of a given trigger
  18576. * @param trigger defines the trigger to be tested
  18577. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  18578. * @return whether the trigger is handled
  18579. */
  18580. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  18581. /**
  18582. * Does this action manager has pointer triggers
  18583. */
  18584. get hasPointerTriggers(): boolean;
  18585. /**
  18586. * Does this action manager has pick triggers
  18587. */
  18588. get hasPickTriggers(): boolean;
  18589. /**
  18590. * Registers an action to this action manager
  18591. * @param action defines the action to be registered
  18592. * @return the action amended (prepared) after registration
  18593. */
  18594. registerAction(action: IAction): Nullable<IAction>;
  18595. /**
  18596. * Unregisters an action to this action manager
  18597. * @param action defines the action to be unregistered
  18598. * @return a boolean indicating whether the action has been unregistered
  18599. */
  18600. unregisterAction(action: IAction): Boolean;
  18601. /**
  18602. * Process a specific trigger
  18603. * @param trigger defines the trigger to process
  18604. * @param evt defines the event details to be processed
  18605. */
  18606. processTrigger(trigger: number, evt?: IActionEvent): void;
  18607. /** @hidden */
  18608. _getEffectiveTarget(target: any, propertyPath: string): any;
  18609. /** @hidden */
  18610. _getProperty(propertyPath: string): string;
  18611. /**
  18612. * Serialize this manager to a JSON object
  18613. * @param name defines the property name to store this manager
  18614. * @returns a JSON representation of this manager
  18615. */
  18616. serialize(name: string): any;
  18617. /**
  18618. * Creates a new ActionManager from a JSON data
  18619. * @param parsedActions defines the JSON data to read from
  18620. * @param object defines the hosting mesh
  18621. * @param scene defines the hosting scene
  18622. */
  18623. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  18624. /**
  18625. * Get a trigger name by index
  18626. * @param trigger defines the trigger index
  18627. * @returns a trigger name
  18628. */
  18629. static GetTriggerName(trigger: number): string;
  18630. }
  18631. }
  18632. declare module "babylonjs/Sprites/sprite" {
  18633. import { Vector3 } from "babylonjs/Maths/math.vector";
  18634. import { Nullable } from "babylonjs/types";
  18635. import { ActionManager } from "babylonjs/Actions/actionManager";
  18636. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  18637. import { Color4 } from "babylonjs/Maths/math.color";
  18638. import { Observable } from "babylonjs/Misc/observable";
  18639. /**
  18640. * Class used to represent a sprite
  18641. * @see http://doc.babylonjs.com/babylon101/sprites
  18642. */
  18643. export class Sprite {
  18644. /** defines the name */
  18645. name: string;
  18646. /** Gets or sets the current world position */
  18647. position: Vector3;
  18648. /** Gets or sets the main color */
  18649. color: Color4;
  18650. /** Gets or sets the width */
  18651. width: number;
  18652. /** Gets or sets the height */
  18653. height: number;
  18654. /** Gets or sets rotation angle */
  18655. angle: number;
  18656. /** Gets or sets the cell index in the sprite sheet */
  18657. cellIndex: number;
  18658. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  18659. cellRef: string;
  18660. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  18661. invertU: number;
  18662. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  18663. invertV: number;
  18664. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  18665. disposeWhenFinishedAnimating: boolean;
  18666. /** Gets the list of attached animations */
  18667. animations: Animation[];
  18668. /** Gets or sets a boolean indicating if the sprite can be picked */
  18669. isPickable: boolean;
  18670. /** Gets or sets a boolean indicating that sprite texture alpha will be used for precise picking (false by default) */
  18671. useAlphaForPicking: boolean;
  18672. /** @hidden */
  18673. _xOffset: number;
  18674. /** @hidden */
  18675. _yOffset: number;
  18676. /** @hidden */
  18677. _xSize: number;
  18678. /** @hidden */
  18679. _ySize: number;
  18680. /**
  18681. * Gets or sets the associated action manager
  18682. */
  18683. actionManager: Nullable<ActionManager>;
  18684. /**
  18685. * An event triggered when the control has been disposed
  18686. */
  18687. onDisposeObservable: Observable<Sprite>;
  18688. private _animationStarted;
  18689. private _loopAnimation;
  18690. private _fromIndex;
  18691. private _toIndex;
  18692. private _delay;
  18693. private _direction;
  18694. private _manager;
  18695. private _time;
  18696. private _onAnimationEnd;
  18697. /**
  18698. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  18699. */
  18700. isVisible: boolean;
  18701. /**
  18702. * Gets or sets the sprite size
  18703. */
  18704. get size(): number;
  18705. set size(value: number);
  18706. /**
  18707. * Creates a new Sprite
  18708. * @param name defines the name
  18709. * @param manager defines the manager
  18710. */
  18711. constructor(
  18712. /** defines the name */
  18713. name: string, manager: ISpriteManager);
  18714. /**
  18715. * Starts an animation
  18716. * @param from defines the initial key
  18717. * @param to defines the end key
  18718. * @param loop defines if the animation must loop
  18719. * @param delay defines the start delay (in ms)
  18720. * @param onAnimationEnd defines a callback to call when animation ends
  18721. */
  18722. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  18723. /** Stops current animation (if any) */
  18724. stopAnimation(): void;
  18725. /** @hidden */
  18726. _animate(deltaTime: number): void;
  18727. /** Release associated resources */
  18728. dispose(): void;
  18729. }
  18730. }
  18731. declare module "babylonjs/Collisions/pickingInfo" {
  18732. import { Nullable } from "babylonjs/types";
  18733. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  18734. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18735. import { Sprite } from "babylonjs/Sprites/sprite";
  18736. import { Ray } from "babylonjs/Culling/ray";
  18737. /**
  18738. * Information about the result of picking within a scene
  18739. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  18740. */
  18741. export class PickingInfo {
  18742. /** @hidden */
  18743. _pickingUnavailable: boolean;
  18744. /**
  18745. * If the pick collided with an object
  18746. */
  18747. hit: boolean;
  18748. /**
  18749. * Distance away where the pick collided
  18750. */
  18751. distance: number;
  18752. /**
  18753. * The location of pick collision
  18754. */
  18755. pickedPoint: Nullable<Vector3>;
  18756. /**
  18757. * The mesh corresponding the the pick collision
  18758. */
  18759. pickedMesh: Nullable<AbstractMesh>;
  18760. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  18761. bu: number;
  18762. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  18763. bv: number;
  18764. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  18765. faceId: number;
  18766. /** Id of the the submesh that was picked */
  18767. subMeshId: number;
  18768. /** If a sprite was picked, this will be the sprite the pick collided with */
  18769. pickedSprite: Nullable<Sprite>;
  18770. /**
  18771. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  18772. */
  18773. originMesh: Nullable<AbstractMesh>;
  18774. /**
  18775. * The ray that was used to perform the picking.
  18776. */
  18777. ray: Nullable<Ray>;
  18778. /**
  18779. * Gets the normal correspodning to the face the pick collided with
  18780. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  18781. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  18782. * @returns The normal correspodning to the face the pick collided with
  18783. */
  18784. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  18785. /**
  18786. * Gets the texture coordinates of where the pick occured
  18787. * @returns the vector containing the coordnates of the texture
  18788. */
  18789. getTextureCoordinates(): Nullable<Vector2>;
  18790. }
  18791. }
  18792. declare module "babylonjs/Events/pointerEvents" {
  18793. import { Nullable } from "babylonjs/types";
  18794. import { Vector2 } from "babylonjs/Maths/math.vector";
  18795. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  18796. import { Ray } from "babylonjs/Culling/ray";
  18797. /**
  18798. * Gather the list of pointer event types as constants.
  18799. */
  18800. export class PointerEventTypes {
  18801. /**
  18802. * 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.
  18803. */
  18804. static readonly POINTERDOWN: number;
  18805. /**
  18806. * The pointerup event is fired when a pointer is no longer active.
  18807. */
  18808. static readonly POINTERUP: number;
  18809. /**
  18810. * The pointermove event is fired when a pointer changes coordinates.
  18811. */
  18812. static readonly POINTERMOVE: number;
  18813. /**
  18814. * The pointerwheel event is fired when a mouse wheel has been rotated.
  18815. */
  18816. static readonly POINTERWHEEL: number;
  18817. /**
  18818. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  18819. */
  18820. static readonly POINTERPICK: number;
  18821. /**
  18822. * The pointertap event is fired when a the object has been touched and released without drag.
  18823. */
  18824. static readonly POINTERTAP: number;
  18825. /**
  18826. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  18827. */
  18828. static readonly POINTERDOUBLETAP: number;
  18829. }
  18830. /**
  18831. * Base class of pointer info types.
  18832. */
  18833. export class PointerInfoBase {
  18834. /**
  18835. * Defines the type of event (PointerEventTypes)
  18836. */
  18837. type: number;
  18838. /**
  18839. * Defines the related dom event
  18840. */
  18841. event: PointerEvent | MouseWheelEvent;
  18842. /**
  18843. * Instantiates the base class of pointers info.
  18844. * @param type Defines the type of event (PointerEventTypes)
  18845. * @param event Defines the related dom event
  18846. */
  18847. constructor(
  18848. /**
  18849. * Defines the type of event (PointerEventTypes)
  18850. */
  18851. type: number,
  18852. /**
  18853. * Defines the related dom event
  18854. */
  18855. event: PointerEvent | MouseWheelEvent);
  18856. }
  18857. /**
  18858. * This class is used to store pointer related info for the onPrePointerObservable event.
  18859. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  18860. */
  18861. export class PointerInfoPre extends PointerInfoBase {
  18862. /**
  18863. * Ray from a pointer if availible (eg. 6dof controller)
  18864. */
  18865. ray: Nullable<Ray>;
  18866. /**
  18867. * Defines the local position of the pointer on the canvas.
  18868. */
  18869. localPosition: Vector2;
  18870. /**
  18871. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  18872. */
  18873. skipOnPointerObservable: boolean;
  18874. /**
  18875. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  18876. * @param type Defines the type of event (PointerEventTypes)
  18877. * @param event Defines the related dom event
  18878. * @param localX Defines the local x coordinates of the pointer when the event occured
  18879. * @param localY Defines the local y coordinates of the pointer when the event occured
  18880. */
  18881. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  18882. }
  18883. /**
  18884. * This type contains all the data related to a pointer event in Babylon.js.
  18885. * 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.
  18886. */
  18887. export class PointerInfo extends PointerInfoBase {
  18888. /**
  18889. * Defines the picking info associated to the info (if any)\
  18890. */
  18891. pickInfo: Nullable<PickingInfo>;
  18892. /**
  18893. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  18894. * @param type Defines the type of event (PointerEventTypes)
  18895. * @param event Defines the related dom event
  18896. * @param pickInfo Defines the picking info associated to the info (if any)\
  18897. */
  18898. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  18899. /**
  18900. * Defines the picking info associated to the info (if any)\
  18901. */
  18902. pickInfo: Nullable<PickingInfo>);
  18903. }
  18904. /**
  18905. * Data relating to a touch event on the screen.
  18906. */
  18907. export interface PointerTouch {
  18908. /**
  18909. * X coordinate of touch.
  18910. */
  18911. x: number;
  18912. /**
  18913. * Y coordinate of touch.
  18914. */
  18915. y: number;
  18916. /**
  18917. * Id of touch. Unique for each finger.
  18918. */
  18919. pointerId: number;
  18920. /**
  18921. * Event type passed from DOM.
  18922. */
  18923. type: any;
  18924. }
  18925. }
  18926. declare module "babylonjs/Cameras/Inputs/freeCameraMouseInput" {
  18927. import { Observable } from "babylonjs/Misc/observable";
  18928. import { Nullable } from "babylonjs/types";
  18929. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  18930. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  18931. /**
  18932. * Manage the mouse inputs to control the movement of a free camera.
  18933. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18934. */
  18935. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  18936. /**
  18937. * Define if touch is enabled in the mouse input
  18938. */
  18939. touchEnabled: boolean;
  18940. /**
  18941. * Defines the camera the input is attached to.
  18942. */
  18943. camera: FreeCamera;
  18944. /**
  18945. * Defines the buttons associated with the input to handle camera move.
  18946. */
  18947. buttons: number[];
  18948. /**
  18949. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  18950. */
  18951. angularSensibility: number;
  18952. private _pointerInput;
  18953. private _onMouseMove;
  18954. private _observer;
  18955. private previousPosition;
  18956. /**
  18957. * Observable for when a pointer move event occurs containing the move offset
  18958. */
  18959. onPointerMovedObservable: Observable<{
  18960. offsetX: number;
  18961. offsetY: number;
  18962. }>;
  18963. /**
  18964. * @hidden
  18965. * If the camera should be rotated automatically based on pointer movement
  18966. */
  18967. _allowCameraRotation: boolean;
  18968. /**
  18969. * Manage the mouse inputs to control the movement of a free camera.
  18970. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18971. * @param touchEnabled Defines if touch is enabled or not
  18972. */
  18973. constructor(
  18974. /**
  18975. * Define if touch is enabled in the mouse input
  18976. */
  18977. touchEnabled?: boolean);
  18978. /**
  18979. * Attach the input controls to a specific dom element to get the input from.
  18980. * @param element Defines the element the controls should be listened from
  18981. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18982. */
  18983. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18984. /**
  18985. * Called on JS contextmenu event.
  18986. * Override this method to provide functionality.
  18987. */
  18988. protected onContextMenu(evt: PointerEvent): void;
  18989. /**
  18990. * Detach the current controls from the specified dom element.
  18991. * @param element Defines the element to stop listening the inputs from
  18992. */
  18993. detachControl(element: Nullable<HTMLElement>): void;
  18994. /**
  18995. * Gets the class name of the current intput.
  18996. * @returns the class name
  18997. */
  18998. getClassName(): string;
  18999. /**
  19000. * Get the friendly name associated with the input class.
  19001. * @returns the input friendly name
  19002. */
  19003. getSimpleName(): string;
  19004. }
  19005. }
  19006. declare module "babylonjs/Cameras/Inputs/freeCameraTouchInput" {
  19007. import { Nullable } from "babylonjs/types";
  19008. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  19009. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  19010. /**
  19011. * Manage the touch inputs to control the movement of a free camera.
  19012. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  19013. */
  19014. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  19015. /**
  19016. * Defines the camera the input is attached to.
  19017. */
  19018. camera: FreeCamera;
  19019. /**
  19020. * Defines the touch sensibility for rotation.
  19021. * The higher the faster.
  19022. */
  19023. touchAngularSensibility: number;
  19024. /**
  19025. * Defines the touch sensibility for move.
  19026. * The higher the faster.
  19027. */
  19028. touchMoveSensibility: number;
  19029. private _offsetX;
  19030. private _offsetY;
  19031. private _pointerPressed;
  19032. private _pointerInput;
  19033. private _observer;
  19034. private _onLostFocus;
  19035. /**
  19036. * Attach the input controls to a specific dom element to get the input from.
  19037. * @param element Defines the element the controls should be listened from
  19038. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19039. */
  19040. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19041. /**
  19042. * Detach the current controls from the specified dom element.
  19043. * @param element Defines the element to stop listening the inputs from
  19044. */
  19045. detachControl(element: Nullable<HTMLElement>): void;
  19046. /**
  19047. * Update the current camera state depending on the inputs that have been used this frame.
  19048. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  19049. */
  19050. checkInputs(): void;
  19051. /**
  19052. * Gets the class name of the current intput.
  19053. * @returns the class name
  19054. */
  19055. getClassName(): string;
  19056. /**
  19057. * Get the friendly name associated with the input class.
  19058. * @returns the input friendly name
  19059. */
  19060. getSimpleName(): string;
  19061. }
  19062. }
  19063. declare module "babylonjs/Cameras/freeCameraInputsManager" {
  19064. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  19065. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  19066. import { FreeCameraMouseInput } from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  19067. import { Nullable } from "babylonjs/types";
  19068. /**
  19069. * Default Inputs manager for the FreeCamera.
  19070. * It groups all the default supported inputs for ease of use.
  19071. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  19072. */
  19073. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  19074. /**
  19075. * @hidden
  19076. */
  19077. _mouseInput: Nullable<FreeCameraMouseInput>;
  19078. /**
  19079. * Instantiates a new FreeCameraInputsManager.
  19080. * @param camera Defines the camera the inputs belong to
  19081. */
  19082. constructor(camera: FreeCamera);
  19083. /**
  19084. * Add keyboard input support to the input manager.
  19085. * @returns the current input manager
  19086. */
  19087. addKeyboard(): FreeCameraInputsManager;
  19088. /**
  19089. * Add mouse input support to the input manager.
  19090. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  19091. * @returns the current input manager
  19092. */
  19093. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  19094. /**
  19095. * Removes the mouse input support from the manager
  19096. * @returns the current input manager
  19097. */
  19098. removeMouse(): FreeCameraInputsManager;
  19099. /**
  19100. * Add touch input support to the input manager.
  19101. * @returns the current input manager
  19102. */
  19103. addTouch(): FreeCameraInputsManager;
  19104. /**
  19105. * Remove all attached input methods from a camera
  19106. */
  19107. clear(): void;
  19108. }
  19109. }
  19110. declare module "babylonjs/Cameras/freeCamera" {
  19111. import { Vector3 } from "babylonjs/Maths/math.vector";
  19112. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19113. import { Scene } from "babylonjs/scene";
  19114. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  19115. import { FreeCameraInputsManager } from "babylonjs/Cameras/freeCameraInputsManager";
  19116. /**
  19117. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  19118. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  19119. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  19120. */
  19121. export class FreeCamera extends TargetCamera {
  19122. /**
  19123. * Define the collision ellipsoid of the camera.
  19124. * This is helpful to simulate a camera body like the player body around the camera
  19125. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  19126. */
  19127. ellipsoid: Vector3;
  19128. /**
  19129. * Define an offset for the position of the ellipsoid around the camera.
  19130. * This can be helpful to determine the center of the body near the gravity center of the body
  19131. * instead of its head.
  19132. */
  19133. ellipsoidOffset: Vector3;
  19134. /**
  19135. * Enable or disable collisions of the camera with the rest of the scene objects.
  19136. */
  19137. checkCollisions: boolean;
  19138. /**
  19139. * Enable or disable gravity on the camera.
  19140. */
  19141. applyGravity: boolean;
  19142. /**
  19143. * Define the input manager associated to the camera.
  19144. */
  19145. inputs: FreeCameraInputsManager;
  19146. /**
  19147. * Gets the input sensibility for a mouse input. (default is 2000.0)
  19148. * Higher values reduce sensitivity.
  19149. */
  19150. get angularSensibility(): number;
  19151. /**
  19152. * Sets the input sensibility for a mouse input. (default is 2000.0)
  19153. * Higher values reduce sensitivity.
  19154. */
  19155. set angularSensibility(value: number);
  19156. /**
  19157. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  19158. */
  19159. get keysUp(): number[];
  19160. set keysUp(value: number[]);
  19161. /**
  19162. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  19163. */
  19164. get keysUpward(): number[];
  19165. set keysUpward(value: number[]);
  19166. /**
  19167. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  19168. */
  19169. get keysDown(): number[];
  19170. set keysDown(value: number[]);
  19171. /**
  19172. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  19173. */
  19174. get keysDownward(): number[];
  19175. set keysDownward(value: number[]);
  19176. /**
  19177. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  19178. */
  19179. get keysLeft(): number[];
  19180. set keysLeft(value: number[]);
  19181. /**
  19182. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  19183. */
  19184. get keysRight(): number[];
  19185. set keysRight(value: number[]);
  19186. /**
  19187. * Event raised when the camera collide with a mesh in the scene.
  19188. */
  19189. onCollide: (collidedMesh: AbstractMesh) => void;
  19190. private _collider;
  19191. private _needMoveForGravity;
  19192. private _oldPosition;
  19193. private _diffPosition;
  19194. private _newPosition;
  19195. /** @hidden */
  19196. _localDirection: Vector3;
  19197. /** @hidden */
  19198. _transformedDirection: Vector3;
  19199. /**
  19200. * Instantiates a Free Camera.
  19201. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  19202. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  19203. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  19204. * @param name Define the name of the camera in the scene
  19205. * @param position Define the start position of the camera in the scene
  19206. * @param scene Define the scene the camera belongs to
  19207. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  19208. */
  19209. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  19210. /**
  19211. * Attached controls to the current camera.
  19212. * @param element Defines the element the controls should be listened from
  19213. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19214. */
  19215. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19216. /**
  19217. * Detach the current controls from the camera.
  19218. * The camera will stop reacting to inputs.
  19219. * @param element Defines the element to stop listening the inputs from
  19220. */
  19221. detachControl(element: HTMLElement): void;
  19222. private _collisionMask;
  19223. /**
  19224. * Define a collision mask to limit the list of object the camera can collide with
  19225. */
  19226. get collisionMask(): number;
  19227. set collisionMask(mask: number);
  19228. /** @hidden */
  19229. _collideWithWorld(displacement: Vector3): void;
  19230. private _onCollisionPositionChange;
  19231. /** @hidden */
  19232. _checkInputs(): void;
  19233. /** @hidden */
  19234. _decideIfNeedsToMove(): boolean;
  19235. /** @hidden */
  19236. _updatePosition(): void;
  19237. /**
  19238. * Destroy the camera and release the current resources hold by it.
  19239. */
  19240. dispose(): void;
  19241. /**
  19242. * Gets the current object class name.
  19243. * @return the class name
  19244. */
  19245. getClassName(): string;
  19246. }
  19247. }
  19248. declare module "babylonjs/Gamepads/gamepad" {
  19249. import { Observable } from "babylonjs/Misc/observable";
  19250. /**
  19251. * Represents a gamepad control stick position
  19252. */
  19253. export class StickValues {
  19254. /**
  19255. * The x component of the control stick
  19256. */
  19257. x: number;
  19258. /**
  19259. * The y component of the control stick
  19260. */
  19261. y: number;
  19262. /**
  19263. * Initializes the gamepad x and y control stick values
  19264. * @param x The x component of the gamepad control stick value
  19265. * @param y The y component of the gamepad control stick value
  19266. */
  19267. constructor(
  19268. /**
  19269. * The x component of the control stick
  19270. */
  19271. x: number,
  19272. /**
  19273. * The y component of the control stick
  19274. */
  19275. y: number);
  19276. }
  19277. /**
  19278. * An interface which manages callbacks for gamepad button changes
  19279. */
  19280. export interface GamepadButtonChanges {
  19281. /**
  19282. * Called when a gamepad has been changed
  19283. */
  19284. changed: boolean;
  19285. /**
  19286. * Called when a gamepad press event has been triggered
  19287. */
  19288. pressChanged: boolean;
  19289. /**
  19290. * Called when a touch event has been triggered
  19291. */
  19292. touchChanged: boolean;
  19293. /**
  19294. * Called when a value has changed
  19295. */
  19296. valueChanged: boolean;
  19297. }
  19298. /**
  19299. * Represents a gamepad
  19300. */
  19301. export class Gamepad {
  19302. /**
  19303. * The id of the gamepad
  19304. */
  19305. id: string;
  19306. /**
  19307. * The index of the gamepad
  19308. */
  19309. index: number;
  19310. /**
  19311. * The browser gamepad
  19312. */
  19313. browserGamepad: any;
  19314. /**
  19315. * Specifies what type of gamepad this represents
  19316. */
  19317. type: number;
  19318. private _leftStick;
  19319. private _rightStick;
  19320. /** @hidden */
  19321. _isConnected: boolean;
  19322. private _leftStickAxisX;
  19323. private _leftStickAxisY;
  19324. private _rightStickAxisX;
  19325. private _rightStickAxisY;
  19326. /**
  19327. * Triggered when the left control stick has been changed
  19328. */
  19329. private _onleftstickchanged;
  19330. /**
  19331. * Triggered when the right control stick has been changed
  19332. */
  19333. private _onrightstickchanged;
  19334. /**
  19335. * Represents a gamepad controller
  19336. */
  19337. static GAMEPAD: number;
  19338. /**
  19339. * Represents a generic controller
  19340. */
  19341. static GENERIC: number;
  19342. /**
  19343. * Represents an XBox controller
  19344. */
  19345. static XBOX: number;
  19346. /**
  19347. * Represents a pose-enabled controller
  19348. */
  19349. static POSE_ENABLED: number;
  19350. /**
  19351. * Represents an Dual Shock controller
  19352. */
  19353. static DUALSHOCK: number;
  19354. /**
  19355. * Specifies whether the left control stick should be Y-inverted
  19356. */
  19357. protected _invertLeftStickY: boolean;
  19358. /**
  19359. * Specifies if the gamepad has been connected
  19360. */
  19361. get isConnected(): boolean;
  19362. /**
  19363. * Initializes the gamepad
  19364. * @param id The id of the gamepad
  19365. * @param index The index of the gamepad
  19366. * @param browserGamepad The browser gamepad
  19367. * @param leftStickX The x component of the left joystick
  19368. * @param leftStickY The y component of the left joystick
  19369. * @param rightStickX The x component of the right joystick
  19370. * @param rightStickY The y component of the right joystick
  19371. */
  19372. constructor(
  19373. /**
  19374. * The id of the gamepad
  19375. */
  19376. id: string,
  19377. /**
  19378. * The index of the gamepad
  19379. */
  19380. index: number,
  19381. /**
  19382. * The browser gamepad
  19383. */
  19384. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  19385. /**
  19386. * Callback triggered when the left joystick has changed
  19387. * @param callback
  19388. */
  19389. onleftstickchanged(callback: (values: StickValues) => void): void;
  19390. /**
  19391. * Callback triggered when the right joystick has changed
  19392. * @param callback
  19393. */
  19394. onrightstickchanged(callback: (values: StickValues) => void): void;
  19395. /**
  19396. * Gets the left joystick
  19397. */
  19398. get leftStick(): StickValues;
  19399. /**
  19400. * Sets the left joystick values
  19401. */
  19402. set leftStick(newValues: StickValues);
  19403. /**
  19404. * Gets the right joystick
  19405. */
  19406. get rightStick(): StickValues;
  19407. /**
  19408. * Sets the right joystick value
  19409. */
  19410. set rightStick(newValues: StickValues);
  19411. /**
  19412. * Updates the gamepad joystick positions
  19413. */
  19414. update(): void;
  19415. /**
  19416. * Disposes the gamepad
  19417. */
  19418. dispose(): void;
  19419. }
  19420. /**
  19421. * Represents a generic gamepad
  19422. */
  19423. export class GenericPad extends Gamepad {
  19424. private _buttons;
  19425. private _onbuttondown;
  19426. private _onbuttonup;
  19427. /**
  19428. * Observable triggered when a button has been pressed
  19429. */
  19430. onButtonDownObservable: Observable<number>;
  19431. /**
  19432. * Observable triggered when a button has been released
  19433. */
  19434. onButtonUpObservable: Observable<number>;
  19435. /**
  19436. * Callback triggered when a button has been pressed
  19437. * @param callback Called when a button has been pressed
  19438. */
  19439. onbuttondown(callback: (buttonPressed: number) => void): void;
  19440. /**
  19441. * Callback triggered when a button has been released
  19442. * @param callback Called when a button has been released
  19443. */
  19444. onbuttonup(callback: (buttonReleased: number) => void): void;
  19445. /**
  19446. * Initializes the generic gamepad
  19447. * @param id The id of the generic gamepad
  19448. * @param index The index of the generic gamepad
  19449. * @param browserGamepad The browser gamepad
  19450. */
  19451. constructor(id: string, index: number, browserGamepad: any);
  19452. private _setButtonValue;
  19453. /**
  19454. * Updates the generic gamepad
  19455. */
  19456. update(): void;
  19457. /**
  19458. * Disposes the generic gamepad
  19459. */
  19460. dispose(): void;
  19461. }
  19462. }
  19463. declare module "babylonjs/Gamepads/Controllers/poseEnabledController" {
  19464. import { Observable } from "babylonjs/Misc/observable";
  19465. import { Nullable } from "babylonjs/types";
  19466. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  19467. import { TransformNode } from "babylonjs/Meshes/transformNode";
  19468. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19469. import { Ray } from "babylonjs/Culling/ray";
  19470. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  19471. import { PoseControlled, DevicePose } from "babylonjs/Cameras/VR/webVRCamera";
  19472. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  19473. /**
  19474. * Defines the types of pose enabled controllers that are supported
  19475. */
  19476. export enum PoseEnabledControllerType {
  19477. /**
  19478. * HTC Vive
  19479. */
  19480. VIVE = 0,
  19481. /**
  19482. * Oculus Rift
  19483. */
  19484. OCULUS = 1,
  19485. /**
  19486. * Windows mixed reality
  19487. */
  19488. WINDOWS = 2,
  19489. /**
  19490. * Samsung gear VR
  19491. */
  19492. GEAR_VR = 3,
  19493. /**
  19494. * Google Daydream
  19495. */
  19496. DAYDREAM = 4,
  19497. /**
  19498. * Generic
  19499. */
  19500. GENERIC = 5
  19501. }
  19502. /**
  19503. * Defines the MutableGamepadButton interface for the state of a gamepad button
  19504. */
  19505. export interface MutableGamepadButton {
  19506. /**
  19507. * Value of the button/trigger
  19508. */
  19509. value: number;
  19510. /**
  19511. * If the button/trigger is currently touched
  19512. */
  19513. touched: boolean;
  19514. /**
  19515. * If the button/trigger is currently pressed
  19516. */
  19517. pressed: boolean;
  19518. }
  19519. /**
  19520. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  19521. * @hidden
  19522. */
  19523. export interface ExtendedGamepadButton extends GamepadButton {
  19524. /**
  19525. * If the button/trigger is currently pressed
  19526. */
  19527. readonly pressed: boolean;
  19528. /**
  19529. * If the button/trigger is currently touched
  19530. */
  19531. readonly touched: boolean;
  19532. /**
  19533. * Value of the button/trigger
  19534. */
  19535. readonly value: number;
  19536. }
  19537. /** @hidden */
  19538. export interface _GamePadFactory {
  19539. /**
  19540. * Returns whether or not the current gamepad can be created for this type of controller.
  19541. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  19542. * @returns true if it can be created, otherwise false
  19543. */
  19544. canCreate(gamepadInfo: any): boolean;
  19545. /**
  19546. * Creates a new instance of the Gamepad.
  19547. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  19548. * @returns the new gamepad instance
  19549. */
  19550. create(gamepadInfo: any): Gamepad;
  19551. }
  19552. /**
  19553. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  19554. */
  19555. export class PoseEnabledControllerHelper {
  19556. /** @hidden */
  19557. static _ControllerFactories: _GamePadFactory[];
  19558. /** @hidden */
  19559. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  19560. /**
  19561. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  19562. * @param vrGamepad the gamepad to initialized
  19563. * @returns a vr controller of the type the gamepad identified as
  19564. */
  19565. static InitiateController(vrGamepad: any): Gamepad;
  19566. }
  19567. /**
  19568. * Defines the PoseEnabledController object that contains state of a vr capable controller
  19569. */
  19570. export class PoseEnabledController extends Gamepad implements PoseControlled {
  19571. /**
  19572. * If the controller is used in a webXR session
  19573. */
  19574. isXR: boolean;
  19575. private _deviceRoomPosition;
  19576. private _deviceRoomRotationQuaternion;
  19577. /**
  19578. * The device position in babylon space
  19579. */
  19580. devicePosition: Vector3;
  19581. /**
  19582. * The device rotation in babylon space
  19583. */
  19584. deviceRotationQuaternion: Quaternion;
  19585. /**
  19586. * The scale factor of the device in babylon space
  19587. */
  19588. deviceScaleFactor: number;
  19589. /**
  19590. * (Likely devicePosition should be used instead) The device position in its room space
  19591. */
  19592. position: Vector3;
  19593. /**
  19594. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  19595. */
  19596. rotationQuaternion: Quaternion;
  19597. /**
  19598. * The type of controller (Eg. Windows mixed reality)
  19599. */
  19600. controllerType: PoseEnabledControllerType;
  19601. protected _calculatedPosition: Vector3;
  19602. private _calculatedRotation;
  19603. /**
  19604. * The raw pose from the device
  19605. */
  19606. rawPose: DevicePose;
  19607. private _trackPosition;
  19608. private _maxRotationDistFromHeadset;
  19609. private _draggedRoomRotation;
  19610. /**
  19611. * @hidden
  19612. */
  19613. _disableTrackPosition(fixedPosition: Vector3): void;
  19614. /**
  19615. * Internal, the mesh attached to the controller
  19616. * @hidden
  19617. */
  19618. _mesh: Nullable<AbstractMesh>;
  19619. private _poseControlledCamera;
  19620. private _leftHandSystemQuaternion;
  19621. /**
  19622. * Internal, matrix used to convert room space to babylon space
  19623. * @hidden
  19624. */
  19625. _deviceToWorld: Matrix;
  19626. /**
  19627. * Node to be used when casting a ray from the controller
  19628. * @hidden
  19629. */
  19630. _pointingPoseNode: Nullable<TransformNode>;
  19631. /**
  19632. * Name of the child mesh that can be used to cast a ray from the controller
  19633. */
  19634. static readonly POINTING_POSE: string;
  19635. /**
  19636. * Creates a new PoseEnabledController from a gamepad
  19637. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  19638. */
  19639. constructor(browserGamepad: any);
  19640. private _workingMatrix;
  19641. /**
  19642. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  19643. */
  19644. update(): void;
  19645. /**
  19646. * Updates only the pose device and mesh without doing any button event checking
  19647. */
  19648. protected _updatePoseAndMesh(): void;
  19649. /**
  19650. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  19651. * @param poseData raw pose fromthe device
  19652. */
  19653. updateFromDevice(poseData: DevicePose): void;
  19654. /**
  19655. * @hidden
  19656. */
  19657. _meshAttachedObservable: Observable<AbstractMesh>;
  19658. /**
  19659. * Attaches a mesh to the controller
  19660. * @param mesh the mesh to be attached
  19661. */
  19662. attachToMesh(mesh: AbstractMesh): void;
  19663. /**
  19664. * Attaches the controllers mesh to a camera
  19665. * @param camera the camera the mesh should be attached to
  19666. */
  19667. attachToPoseControlledCamera(camera: TargetCamera): void;
  19668. /**
  19669. * Disposes of the controller
  19670. */
  19671. dispose(): void;
  19672. /**
  19673. * The mesh that is attached to the controller
  19674. */
  19675. get mesh(): Nullable<AbstractMesh>;
  19676. /**
  19677. * Gets the ray of the controller in the direction the controller is pointing
  19678. * @param length the length the resulting ray should be
  19679. * @returns a ray in the direction the controller is pointing
  19680. */
  19681. getForwardRay(length?: number): Ray;
  19682. }
  19683. }
  19684. declare module "babylonjs/Gamepads/Controllers/webVRController" {
  19685. import { Observable } from "babylonjs/Misc/observable";
  19686. import { Scene } from "babylonjs/scene";
  19687. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19688. import { PoseEnabledController, ExtendedGamepadButton, MutableGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  19689. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  19690. import { Nullable } from "babylonjs/types";
  19691. /**
  19692. * Defines the WebVRController object that represents controllers tracked in 3D space
  19693. */
  19694. export abstract class WebVRController extends PoseEnabledController {
  19695. /**
  19696. * Internal, the default controller model for the controller
  19697. */
  19698. protected _defaultModel: Nullable<AbstractMesh>;
  19699. /**
  19700. * Fired when the trigger state has changed
  19701. */
  19702. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  19703. /**
  19704. * Fired when the main button state has changed
  19705. */
  19706. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19707. /**
  19708. * Fired when the secondary button state has changed
  19709. */
  19710. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19711. /**
  19712. * Fired when the pad state has changed
  19713. */
  19714. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  19715. /**
  19716. * Fired when controllers stick values have changed
  19717. */
  19718. onPadValuesChangedObservable: Observable<StickValues>;
  19719. /**
  19720. * Array of button availible on the controller
  19721. */
  19722. protected _buttons: Array<MutableGamepadButton>;
  19723. private _onButtonStateChange;
  19724. /**
  19725. * Fired when a controller button's state has changed
  19726. * @param callback the callback containing the button that was modified
  19727. */
  19728. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  19729. /**
  19730. * X and Y axis corresponding to the controllers joystick
  19731. */
  19732. pad: StickValues;
  19733. /**
  19734. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  19735. */
  19736. hand: string;
  19737. /**
  19738. * The default controller model for the controller
  19739. */
  19740. get defaultModel(): Nullable<AbstractMesh>;
  19741. /**
  19742. * Creates a new WebVRController from a gamepad
  19743. * @param vrGamepad the gamepad that the WebVRController should be created from
  19744. */
  19745. constructor(vrGamepad: any);
  19746. /**
  19747. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  19748. */
  19749. update(): void;
  19750. /**
  19751. * Function to be called when a button is modified
  19752. */
  19753. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  19754. /**
  19755. * Loads a mesh and attaches it to the controller
  19756. * @param scene the scene the mesh should be added to
  19757. * @param meshLoaded callback for when the mesh has been loaded
  19758. */
  19759. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  19760. private _setButtonValue;
  19761. private _changes;
  19762. private _checkChanges;
  19763. /**
  19764. * Disposes of th webVRCOntroller
  19765. */
  19766. dispose(): void;
  19767. }
  19768. }
  19769. declare module "babylonjs/Lights/hemisphericLight" {
  19770. import { Nullable } from "babylonjs/types";
  19771. import { Scene } from "babylonjs/scene";
  19772. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  19773. import { Color3 } from "babylonjs/Maths/math.color";
  19774. import { Effect } from "babylonjs/Materials/effect";
  19775. import { Light } from "babylonjs/Lights/light";
  19776. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  19777. /**
  19778. * The HemisphericLight simulates the ambient environment light,
  19779. * so the passed direction is the light reflection direction, not the incoming direction.
  19780. */
  19781. export class HemisphericLight extends Light {
  19782. /**
  19783. * The groundColor is the light in the opposite direction to the one specified during creation.
  19784. * 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.
  19785. */
  19786. groundColor: Color3;
  19787. /**
  19788. * The light reflection direction, not the incoming direction.
  19789. */
  19790. direction: Vector3;
  19791. /**
  19792. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  19793. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  19794. * The HemisphericLight can't cast shadows.
  19795. * Documentation : https://doc.babylonjs.com/babylon101/lights
  19796. * @param name The friendly name of the light
  19797. * @param direction The direction of the light reflection
  19798. * @param scene The scene the light belongs to
  19799. */
  19800. constructor(name: string, direction: Vector3, scene: Scene);
  19801. protected _buildUniformLayout(): void;
  19802. /**
  19803. * Returns the string "HemisphericLight".
  19804. * @return The class name
  19805. */
  19806. getClassName(): string;
  19807. /**
  19808. * Sets the HemisphericLight direction towards the passed target (Vector3).
  19809. * Returns the updated direction.
  19810. * @param target The target the direction should point to
  19811. * @return The computed direction
  19812. */
  19813. setDirectionToTarget(target: Vector3): Vector3;
  19814. /**
  19815. * Returns the shadow generator associated to the light.
  19816. * @returns Always null for hemispheric lights because it does not support shadows.
  19817. */
  19818. getShadowGenerator(): Nullable<IShadowGenerator>;
  19819. /**
  19820. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  19821. * @param effect The effect to update
  19822. * @param lightIndex The index of the light in the effect to update
  19823. * @returns The hemispheric light
  19824. */
  19825. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  19826. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  19827. /**
  19828. * Computes the world matrix of the node
  19829. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  19830. * @param useWasUpdatedFlag defines a reserved property
  19831. * @returns the world matrix
  19832. */
  19833. computeWorldMatrix(): Matrix;
  19834. /**
  19835. * Returns the integer 3.
  19836. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  19837. */
  19838. getTypeID(): number;
  19839. /**
  19840. * Prepares the list of defines specific to the light type.
  19841. * @param defines the list of defines
  19842. * @param lightIndex defines the index of the light for the effect
  19843. */
  19844. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  19845. }
  19846. }
  19847. declare module "babylonjs/Shaders/vrMultiviewToSingleview.fragment" {
  19848. /** @hidden */
  19849. export var vrMultiviewToSingleviewPixelShader: {
  19850. name: string;
  19851. shader: string;
  19852. };
  19853. }
  19854. declare module "babylonjs/Materials/Textures/MultiviewRenderTarget" {
  19855. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  19856. import { Scene } from "babylonjs/scene";
  19857. /**
  19858. * Renders to multiple views with a single draw call
  19859. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  19860. */
  19861. export class MultiviewRenderTarget extends RenderTargetTexture {
  19862. /**
  19863. * Creates a multiview render target
  19864. * @param scene scene used with the render target
  19865. * @param size the size of the render target (used for each view)
  19866. */
  19867. constructor(scene: Scene, size?: number | {
  19868. width: number;
  19869. height: number;
  19870. } | {
  19871. ratio: number;
  19872. });
  19873. /**
  19874. * @hidden
  19875. * @param faceIndex the face index, if its a cube texture
  19876. */
  19877. _bindFrameBuffer(faceIndex?: number): void;
  19878. /**
  19879. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  19880. * @returns the view count
  19881. */
  19882. getViewCount(): number;
  19883. }
  19884. }
  19885. declare module "babylonjs/Maths/math.frustum" {
  19886. import { Matrix } from "babylonjs/Maths/math.vector";
  19887. import { DeepImmutable } from "babylonjs/types";
  19888. import { Plane } from "babylonjs/Maths/math.plane";
  19889. /**
  19890. * Represents a camera frustum
  19891. */
  19892. export class Frustum {
  19893. /**
  19894. * Gets the planes representing the frustum
  19895. * @param transform matrix to be applied to the returned planes
  19896. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  19897. */
  19898. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  19899. /**
  19900. * Gets the near frustum plane transformed by the transform matrix
  19901. * @param transform transformation matrix to be applied to the resulting frustum plane
  19902. * @param frustumPlane the resuling frustum plane
  19903. */
  19904. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19905. /**
  19906. * Gets the far frustum plane transformed by the transform matrix
  19907. * @param transform transformation matrix to be applied to the resulting frustum plane
  19908. * @param frustumPlane the resuling frustum plane
  19909. */
  19910. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19911. /**
  19912. * Gets the left frustum plane transformed by the transform matrix
  19913. * @param transform transformation matrix to be applied to the resulting frustum plane
  19914. * @param frustumPlane the resuling frustum plane
  19915. */
  19916. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19917. /**
  19918. * Gets the right frustum plane transformed by the transform matrix
  19919. * @param transform transformation matrix to be applied to the resulting frustum plane
  19920. * @param frustumPlane the resuling frustum plane
  19921. */
  19922. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19923. /**
  19924. * Gets the top frustum plane transformed by the transform matrix
  19925. * @param transform transformation matrix to be applied to the resulting frustum plane
  19926. * @param frustumPlane the resuling frustum plane
  19927. */
  19928. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19929. /**
  19930. * Gets the bottom frustum plane transformed by the transform matrix
  19931. * @param transform transformation matrix to be applied to the resulting frustum plane
  19932. * @param frustumPlane the resuling frustum plane
  19933. */
  19934. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19935. /**
  19936. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  19937. * @param transform transformation matrix to be applied to the resulting frustum planes
  19938. * @param frustumPlanes the resuling frustum planes
  19939. */
  19940. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  19941. }
  19942. }
  19943. declare module "babylonjs/Engines/Extensions/engine.multiview" {
  19944. import { Camera } from "babylonjs/Cameras/camera";
  19945. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  19946. import { Nullable } from "babylonjs/types";
  19947. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  19948. import { Matrix } from "babylonjs/Maths/math.vector";
  19949. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  19950. module "babylonjs/Engines/engine" {
  19951. interface Engine {
  19952. /**
  19953. * Creates a new multiview render target
  19954. * @param width defines the width of the texture
  19955. * @param height defines the height of the texture
  19956. * @returns the created multiview texture
  19957. */
  19958. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  19959. /**
  19960. * Binds a multiview framebuffer to be drawn to
  19961. * @param multiviewTexture texture to bind
  19962. */
  19963. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  19964. }
  19965. }
  19966. module "babylonjs/Cameras/camera" {
  19967. interface Camera {
  19968. /**
  19969. * @hidden
  19970. * 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)
  19971. */
  19972. _useMultiviewToSingleView: boolean;
  19973. /**
  19974. * @hidden
  19975. * 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)
  19976. */
  19977. _multiviewTexture: Nullable<RenderTargetTexture>;
  19978. /**
  19979. * @hidden
  19980. * ensures the multiview texture of the camera exists and has the specified width/height
  19981. * @param width height to set on the multiview texture
  19982. * @param height width to set on the multiview texture
  19983. */
  19984. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  19985. }
  19986. }
  19987. module "babylonjs/scene" {
  19988. interface Scene {
  19989. /** @hidden */
  19990. _transformMatrixR: Matrix;
  19991. /** @hidden */
  19992. _multiviewSceneUbo: Nullable<UniformBuffer>;
  19993. /** @hidden */
  19994. _createMultiviewUbo(): void;
  19995. /** @hidden */
  19996. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  19997. /** @hidden */
  19998. _renderMultiviewToSingleView(camera: Camera): void;
  19999. }
  20000. }
  20001. }
  20002. declare module "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess" {
  20003. import { Camera } from "babylonjs/Cameras/camera";
  20004. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  20005. import "babylonjs/Shaders/vrMultiviewToSingleview.fragment";
  20006. import "babylonjs/Engines/Extensions/engine.multiview";
  20007. /**
  20008. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  20009. * This will not be used for webXR as it supports displaying texture arrays directly
  20010. */
  20011. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  20012. /**
  20013. * Initializes a VRMultiviewToSingleview
  20014. * @param name name of the post process
  20015. * @param camera camera to be applied to
  20016. * @param scaleFactor scaling factor to the size of the output texture
  20017. */
  20018. constructor(name: string, camera: Camera, scaleFactor: number);
  20019. }
  20020. }
  20021. declare module "babylonjs/Cameras/RigModes/webVRRigMode" { }
  20022. declare module "babylonjs/Engines/Extensions/engine.webVR" {
  20023. import { Nullable } from "babylonjs/types";
  20024. import { Size } from "babylonjs/Maths/math.size";
  20025. import { Observable } from "babylonjs/Misc/observable";
  20026. import { WebVROptions } from "babylonjs/Cameras/VR/webVRCamera";
  20027. /**
  20028. * Interface used to define additional presentation attributes
  20029. */
  20030. export interface IVRPresentationAttributes {
  20031. /**
  20032. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  20033. */
  20034. highRefreshRate: boolean;
  20035. /**
  20036. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  20037. */
  20038. foveationLevel: number;
  20039. }
  20040. module "babylonjs/Engines/engine" {
  20041. interface Engine {
  20042. /** @hidden */
  20043. _vrDisplay: any;
  20044. /** @hidden */
  20045. _vrSupported: boolean;
  20046. /** @hidden */
  20047. _oldSize: Size;
  20048. /** @hidden */
  20049. _oldHardwareScaleFactor: number;
  20050. /** @hidden */
  20051. _vrExclusivePointerMode: boolean;
  20052. /** @hidden */
  20053. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  20054. /** @hidden */
  20055. _onVRDisplayPointerRestricted: () => void;
  20056. /** @hidden */
  20057. _onVRDisplayPointerUnrestricted: () => void;
  20058. /** @hidden */
  20059. _onVrDisplayConnect: Nullable<(display: any) => void>;
  20060. /** @hidden */
  20061. _onVrDisplayDisconnect: Nullable<() => void>;
  20062. /** @hidden */
  20063. _onVrDisplayPresentChange: Nullable<() => void>;
  20064. /**
  20065. * Observable signaled when VR display mode changes
  20066. */
  20067. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  20068. /**
  20069. * Observable signaled when VR request present is complete
  20070. */
  20071. onVRRequestPresentComplete: Observable<boolean>;
  20072. /**
  20073. * Observable signaled when VR request present starts
  20074. */
  20075. onVRRequestPresentStart: Observable<Engine>;
  20076. /**
  20077. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  20078. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  20079. */
  20080. isInVRExclusivePointerMode: boolean;
  20081. /**
  20082. * Gets a boolean indicating if a webVR device was detected
  20083. * @returns true if a webVR device was detected
  20084. */
  20085. isVRDevicePresent(): boolean;
  20086. /**
  20087. * Gets the current webVR device
  20088. * @returns the current webVR device (or null)
  20089. */
  20090. getVRDevice(): any;
  20091. /**
  20092. * Initializes a webVR display and starts listening to display change events
  20093. * The onVRDisplayChangedObservable will be notified upon these changes
  20094. * @returns A promise containing a VRDisplay and if vr is supported
  20095. */
  20096. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  20097. /** @hidden */
  20098. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  20099. /**
  20100. * Gets or sets the presentation attributes used to configure VR rendering
  20101. */
  20102. vrPresentationAttributes?: IVRPresentationAttributes;
  20103. /**
  20104. * Call this function to switch to webVR mode
  20105. * Will do nothing if webVR is not supported or if there is no webVR device
  20106. * @param options the webvr options provided to the camera. mainly used for multiview
  20107. * @see http://doc.babylonjs.com/how_to/webvr_camera
  20108. */
  20109. enableVR(options: WebVROptions): void;
  20110. /** @hidden */
  20111. _onVRFullScreenTriggered(): void;
  20112. }
  20113. }
  20114. }
  20115. declare module "babylonjs/Cameras/VR/webVRCamera" {
  20116. import { Nullable } from "babylonjs/types";
  20117. import { Observable } from "babylonjs/Misc/observable";
  20118. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  20119. import { Scene } from "babylonjs/scene";
  20120. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  20121. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  20122. import { Node } from "babylonjs/node";
  20123. import { Ray } from "babylonjs/Culling/ray";
  20124. import "babylonjs/Cameras/RigModes/webVRRigMode";
  20125. import "babylonjs/Engines/Extensions/engine.webVR";
  20126. /**
  20127. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  20128. * IMPORTANT!! The data is right-hand data.
  20129. * @export
  20130. * @interface DevicePose
  20131. */
  20132. export interface DevicePose {
  20133. /**
  20134. * The position of the device, values in array are [x,y,z].
  20135. */
  20136. readonly position: Nullable<Float32Array>;
  20137. /**
  20138. * The linearVelocity of the device, values in array are [x,y,z].
  20139. */
  20140. readonly linearVelocity: Nullable<Float32Array>;
  20141. /**
  20142. * The linearAcceleration of the device, values in array are [x,y,z].
  20143. */
  20144. readonly linearAcceleration: Nullable<Float32Array>;
  20145. /**
  20146. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  20147. */
  20148. readonly orientation: Nullable<Float32Array>;
  20149. /**
  20150. * The angularVelocity of the device, values in array are [x,y,z].
  20151. */
  20152. readonly angularVelocity: Nullable<Float32Array>;
  20153. /**
  20154. * The angularAcceleration of the device, values in array are [x,y,z].
  20155. */
  20156. readonly angularAcceleration: Nullable<Float32Array>;
  20157. }
  20158. /**
  20159. * Interface representing a pose controlled object in Babylon.
  20160. * A pose controlled object has both regular pose values as well as pose values
  20161. * from an external device such as a VR head mounted display
  20162. */
  20163. export interface PoseControlled {
  20164. /**
  20165. * The position of the object in babylon space.
  20166. */
  20167. position: Vector3;
  20168. /**
  20169. * The rotation quaternion of the object in babylon space.
  20170. */
  20171. rotationQuaternion: Quaternion;
  20172. /**
  20173. * The position of the device in babylon space.
  20174. */
  20175. devicePosition?: Vector3;
  20176. /**
  20177. * The rotation quaternion of the device in babylon space.
  20178. */
  20179. deviceRotationQuaternion: Quaternion;
  20180. /**
  20181. * The raw pose coming from the device.
  20182. */
  20183. rawPose: Nullable<DevicePose>;
  20184. /**
  20185. * The scale of the device to be used when translating from device space to babylon space.
  20186. */
  20187. deviceScaleFactor: number;
  20188. /**
  20189. * Updates the poseControlled values based on the input device pose.
  20190. * @param poseData the pose data to update the object with
  20191. */
  20192. updateFromDevice(poseData: DevicePose): void;
  20193. }
  20194. /**
  20195. * Set of options to customize the webVRCamera
  20196. */
  20197. export interface WebVROptions {
  20198. /**
  20199. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  20200. */
  20201. trackPosition?: boolean;
  20202. /**
  20203. * Sets the scale of the vrDevice in babylon space. (default: 1)
  20204. */
  20205. positionScale?: number;
  20206. /**
  20207. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  20208. */
  20209. displayName?: string;
  20210. /**
  20211. * Should the native controller meshes be initialized. (default: true)
  20212. */
  20213. controllerMeshes?: boolean;
  20214. /**
  20215. * Creating a default HemiLight only on controllers. (default: true)
  20216. */
  20217. defaultLightingOnControllers?: boolean;
  20218. /**
  20219. * If you don't want to use the default VR button of the helper. (default: false)
  20220. */
  20221. useCustomVRButton?: boolean;
  20222. /**
  20223. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  20224. */
  20225. customVRButton?: HTMLButtonElement;
  20226. /**
  20227. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  20228. */
  20229. rayLength?: number;
  20230. /**
  20231. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  20232. */
  20233. defaultHeight?: number;
  20234. /**
  20235. * If multiview should be used if availible (default: false)
  20236. */
  20237. useMultiview?: boolean;
  20238. }
  20239. /**
  20240. * This represents a WebVR camera.
  20241. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  20242. * @example http://doc.babylonjs.com/how_to/webvr_camera
  20243. */
  20244. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  20245. private webVROptions;
  20246. /**
  20247. * @hidden
  20248. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  20249. */
  20250. _vrDevice: any;
  20251. /**
  20252. * The rawPose of the vrDevice.
  20253. */
  20254. rawPose: Nullable<DevicePose>;
  20255. private _onVREnabled;
  20256. private _specsVersion;
  20257. private _attached;
  20258. private _frameData;
  20259. protected _descendants: Array<Node>;
  20260. private _deviceRoomPosition;
  20261. /** @hidden */
  20262. _deviceRoomRotationQuaternion: Quaternion;
  20263. private _standingMatrix;
  20264. /**
  20265. * Represents device position in babylon space.
  20266. */
  20267. devicePosition: Vector3;
  20268. /**
  20269. * Represents device rotation in babylon space.
  20270. */
  20271. deviceRotationQuaternion: Quaternion;
  20272. /**
  20273. * The scale of the device to be used when translating from device space to babylon space.
  20274. */
  20275. deviceScaleFactor: number;
  20276. private _deviceToWorld;
  20277. private _worldToDevice;
  20278. /**
  20279. * References to the webVR controllers for the vrDevice.
  20280. */
  20281. controllers: Array<WebVRController>;
  20282. /**
  20283. * Emits an event when a controller is attached.
  20284. */
  20285. onControllersAttachedObservable: Observable<WebVRController[]>;
  20286. /**
  20287. * Emits an event when a controller's mesh has been loaded;
  20288. */
  20289. onControllerMeshLoadedObservable: Observable<WebVRController>;
  20290. /**
  20291. * Emits an event when the HMD's pose has been updated.
  20292. */
  20293. onPoseUpdatedFromDeviceObservable: Observable<any>;
  20294. private _poseSet;
  20295. /**
  20296. * If the rig cameras be used as parent instead of this camera.
  20297. */
  20298. rigParenting: boolean;
  20299. private _lightOnControllers;
  20300. private _defaultHeight?;
  20301. /**
  20302. * Instantiates a WebVRFreeCamera.
  20303. * @param name The name of the WebVRFreeCamera
  20304. * @param position The starting anchor position for the camera
  20305. * @param scene The scene the camera belongs to
  20306. * @param webVROptions a set of customizable options for the webVRCamera
  20307. */
  20308. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  20309. /**
  20310. * Gets the device distance from the ground in meters.
  20311. * @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.
  20312. */
  20313. deviceDistanceToRoomGround(): number;
  20314. /**
  20315. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  20316. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  20317. */
  20318. useStandingMatrix(callback?: (bool: boolean) => void): void;
  20319. /**
  20320. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  20321. * @returns A promise with a boolean set to if the standing matrix is supported.
  20322. */
  20323. useStandingMatrixAsync(): Promise<boolean>;
  20324. /**
  20325. * Disposes the camera
  20326. */
  20327. dispose(): void;
  20328. /**
  20329. * Gets a vrController by name.
  20330. * @param name The name of the controller to retreive
  20331. * @returns the controller matching the name specified or null if not found
  20332. */
  20333. getControllerByName(name: string): Nullable<WebVRController>;
  20334. private _leftController;
  20335. /**
  20336. * The controller corresponding to the users left hand.
  20337. */
  20338. get leftController(): Nullable<WebVRController>;
  20339. private _rightController;
  20340. /**
  20341. * The controller corresponding to the users right hand.
  20342. */
  20343. get rightController(): Nullable<WebVRController>;
  20344. /**
  20345. * Casts a ray forward from the vrCamera's gaze.
  20346. * @param length Length of the ray (default: 100)
  20347. * @returns the ray corresponding to the gaze
  20348. */
  20349. getForwardRay(length?: number): Ray;
  20350. /**
  20351. * @hidden
  20352. * Updates the camera based on device's frame data
  20353. */
  20354. _checkInputs(): void;
  20355. /**
  20356. * Updates the poseControlled values based on the input device pose.
  20357. * @param poseData Pose coming from the device
  20358. */
  20359. updateFromDevice(poseData: DevicePose): void;
  20360. private _htmlElementAttached;
  20361. private _detachIfAttached;
  20362. /**
  20363. * WebVR's attach control will start broadcasting frames to the device.
  20364. * Note that in certain browsers (chrome for example) this function must be called
  20365. * within a user-interaction callback. Example:
  20366. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  20367. *
  20368. * @param element html element to attach the vrDevice to
  20369. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  20370. */
  20371. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  20372. /**
  20373. * Detaches the camera from the html element and disables VR
  20374. *
  20375. * @param element html element to detach from
  20376. */
  20377. detachControl(element: HTMLElement): void;
  20378. /**
  20379. * @returns the name of this class
  20380. */
  20381. getClassName(): string;
  20382. /**
  20383. * Calls resetPose on the vrDisplay
  20384. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  20385. */
  20386. resetToCurrentRotation(): void;
  20387. /**
  20388. * @hidden
  20389. * Updates the rig cameras (left and right eye)
  20390. */
  20391. _updateRigCameras(): void;
  20392. private _workingVector;
  20393. private _oneVector;
  20394. private _workingMatrix;
  20395. private updateCacheCalled;
  20396. private _correctPositionIfNotTrackPosition;
  20397. /**
  20398. * @hidden
  20399. * Updates the cached values of the camera
  20400. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  20401. */
  20402. _updateCache(ignoreParentClass?: boolean): void;
  20403. /**
  20404. * @hidden
  20405. * Get current device position in babylon world
  20406. */
  20407. _computeDevicePosition(): void;
  20408. /**
  20409. * Updates the current device position and rotation in the babylon world
  20410. */
  20411. update(): void;
  20412. /**
  20413. * @hidden
  20414. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  20415. * @returns an identity matrix
  20416. */
  20417. _getViewMatrix(): Matrix;
  20418. private _tmpMatrix;
  20419. /**
  20420. * This function is called by the two RIG cameras.
  20421. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  20422. * @hidden
  20423. */
  20424. _getWebVRViewMatrix(): Matrix;
  20425. /** @hidden */
  20426. _getWebVRProjectionMatrix(): Matrix;
  20427. private _onGamepadConnectedObserver;
  20428. private _onGamepadDisconnectedObserver;
  20429. private _updateCacheWhenTrackingDisabledObserver;
  20430. /**
  20431. * Initializes the controllers and their meshes
  20432. */
  20433. initControllers(): void;
  20434. }
  20435. }
  20436. declare module "babylonjs/PostProcesses/postProcess" {
  20437. import { Nullable } from "babylonjs/types";
  20438. import { SmartArray } from "babylonjs/Misc/smartArray";
  20439. import { Observable } from "babylonjs/Misc/observable";
  20440. import { Vector2 } from "babylonjs/Maths/math.vector";
  20441. import { Camera } from "babylonjs/Cameras/camera";
  20442. import { Effect } from "babylonjs/Materials/effect";
  20443. import "babylonjs/Shaders/postprocess.vertex";
  20444. import { IInspectable } from "babylonjs/Misc/iInspectable";
  20445. import { Engine } from "babylonjs/Engines/engine";
  20446. import { Color4 } from "babylonjs/Maths/math.color";
  20447. import "babylonjs/Engines/Extensions/engine.renderTarget";
  20448. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  20449. /**
  20450. * Size options for a post process
  20451. */
  20452. export type PostProcessOptions = {
  20453. width: number;
  20454. height: number;
  20455. };
  20456. /**
  20457. * PostProcess can be used to apply a shader to a texture after it has been rendered
  20458. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  20459. */
  20460. export class PostProcess {
  20461. /** Name of the PostProcess. */
  20462. name: string;
  20463. /**
  20464. * Gets or sets the unique id of the post process
  20465. */
  20466. uniqueId: number;
  20467. /**
  20468. * Width of the texture to apply the post process on
  20469. */
  20470. width: number;
  20471. /**
  20472. * Height of the texture to apply the post process on
  20473. */
  20474. height: number;
  20475. /**
  20476. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  20477. * @hidden
  20478. */
  20479. _outputTexture: Nullable<InternalTexture>;
  20480. /**
  20481. * Sampling mode used by the shader
  20482. * See https://doc.babylonjs.com/classes/3.1/texture
  20483. */
  20484. renderTargetSamplingMode: number;
  20485. /**
  20486. * Clear color to use when screen clearing
  20487. */
  20488. clearColor: Color4;
  20489. /**
  20490. * If the buffer needs to be cleared before applying the post process. (default: true)
  20491. * Should be set to false if shader will overwrite all previous pixels.
  20492. */
  20493. autoClear: boolean;
  20494. /**
  20495. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  20496. */
  20497. alphaMode: number;
  20498. /**
  20499. * Sets the setAlphaBlendConstants of the babylon engine
  20500. */
  20501. alphaConstants: Color4;
  20502. /**
  20503. * Animations to be used for the post processing
  20504. */
  20505. animations: import("babylonjs/Animations/animation").Animation[];
  20506. /**
  20507. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  20508. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  20509. */
  20510. enablePixelPerfectMode: boolean;
  20511. /**
  20512. * Force the postprocess to be applied without taking in account viewport
  20513. */
  20514. forceFullscreenViewport: boolean;
  20515. /**
  20516. * List of inspectable custom properties (used by the Inspector)
  20517. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  20518. */
  20519. inspectableCustomProperties: IInspectable[];
  20520. /**
  20521. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  20522. *
  20523. * | Value | Type | Description |
  20524. * | ----- | ----------------------------------- | ----------- |
  20525. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  20526. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  20527. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  20528. *
  20529. */
  20530. scaleMode: number;
  20531. /**
  20532. * Force textures to be a power of two (default: false)
  20533. */
  20534. alwaysForcePOT: boolean;
  20535. private _samples;
  20536. /**
  20537. * Number of sample textures (default: 1)
  20538. */
  20539. get samples(): number;
  20540. set samples(n: number);
  20541. /**
  20542. * Modify the scale of the post process to be the same as the viewport (default: false)
  20543. */
  20544. adaptScaleToCurrentViewport: boolean;
  20545. private _camera;
  20546. private _scene;
  20547. private _engine;
  20548. private _options;
  20549. private _reusable;
  20550. private _textureType;
  20551. private _textureFormat;
  20552. /**
  20553. * Smart array of input and output textures for the post process.
  20554. * @hidden
  20555. */
  20556. _textures: SmartArray<import("babylonjs/Materials/Textures/internalTexture").InternalTexture>;
  20557. /**
  20558. * The index in _textures that corresponds to the output texture.
  20559. * @hidden
  20560. */
  20561. _currentRenderTextureInd: number;
  20562. private _effect;
  20563. private _samplers;
  20564. private _fragmentUrl;
  20565. private _vertexUrl;
  20566. private _parameters;
  20567. private _scaleRatio;
  20568. protected _indexParameters: any;
  20569. private _shareOutputWithPostProcess;
  20570. private _texelSize;
  20571. private _forcedOutputTexture;
  20572. /**
  20573. * Returns the fragment url or shader name used in the post process.
  20574. * @returns the fragment url or name in the shader store.
  20575. */
  20576. getEffectName(): string;
  20577. /**
  20578. * An event triggered when the postprocess is activated.
  20579. */
  20580. onActivateObservable: Observable<Camera>;
  20581. private _onActivateObserver;
  20582. /**
  20583. * A function that is added to the onActivateObservable
  20584. */
  20585. set onActivate(callback: Nullable<(camera: Camera) => void>);
  20586. /**
  20587. * An event triggered when the postprocess changes its size.
  20588. */
  20589. onSizeChangedObservable: Observable<PostProcess>;
  20590. private _onSizeChangedObserver;
  20591. /**
  20592. * A function that is added to the onSizeChangedObservable
  20593. */
  20594. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  20595. /**
  20596. * An event triggered when the postprocess applies its effect.
  20597. */
  20598. onApplyObservable: Observable<Effect>;
  20599. private _onApplyObserver;
  20600. /**
  20601. * A function that is added to the onApplyObservable
  20602. */
  20603. set onApply(callback: (effect: Effect) => void);
  20604. /**
  20605. * An event triggered before rendering the postprocess
  20606. */
  20607. onBeforeRenderObservable: Observable<Effect>;
  20608. private _onBeforeRenderObserver;
  20609. /**
  20610. * A function that is added to the onBeforeRenderObservable
  20611. */
  20612. set onBeforeRender(callback: (effect: Effect) => void);
  20613. /**
  20614. * An event triggered after rendering the postprocess
  20615. */
  20616. onAfterRenderObservable: Observable<Effect>;
  20617. private _onAfterRenderObserver;
  20618. /**
  20619. * A function that is added to the onAfterRenderObservable
  20620. */
  20621. set onAfterRender(callback: (efect: Effect) => void);
  20622. /**
  20623. * 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
  20624. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  20625. */
  20626. get inputTexture(): InternalTexture;
  20627. set inputTexture(value: InternalTexture);
  20628. /**
  20629. * Gets the camera which post process is applied to.
  20630. * @returns The camera the post process is applied to.
  20631. */
  20632. getCamera(): Camera;
  20633. /**
  20634. * Gets the texel size of the postprocess.
  20635. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  20636. */
  20637. get texelSize(): Vector2;
  20638. /**
  20639. * Creates a new instance PostProcess
  20640. * @param name The name of the PostProcess.
  20641. * @param fragmentUrl The url of the fragment shader to be used.
  20642. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  20643. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  20644. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  20645. * @param camera The camera to apply the render pass to.
  20646. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  20647. * @param engine The engine which the post process will be applied. (default: current engine)
  20648. * @param reusable If the post process can be reused on the same frame. (default: false)
  20649. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  20650. * @param textureType Type of textures used when performing the post process. (default: 0)
  20651. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  20652. * @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
  20653. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  20654. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  20655. */
  20656. constructor(
  20657. /** Name of the PostProcess. */
  20658. 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);
  20659. /**
  20660. * Gets a string idenfifying the name of the class
  20661. * @returns "PostProcess" string
  20662. */
  20663. getClassName(): string;
  20664. /**
  20665. * Gets the engine which this post process belongs to.
  20666. * @returns The engine the post process was enabled with.
  20667. */
  20668. getEngine(): Engine;
  20669. /**
  20670. * The effect that is created when initializing the post process.
  20671. * @returns The created effect corresponding the the postprocess.
  20672. */
  20673. getEffect(): Effect;
  20674. /**
  20675. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  20676. * @param postProcess The post process to share the output with.
  20677. * @returns This post process.
  20678. */
  20679. shareOutputWith(postProcess: PostProcess): PostProcess;
  20680. /**
  20681. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  20682. * This should be called if the post process that shares output with this post process is disabled/disposed.
  20683. */
  20684. useOwnOutput(): void;
  20685. /**
  20686. * Updates the effect with the current post process compile time values and recompiles the shader.
  20687. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  20688. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  20689. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  20690. * @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
  20691. * @param onCompiled Called when the shader has been compiled.
  20692. * @param onError Called if there is an error when compiling a shader.
  20693. * @param vertexUrl The url of the vertex shader to be used (default: the one given at construction time)
  20694. * @param fragmentUrl The url of the fragment shader to be used (default: the one given at construction time)
  20695. */
  20696. 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;
  20697. /**
  20698. * The post process is reusable if it can be used multiple times within one frame.
  20699. * @returns If the post process is reusable
  20700. */
  20701. isReusable(): boolean;
  20702. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  20703. markTextureDirty(): void;
  20704. /**
  20705. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  20706. * 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.
  20707. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  20708. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  20709. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  20710. * @returns The target texture that was bound to be written to.
  20711. */
  20712. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  20713. /**
  20714. * If the post process is supported.
  20715. */
  20716. get isSupported(): boolean;
  20717. /**
  20718. * The aspect ratio of the output texture.
  20719. */
  20720. get aspectRatio(): number;
  20721. /**
  20722. * Get a value indicating if the post-process is ready to be used
  20723. * @returns true if the post-process is ready (shader is compiled)
  20724. */
  20725. isReady(): boolean;
  20726. /**
  20727. * Binds all textures and uniforms to the shader, this will be run on every pass.
  20728. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  20729. */
  20730. apply(): Nullable<Effect>;
  20731. private _disposeTextures;
  20732. /**
  20733. * Disposes the post process.
  20734. * @param camera The camera to dispose the post process on.
  20735. */
  20736. dispose(camera?: Camera): void;
  20737. }
  20738. }
  20739. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration" {
  20740. /** @hidden */
  20741. export var kernelBlurVaryingDeclaration: {
  20742. name: string;
  20743. shader: string;
  20744. };
  20745. }
  20746. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment" {
  20747. /** @hidden */
  20748. export var kernelBlurFragment: {
  20749. name: string;
  20750. shader: string;
  20751. };
  20752. }
  20753. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2" {
  20754. /** @hidden */
  20755. export var kernelBlurFragment2: {
  20756. name: string;
  20757. shader: string;
  20758. };
  20759. }
  20760. declare module "babylonjs/Shaders/kernelBlur.fragment" {
  20761. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  20762. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  20763. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment";
  20764. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2";
  20765. /** @hidden */
  20766. export var kernelBlurPixelShader: {
  20767. name: string;
  20768. shader: string;
  20769. };
  20770. }
  20771. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVertex" {
  20772. /** @hidden */
  20773. export var kernelBlurVertex: {
  20774. name: string;
  20775. shader: string;
  20776. };
  20777. }
  20778. declare module "babylonjs/Shaders/kernelBlur.vertex" {
  20779. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  20780. import "babylonjs/Shaders/ShadersInclude/kernelBlurVertex";
  20781. /** @hidden */
  20782. export var kernelBlurVertexShader: {
  20783. name: string;
  20784. shader: string;
  20785. };
  20786. }
  20787. declare module "babylonjs/PostProcesses/blurPostProcess" {
  20788. import { Vector2 } from "babylonjs/Maths/math.vector";
  20789. import { Nullable } from "babylonjs/types";
  20790. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  20791. import { Camera } from "babylonjs/Cameras/camera";
  20792. import { Effect } from "babylonjs/Materials/effect";
  20793. import { Engine } from "babylonjs/Engines/engine";
  20794. import "babylonjs/Shaders/kernelBlur.fragment";
  20795. import "babylonjs/Shaders/kernelBlur.vertex";
  20796. /**
  20797. * The Blur Post Process which blurs an image based on a kernel and direction.
  20798. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  20799. */
  20800. export class BlurPostProcess extends PostProcess {
  20801. /** The direction in which to blur the image. */
  20802. direction: Vector2;
  20803. private blockCompilation;
  20804. protected _kernel: number;
  20805. protected _idealKernel: number;
  20806. protected _packedFloat: boolean;
  20807. private _staticDefines;
  20808. /**
  20809. * Sets the length in pixels of the blur sample region
  20810. */
  20811. set kernel(v: number);
  20812. /**
  20813. * Gets the length in pixels of the blur sample region
  20814. */
  20815. get kernel(): number;
  20816. /**
  20817. * Sets wether or not the blur needs to unpack/repack floats
  20818. */
  20819. set packedFloat(v: boolean);
  20820. /**
  20821. * Gets wether or not the blur is unpacking/repacking floats
  20822. */
  20823. get packedFloat(): boolean;
  20824. /**
  20825. * Creates a new instance BlurPostProcess
  20826. * @param name The name of the effect.
  20827. * @param direction The direction in which to blur the image.
  20828. * @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.
  20829. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  20830. * @param camera The camera to apply the render pass to.
  20831. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  20832. * @param engine The engine which the post process will be applied. (default: current engine)
  20833. * @param reusable If the post process can be reused on the same frame. (default: false)
  20834. * @param textureType Type of textures used when performing the post process. (default: 0)
  20835. * @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)
  20836. */
  20837. constructor(name: string,
  20838. /** The direction in which to blur the image. */
  20839. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  20840. /**
  20841. * Updates the effect with the current post process compile time values and recompiles the shader.
  20842. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  20843. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  20844. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  20845. * @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
  20846. * @param onCompiled Called when the shader has been compiled.
  20847. * @param onError Called if there is an error when compiling a shader.
  20848. */
  20849. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  20850. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  20851. /**
  20852. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  20853. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  20854. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  20855. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  20856. * The gaps between physical kernels are compensated for in the weighting of the samples
  20857. * @param idealKernel Ideal blur kernel.
  20858. * @return Nearest best kernel.
  20859. */
  20860. protected _nearestBestKernel(idealKernel: number): number;
  20861. /**
  20862. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  20863. * @param x The point on the Gaussian distribution to sample.
  20864. * @return the value of the Gaussian function at x.
  20865. */
  20866. protected _gaussianWeight(x: number): number;
  20867. /**
  20868. * Generates a string that can be used as a floating point number in GLSL.
  20869. * @param x Value to print.
  20870. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  20871. * @return GLSL float string.
  20872. */
  20873. protected _glslFloat(x: number, decimalFigures?: number): string;
  20874. }
  20875. }
  20876. declare module "babylonjs/Materials/Textures/mirrorTexture" {
  20877. import { Scene } from "babylonjs/scene";
  20878. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  20879. import { Plane } from "babylonjs/Maths/math.plane";
  20880. /**
  20881. * Mirror texture can be used to simulate the view from a mirror in a scene.
  20882. * It will dynamically be rendered every frame to adapt to the camera point of view.
  20883. * You can then easily use it as a reflectionTexture on a flat surface.
  20884. * In case the surface is not a plane, please consider relying on reflection probes.
  20885. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  20886. */
  20887. export class MirrorTexture extends RenderTargetTexture {
  20888. private scene;
  20889. /**
  20890. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  20891. * 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.
  20892. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  20893. */
  20894. mirrorPlane: Plane;
  20895. /**
  20896. * Define the blur ratio used to blur the reflection if needed.
  20897. */
  20898. set blurRatio(value: number);
  20899. get blurRatio(): number;
  20900. /**
  20901. * Define the adaptive blur kernel used to blur the reflection if needed.
  20902. * This will autocompute the closest best match for the `blurKernel`
  20903. */
  20904. set adaptiveBlurKernel(value: number);
  20905. /**
  20906. * Define the blur kernel used to blur the reflection if needed.
  20907. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  20908. */
  20909. set blurKernel(value: number);
  20910. /**
  20911. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  20912. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  20913. */
  20914. set blurKernelX(value: number);
  20915. get blurKernelX(): number;
  20916. /**
  20917. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  20918. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  20919. */
  20920. set blurKernelY(value: number);
  20921. get blurKernelY(): number;
  20922. private _autoComputeBlurKernel;
  20923. protected _onRatioRescale(): void;
  20924. private _updateGammaSpace;
  20925. private _imageProcessingConfigChangeObserver;
  20926. private _transformMatrix;
  20927. private _mirrorMatrix;
  20928. private _savedViewMatrix;
  20929. private _blurX;
  20930. private _blurY;
  20931. private _adaptiveBlurKernel;
  20932. private _blurKernelX;
  20933. private _blurKernelY;
  20934. private _blurRatio;
  20935. /**
  20936. * Instantiates a Mirror Texture.
  20937. * Mirror texture can be used to simulate the view from a mirror in a scene.
  20938. * It will dynamically be rendered every frame to adapt to the camera point of view.
  20939. * You can then easily use it as a reflectionTexture on a flat surface.
  20940. * In case the surface is not a plane, please consider relying on reflection probes.
  20941. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  20942. * @param name
  20943. * @param size
  20944. * @param scene
  20945. * @param generateMipMaps
  20946. * @param type
  20947. * @param samplingMode
  20948. * @param generateDepthBuffer
  20949. */
  20950. constructor(name: string, size: number | {
  20951. width: number;
  20952. height: number;
  20953. } | {
  20954. ratio: number;
  20955. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  20956. private _preparePostProcesses;
  20957. /**
  20958. * Clone the mirror texture.
  20959. * @returns the cloned texture
  20960. */
  20961. clone(): MirrorTexture;
  20962. /**
  20963. * Serialize the texture to a JSON representation you could use in Parse later on
  20964. * @returns the serialized JSON representation
  20965. */
  20966. serialize(): any;
  20967. /**
  20968. * Dispose the texture and release its associated resources.
  20969. */
  20970. dispose(): void;
  20971. }
  20972. }
  20973. declare module "babylonjs/Materials/Textures/texture" {
  20974. import { Observable } from "babylonjs/Misc/observable";
  20975. import { Nullable } from "babylonjs/types";
  20976. import { Matrix } from "babylonjs/Maths/math.vector";
  20977. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  20978. import { IInspectable } from "babylonjs/Misc/iInspectable";
  20979. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  20980. import { Scene } from "babylonjs/scene";
  20981. /**
  20982. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  20983. * @see http://doc.babylonjs.com/babylon101/materials#texture
  20984. */
  20985. export class Texture extends BaseTexture {
  20986. /**
  20987. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  20988. */
  20989. static SerializeBuffers: boolean;
  20990. /** @hidden */
  20991. static _CubeTextureParser: (jsonTexture: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => import("babylonjs/Materials/Textures/cubeTexture").CubeTexture;
  20992. /** @hidden */
  20993. static _CreateMirror: (name: string, renderTargetSize: number, scene: import("babylonjs/scene").Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/mirrorTexture").MirrorTexture;
  20994. /** @hidden */
  20995. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: import("babylonjs/scene").Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture;
  20996. /** nearest is mag = nearest and min = nearest and mip = linear */
  20997. static readonly NEAREST_SAMPLINGMODE: number;
  20998. /** nearest is mag = nearest and min = nearest and mip = linear */
  20999. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  21000. /** Bilinear is mag = linear and min = linear and mip = nearest */
  21001. static readonly BILINEAR_SAMPLINGMODE: number;
  21002. /** Bilinear is mag = linear and min = linear and mip = nearest */
  21003. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  21004. /** Trilinear is mag = linear and min = linear and mip = linear */
  21005. static readonly TRILINEAR_SAMPLINGMODE: number;
  21006. /** Trilinear is mag = linear and min = linear and mip = linear */
  21007. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  21008. /** mag = nearest and min = nearest and mip = nearest */
  21009. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  21010. /** mag = nearest and min = linear and mip = nearest */
  21011. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  21012. /** mag = nearest and min = linear and mip = linear */
  21013. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  21014. /** mag = nearest and min = linear and mip = none */
  21015. static readonly NEAREST_LINEAR: number;
  21016. /** mag = nearest and min = nearest and mip = none */
  21017. static readonly NEAREST_NEAREST: number;
  21018. /** mag = linear and min = nearest and mip = nearest */
  21019. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  21020. /** mag = linear and min = nearest and mip = linear */
  21021. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  21022. /** mag = linear and min = linear and mip = none */
  21023. static readonly LINEAR_LINEAR: number;
  21024. /** mag = linear and min = nearest and mip = none */
  21025. static readonly LINEAR_NEAREST: number;
  21026. /** Explicit coordinates mode */
  21027. static readonly EXPLICIT_MODE: number;
  21028. /** Spherical coordinates mode */
  21029. static readonly SPHERICAL_MODE: number;
  21030. /** Planar coordinates mode */
  21031. static readonly PLANAR_MODE: number;
  21032. /** Cubic coordinates mode */
  21033. static readonly CUBIC_MODE: number;
  21034. /** Projection coordinates mode */
  21035. static readonly PROJECTION_MODE: number;
  21036. /** Inverse Cubic coordinates mode */
  21037. static readonly SKYBOX_MODE: number;
  21038. /** Inverse Cubic coordinates mode */
  21039. static readonly INVCUBIC_MODE: number;
  21040. /** Equirectangular coordinates mode */
  21041. static readonly EQUIRECTANGULAR_MODE: number;
  21042. /** Equirectangular Fixed coordinates mode */
  21043. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  21044. /** Equirectangular Fixed Mirrored coordinates mode */
  21045. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  21046. /** Texture is not repeating outside of 0..1 UVs */
  21047. static readonly CLAMP_ADDRESSMODE: number;
  21048. /** Texture is repeating outside of 0..1 UVs */
  21049. static readonly WRAP_ADDRESSMODE: number;
  21050. /** Texture is repeating and mirrored */
  21051. static readonly MIRROR_ADDRESSMODE: number;
  21052. /**
  21053. * 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
  21054. */
  21055. static UseSerializedUrlIfAny: boolean;
  21056. /**
  21057. * Define the url of the texture.
  21058. */
  21059. url: Nullable<string>;
  21060. /**
  21061. * Define an offset on the texture to offset the u coordinates of the UVs
  21062. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  21063. */
  21064. uOffset: number;
  21065. /**
  21066. * Define an offset on the texture to offset the v coordinates of the UVs
  21067. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  21068. */
  21069. vOffset: number;
  21070. /**
  21071. * Define an offset on the texture to scale the u coordinates of the UVs
  21072. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  21073. */
  21074. uScale: number;
  21075. /**
  21076. * Define an offset on the texture to scale the v coordinates of the UVs
  21077. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  21078. */
  21079. vScale: number;
  21080. /**
  21081. * Define an offset on the texture to rotate around the u coordinates of the UVs
  21082. * @see http://doc.babylonjs.com/how_to/more_materials
  21083. */
  21084. uAng: number;
  21085. /**
  21086. * Define an offset on the texture to rotate around the v coordinates of the UVs
  21087. * @see http://doc.babylonjs.com/how_to/more_materials
  21088. */
  21089. vAng: number;
  21090. /**
  21091. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  21092. * @see http://doc.babylonjs.com/how_to/more_materials
  21093. */
  21094. wAng: number;
  21095. /**
  21096. * Defines the center of rotation (U)
  21097. */
  21098. uRotationCenter: number;
  21099. /**
  21100. * Defines the center of rotation (V)
  21101. */
  21102. vRotationCenter: number;
  21103. /**
  21104. * Defines the center of rotation (W)
  21105. */
  21106. wRotationCenter: number;
  21107. /**
  21108. * Are mip maps generated for this texture or not.
  21109. */
  21110. get noMipmap(): boolean;
  21111. /**
  21112. * List of inspectable custom properties (used by the Inspector)
  21113. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  21114. */
  21115. inspectableCustomProperties: Nullable<IInspectable[]>;
  21116. private _noMipmap;
  21117. /** @hidden */
  21118. _invertY: boolean;
  21119. private _rowGenerationMatrix;
  21120. private _cachedTextureMatrix;
  21121. private _projectionModeMatrix;
  21122. private _t0;
  21123. private _t1;
  21124. private _t2;
  21125. private _cachedUOffset;
  21126. private _cachedVOffset;
  21127. private _cachedUScale;
  21128. private _cachedVScale;
  21129. private _cachedUAng;
  21130. private _cachedVAng;
  21131. private _cachedWAng;
  21132. private _cachedProjectionMatrixId;
  21133. private _cachedCoordinatesMode;
  21134. /** @hidden */
  21135. protected _initialSamplingMode: number;
  21136. /** @hidden */
  21137. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  21138. private _deleteBuffer;
  21139. protected _format: Nullable<number>;
  21140. private _delayedOnLoad;
  21141. private _delayedOnError;
  21142. private _mimeType?;
  21143. /**
  21144. * Observable triggered once the texture has been loaded.
  21145. */
  21146. onLoadObservable: Observable<Texture>;
  21147. protected _isBlocking: boolean;
  21148. /**
  21149. * Is the texture preventing material to render while loading.
  21150. * If false, a default texture will be used instead of the loading one during the preparation step.
  21151. */
  21152. set isBlocking(value: boolean);
  21153. get isBlocking(): boolean;
  21154. /**
  21155. * Get the current sampling mode associated with the texture.
  21156. */
  21157. get samplingMode(): number;
  21158. /**
  21159. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  21160. */
  21161. get invertY(): boolean;
  21162. /**
  21163. * Instantiates a new texture.
  21164. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  21165. * @see http://doc.babylonjs.com/babylon101/materials#texture
  21166. * @param url defines the url of the picture to load as a texture
  21167. * @param sceneOrEngine defines the scene or engine the texture will belong to
  21168. * @param noMipmap defines if the texture will require mip maps or not
  21169. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  21170. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  21171. * @param onLoad defines a callback triggered when the texture has been loaded
  21172. * @param onError defines a callback triggered when an error occurred during the loading session
  21173. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  21174. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  21175. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  21176. * @param mimeType defines an optional mime type information
  21177. */
  21178. 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);
  21179. /**
  21180. * Update the url (and optional buffer) of this texture if url was null during construction.
  21181. * @param url the url of the texture
  21182. * @param buffer the buffer of the texture (defaults to null)
  21183. * @param onLoad callback called when the texture is loaded (defaults to null)
  21184. */
  21185. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  21186. /**
  21187. * Finish the loading sequence of a texture flagged as delayed load.
  21188. * @hidden
  21189. */
  21190. delayLoad(): void;
  21191. private _prepareRowForTextureGeneration;
  21192. /**
  21193. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  21194. * @returns the transform matrix of the texture.
  21195. */
  21196. getTextureMatrix(uBase?: number): Matrix;
  21197. /**
  21198. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  21199. * @returns The reflection texture transform
  21200. */
  21201. getReflectionTextureMatrix(): Matrix;
  21202. /**
  21203. * Clones the texture.
  21204. * @returns the cloned texture
  21205. */
  21206. clone(): Texture;
  21207. /**
  21208. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  21209. * @returns The JSON representation of the texture
  21210. */
  21211. serialize(): any;
  21212. /**
  21213. * Get the current class name of the texture useful for serialization or dynamic coding.
  21214. * @returns "Texture"
  21215. */
  21216. getClassName(): string;
  21217. /**
  21218. * Dispose the texture and release its associated resources.
  21219. */
  21220. dispose(): void;
  21221. /**
  21222. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  21223. * @param parsedTexture Define the JSON representation of the texture
  21224. * @param scene Define the scene the parsed texture should be instantiated in
  21225. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  21226. * @returns The parsed texture if successful
  21227. */
  21228. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  21229. /**
  21230. * Creates a texture from its base 64 representation.
  21231. * @param data Define the base64 payload without the data: prefix
  21232. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  21233. * @param scene Define the scene the texture should belong to
  21234. * @param noMipmap Forces the texture to not create mip map information if true
  21235. * @param invertY define if the texture needs to be inverted on the y axis during loading
  21236. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  21237. * @param onLoad define a callback triggered when the texture has been loaded
  21238. * @param onError define a callback triggered when an error occurred during the loading session
  21239. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  21240. * @returns the created texture
  21241. */
  21242. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  21243. /**
  21244. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  21245. * @param data Define the base64 payload without the data: prefix
  21246. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  21247. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  21248. * @param scene Define the scene the texture should belong to
  21249. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  21250. * @param noMipmap Forces the texture to not create mip map information if true
  21251. * @param invertY define if the texture needs to be inverted on the y axis during loading
  21252. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  21253. * @param onLoad define a callback triggered when the texture has been loaded
  21254. * @param onError define a callback triggered when an error occurred during the loading session
  21255. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  21256. * @returns the created texture
  21257. */
  21258. 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;
  21259. }
  21260. }
  21261. declare module "babylonjs/PostProcesses/postProcessManager" {
  21262. import { Nullable } from "babylonjs/types";
  21263. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  21264. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  21265. import { Scene } from "babylonjs/scene";
  21266. /**
  21267. * PostProcessManager is used to manage one or more post processes or post process pipelines
  21268. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  21269. */
  21270. export class PostProcessManager {
  21271. private _scene;
  21272. private _indexBuffer;
  21273. private _vertexBuffers;
  21274. /**
  21275. * Creates a new instance PostProcess
  21276. * @param scene The scene that the post process is associated with.
  21277. */
  21278. constructor(scene: Scene);
  21279. private _prepareBuffers;
  21280. private _buildIndexBuffer;
  21281. /**
  21282. * Rebuilds the vertex buffers of the manager.
  21283. * @hidden
  21284. */
  21285. _rebuild(): void;
  21286. /**
  21287. * Prepares a frame to be run through a post process.
  21288. * @param sourceTexture The input texture to the post procesess. (default: null)
  21289. * @param postProcesses An array of post processes to be run. (default: null)
  21290. * @returns True if the post processes were able to be run.
  21291. * @hidden
  21292. */
  21293. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  21294. /**
  21295. * Manually render a set of post processes to a texture.
  21296. * Please note, the frame buffer won't be unbound after the call in case you have more render to do.
  21297. * @param postProcesses An array of post processes to be run.
  21298. * @param targetTexture The target texture to render to.
  21299. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  21300. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  21301. * @param lodLevel defines which lod of the texture to render to
  21302. */
  21303. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  21304. /**
  21305. * Finalize the result of the output of the postprocesses.
  21306. * @param doNotPresent If true the result will not be displayed to the screen.
  21307. * @param targetTexture The target texture to render to.
  21308. * @param faceIndex The index of the face to bind the target texture to.
  21309. * @param postProcesses The array of post processes to render.
  21310. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  21311. * @hidden
  21312. */
  21313. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  21314. /**
  21315. * Disposes of the post process manager.
  21316. */
  21317. dispose(): void;
  21318. }
  21319. }
  21320. declare module "babylonjs/Materials/Textures/renderTargetTexture" {
  21321. import { Observable } from "babylonjs/Misc/observable";
  21322. import { SmartArray } from "babylonjs/Misc/smartArray";
  21323. import { Nullable, Immutable } from "babylonjs/types";
  21324. import { Camera } from "babylonjs/Cameras/camera";
  21325. import { Scene } from "babylonjs/scene";
  21326. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  21327. import { Color4 } from "babylonjs/Maths/math.color";
  21328. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  21329. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21330. import { SubMesh } from "babylonjs/Meshes/subMesh";
  21331. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  21332. import { Texture } from "babylonjs/Materials/Textures/texture";
  21333. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  21334. import { RenderingManager } from "babylonjs/Rendering/renderingManager";
  21335. import "babylonjs/Engines/Extensions/engine.renderTarget";
  21336. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  21337. import { Engine } from "babylonjs/Engines/engine";
  21338. /**
  21339. * This Helps creating a texture that will be created from a camera in your scene.
  21340. * It is basically a dynamic texture that could be used to create special effects for instance.
  21341. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  21342. */
  21343. export class RenderTargetTexture extends Texture {
  21344. isCube: boolean;
  21345. /**
  21346. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  21347. */
  21348. static readonly REFRESHRATE_RENDER_ONCE: number;
  21349. /**
  21350. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  21351. */
  21352. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  21353. /**
  21354. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  21355. * the central point of your effect and can save a lot of performances.
  21356. */
  21357. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  21358. /**
  21359. * Use this predicate to dynamically define the list of mesh you want to render.
  21360. * If set, the renderList property will be overwritten.
  21361. */
  21362. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  21363. private _renderList;
  21364. /**
  21365. * Use this list to define the list of mesh you want to render.
  21366. */
  21367. get renderList(): Nullable<Array<AbstractMesh>>;
  21368. set renderList(value: Nullable<Array<AbstractMesh>>);
  21369. /**
  21370. * Use this function to overload the renderList array at rendering time.
  21371. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  21372. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  21373. * the cube (if the RTT is a cube, else layerOrFace=0).
  21374. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  21375. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  21376. * hold dummy elements!
  21377. */
  21378. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  21379. private _hookArray;
  21380. /**
  21381. * Define if particles should be rendered in your texture.
  21382. */
  21383. renderParticles: boolean;
  21384. /**
  21385. * Define if sprites should be rendered in your texture.
  21386. */
  21387. renderSprites: boolean;
  21388. /**
  21389. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  21390. */
  21391. coordinatesMode: number;
  21392. /**
  21393. * Define the camera used to render the texture.
  21394. */
  21395. activeCamera: Nullable<Camera>;
  21396. /**
  21397. * Override the mesh isReady function with your own one.
  21398. */
  21399. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  21400. /**
  21401. * Override the render function of the texture with your own one.
  21402. */
  21403. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  21404. /**
  21405. * Define if camera post processes should be use while rendering the texture.
  21406. */
  21407. useCameraPostProcesses: boolean;
  21408. /**
  21409. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  21410. */
  21411. ignoreCameraViewport: boolean;
  21412. private _postProcessManager;
  21413. private _postProcesses;
  21414. private _resizeObserver;
  21415. /**
  21416. * An event triggered when the texture is unbind.
  21417. */
  21418. onBeforeBindObservable: Observable<RenderTargetTexture>;
  21419. /**
  21420. * An event triggered when the texture is unbind.
  21421. */
  21422. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  21423. private _onAfterUnbindObserver;
  21424. /**
  21425. * Set a after unbind callback in the texture.
  21426. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  21427. */
  21428. set onAfterUnbind(callback: () => void);
  21429. /**
  21430. * An event triggered before rendering the texture
  21431. */
  21432. onBeforeRenderObservable: Observable<number>;
  21433. private _onBeforeRenderObserver;
  21434. /**
  21435. * Set a before render callback in the texture.
  21436. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  21437. */
  21438. set onBeforeRender(callback: (faceIndex: number) => void);
  21439. /**
  21440. * An event triggered after rendering the texture
  21441. */
  21442. onAfterRenderObservable: Observable<number>;
  21443. private _onAfterRenderObserver;
  21444. /**
  21445. * Set a after render callback in the texture.
  21446. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  21447. */
  21448. set onAfterRender(callback: (faceIndex: number) => void);
  21449. /**
  21450. * An event triggered after the texture clear
  21451. */
  21452. onClearObservable: Observable<Engine>;
  21453. private _onClearObserver;
  21454. /**
  21455. * Set a clear callback in the texture.
  21456. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  21457. */
  21458. set onClear(callback: (Engine: Engine) => void);
  21459. /**
  21460. * An event triggered when the texture is resized.
  21461. */
  21462. onResizeObservable: Observable<RenderTargetTexture>;
  21463. /**
  21464. * Define the clear color of the Render Target if it should be different from the scene.
  21465. */
  21466. clearColor: Color4;
  21467. protected _size: number | {
  21468. width: number;
  21469. height: number;
  21470. layers?: number;
  21471. };
  21472. protected _initialSizeParameter: number | {
  21473. width: number;
  21474. height: number;
  21475. } | {
  21476. ratio: number;
  21477. };
  21478. protected _sizeRatio: Nullable<number>;
  21479. /** @hidden */
  21480. _generateMipMaps: boolean;
  21481. protected _renderingManager: RenderingManager;
  21482. /** @hidden */
  21483. _waitingRenderList: string[];
  21484. protected _doNotChangeAspectRatio: boolean;
  21485. protected _currentRefreshId: number;
  21486. protected _refreshRate: number;
  21487. protected _textureMatrix: Matrix;
  21488. protected _samples: number;
  21489. protected _renderTargetOptions: RenderTargetCreationOptions;
  21490. /**
  21491. * Gets render target creation options that were used.
  21492. */
  21493. get renderTargetOptions(): RenderTargetCreationOptions;
  21494. protected _onRatioRescale(): void;
  21495. /**
  21496. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  21497. * It must define where the camera used to render the texture is set
  21498. */
  21499. boundingBoxPosition: Vector3;
  21500. private _boundingBoxSize;
  21501. /**
  21502. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  21503. * When defined, the cubemap will switch to local mode
  21504. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  21505. * @example https://www.babylonjs-playground.com/#RNASML
  21506. */
  21507. set boundingBoxSize(value: Vector3);
  21508. get boundingBoxSize(): Vector3;
  21509. /**
  21510. * In case the RTT has been created with a depth texture, get the associated
  21511. * depth texture.
  21512. * Otherwise, return null.
  21513. */
  21514. get depthStencilTexture(): Nullable<InternalTexture>;
  21515. /**
  21516. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  21517. * or used a shadow, depth texture...
  21518. * @param name The friendly name of the texture
  21519. * @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)
  21520. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  21521. * @param generateMipMaps True if mip maps need to be generated after render.
  21522. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  21523. * @param type The type of the buffer in the RTT (int, half float, float...)
  21524. * @param isCube True if a cube texture needs to be created
  21525. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  21526. * @param generateDepthBuffer True to generate a depth buffer
  21527. * @param generateStencilBuffer True to generate a stencil buffer
  21528. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  21529. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  21530. * @param delayAllocation if the texture allocation should be delayed (default: false)
  21531. */
  21532. constructor(name: string, size: number | {
  21533. width: number;
  21534. height: number;
  21535. layers?: number;
  21536. } | {
  21537. ratio: number;
  21538. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  21539. /**
  21540. * Creates a depth stencil texture.
  21541. * This is only available in WebGL 2 or with the depth texture extension available.
  21542. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  21543. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  21544. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  21545. */
  21546. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  21547. private _processSizeParameter;
  21548. /**
  21549. * Define the number of samples to use in case of MSAA.
  21550. * It defaults to one meaning no MSAA has been enabled.
  21551. */
  21552. get samples(): number;
  21553. set samples(value: number);
  21554. /**
  21555. * Resets the refresh counter of the texture and start bak from scratch.
  21556. * Could be useful to regenerate the texture if it is setup to render only once.
  21557. */
  21558. resetRefreshCounter(): void;
  21559. /**
  21560. * Define the refresh rate of the texture or the rendering frequency.
  21561. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  21562. */
  21563. get refreshRate(): number;
  21564. set refreshRate(value: number);
  21565. /**
  21566. * Adds a post process to the render target rendering passes.
  21567. * @param postProcess define the post process to add
  21568. */
  21569. addPostProcess(postProcess: PostProcess): void;
  21570. /**
  21571. * Clear all the post processes attached to the render target
  21572. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  21573. */
  21574. clearPostProcesses(dispose?: boolean): void;
  21575. /**
  21576. * Remove one of the post process from the list of attached post processes to the texture
  21577. * @param postProcess define the post process to remove from the list
  21578. */
  21579. removePostProcess(postProcess: PostProcess): void;
  21580. /** @hidden */
  21581. _shouldRender(): boolean;
  21582. /**
  21583. * Gets the actual render size of the texture.
  21584. * @returns the width of the render size
  21585. */
  21586. getRenderSize(): number;
  21587. /**
  21588. * Gets the actual render width of the texture.
  21589. * @returns the width of the render size
  21590. */
  21591. getRenderWidth(): number;
  21592. /**
  21593. * Gets the actual render height of the texture.
  21594. * @returns the height of the render size
  21595. */
  21596. getRenderHeight(): number;
  21597. /**
  21598. * Gets the actual number of layers of the texture.
  21599. * @returns the number of layers
  21600. */
  21601. getRenderLayers(): number;
  21602. /**
  21603. * Get if the texture can be rescaled or not.
  21604. */
  21605. get canRescale(): boolean;
  21606. /**
  21607. * Resize the texture using a ratio.
  21608. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  21609. */
  21610. scale(ratio: number): void;
  21611. /**
  21612. * Get the texture reflection matrix used to rotate/transform the reflection.
  21613. * @returns the reflection matrix
  21614. */
  21615. getReflectionTextureMatrix(): Matrix;
  21616. /**
  21617. * Resize the texture to a new desired size.
  21618. * Be carrefull as it will recreate all the data in the new texture.
  21619. * @param size Define the new size. It can be:
  21620. * - a number for squared texture,
  21621. * - an object containing { width: number, height: number }
  21622. * - or an object containing a ratio { ratio: number }
  21623. */
  21624. resize(size: number | {
  21625. width: number;
  21626. height: number;
  21627. } | {
  21628. ratio: number;
  21629. }): void;
  21630. private _defaultRenderListPrepared;
  21631. /**
  21632. * Renders all the objects from the render list into the texture.
  21633. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  21634. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  21635. */
  21636. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  21637. private _bestReflectionRenderTargetDimension;
  21638. private _prepareRenderingManager;
  21639. /**
  21640. * @hidden
  21641. * @param faceIndex face index to bind to if this is a cubetexture
  21642. * @param layer defines the index of the texture to bind in the array
  21643. */
  21644. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  21645. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  21646. private renderToTarget;
  21647. /**
  21648. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  21649. * This allowed control for front to back rendering or reversly depending of the special needs.
  21650. *
  21651. * @param renderingGroupId The rendering group id corresponding to its index
  21652. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  21653. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  21654. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  21655. */
  21656. 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;
  21657. /**
  21658. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  21659. *
  21660. * @param renderingGroupId The rendering group id corresponding to its index
  21661. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  21662. */
  21663. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  21664. /**
  21665. * Clones the texture.
  21666. * @returns the cloned texture
  21667. */
  21668. clone(): RenderTargetTexture;
  21669. /**
  21670. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  21671. * @returns The JSON representation of the texture
  21672. */
  21673. serialize(): any;
  21674. /**
  21675. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  21676. */
  21677. disposeFramebufferObjects(): void;
  21678. /**
  21679. * Dispose the texture and release its associated resources.
  21680. */
  21681. dispose(): void;
  21682. /** @hidden */
  21683. _rebuild(): void;
  21684. /**
  21685. * Clear the info related to rendering groups preventing retention point in material dispose.
  21686. */
  21687. freeRenderingGroups(): void;
  21688. /**
  21689. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  21690. * @returns the view count
  21691. */
  21692. getViewCount(): number;
  21693. }
  21694. }
  21695. declare module "babylonjs/Misc/guid" {
  21696. /**
  21697. * Class used to manipulate GUIDs
  21698. */
  21699. export class GUID {
  21700. /**
  21701. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  21702. * Be aware Math.random() could cause collisions, but:
  21703. * "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"
  21704. * @returns a pseudo random id
  21705. */
  21706. static RandomId(): string;
  21707. }
  21708. }
  21709. declare module "babylonjs/Materials/shadowDepthWrapper" {
  21710. import { Nullable } from "babylonjs/types";
  21711. import { Scene } from "babylonjs/scene";
  21712. import { SubMesh } from "babylonjs/Meshes/subMesh";
  21713. import { Material } from "babylonjs/Materials/material";
  21714. import { Effect } from "babylonjs/Materials/effect";
  21715. import { ShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  21716. /**
  21717. * Options to be used when creating a shadow depth material
  21718. */
  21719. export interface IIOptionShadowDepthMaterial {
  21720. /** Variables in the vertex shader code that need to have their names remapped.
  21721. * The format is: ["var_name", "var_remapped_name", "var_name", "var_remapped_name", ...]
  21722. * "var_name" should be either: worldPos or vNormalW
  21723. * So, if the variable holding the world position in your vertex shader is not named worldPos, you must tell the system
  21724. * the name to use instead by using: ["worldPos", "myWorldPosVar"] assuming the variable is named myWorldPosVar in your code.
  21725. * If the normal must also be remapped: ["worldPos", "myWorldPosVar", "vNormalW", "myWorldNormal"]
  21726. */
  21727. remappedVariables?: string[];
  21728. /** Set standalone to true if the base material wrapped by ShadowDepthMaterial is not used for a regular object but for depth shadow generation only */
  21729. standalone?: boolean;
  21730. }
  21731. /**
  21732. * Class that can be used to wrap a base material to generate accurate shadows when using custom vertex/fragment code in the base material
  21733. */
  21734. export class ShadowDepthWrapper {
  21735. private _scene;
  21736. private _options?;
  21737. private _baseMaterial;
  21738. private _onEffectCreatedObserver;
  21739. private _subMeshToEffect;
  21740. private _subMeshToDepthEffect;
  21741. private _meshes;
  21742. /** @hidden */
  21743. _matriceNames: any;
  21744. /** Gets the standalone status of the wrapper */
  21745. get standalone(): boolean;
  21746. /** Gets the base material the wrapper is built upon */
  21747. get baseMaterial(): Material;
  21748. /**
  21749. * Instantiate a new shadow depth wrapper.
  21750. * It works by injecting some specific code in the vertex/fragment shaders of the base material and is used by a shadow generator to
  21751. * generate the shadow depth map. For more information, please refer to the documentation:
  21752. * https://doc.babylonjs.com/babylon101/shadows
  21753. * @param baseMaterial Material to wrap
  21754. * @param scene Define the scene the material belongs to
  21755. * @param options Options used to create the wrapper
  21756. */
  21757. constructor(baseMaterial: Material, scene: Scene, options?: IIOptionShadowDepthMaterial);
  21758. /**
  21759. * Gets the effect to use to generate the depth map
  21760. * @param subMesh subMesh to get the effect for
  21761. * @param shadowGenerator shadow generator to get the effect for
  21762. * @returns the effect to use to generate the depth map for the subMesh + shadow generator specified
  21763. */
  21764. getEffect(subMesh: Nullable<SubMesh>, shadowGenerator: ShadowGenerator): Nullable<Effect>;
  21765. /**
  21766. * Specifies that the submesh is ready to be used for depth rendering
  21767. * @param subMesh submesh to check
  21768. * @param defines the list of defines to take into account when checking the effect
  21769. * @param shadowGenerator combined with subMesh, it defines the effect to check
  21770. * @param useInstances specifies that instances should be used
  21771. * @returns a boolean indicating that the submesh is ready or not
  21772. */
  21773. isReadyForSubMesh(subMesh: SubMesh, defines: string[], shadowGenerator: ShadowGenerator, useInstances: boolean): boolean;
  21774. /**
  21775. * Disposes the resources
  21776. */
  21777. dispose(): void;
  21778. private _makeEffect;
  21779. }
  21780. }
  21781. declare module "babylonjs/Materials/material" {
  21782. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  21783. import { SmartArray } from "babylonjs/Misc/smartArray";
  21784. import { Observable } from "babylonjs/Misc/observable";
  21785. import { Nullable } from "babylonjs/types";
  21786. import { Scene } from "babylonjs/scene";
  21787. import { Matrix } from "babylonjs/Maths/math.vector";
  21788. import { BaseSubMesh, SubMesh } from "babylonjs/Meshes/subMesh";
  21789. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21790. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  21791. import { Effect } from "babylonjs/Materials/effect";
  21792. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21793. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  21794. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  21795. import { IInspectable } from "babylonjs/Misc/iInspectable";
  21796. import { ShadowDepthWrapper } from "babylonjs/Materials/shadowDepthWrapper";
  21797. import { Mesh } from "babylonjs/Meshes/mesh";
  21798. import { Animation } from "babylonjs/Animations/animation";
  21799. /**
  21800. * Options for compiling materials.
  21801. */
  21802. export interface IMaterialCompilationOptions {
  21803. /**
  21804. * Defines whether clip planes are enabled.
  21805. */
  21806. clipPlane: boolean;
  21807. /**
  21808. * Defines whether instances are enabled.
  21809. */
  21810. useInstances: boolean;
  21811. }
  21812. /**
  21813. * Base class for the main features of a material in Babylon.js
  21814. */
  21815. export class Material implements IAnimatable {
  21816. /**
  21817. * Returns the triangle fill mode
  21818. */
  21819. static readonly TriangleFillMode: number;
  21820. /**
  21821. * Returns the wireframe mode
  21822. */
  21823. static readonly WireFrameFillMode: number;
  21824. /**
  21825. * Returns the point fill mode
  21826. */
  21827. static readonly PointFillMode: number;
  21828. /**
  21829. * Returns the point list draw mode
  21830. */
  21831. static readonly PointListDrawMode: number;
  21832. /**
  21833. * Returns the line list draw mode
  21834. */
  21835. static readonly LineListDrawMode: number;
  21836. /**
  21837. * Returns the line loop draw mode
  21838. */
  21839. static readonly LineLoopDrawMode: number;
  21840. /**
  21841. * Returns the line strip draw mode
  21842. */
  21843. static readonly LineStripDrawMode: number;
  21844. /**
  21845. * Returns the triangle strip draw mode
  21846. */
  21847. static readonly TriangleStripDrawMode: number;
  21848. /**
  21849. * Returns the triangle fan draw mode
  21850. */
  21851. static readonly TriangleFanDrawMode: number;
  21852. /**
  21853. * Stores the clock-wise side orientation
  21854. */
  21855. static readonly ClockWiseSideOrientation: number;
  21856. /**
  21857. * Stores the counter clock-wise side orientation
  21858. */
  21859. static readonly CounterClockWiseSideOrientation: number;
  21860. /**
  21861. * The dirty texture flag value
  21862. */
  21863. static readonly TextureDirtyFlag: number;
  21864. /**
  21865. * The dirty light flag value
  21866. */
  21867. static readonly LightDirtyFlag: number;
  21868. /**
  21869. * The dirty fresnel flag value
  21870. */
  21871. static readonly FresnelDirtyFlag: number;
  21872. /**
  21873. * The dirty attribute flag value
  21874. */
  21875. static readonly AttributesDirtyFlag: number;
  21876. /**
  21877. * The dirty misc flag value
  21878. */
  21879. static readonly MiscDirtyFlag: number;
  21880. /**
  21881. * The all dirty flag value
  21882. */
  21883. static readonly AllDirtyFlag: number;
  21884. /**
  21885. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  21886. */
  21887. static readonly MATERIAL_OPAQUE: number;
  21888. /**
  21889. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  21890. */
  21891. static readonly MATERIAL_ALPHATEST: number;
  21892. /**
  21893. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  21894. */
  21895. static readonly MATERIAL_ALPHABLEND: number;
  21896. /**
  21897. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  21898. * They are also discarded below the alpha cutoff threshold to improve performances.
  21899. */
  21900. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  21901. /**
  21902. * Custom callback helping to override the default shader used in the material.
  21903. */
  21904. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: MaterialDefines | string[], attributes?: string[]) => string;
  21905. /**
  21906. * Custom shadow depth material to use for shadow rendering instead of the in-built one
  21907. */
  21908. shadowDepthWrapper: Nullable<ShadowDepthWrapper>;
  21909. /**
  21910. * The ID of the material
  21911. */
  21912. id: string;
  21913. /**
  21914. * Gets or sets the unique id of the material
  21915. */
  21916. uniqueId: number;
  21917. /**
  21918. * The name of the material
  21919. */
  21920. name: string;
  21921. /**
  21922. * Gets or sets user defined metadata
  21923. */
  21924. metadata: any;
  21925. /**
  21926. * For internal use only. Please do not use.
  21927. */
  21928. reservedDataStore: any;
  21929. /**
  21930. * Specifies if the ready state should be checked on each call
  21931. */
  21932. checkReadyOnEveryCall: boolean;
  21933. /**
  21934. * Specifies if the ready state should be checked once
  21935. */
  21936. checkReadyOnlyOnce: boolean;
  21937. /**
  21938. * The state of the material
  21939. */
  21940. state: string;
  21941. /**
  21942. * The alpha value of the material
  21943. */
  21944. protected _alpha: number;
  21945. /**
  21946. * List of inspectable custom properties (used by the Inspector)
  21947. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  21948. */
  21949. inspectableCustomProperties: IInspectable[];
  21950. /**
  21951. * Sets the alpha value of the material
  21952. */
  21953. set alpha(value: number);
  21954. /**
  21955. * Gets the alpha value of the material
  21956. */
  21957. get alpha(): number;
  21958. /**
  21959. * Specifies if back face culling is enabled
  21960. */
  21961. protected _backFaceCulling: boolean;
  21962. /**
  21963. * Sets the back-face culling state
  21964. */
  21965. set backFaceCulling(value: boolean);
  21966. /**
  21967. * Gets the back-face culling state
  21968. */
  21969. get backFaceCulling(): boolean;
  21970. /**
  21971. * Stores the value for side orientation
  21972. */
  21973. sideOrientation: number;
  21974. /**
  21975. * Callback triggered when the material is compiled
  21976. */
  21977. onCompiled: Nullable<(effect: Effect) => void>;
  21978. /**
  21979. * Callback triggered when an error occurs
  21980. */
  21981. onError: Nullable<(effect: Effect, errors: string) => void>;
  21982. /**
  21983. * Callback triggered to get the render target textures
  21984. */
  21985. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  21986. /**
  21987. * Gets a boolean indicating that current material needs to register RTT
  21988. */
  21989. get hasRenderTargetTextures(): boolean;
  21990. /**
  21991. * Specifies if the material should be serialized
  21992. */
  21993. doNotSerialize: boolean;
  21994. /**
  21995. * @hidden
  21996. */
  21997. _storeEffectOnSubMeshes: boolean;
  21998. /**
  21999. * Stores the animations for the material
  22000. */
  22001. animations: Nullable<Array<Animation>>;
  22002. /**
  22003. * An event triggered when the material is disposed
  22004. */
  22005. onDisposeObservable: Observable<Material>;
  22006. /**
  22007. * An observer which watches for dispose events
  22008. */
  22009. private _onDisposeObserver;
  22010. private _onUnBindObservable;
  22011. /**
  22012. * Called during a dispose event
  22013. */
  22014. set onDispose(callback: () => void);
  22015. private _onBindObservable;
  22016. /**
  22017. * An event triggered when the material is bound
  22018. */
  22019. get onBindObservable(): Observable<AbstractMesh>;
  22020. /**
  22021. * An observer which watches for bind events
  22022. */
  22023. private _onBindObserver;
  22024. /**
  22025. * Called during a bind event
  22026. */
  22027. set onBind(callback: (Mesh: AbstractMesh) => void);
  22028. /**
  22029. * An event triggered when the material is unbound
  22030. */
  22031. get onUnBindObservable(): Observable<Material>;
  22032. protected _onEffectCreatedObservable: Nullable<Observable<{
  22033. effect: Effect;
  22034. subMesh: Nullable<SubMesh>;
  22035. }>>;
  22036. /**
  22037. * An event triggered when the effect is (re)created
  22038. */
  22039. get onEffectCreatedObservable(): Observable<{
  22040. effect: Effect;
  22041. subMesh: Nullable<SubMesh>;
  22042. }>;
  22043. /**
  22044. * Stores the value of the alpha mode
  22045. */
  22046. private _alphaMode;
  22047. /**
  22048. * Sets the value of the alpha mode.
  22049. *
  22050. * | Value | Type | Description |
  22051. * | --- | --- | --- |
  22052. * | 0 | ALPHA_DISABLE | |
  22053. * | 1 | ALPHA_ADD | |
  22054. * | 2 | ALPHA_COMBINE | |
  22055. * | 3 | ALPHA_SUBTRACT | |
  22056. * | 4 | ALPHA_MULTIPLY | |
  22057. * | 5 | ALPHA_MAXIMIZED | |
  22058. * | 6 | ALPHA_ONEONE | |
  22059. * | 7 | ALPHA_PREMULTIPLIED | |
  22060. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  22061. * | 9 | ALPHA_INTERPOLATE | |
  22062. * | 10 | ALPHA_SCREENMODE | |
  22063. *
  22064. */
  22065. set alphaMode(value: number);
  22066. /**
  22067. * Gets the value of the alpha mode
  22068. */
  22069. get alphaMode(): number;
  22070. /**
  22071. * Stores the state of the need depth pre-pass value
  22072. */
  22073. private _needDepthPrePass;
  22074. /**
  22075. * Sets the need depth pre-pass value
  22076. */
  22077. set needDepthPrePass(value: boolean);
  22078. /**
  22079. * Gets the depth pre-pass value
  22080. */
  22081. get needDepthPrePass(): boolean;
  22082. /**
  22083. * Specifies if depth writing should be disabled
  22084. */
  22085. disableDepthWrite: boolean;
  22086. /**
  22087. * Specifies if color writing should be disabled
  22088. */
  22089. disableColorWrite: boolean;
  22090. /**
  22091. * Specifies if depth writing should be forced
  22092. */
  22093. forceDepthWrite: boolean;
  22094. /**
  22095. * Specifies the depth function that should be used. 0 means the default engine function
  22096. */
  22097. depthFunction: number;
  22098. /**
  22099. * Specifies if there should be a separate pass for culling
  22100. */
  22101. separateCullingPass: boolean;
  22102. /**
  22103. * Stores the state specifing if fog should be enabled
  22104. */
  22105. private _fogEnabled;
  22106. /**
  22107. * Sets the state for enabling fog
  22108. */
  22109. set fogEnabled(value: boolean);
  22110. /**
  22111. * Gets the value of the fog enabled state
  22112. */
  22113. get fogEnabled(): boolean;
  22114. /**
  22115. * Stores the size of points
  22116. */
  22117. pointSize: number;
  22118. /**
  22119. * Stores the z offset value
  22120. */
  22121. zOffset: number;
  22122. get wireframe(): boolean;
  22123. /**
  22124. * Sets the state of wireframe mode
  22125. */
  22126. set wireframe(value: boolean);
  22127. /**
  22128. * Gets the value specifying if point clouds are enabled
  22129. */
  22130. get pointsCloud(): boolean;
  22131. /**
  22132. * Sets the state of point cloud mode
  22133. */
  22134. set pointsCloud(value: boolean);
  22135. /**
  22136. * Gets the material fill mode
  22137. */
  22138. get fillMode(): number;
  22139. /**
  22140. * Sets the material fill mode
  22141. */
  22142. set fillMode(value: number);
  22143. /**
  22144. * @hidden
  22145. * Stores the effects for the material
  22146. */
  22147. _effect: Nullable<Effect>;
  22148. /**
  22149. * Specifies if uniform buffers should be used
  22150. */
  22151. private _useUBO;
  22152. /**
  22153. * Stores a reference to the scene
  22154. */
  22155. private _scene;
  22156. /**
  22157. * Stores the fill mode state
  22158. */
  22159. private _fillMode;
  22160. /**
  22161. * Specifies if the depth write state should be cached
  22162. */
  22163. private _cachedDepthWriteState;
  22164. /**
  22165. * Specifies if the color write state should be cached
  22166. */
  22167. private _cachedColorWriteState;
  22168. /**
  22169. * Specifies if the depth function state should be cached
  22170. */
  22171. private _cachedDepthFunctionState;
  22172. /**
  22173. * Stores the uniform buffer
  22174. */
  22175. protected _uniformBuffer: UniformBuffer;
  22176. /** @hidden */
  22177. _indexInSceneMaterialArray: number;
  22178. /** @hidden */
  22179. meshMap: Nullable<{
  22180. [id: string]: AbstractMesh | undefined;
  22181. }>;
  22182. /**
  22183. * Creates a material instance
  22184. * @param name defines the name of the material
  22185. * @param scene defines the scene to reference
  22186. * @param doNotAdd specifies if the material should be added to the scene
  22187. */
  22188. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  22189. /**
  22190. * Returns a string representation of the current material
  22191. * @param fullDetails defines a boolean indicating which levels of logging is desired
  22192. * @returns a string with material information
  22193. */
  22194. toString(fullDetails?: boolean): string;
  22195. /**
  22196. * Gets the class name of the material
  22197. * @returns a string with the class name of the material
  22198. */
  22199. getClassName(): string;
  22200. /**
  22201. * Specifies if updates for the material been locked
  22202. */
  22203. get isFrozen(): boolean;
  22204. /**
  22205. * Locks updates for the material
  22206. */
  22207. freeze(): void;
  22208. /**
  22209. * Unlocks updates for the material
  22210. */
  22211. unfreeze(): void;
  22212. /**
  22213. * Specifies if the material is ready to be used
  22214. * @param mesh defines the mesh to check
  22215. * @param useInstances specifies if instances should be used
  22216. * @returns a boolean indicating if the material is ready to be used
  22217. */
  22218. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  22219. /**
  22220. * Specifies that the submesh is ready to be used
  22221. * @param mesh defines the mesh to check
  22222. * @param subMesh defines which submesh to check
  22223. * @param useInstances specifies that instances should be used
  22224. * @returns a boolean indicating that the submesh is ready or not
  22225. */
  22226. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  22227. /**
  22228. * Returns the material effect
  22229. * @returns the effect associated with the material
  22230. */
  22231. getEffect(): Nullable<Effect>;
  22232. /**
  22233. * Returns the current scene
  22234. * @returns a Scene
  22235. */
  22236. getScene(): Scene;
  22237. /**
  22238. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  22239. */
  22240. protected _forceAlphaTest: boolean;
  22241. /**
  22242. * The transparency mode of the material.
  22243. */
  22244. protected _transparencyMode: Nullable<number>;
  22245. /**
  22246. * Gets the current transparency mode.
  22247. */
  22248. get transparencyMode(): Nullable<number>;
  22249. /**
  22250. * Sets the transparency mode of the material.
  22251. *
  22252. * | Value | Type | Description |
  22253. * | ----- | ----------------------------------- | ----------- |
  22254. * | 0 | OPAQUE | |
  22255. * | 1 | ALPHATEST | |
  22256. * | 2 | ALPHABLEND | |
  22257. * | 3 | ALPHATESTANDBLEND | |
  22258. *
  22259. */
  22260. set transparencyMode(value: Nullable<number>);
  22261. /**
  22262. * Returns true if alpha blending should be disabled.
  22263. */
  22264. protected get _disableAlphaBlending(): boolean;
  22265. /**
  22266. * Specifies whether or not this material should be rendered in alpha blend mode.
  22267. * @returns a boolean specifying if alpha blending is needed
  22268. */
  22269. needAlphaBlending(): boolean;
  22270. /**
  22271. * Specifies if the mesh will require alpha blending
  22272. * @param mesh defines the mesh to check
  22273. * @returns a boolean specifying if alpha blending is needed for the mesh
  22274. */
  22275. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  22276. /**
  22277. * Specifies whether or not this material should be rendered in alpha test mode.
  22278. * @returns a boolean specifying if an alpha test is needed.
  22279. */
  22280. needAlphaTesting(): boolean;
  22281. /**
  22282. * Specifies if material alpha testing should be turned on for the mesh
  22283. * @param mesh defines the mesh to check
  22284. */
  22285. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  22286. /**
  22287. * Gets the texture used for the alpha test
  22288. * @returns the texture to use for alpha testing
  22289. */
  22290. getAlphaTestTexture(): Nullable<BaseTexture>;
  22291. /**
  22292. * Marks the material to indicate that it needs to be re-calculated
  22293. */
  22294. markDirty(): void;
  22295. /** @hidden */
  22296. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  22297. /**
  22298. * Binds the material to the mesh
  22299. * @param world defines the world transformation matrix
  22300. * @param mesh defines the mesh to bind the material to
  22301. */
  22302. bind(world: Matrix, mesh?: Mesh): void;
  22303. /**
  22304. * Binds the submesh to the material
  22305. * @param world defines the world transformation matrix
  22306. * @param mesh defines the mesh containing the submesh
  22307. * @param subMesh defines the submesh to bind the material to
  22308. */
  22309. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  22310. /**
  22311. * Binds the world matrix to the material
  22312. * @param world defines the world transformation matrix
  22313. */
  22314. bindOnlyWorldMatrix(world: Matrix): void;
  22315. /**
  22316. * Binds the scene's uniform buffer to the effect.
  22317. * @param effect defines the effect to bind to the scene uniform buffer
  22318. * @param sceneUbo defines the uniform buffer storing scene data
  22319. */
  22320. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  22321. /**
  22322. * Binds the view matrix to the effect
  22323. * @param effect defines the effect to bind the view matrix to
  22324. */
  22325. bindView(effect: Effect): void;
  22326. /**
  22327. * Binds the view projection matrix to the effect
  22328. * @param effect defines the effect to bind the view projection matrix to
  22329. */
  22330. bindViewProjection(effect: Effect): void;
  22331. /**
  22332. * Processes to execute after binding the material to a mesh
  22333. * @param mesh defines the rendered mesh
  22334. */
  22335. protected _afterBind(mesh?: Mesh): void;
  22336. /**
  22337. * Unbinds the material from the mesh
  22338. */
  22339. unbind(): void;
  22340. /**
  22341. * Gets the active textures from the material
  22342. * @returns an array of textures
  22343. */
  22344. getActiveTextures(): BaseTexture[];
  22345. /**
  22346. * Specifies if the material uses a texture
  22347. * @param texture defines the texture to check against the material
  22348. * @returns a boolean specifying if the material uses the texture
  22349. */
  22350. hasTexture(texture: BaseTexture): boolean;
  22351. /**
  22352. * Makes a duplicate of the material, and gives it a new name
  22353. * @param name defines the new name for the duplicated material
  22354. * @returns the cloned material
  22355. */
  22356. clone(name: string): Nullable<Material>;
  22357. /**
  22358. * Gets the meshes bound to the material
  22359. * @returns an array of meshes bound to the material
  22360. */
  22361. getBindedMeshes(): AbstractMesh[];
  22362. /**
  22363. * Force shader compilation
  22364. * @param mesh defines the mesh associated with this material
  22365. * @param onCompiled defines a function to execute once the material is compiled
  22366. * @param options defines the options to configure the compilation
  22367. * @param onError defines a function to execute if the material fails compiling
  22368. */
  22369. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  22370. /**
  22371. * Force shader compilation
  22372. * @param mesh defines the mesh that will use this material
  22373. * @param options defines additional options for compiling the shaders
  22374. * @returns a promise that resolves when the compilation completes
  22375. */
  22376. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  22377. private static readonly _AllDirtyCallBack;
  22378. private static readonly _ImageProcessingDirtyCallBack;
  22379. private static readonly _TextureDirtyCallBack;
  22380. private static readonly _FresnelDirtyCallBack;
  22381. private static readonly _MiscDirtyCallBack;
  22382. private static readonly _LightsDirtyCallBack;
  22383. private static readonly _AttributeDirtyCallBack;
  22384. private static _FresnelAndMiscDirtyCallBack;
  22385. private static _TextureAndMiscDirtyCallBack;
  22386. private static readonly _DirtyCallbackArray;
  22387. private static readonly _RunDirtyCallBacks;
  22388. /**
  22389. * Marks a define in the material to indicate that it needs to be re-computed
  22390. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  22391. */
  22392. markAsDirty(flag: number): void;
  22393. /**
  22394. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  22395. * @param func defines a function which checks material defines against the submeshes
  22396. */
  22397. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  22398. /**
  22399. * Indicates that we need to re-calculated for all submeshes
  22400. */
  22401. protected _markAllSubMeshesAsAllDirty(): void;
  22402. /**
  22403. * Indicates that image processing needs to be re-calculated for all submeshes
  22404. */
  22405. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  22406. /**
  22407. * Indicates that textures need to be re-calculated for all submeshes
  22408. */
  22409. protected _markAllSubMeshesAsTexturesDirty(): void;
  22410. /**
  22411. * Indicates that fresnel needs to be re-calculated for all submeshes
  22412. */
  22413. protected _markAllSubMeshesAsFresnelDirty(): void;
  22414. /**
  22415. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  22416. */
  22417. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  22418. /**
  22419. * Indicates that lights need to be re-calculated for all submeshes
  22420. */
  22421. protected _markAllSubMeshesAsLightsDirty(): void;
  22422. /**
  22423. * Indicates that attributes need to be re-calculated for all submeshes
  22424. */
  22425. protected _markAllSubMeshesAsAttributesDirty(): void;
  22426. /**
  22427. * Indicates that misc needs to be re-calculated for all submeshes
  22428. */
  22429. protected _markAllSubMeshesAsMiscDirty(): void;
  22430. /**
  22431. * Indicates that textures and misc need to be re-calculated for all submeshes
  22432. */
  22433. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  22434. /**
  22435. * Disposes the material
  22436. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  22437. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  22438. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  22439. */
  22440. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  22441. /** @hidden */
  22442. private releaseVertexArrayObject;
  22443. /**
  22444. * Serializes this material
  22445. * @returns the serialized material object
  22446. */
  22447. serialize(): any;
  22448. /**
  22449. * Creates a material from parsed material data
  22450. * @param parsedMaterial defines parsed material data
  22451. * @param scene defines the hosting scene
  22452. * @param rootUrl defines the root URL to use to load textures
  22453. * @returns a new material
  22454. */
  22455. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  22456. }
  22457. }
  22458. declare module "babylonjs/Materials/multiMaterial" {
  22459. import { Nullable } from "babylonjs/types";
  22460. import { Scene } from "babylonjs/scene";
  22461. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22462. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  22463. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  22464. import { Material } from "babylonjs/Materials/material";
  22465. /**
  22466. * A multi-material is used to apply different materials to different parts of the same object without the need of
  22467. * separate meshes. This can be use to improve performances.
  22468. * @see http://doc.babylonjs.com/how_to/multi_materials
  22469. */
  22470. export class MultiMaterial extends Material {
  22471. private _subMaterials;
  22472. /**
  22473. * Gets or Sets the list of Materials used within the multi material.
  22474. * They need to be ordered according to the submeshes order in the associated mesh
  22475. */
  22476. get subMaterials(): Nullable<Material>[];
  22477. set subMaterials(value: Nullable<Material>[]);
  22478. /**
  22479. * Function used to align with Node.getChildren()
  22480. * @returns the list of Materials used within the multi material
  22481. */
  22482. getChildren(): Nullable<Material>[];
  22483. /**
  22484. * Instantiates a new Multi Material
  22485. * A multi-material is used to apply different materials to different parts of the same object without the need of
  22486. * separate meshes. This can be use to improve performances.
  22487. * @see http://doc.babylonjs.com/how_to/multi_materials
  22488. * @param name Define the name in the scene
  22489. * @param scene Define the scene the material belongs to
  22490. */
  22491. constructor(name: string, scene: Scene);
  22492. private _hookArray;
  22493. /**
  22494. * Get one of the submaterial by its index in the submaterials array
  22495. * @param index The index to look the sub material at
  22496. * @returns The Material if the index has been defined
  22497. */
  22498. getSubMaterial(index: number): Nullable<Material>;
  22499. /**
  22500. * Get the list of active textures for the whole sub materials list.
  22501. * @returns All the textures that will be used during the rendering
  22502. */
  22503. getActiveTextures(): BaseTexture[];
  22504. /**
  22505. * Gets the current class name of the material e.g. "MultiMaterial"
  22506. * Mainly use in serialization.
  22507. * @returns the class name
  22508. */
  22509. getClassName(): string;
  22510. /**
  22511. * Checks if the material is ready to render the requested sub mesh
  22512. * @param mesh Define the mesh the submesh belongs to
  22513. * @param subMesh Define the sub mesh to look readyness for
  22514. * @param useInstances Define whether or not the material is used with instances
  22515. * @returns true if ready, otherwise false
  22516. */
  22517. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  22518. /**
  22519. * Clones the current material and its related sub materials
  22520. * @param name Define the name of the newly cloned material
  22521. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  22522. * @returns the cloned material
  22523. */
  22524. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  22525. /**
  22526. * Serializes the materials into a JSON representation.
  22527. * @returns the JSON representation
  22528. */
  22529. serialize(): any;
  22530. /**
  22531. * Dispose the material and release its associated resources
  22532. * @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)
  22533. * @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)
  22534. * @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)
  22535. */
  22536. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  22537. /**
  22538. * Creates a MultiMaterial from parsed MultiMaterial data.
  22539. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  22540. * @param scene defines the hosting scene
  22541. * @returns a new MultiMaterial
  22542. */
  22543. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  22544. }
  22545. }
  22546. declare module "babylonjs/Meshes/subMesh" {
  22547. import { Nullable, IndicesArray, DeepImmutable, FloatArray } from "babylonjs/types";
  22548. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  22549. import { Engine } from "babylonjs/Engines/engine";
  22550. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  22551. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  22552. import { Effect } from "babylonjs/Materials/effect";
  22553. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  22554. import { Plane } from "babylonjs/Maths/math.plane";
  22555. import { Collider } from "babylonjs/Collisions/collider";
  22556. import { Material } from "babylonjs/Materials/material";
  22557. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  22558. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22559. import { Mesh } from "babylonjs/Meshes/mesh";
  22560. import { Ray } from "babylonjs/Culling/ray";
  22561. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  22562. /**
  22563. * Base class for submeshes
  22564. */
  22565. export class BaseSubMesh {
  22566. /** @hidden */
  22567. _materialDefines: Nullable<MaterialDefines>;
  22568. /** @hidden */
  22569. _materialEffect: Nullable<Effect>;
  22570. /** @hidden */
  22571. _effectOverride: Nullable<Effect>;
  22572. /**
  22573. * Gets material defines used by the effect associated to the sub mesh
  22574. */
  22575. get materialDefines(): Nullable<MaterialDefines>;
  22576. /**
  22577. * Sets material defines used by the effect associated to the sub mesh
  22578. */
  22579. set materialDefines(defines: Nullable<MaterialDefines>);
  22580. /**
  22581. * Gets associated effect
  22582. */
  22583. get effect(): Nullable<Effect>;
  22584. /**
  22585. * Sets associated effect (effect used to render this submesh)
  22586. * @param effect defines the effect to associate with
  22587. * @param defines defines the set of defines used to compile this effect
  22588. */
  22589. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  22590. }
  22591. /**
  22592. * Defines a subdivision inside a mesh
  22593. */
  22594. export class SubMesh extends BaseSubMesh implements ICullable {
  22595. /** the material index to use */
  22596. materialIndex: number;
  22597. /** vertex index start */
  22598. verticesStart: number;
  22599. /** vertices count */
  22600. verticesCount: number;
  22601. /** index start */
  22602. indexStart: number;
  22603. /** indices count */
  22604. indexCount: number;
  22605. /** @hidden */
  22606. _linesIndexCount: number;
  22607. private _mesh;
  22608. private _renderingMesh;
  22609. private _boundingInfo;
  22610. private _linesIndexBuffer;
  22611. /** @hidden */
  22612. _lastColliderWorldVertices: Nullable<Vector3[]>;
  22613. /** @hidden */
  22614. _trianglePlanes: Plane[];
  22615. /** @hidden */
  22616. _lastColliderTransformMatrix: Nullable<Matrix>;
  22617. /** @hidden */
  22618. _renderId: number;
  22619. /** @hidden */
  22620. _alphaIndex: number;
  22621. /** @hidden */
  22622. _distanceToCamera: number;
  22623. /** @hidden */
  22624. _id: number;
  22625. private _currentMaterial;
  22626. /**
  22627. * Add a new submesh to a mesh
  22628. * @param materialIndex defines the material index to use
  22629. * @param verticesStart defines vertex index start
  22630. * @param verticesCount defines vertices count
  22631. * @param indexStart defines index start
  22632. * @param indexCount defines indices count
  22633. * @param mesh defines the parent mesh
  22634. * @param renderingMesh defines an optional rendering mesh
  22635. * @param createBoundingBox defines if bounding box should be created for this submesh
  22636. * @returns the new submesh
  22637. */
  22638. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  22639. /**
  22640. * Creates a new submesh
  22641. * @param materialIndex defines the material index to use
  22642. * @param verticesStart defines vertex index start
  22643. * @param verticesCount defines vertices count
  22644. * @param indexStart defines index start
  22645. * @param indexCount defines indices count
  22646. * @param mesh defines the parent mesh
  22647. * @param renderingMesh defines an optional rendering mesh
  22648. * @param createBoundingBox defines if bounding box should be created for this submesh
  22649. */
  22650. constructor(
  22651. /** the material index to use */
  22652. materialIndex: number,
  22653. /** vertex index start */
  22654. verticesStart: number,
  22655. /** vertices count */
  22656. verticesCount: number,
  22657. /** index start */
  22658. indexStart: number,
  22659. /** indices count */
  22660. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  22661. /**
  22662. * Returns true if this submesh covers the entire parent mesh
  22663. * @ignorenaming
  22664. */
  22665. get IsGlobal(): boolean;
  22666. /**
  22667. * Returns the submesh BoudingInfo object
  22668. * @returns current bounding info (or mesh's one if the submesh is global)
  22669. */
  22670. getBoundingInfo(): BoundingInfo;
  22671. /**
  22672. * Sets the submesh BoundingInfo
  22673. * @param boundingInfo defines the new bounding info to use
  22674. * @returns the SubMesh
  22675. */
  22676. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  22677. /**
  22678. * Returns the mesh of the current submesh
  22679. * @return the parent mesh
  22680. */
  22681. getMesh(): AbstractMesh;
  22682. /**
  22683. * Returns the rendering mesh of the submesh
  22684. * @returns the rendering mesh (could be different from parent mesh)
  22685. */
  22686. getRenderingMesh(): Mesh;
  22687. /**
  22688. * Returns the submesh material
  22689. * @returns null or the current material
  22690. */
  22691. getMaterial(): Nullable<Material>;
  22692. /**
  22693. * Sets a new updated BoundingInfo object to the submesh
  22694. * @param data defines an optional position array to use to determine the bounding info
  22695. * @returns the SubMesh
  22696. */
  22697. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  22698. /** @hidden */
  22699. _checkCollision(collider: Collider): boolean;
  22700. /**
  22701. * Updates the submesh BoundingInfo
  22702. * @param world defines the world matrix to use to update the bounding info
  22703. * @returns the submesh
  22704. */
  22705. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  22706. /**
  22707. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  22708. * @param frustumPlanes defines the frustum planes
  22709. * @returns true if the submesh is intersecting with the frustum
  22710. */
  22711. isInFrustum(frustumPlanes: Plane[]): boolean;
  22712. /**
  22713. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  22714. * @param frustumPlanes defines the frustum planes
  22715. * @returns true if the submesh is inside the frustum
  22716. */
  22717. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  22718. /**
  22719. * Renders the submesh
  22720. * @param enableAlphaMode defines if alpha needs to be used
  22721. * @returns the submesh
  22722. */
  22723. render(enableAlphaMode: boolean): SubMesh;
  22724. /**
  22725. * @hidden
  22726. */
  22727. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  22728. /**
  22729. * Checks if the submesh intersects with a ray
  22730. * @param ray defines the ray to test
  22731. * @returns true is the passed ray intersects the submesh bounding box
  22732. */
  22733. canIntersects(ray: Ray): boolean;
  22734. /**
  22735. * Intersects current submesh with a ray
  22736. * @param ray defines the ray to test
  22737. * @param positions defines mesh's positions array
  22738. * @param indices defines mesh's indices array
  22739. * @param fastCheck defines if the first intersection will be used (and not the closest)
  22740. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  22741. * @returns intersection info or null if no intersection
  22742. */
  22743. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  22744. /** @hidden */
  22745. private _intersectLines;
  22746. /** @hidden */
  22747. private _intersectUnIndexedLines;
  22748. /** @hidden */
  22749. private _intersectTriangles;
  22750. /** @hidden */
  22751. private _intersectUnIndexedTriangles;
  22752. /** @hidden */
  22753. _rebuild(): void;
  22754. /**
  22755. * Creates a new submesh from the passed mesh
  22756. * @param newMesh defines the new hosting mesh
  22757. * @param newRenderingMesh defines an optional rendering mesh
  22758. * @returns the new submesh
  22759. */
  22760. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  22761. /**
  22762. * Release associated resources
  22763. */
  22764. dispose(): void;
  22765. /**
  22766. * Gets the class name
  22767. * @returns the string "SubMesh".
  22768. */
  22769. getClassName(): string;
  22770. /**
  22771. * Creates a new submesh from indices data
  22772. * @param materialIndex the index of the main mesh material
  22773. * @param startIndex the index where to start the copy in the mesh indices array
  22774. * @param indexCount the number of indices to copy then from the startIndex
  22775. * @param mesh the main mesh to create the submesh from
  22776. * @param renderingMesh the optional rendering mesh
  22777. * @returns a new submesh
  22778. */
  22779. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  22780. }
  22781. }
  22782. declare module "babylonjs/Loading/sceneLoaderFlags" {
  22783. /**
  22784. * Class used to represent data loading progression
  22785. */
  22786. export class SceneLoaderFlags {
  22787. private static _ForceFullSceneLoadingForIncremental;
  22788. private static _ShowLoadingScreen;
  22789. private static _CleanBoneMatrixWeights;
  22790. private static _loggingLevel;
  22791. /**
  22792. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  22793. */
  22794. static get ForceFullSceneLoadingForIncremental(): boolean;
  22795. static set ForceFullSceneLoadingForIncremental(value: boolean);
  22796. /**
  22797. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  22798. */
  22799. static get ShowLoadingScreen(): boolean;
  22800. static set ShowLoadingScreen(value: boolean);
  22801. /**
  22802. * Defines the current logging level (while loading the scene)
  22803. * @ignorenaming
  22804. */
  22805. static get loggingLevel(): number;
  22806. static set loggingLevel(value: number);
  22807. /**
  22808. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  22809. */
  22810. static get CleanBoneMatrixWeights(): boolean;
  22811. static set CleanBoneMatrixWeights(value: boolean);
  22812. }
  22813. }
  22814. declare module "babylonjs/Meshes/geometry" {
  22815. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  22816. import { Scene } from "babylonjs/scene";
  22817. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  22818. import { Engine } from "babylonjs/Engines/engine";
  22819. import { IGetSetVerticesData, VertexData } from "babylonjs/Meshes/mesh.vertexData";
  22820. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  22821. import { Effect } from "babylonjs/Materials/effect";
  22822. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  22823. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  22824. import { Mesh } from "babylonjs/Meshes/mesh";
  22825. /**
  22826. * Class used to store geometry data (vertex buffers + index buffer)
  22827. */
  22828. export class Geometry implements IGetSetVerticesData {
  22829. /**
  22830. * Gets or sets the ID of the geometry
  22831. */
  22832. id: string;
  22833. /**
  22834. * Gets or sets the unique ID of the geometry
  22835. */
  22836. uniqueId: number;
  22837. /**
  22838. * Gets the delay loading state of the geometry (none by default which means not delayed)
  22839. */
  22840. delayLoadState: number;
  22841. /**
  22842. * Gets the file containing the data to load when running in delay load state
  22843. */
  22844. delayLoadingFile: Nullable<string>;
  22845. /**
  22846. * Callback called when the geometry is updated
  22847. */
  22848. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  22849. private _scene;
  22850. private _engine;
  22851. private _meshes;
  22852. private _totalVertices;
  22853. /** @hidden */
  22854. _indices: IndicesArray;
  22855. /** @hidden */
  22856. _vertexBuffers: {
  22857. [key: string]: VertexBuffer;
  22858. };
  22859. private _isDisposed;
  22860. private _extend;
  22861. private _boundingBias;
  22862. /** @hidden */
  22863. _delayInfo: Array<string>;
  22864. private _indexBuffer;
  22865. private _indexBufferIsUpdatable;
  22866. /** @hidden */
  22867. _boundingInfo: Nullable<BoundingInfo>;
  22868. /** @hidden */
  22869. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  22870. /** @hidden */
  22871. _softwareSkinningFrameId: number;
  22872. private _vertexArrayObjects;
  22873. private _updatable;
  22874. /** @hidden */
  22875. _positions: Nullable<Vector3[]>;
  22876. /**
  22877. * 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
  22878. */
  22879. get boundingBias(): Vector2;
  22880. /**
  22881. * 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
  22882. */
  22883. set boundingBias(value: Vector2);
  22884. /**
  22885. * Static function used to attach a new empty geometry to a mesh
  22886. * @param mesh defines the mesh to attach the geometry to
  22887. * @returns the new Geometry
  22888. */
  22889. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  22890. /** Get the list of meshes using this geometry */
  22891. get meshes(): Mesh[];
  22892. /**
  22893. * Creates a new geometry
  22894. * @param id defines the unique ID
  22895. * @param scene defines the hosting scene
  22896. * @param vertexData defines the VertexData used to get geometry data
  22897. * @param updatable defines if geometry must be updatable (false by default)
  22898. * @param mesh defines the mesh that will be associated with the geometry
  22899. */
  22900. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  22901. /**
  22902. * Gets the current extend of the geometry
  22903. */
  22904. get extend(): {
  22905. minimum: Vector3;
  22906. maximum: Vector3;
  22907. };
  22908. /**
  22909. * Gets the hosting scene
  22910. * @returns the hosting Scene
  22911. */
  22912. getScene(): Scene;
  22913. /**
  22914. * Gets the hosting engine
  22915. * @returns the hosting Engine
  22916. */
  22917. getEngine(): Engine;
  22918. /**
  22919. * Defines if the geometry is ready to use
  22920. * @returns true if the geometry is ready to be used
  22921. */
  22922. isReady(): boolean;
  22923. /**
  22924. * Gets a value indicating that the geometry should not be serialized
  22925. */
  22926. get doNotSerialize(): boolean;
  22927. /** @hidden */
  22928. _rebuild(): void;
  22929. /**
  22930. * Affects all geometry data in one call
  22931. * @param vertexData defines the geometry data
  22932. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  22933. */
  22934. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  22935. /**
  22936. * Set specific vertex data
  22937. * @param kind defines the data kind (Position, normal, etc...)
  22938. * @param data defines the vertex data to use
  22939. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22940. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22941. */
  22942. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  22943. /**
  22944. * Removes a specific vertex data
  22945. * @param kind defines the data kind (Position, normal, etc...)
  22946. */
  22947. removeVerticesData(kind: string): void;
  22948. /**
  22949. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  22950. * @param buffer defines the vertex buffer to use
  22951. * @param totalVertices defines the total number of vertices for position kind (could be null)
  22952. */
  22953. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  22954. /**
  22955. * Update a specific vertex buffer
  22956. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  22957. * It will do nothing if the buffer is not updatable
  22958. * @param kind defines the data kind (Position, normal, etc...)
  22959. * @param data defines the data to use
  22960. * @param offset defines the offset in the target buffer where to store the data
  22961. * @param useBytes set to true if the offset is in bytes
  22962. */
  22963. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  22964. /**
  22965. * Update a specific vertex buffer
  22966. * This function will create a new buffer if the current one is not updatable
  22967. * @param kind defines the data kind (Position, normal, etc...)
  22968. * @param data defines the data to use
  22969. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  22970. */
  22971. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  22972. private _updateBoundingInfo;
  22973. /** @hidden */
  22974. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  22975. /**
  22976. * Gets total number of vertices
  22977. * @returns the total number of vertices
  22978. */
  22979. getTotalVertices(): number;
  22980. /**
  22981. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22982. * @param kind defines the data kind (Position, normal, etc...)
  22983. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22984. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22985. * @returns a float array containing vertex data
  22986. */
  22987. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22988. /**
  22989. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  22990. * @param kind defines the data kind (Position, normal, etc...)
  22991. * @returns true if the vertex buffer with the specified kind is updatable
  22992. */
  22993. isVertexBufferUpdatable(kind: string): boolean;
  22994. /**
  22995. * Gets a specific vertex buffer
  22996. * @param kind defines the data kind (Position, normal, etc...)
  22997. * @returns a VertexBuffer
  22998. */
  22999. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  23000. /**
  23001. * Returns all vertex buffers
  23002. * @return an object holding all vertex buffers indexed by kind
  23003. */
  23004. getVertexBuffers(): Nullable<{
  23005. [key: string]: VertexBuffer;
  23006. }>;
  23007. /**
  23008. * Gets a boolean indicating if specific vertex buffer is present
  23009. * @param kind defines the data kind (Position, normal, etc...)
  23010. * @returns true if data is present
  23011. */
  23012. isVerticesDataPresent(kind: string): boolean;
  23013. /**
  23014. * Gets a list of all attached data kinds (Position, normal, etc...)
  23015. * @returns a list of string containing all kinds
  23016. */
  23017. getVerticesDataKinds(): string[];
  23018. /**
  23019. * Update index buffer
  23020. * @param indices defines the indices to store in the index buffer
  23021. * @param offset defines the offset in the target buffer where to store the data
  23022. * @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)
  23023. */
  23024. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  23025. /**
  23026. * Creates a new index buffer
  23027. * @param indices defines the indices to store in the index buffer
  23028. * @param totalVertices defines the total number of vertices (could be null)
  23029. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  23030. */
  23031. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  23032. /**
  23033. * Return the total number of indices
  23034. * @returns the total number of indices
  23035. */
  23036. getTotalIndices(): number;
  23037. /**
  23038. * Gets the index buffer array
  23039. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  23040. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23041. * @returns the index buffer array
  23042. */
  23043. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  23044. /**
  23045. * Gets the index buffer
  23046. * @return the index buffer
  23047. */
  23048. getIndexBuffer(): Nullable<DataBuffer>;
  23049. /** @hidden */
  23050. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  23051. /**
  23052. * Release the associated resources for a specific mesh
  23053. * @param mesh defines the source mesh
  23054. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  23055. */
  23056. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  23057. /**
  23058. * Apply current geometry to a given mesh
  23059. * @param mesh defines the mesh to apply geometry to
  23060. */
  23061. applyToMesh(mesh: Mesh): void;
  23062. private _updateExtend;
  23063. private _applyToMesh;
  23064. private notifyUpdate;
  23065. /**
  23066. * Load the geometry if it was flagged as delay loaded
  23067. * @param scene defines the hosting scene
  23068. * @param onLoaded defines a callback called when the geometry is loaded
  23069. */
  23070. load(scene: Scene, onLoaded?: () => void): void;
  23071. private _queueLoad;
  23072. /**
  23073. * Invert the geometry to move from a right handed system to a left handed one.
  23074. */
  23075. toLeftHanded(): void;
  23076. /** @hidden */
  23077. _resetPointsArrayCache(): void;
  23078. /** @hidden */
  23079. _generatePointsArray(): boolean;
  23080. /**
  23081. * Gets a value indicating if the geometry is disposed
  23082. * @returns true if the geometry was disposed
  23083. */
  23084. isDisposed(): boolean;
  23085. private _disposeVertexArrayObjects;
  23086. /**
  23087. * Free all associated resources
  23088. */
  23089. dispose(): void;
  23090. /**
  23091. * Clone the current geometry into a new geometry
  23092. * @param id defines the unique ID of the new geometry
  23093. * @returns a new geometry object
  23094. */
  23095. copy(id: string): Geometry;
  23096. /**
  23097. * Serialize the current geometry info (and not the vertices data) into a JSON object
  23098. * @return a JSON representation of the current geometry data (without the vertices data)
  23099. */
  23100. serialize(): any;
  23101. private toNumberArray;
  23102. /**
  23103. * Serialize all vertices data into a JSON oject
  23104. * @returns a JSON representation of the current geometry data
  23105. */
  23106. serializeVerticeData(): any;
  23107. /**
  23108. * Extracts a clone of a mesh geometry
  23109. * @param mesh defines the source mesh
  23110. * @param id defines the unique ID of the new geometry object
  23111. * @returns the new geometry object
  23112. */
  23113. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  23114. /**
  23115. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  23116. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  23117. * Be aware Math.random() could cause collisions, but:
  23118. * "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"
  23119. * @returns a string containing a new GUID
  23120. */
  23121. static RandomId(): string;
  23122. /** @hidden */
  23123. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  23124. private static _CleanMatricesWeights;
  23125. /**
  23126. * Create a new geometry from persisted data (Using .babylon file format)
  23127. * @param parsedVertexData defines the persisted data
  23128. * @param scene defines the hosting scene
  23129. * @param rootUrl defines the root url to use to load assets (like delayed data)
  23130. * @returns the new geometry object
  23131. */
  23132. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  23133. }
  23134. }
  23135. declare module "babylonjs/Meshes/mesh.vertexData" {
  23136. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  23137. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  23138. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  23139. import { Geometry } from "babylonjs/Meshes/geometry";
  23140. import { Mesh } from "babylonjs/Meshes/mesh";
  23141. /**
  23142. * Define an interface for all classes that will get and set the data on vertices
  23143. */
  23144. export interface IGetSetVerticesData {
  23145. /**
  23146. * Gets a boolean indicating if specific vertex data is present
  23147. * @param kind defines the vertex data kind to use
  23148. * @returns true is data kind is present
  23149. */
  23150. isVerticesDataPresent(kind: string): boolean;
  23151. /**
  23152. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  23153. * @param kind defines the data kind (Position, normal, etc...)
  23154. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  23155. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23156. * @returns a float array containing vertex data
  23157. */
  23158. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  23159. /**
  23160. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  23161. * @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.
  23162. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23163. * @returns the indices array or an empty array if the mesh has no geometry
  23164. */
  23165. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  23166. /**
  23167. * Set specific vertex data
  23168. * @param kind defines the data kind (Position, normal, etc...)
  23169. * @param data defines the vertex data to use
  23170. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  23171. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  23172. */
  23173. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  23174. /**
  23175. * Update a specific associated vertex buffer
  23176. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  23177. * - VertexBuffer.PositionKind
  23178. * - VertexBuffer.UVKind
  23179. * - VertexBuffer.UV2Kind
  23180. * - VertexBuffer.UV3Kind
  23181. * - VertexBuffer.UV4Kind
  23182. * - VertexBuffer.UV5Kind
  23183. * - VertexBuffer.UV6Kind
  23184. * - VertexBuffer.ColorKind
  23185. * - VertexBuffer.MatricesIndicesKind
  23186. * - VertexBuffer.MatricesIndicesExtraKind
  23187. * - VertexBuffer.MatricesWeightsKind
  23188. * - VertexBuffer.MatricesWeightsExtraKind
  23189. * @param data defines the data source
  23190. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  23191. * @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)
  23192. */
  23193. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  23194. /**
  23195. * Creates a new index buffer
  23196. * @param indices defines the indices to store in the index buffer
  23197. * @param totalVertices defines the total number of vertices (could be null)
  23198. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  23199. */
  23200. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  23201. }
  23202. /**
  23203. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  23204. */
  23205. export class VertexData {
  23206. /**
  23207. * Mesh side orientation : usually the external or front surface
  23208. */
  23209. static readonly FRONTSIDE: number;
  23210. /**
  23211. * Mesh side orientation : usually the internal or back surface
  23212. */
  23213. static readonly BACKSIDE: number;
  23214. /**
  23215. * Mesh side orientation : both internal and external or front and back surfaces
  23216. */
  23217. static readonly DOUBLESIDE: number;
  23218. /**
  23219. * Mesh side orientation : by default, `FRONTSIDE`
  23220. */
  23221. static readonly DEFAULTSIDE: number;
  23222. /**
  23223. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  23224. */
  23225. positions: Nullable<FloatArray>;
  23226. /**
  23227. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  23228. */
  23229. normals: Nullable<FloatArray>;
  23230. /**
  23231. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  23232. */
  23233. tangents: Nullable<FloatArray>;
  23234. /**
  23235. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23236. */
  23237. uvs: Nullable<FloatArray>;
  23238. /**
  23239. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23240. */
  23241. uvs2: Nullable<FloatArray>;
  23242. /**
  23243. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23244. */
  23245. uvs3: Nullable<FloatArray>;
  23246. /**
  23247. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23248. */
  23249. uvs4: Nullable<FloatArray>;
  23250. /**
  23251. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23252. */
  23253. uvs5: Nullable<FloatArray>;
  23254. /**
  23255. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23256. */
  23257. uvs6: Nullable<FloatArray>;
  23258. /**
  23259. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  23260. */
  23261. colors: Nullable<FloatArray>;
  23262. /**
  23263. * 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).
  23264. */
  23265. matricesIndices: Nullable<FloatArray>;
  23266. /**
  23267. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  23268. */
  23269. matricesWeights: Nullable<FloatArray>;
  23270. /**
  23271. * An array extending the number of possible indices
  23272. */
  23273. matricesIndicesExtra: Nullable<FloatArray>;
  23274. /**
  23275. * An array extending the number of possible weights when the number of indices is extended
  23276. */
  23277. matricesWeightsExtra: Nullable<FloatArray>;
  23278. /**
  23279. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  23280. */
  23281. indices: Nullable<IndicesArray>;
  23282. /**
  23283. * Uses the passed data array to set the set the values for the specified kind of data
  23284. * @param data a linear array of floating numbers
  23285. * @param kind the type of data that is being set, eg positions, colors etc
  23286. */
  23287. set(data: FloatArray, kind: string): void;
  23288. /**
  23289. * Associates the vertexData to the passed Mesh.
  23290. * Sets it as updatable or not (default `false`)
  23291. * @param mesh the mesh the vertexData is applied to
  23292. * @param updatable when used and having the value true allows new data to update the vertexData
  23293. * @returns the VertexData
  23294. */
  23295. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  23296. /**
  23297. * Associates the vertexData to the passed Geometry.
  23298. * Sets it as updatable or not (default `false`)
  23299. * @param geometry the geometry the vertexData is applied to
  23300. * @param updatable when used and having the value true allows new data to update the vertexData
  23301. * @returns VertexData
  23302. */
  23303. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  23304. /**
  23305. * Updates the associated mesh
  23306. * @param mesh the mesh to be updated
  23307. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  23308. * @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
  23309. * @returns VertexData
  23310. */
  23311. updateMesh(mesh: Mesh): VertexData;
  23312. /**
  23313. * Updates the associated geometry
  23314. * @param geometry the geometry to be updated
  23315. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  23316. * @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
  23317. * @returns VertexData.
  23318. */
  23319. updateGeometry(geometry: Geometry): VertexData;
  23320. private _applyTo;
  23321. private _update;
  23322. /**
  23323. * Transforms each position and each normal of the vertexData according to the passed Matrix
  23324. * @param matrix the transforming matrix
  23325. * @returns the VertexData
  23326. */
  23327. transform(matrix: Matrix): VertexData;
  23328. /**
  23329. * Merges the passed VertexData into the current one
  23330. * @param other the VertexData to be merged into the current one
  23331. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  23332. * @returns the modified VertexData
  23333. */
  23334. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  23335. private _mergeElement;
  23336. private _validate;
  23337. /**
  23338. * Serializes the VertexData
  23339. * @returns a serialized object
  23340. */
  23341. serialize(): any;
  23342. /**
  23343. * Extracts the vertexData from a mesh
  23344. * @param mesh the mesh from which to extract the VertexData
  23345. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  23346. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  23347. * @returns the object VertexData associated to the passed mesh
  23348. */
  23349. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  23350. /**
  23351. * Extracts the vertexData from the geometry
  23352. * @param geometry the geometry from which to extract the VertexData
  23353. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  23354. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  23355. * @returns the object VertexData associated to the passed mesh
  23356. */
  23357. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  23358. private static _ExtractFrom;
  23359. /**
  23360. * Creates the VertexData for a Ribbon
  23361. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  23362. * * pathArray array of paths, each of which an array of successive Vector3
  23363. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  23364. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  23365. * * 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
  23366. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23367. * * 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)
  23368. * * 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)
  23369. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  23370. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  23371. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  23372. * @returns the VertexData of the ribbon
  23373. */
  23374. static CreateRibbon(options: {
  23375. pathArray: Vector3[][];
  23376. closeArray?: boolean;
  23377. closePath?: boolean;
  23378. offset?: number;
  23379. sideOrientation?: number;
  23380. frontUVs?: Vector4;
  23381. backUVs?: Vector4;
  23382. invertUV?: boolean;
  23383. uvs?: Vector2[];
  23384. colors?: Color4[];
  23385. }): VertexData;
  23386. /**
  23387. * Creates the VertexData for a box
  23388. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23389. * * size sets the width, height and depth of the box to the value of size, optional default 1
  23390. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  23391. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  23392. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  23393. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  23394. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  23395. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23396. * * 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)
  23397. * * 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)
  23398. * @returns the VertexData of the box
  23399. */
  23400. static CreateBox(options: {
  23401. size?: number;
  23402. width?: number;
  23403. height?: number;
  23404. depth?: number;
  23405. faceUV?: Vector4[];
  23406. faceColors?: Color4[];
  23407. sideOrientation?: number;
  23408. frontUVs?: Vector4;
  23409. backUVs?: Vector4;
  23410. }): VertexData;
  23411. /**
  23412. * Creates the VertexData for a tiled box
  23413. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23414. * * faceTiles sets the pattern, tile size and number of tiles for a face
  23415. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  23416. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  23417. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23418. * @returns the VertexData of the box
  23419. */
  23420. static CreateTiledBox(options: {
  23421. pattern?: number;
  23422. width?: number;
  23423. height?: number;
  23424. depth?: number;
  23425. tileSize?: number;
  23426. tileWidth?: number;
  23427. tileHeight?: number;
  23428. alignHorizontal?: number;
  23429. alignVertical?: number;
  23430. faceUV?: Vector4[];
  23431. faceColors?: Color4[];
  23432. sideOrientation?: number;
  23433. }): VertexData;
  23434. /**
  23435. * Creates the VertexData for a tiled plane
  23436. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23437. * * pattern a limited pattern arrangement depending on the number
  23438. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  23439. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  23440. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  23441. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23442. * * 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)
  23443. * * 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)
  23444. * @returns the VertexData of the tiled plane
  23445. */
  23446. static CreateTiledPlane(options: {
  23447. pattern?: number;
  23448. tileSize?: number;
  23449. tileWidth?: number;
  23450. tileHeight?: number;
  23451. size?: number;
  23452. width?: number;
  23453. height?: number;
  23454. alignHorizontal?: number;
  23455. alignVertical?: number;
  23456. sideOrientation?: number;
  23457. frontUVs?: Vector4;
  23458. backUVs?: Vector4;
  23459. }): VertexData;
  23460. /**
  23461. * Creates the VertexData for an ellipsoid, defaults to a sphere
  23462. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23463. * * segments sets the number of horizontal strips optional, default 32
  23464. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  23465. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  23466. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  23467. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  23468. * * 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
  23469. * * 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
  23470. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23471. * * 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)
  23472. * * 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)
  23473. * @returns the VertexData of the ellipsoid
  23474. */
  23475. static CreateSphere(options: {
  23476. segments?: number;
  23477. diameter?: number;
  23478. diameterX?: number;
  23479. diameterY?: number;
  23480. diameterZ?: number;
  23481. arc?: number;
  23482. slice?: number;
  23483. sideOrientation?: number;
  23484. frontUVs?: Vector4;
  23485. backUVs?: Vector4;
  23486. }): VertexData;
  23487. /**
  23488. * Creates the VertexData for a cylinder, cone or prism
  23489. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23490. * * height sets the height (y direction) of the cylinder, optional, default 2
  23491. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  23492. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  23493. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  23494. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  23495. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  23496. * * 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
  23497. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23498. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23499. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  23500. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  23501. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23502. * * 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)
  23503. * * 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)
  23504. * @returns the VertexData of the cylinder, cone or prism
  23505. */
  23506. static CreateCylinder(options: {
  23507. height?: number;
  23508. diameterTop?: number;
  23509. diameterBottom?: number;
  23510. diameter?: number;
  23511. tessellation?: number;
  23512. subdivisions?: number;
  23513. arc?: number;
  23514. faceColors?: Color4[];
  23515. faceUV?: Vector4[];
  23516. hasRings?: boolean;
  23517. enclose?: boolean;
  23518. sideOrientation?: number;
  23519. frontUVs?: Vector4;
  23520. backUVs?: Vector4;
  23521. }): VertexData;
  23522. /**
  23523. * Creates the VertexData for a torus
  23524. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23525. * * diameter the diameter of the torus, optional default 1
  23526. * * thickness the diameter of the tube forming the torus, optional default 0.5
  23527. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  23528. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23529. * * 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)
  23530. * * 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)
  23531. * @returns the VertexData of the torus
  23532. */
  23533. static CreateTorus(options: {
  23534. diameter?: number;
  23535. thickness?: number;
  23536. tessellation?: number;
  23537. sideOrientation?: number;
  23538. frontUVs?: Vector4;
  23539. backUVs?: Vector4;
  23540. }): VertexData;
  23541. /**
  23542. * Creates the VertexData of the LineSystem
  23543. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  23544. * - lines an array of lines, each line being an array of successive Vector3
  23545. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  23546. * @returns the VertexData of the LineSystem
  23547. */
  23548. static CreateLineSystem(options: {
  23549. lines: Vector3[][];
  23550. colors?: Nullable<Color4[][]>;
  23551. }): VertexData;
  23552. /**
  23553. * Create the VertexData for a DashedLines
  23554. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  23555. * - points an array successive Vector3
  23556. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  23557. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  23558. * - dashNb the intended total number of dashes, optional, default 200
  23559. * @returns the VertexData for the DashedLines
  23560. */
  23561. static CreateDashedLines(options: {
  23562. points: Vector3[];
  23563. dashSize?: number;
  23564. gapSize?: number;
  23565. dashNb?: number;
  23566. }): VertexData;
  23567. /**
  23568. * Creates the VertexData for a Ground
  23569. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  23570. * - width the width (x direction) of the ground, optional, default 1
  23571. * - height the height (z direction) of the ground, optional, default 1
  23572. * - subdivisions the number of subdivisions per side, optional, default 1
  23573. * @returns the VertexData of the Ground
  23574. */
  23575. static CreateGround(options: {
  23576. width?: number;
  23577. height?: number;
  23578. subdivisions?: number;
  23579. subdivisionsX?: number;
  23580. subdivisionsY?: number;
  23581. }): VertexData;
  23582. /**
  23583. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  23584. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  23585. * * xmin the ground minimum X coordinate, optional, default -1
  23586. * * zmin the ground minimum Z coordinate, optional, default -1
  23587. * * xmax the ground maximum X coordinate, optional, default 1
  23588. * * zmax the ground maximum Z coordinate, optional, default 1
  23589. * * 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}
  23590. * * 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}
  23591. * @returns the VertexData of the TiledGround
  23592. */
  23593. static CreateTiledGround(options: {
  23594. xmin: number;
  23595. zmin: number;
  23596. xmax: number;
  23597. zmax: number;
  23598. subdivisions?: {
  23599. w: number;
  23600. h: number;
  23601. };
  23602. precision?: {
  23603. w: number;
  23604. h: number;
  23605. };
  23606. }): VertexData;
  23607. /**
  23608. * Creates the VertexData of the Ground designed from a heightmap
  23609. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  23610. * * width the width (x direction) of the ground
  23611. * * height the height (z direction) of the ground
  23612. * * subdivisions the number of subdivisions per side
  23613. * * minHeight the minimum altitude on the ground, optional, default 0
  23614. * * maxHeight the maximum altitude on the ground, optional default 1
  23615. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  23616. * * buffer the array holding the image color data
  23617. * * bufferWidth the width of image
  23618. * * bufferHeight the height of image
  23619. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  23620. * @returns the VertexData of the Ground designed from a heightmap
  23621. */
  23622. static CreateGroundFromHeightMap(options: {
  23623. width: number;
  23624. height: number;
  23625. subdivisions: number;
  23626. minHeight: number;
  23627. maxHeight: number;
  23628. colorFilter: Color3;
  23629. buffer: Uint8Array;
  23630. bufferWidth: number;
  23631. bufferHeight: number;
  23632. alphaFilter: number;
  23633. }): VertexData;
  23634. /**
  23635. * Creates the VertexData for a Plane
  23636. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  23637. * * size sets the width and height of the plane to the value of size, optional default 1
  23638. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  23639. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  23640. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23641. * * 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)
  23642. * * 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)
  23643. * @returns the VertexData of the box
  23644. */
  23645. static CreatePlane(options: {
  23646. size?: number;
  23647. width?: number;
  23648. height?: number;
  23649. sideOrientation?: number;
  23650. frontUVs?: Vector4;
  23651. backUVs?: Vector4;
  23652. }): VertexData;
  23653. /**
  23654. * Creates the VertexData of the Disc or regular Polygon
  23655. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  23656. * * radius the radius of the disc, optional default 0.5
  23657. * * tessellation the number of polygon sides, optional, default 64
  23658. * * 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
  23659. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23660. * * 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)
  23661. * * 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)
  23662. * @returns the VertexData of the box
  23663. */
  23664. static CreateDisc(options: {
  23665. radius?: number;
  23666. tessellation?: number;
  23667. arc?: number;
  23668. sideOrientation?: number;
  23669. frontUVs?: Vector4;
  23670. backUVs?: Vector4;
  23671. }): VertexData;
  23672. /**
  23673. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  23674. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  23675. * @param polygon a mesh built from polygonTriangulation.build()
  23676. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23677. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23678. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23679. * @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)
  23680. * @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)
  23681. * @param wrap a boolean, default false, when true and fUVs used texture is wrapped around all sides, when false texture is applied side
  23682. * @returns the VertexData of the Polygon
  23683. */
  23684. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4, wrap?: boolean): VertexData;
  23685. /**
  23686. * Creates the VertexData of the IcoSphere
  23687. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  23688. * * radius the radius of the IcoSphere, optional default 1
  23689. * * radiusX allows stretching in the x direction, optional, default radius
  23690. * * radiusY allows stretching in the y direction, optional, default radius
  23691. * * radiusZ allows stretching in the z direction, optional, default radius
  23692. * * flat when true creates a flat shaded mesh, optional, default true
  23693. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  23694. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23695. * * 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)
  23696. * * 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)
  23697. * @returns the VertexData of the IcoSphere
  23698. */
  23699. static CreateIcoSphere(options: {
  23700. radius?: number;
  23701. radiusX?: number;
  23702. radiusY?: number;
  23703. radiusZ?: number;
  23704. flat?: boolean;
  23705. subdivisions?: number;
  23706. sideOrientation?: number;
  23707. frontUVs?: Vector4;
  23708. backUVs?: Vector4;
  23709. }): VertexData;
  23710. /**
  23711. * Creates the VertexData for a Polyhedron
  23712. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  23713. * * type provided types are:
  23714. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  23715. * * 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)
  23716. * * size the size of the IcoSphere, optional default 1
  23717. * * sizeX allows stretching in the x direction, optional, default size
  23718. * * sizeY allows stretching in the y direction, optional, default size
  23719. * * sizeZ allows stretching in the z direction, optional, default size
  23720. * * 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
  23721. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23722. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23723. * * flat when true creates a flat shaded mesh, optional, default true
  23724. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  23725. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23726. * * 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)
  23727. * * 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)
  23728. * @returns the VertexData of the Polyhedron
  23729. */
  23730. static CreatePolyhedron(options: {
  23731. type?: number;
  23732. size?: number;
  23733. sizeX?: number;
  23734. sizeY?: number;
  23735. sizeZ?: number;
  23736. custom?: any;
  23737. faceUV?: Vector4[];
  23738. faceColors?: Color4[];
  23739. flat?: boolean;
  23740. sideOrientation?: number;
  23741. frontUVs?: Vector4;
  23742. backUVs?: Vector4;
  23743. }): VertexData;
  23744. /**
  23745. * Creates the VertexData for a TorusKnot
  23746. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  23747. * * radius the radius of the torus knot, optional, default 2
  23748. * * tube the thickness of the tube, optional, default 0.5
  23749. * * radialSegments the number of sides on each tube segments, optional, default 32
  23750. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  23751. * * p the number of windings around the z axis, optional, default 2
  23752. * * q the number of windings around the x axis, optional, default 3
  23753. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23754. * * 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)
  23755. * * 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)
  23756. * @returns the VertexData of the Torus Knot
  23757. */
  23758. static CreateTorusKnot(options: {
  23759. radius?: number;
  23760. tube?: number;
  23761. radialSegments?: number;
  23762. tubularSegments?: number;
  23763. p?: number;
  23764. q?: number;
  23765. sideOrientation?: number;
  23766. frontUVs?: Vector4;
  23767. backUVs?: Vector4;
  23768. }): VertexData;
  23769. /**
  23770. * Compute normals for given positions and indices
  23771. * @param positions an array of vertex positions, [...., x, y, z, ......]
  23772. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  23773. * @param normals an array of vertex normals, [...., x, y, z, ......]
  23774. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  23775. * * facetNormals : optional array of facet normals (vector3)
  23776. * * facetPositions : optional array of facet positions (vector3)
  23777. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  23778. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  23779. * * bInfo : optional bounding info, required for facetPartitioning computation
  23780. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  23781. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  23782. * * useRightHandedSystem: optional boolean to for right handed system computation
  23783. * * depthSort : optional boolean to enable the facet depth sort computation
  23784. * * distanceTo : optional Vector3 to compute the facet depth from this location
  23785. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  23786. */
  23787. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  23788. facetNormals?: any;
  23789. facetPositions?: any;
  23790. facetPartitioning?: any;
  23791. ratio?: number;
  23792. bInfo?: any;
  23793. bbSize?: Vector3;
  23794. subDiv?: any;
  23795. useRightHandedSystem?: boolean;
  23796. depthSort?: boolean;
  23797. distanceTo?: Vector3;
  23798. depthSortedFacets?: any;
  23799. }): void;
  23800. /** @hidden */
  23801. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  23802. /**
  23803. * Applies VertexData created from the imported parameters to the geometry
  23804. * @param parsedVertexData the parsed data from an imported file
  23805. * @param geometry the geometry to apply the VertexData to
  23806. */
  23807. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  23808. }
  23809. }
  23810. declare module "babylonjs/Morph/morphTarget" {
  23811. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  23812. import { Observable } from "babylonjs/Misc/observable";
  23813. import { Nullable, FloatArray } from "babylonjs/types";
  23814. import { Scene } from "babylonjs/scene";
  23815. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23816. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  23817. /**
  23818. * Defines a target to use with MorphTargetManager
  23819. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  23820. */
  23821. export class MorphTarget implements IAnimatable {
  23822. /** defines the name of the target */
  23823. name: string;
  23824. /**
  23825. * Gets or sets the list of animations
  23826. */
  23827. animations: import("babylonjs/Animations/animation").Animation[];
  23828. private _scene;
  23829. private _positions;
  23830. private _normals;
  23831. private _tangents;
  23832. private _uvs;
  23833. private _influence;
  23834. private _uniqueId;
  23835. /**
  23836. * Observable raised when the influence changes
  23837. */
  23838. onInfluenceChanged: Observable<boolean>;
  23839. /** @hidden */
  23840. _onDataLayoutChanged: Observable<void>;
  23841. /**
  23842. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  23843. */
  23844. get influence(): number;
  23845. set influence(influence: number);
  23846. /**
  23847. * Gets or sets the id of the morph Target
  23848. */
  23849. id: string;
  23850. private _animationPropertiesOverride;
  23851. /**
  23852. * Gets or sets the animation properties override
  23853. */
  23854. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  23855. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  23856. /**
  23857. * Creates a new MorphTarget
  23858. * @param name defines the name of the target
  23859. * @param influence defines the influence to use
  23860. * @param scene defines the scene the morphtarget belongs to
  23861. */
  23862. constructor(
  23863. /** defines the name of the target */
  23864. name: string, influence?: number, scene?: Nullable<Scene>);
  23865. /**
  23866. * Gets the unique ID of this manager
  23867. */
  23868. get uniqueId(): number;
  23869. /**
  23870. * Gets a boolean defining if the target contains position data
  23871. */
  23872. get hasPositions(): boolean;
  23873. /**
  23874. * Gets a boolean defining if the target contains normal data
  23875. */
  23876. get hasNormals(): boolean;
  23877. /**
  23878. * Gets a boolean defining if the target contains tangent data
  23879. */
  23880. get hasTangents(): boolean;
  23881. /**
  23882. * Gets a boolean defining if the target contains texture coordinates data
  23883. */
  23884. get hasUVs(): boolean;
  23885. /**
  23886. * Affects position data to this target
  23887. * @param data defines the position data to use
  23888. */
  23889. setPositions(data: Nullable<FloatArray>): void;
  23890. /**
  23891. * Gets the position data stored in this target
  23892. * @returns a FloatArray containing the position data (or null if not present)
  23893. */
  23894. getPositions(): Nullable<FloatArray>;
  23895. /**
  23896. * Affects normal data to this target
  23897. * @param data defines the normal data to use
  23898. */
  23899. setNormals(data: Nullable<FloatArray>): void;
  23900. /**
  23901. * Gets the normal data stored in this target
  23902. * @returns a FloatArray containing the normal data (or null if not present)
  23903. */
  23904. getNormals(): Nullable<FloatArray>;
  23905. /**
  23906. * Affects tangent data to this target
  23907. * @param data defines the tangent data to use
  23908. */
  23909. setTangents(data: Nullable<FloatArray>): void;
  23910. /**
  23911. * Gets the tangent data stored in this target
  23912. * @returns a FloatArray containing the tangent data (or null if not present)
  23913. */
  23914. getTangents(): Nullable<FloatArray>;
  23915. /**
  23916. * Affects texture coordinates data to this target
  23917. * @param data defines the texture coordinates data to use
  23918. */
  23919. setUVs(data: Nullable<FloatArray>): void;
  23920. /**
  23921. * Gets the texture coordinates data stored in this target
  23922. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  23923. */
  23924. getUVs(): Nullable<FloatArray>;
  23925. /**
  23926. * Clone the current target
  23927. * @returns a new MorphTarget
  23928. */
  23929. clone(): MorphTarget;
  23930. /**
  23931. * Serializes the current target into a Serialization object
  23932. * @returns the serialized object
  23933. */
  23934. serialize(): any;
  23935. /**
  23936. * Returns the string "MorphTarget"
  23937. * @returns "MorphTarget"
  23938. */
  23939. getClassName(): string;
  23940. /**
  23941. * Creates a new target from serialized data
  23942. * @param serializationObject defines the serialized data to use
  23943. * @returns a new MorphTarget
  23944. */
  23945. static Parse(serializationObject: any): MorphTarget;
  23946. /**
  23947. * Creates a MorphTarget from mesh data
  23948. * @param mesh defines the source mesh
  23949. * @param name defines the name to use for the new target
  23950. * @param influence defines the influence to attach to the target
  23951. * @returns a new MorphTarget
  23952. */
  23953. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  23954. }
  23955. }
  23956. declare module "babylonjs/Morph/morphTargetManager" {
  23957. import { Nullable } from "babylonjs/types";
  23958. import { Scene } from "babylonjs/scene";
  23959. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  23960. /**
  23961. * This class is used to deform meshes using morphing between different targets
  23962. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  23963. */
  23964. export class MorphTargetManager {
  23965. private _targets;
  23966. private _targetInfluenceChangedObservers;
  23967. private _targetDataLayoutChangedObservers;
  23968. private _activeTargets;
  23969. private _scene;
  23970. private _influences;
  23971. private _supportsNormals;
  23972. private _supportsTangents;
  23973. private _supportsUVs;
  23974. private _vertexCount;
  23975. private _uniqueId;
  23976. private _tempInfluences;
  23977. /**
  23978. * Gets or sets a boolean indicating if normals must be morphed
  23979. */
  23980. enableNormalMorphing: boolean;
  23981. /**
  23982. * Gets or sets a boolean indicating if tangents must be morphed
  23983. */
  23984. enableTangentMorphing: boolean;
  23985. /**
  23986. * Gets or sets a boolean indicating if UV must be morphed
  23987. */
  23988. enableUVMorphing: boolean;
  23989. /**
  23990. * Creates a new MorphTargetManager
  23991. * @param scene defines the current scene
  23992. */
  23993. constructor(scene?: Nullable<Scene>);
  23994. /**
  23995. * Gets the unique ID of this manager
  23996. */
  23997. get uniqueId(): number;
  23998. /**
  23999. * Gets the number of vertices handled by this manager
  24000. */
  24001. get vertexCount(): number;
  24002. /**
  24003. * Gets a boolean indicating if this manager supports morphing of normals
  24004. */
  24005. get supportsNormals(): boolean;
  24006. /**
  24007. * Gets a boolean indicating if this manager supports morphing of tangents
  24008. */
  24009. get supportsTangents(): boolean;
  24010. /**
  24011. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  24012. */
  24013. get supportsUVs(): boolean;
  24014. /**
  24015. * Gets the number of targets stored in this manager
  24016. */
  24017. get numTargets(): number;
  24018. /**
  24019. * Gets the number of influencers (ie. the number of targets with influences > 0)
  24020. */
  24021. get numInfluencers(): number;
  24022. /**
  24023. * Gets the list of influences (one per target)
  24024. */
  24025. get influences(): Float32Array;
  24026. /**
  24027. * Gets the active target at specified index. An active target is a target with an influence > 0
  24028. * @param index defines the index to check
  24029. * @returns the requested target
  24030. */
  24031. getActiveTarget(index: number): MorphTarget;
  24032. /**
  24033. * Gets the target at specified index
  24034. * @param index defines the index to check
  24035. * @returns the requested target
  24036. */
  24037. getTarget(index: number): MorphTarget;
  24038. /**
  24039. * Add a new target to this manager
  24040. * @param target defines the target to add
  24041. */
  24042. addTarget(target: MorphTarget): void;
  24043. /**
  24044. * Removes a target from the manager
  24045. * @param target defines the target to remove
  24046. */
  24047. removeTarget(target: MorphTarget): void;
  24048. /**
  24049. * Clone the current manager
  24050. * @returns a new MorphTargetManager
  24051. */
  24052. clone(): MorphTargetManager;
  24053. /**
  24054. * Serializes the current manager into a Serialization object
  24055. * @returns the serialized object
  24056. */
  24057. serialize(): any;
  24058. private _syncActiveTargets;
  24059. /**
  24060. * Syncrhonize the targets with all the meshes using this morph target manager
  24061. */
  24062. synchronize(): void;
  24063. /**
  24064. * Creates a new MorphTargetManager from serialized data
  24065. * @param serializationObject defines the serialized data
  24066. * @param scene defines the hosting scene
  24067. * @returns the new MorphTargetManager
  24068. */
  24069. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  24070. }
  24071. }
  24072. declare module "babylonjs/Meshes/meshLODLevel" {
  24073. import { Mesh } from "babylonjs/Meshes/mesh";
  24074. import { Nullable } from "babylonjs/types";
  24075. /**
  24076. * Class used to represent a specific level of detail of a mesh
  24077. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  24078. */
  24079. export class MeshLODLevel {
  24080. /** Defines the distance where this level should start being displayed */
  24081. distance: number;
  24082. /** Defines the mesh to use to render this level */
  24083. mesh: Nullable<Mesh>;
  24084. /**
  24085. * Creates a new LOD level
  24086. * @param distance defines the distance where this level should star being displayed
  24087. * @param mesh defines the mesh to use to render this level
  24088. */
  24089. constructor(
  24090. /** Defines the distance where this level should start being displayed */
  24091. distance: number,
  24092. /** Defines the mesh to use to render this level */
  24093. mesh: Nullable<Mesh>);
  24094. }
  24095. }
  24096. declare module "babylonjs/Meshes/groundMesh" {
  24097. import { Scene } from "babylonjs/scene";
  24098. import { Vector3 } from "babylonjs/Maths/math.vector";
  24099. import { Mesh } from "babylonjs/Meshes/mesh";
  24100. /**
  24101. * Mesh representing the gorund
  24102. */
  24103. export class GroundMesh extends Mesh {
  24104. /** If octree should be generated */
  24105. generateOctree: boolean;
  24106. private _heightQuads;
  24107. /** @hidden */
  24108. _subdivisionsX: number;
  24109. /** @hidden */
  24110. _subdivisionsY: number;
  24111. /** @hidden */
  24112. _width: number;
  24113. /** @hidden */
  24114. _height: number;
  24115. /** @hidden */
  24116. _minX: number;
  24117. /** @hidden */
  24118. _maxX: number;
  24119. /** @hidden */
  24120. _minZ: number;
  24121. /** @hidden */
  24122. _maxZ: number;
  24123. constructor(name: string, scene: Scene);
  24124. /**
  24125. * "GroundMesh"
  24126. * @returns "GroundMesh"
  24127. */
  24128. getClassName(): string;
  24129. /**
  24130. * The minimum of x and y subdivisions
  24131. */
  24132. get subdivisions(): number;
  24133. /**
  24134. * X subdivisions
  24135. */
  24136. get subdivisionsX(): number;
  24137. /**
  24138. * Y subdivisions
  24139. */
  24140. get subdivisionsY(): number;
  24141. /**
  24142. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  24143. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  24144. * @param chunksCount the number of subdivisions for x and y
  24145. * @param octreeBlocksSize (Default: 32)
  24146. */
  24147. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  24148. /**
  24149. * Returns a height (y) value in the Worl system :
  24150. * the ground altitude at the coordinates (x, z) expressed in the World system.
  24151. * @param x x coordinate
  24152. * @param z z coordinate
  24153. * @returns the ground y position if (x, z) are outside the ground surface.
  24154. */
  24155. getHeightAtCoordinates(x: number, z: number): number;
  24156. /**
  24157. * Returns a normalized vector (Vector3) orthogonal to the ground
  24158. * at the ground coordinates (x, z) expressed in the World system.
  24159. * @param x x coordinate
  24160. * @param z z coordinate
  24161. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  24162. */
  24163. getNormalAtCoordinates(x: number, z: number): Vector3;
  24164. /**
  24165. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  24166. * at the ground coordinates (x, z) expressed in the World system.
  24167. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  24168. * @param x x coordinate
  24169. * @param z z coordinate
  24170. * @param ref vector to store the result
  24171. * @returns the GroundMesh.
  24172. */
  24173. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  24174. /**
  24175. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  24176. * if the ground has been updated.
  24177. * This can be used in the render loop.
  24178. * @returns the GroundMesh.
  24179. */
  24180. updateCoordinateHeights(): GroundMesh;
  24181. private _getFacetAt;
  24182. private _initHeightQuads;
  24183. private _computeHeightQuads;
  24184. /**
  24185. * Serializes this ground mesh
  24186. * @param serializationObject object to write serialization to
  24187. */
  24188. serialize(serializationObject: any): void;
  24189. /**
  24190. * Parses a serialized ground mesh
  24191. * @param parsedMesh the serialized mesh
  24192. * @param scene the scene to create the ground mesh in
  24193. * @returns the created ground mesh
  24194. */
  24195. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  24196. }
  24197. }
  24198. declare module "babylonjs/Physics/physicsJoint" {
  24199. import { Vector3 } from "babylonjs/Maths/math.vector";
  24200. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  24201. /**
  24202. * Interface for Physics-Joint data
  24203. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24204. */
  24205. export interface PhysicsJointData {
  24206. /**
  24207. * The main pivot of the joint
  24208. */
  24209. mainPivot?: Vector3;
  24210. /**
  24211. * The connected pivot of the joint
  24212. */
  24213. connectedPivot?: Vector3;
  24214. /**
  24215. * The main axis of the joint
  24216. */
  24217. mainAxis?: Vector3;
  24218. /**
  24219. * The connected axis of the joint
  24220. */
  24221. connectedAxis?: Vector3;
  24222. /**
  24223. * The collision of the joint
  24224. */
  24225. collision?: boolean;
  24226. /**
  24227. * Native Oimo/Cannon/Energy data
  24228. */
  24229. nativeParams?: any;
  24230. }
  24231. /**
  24232. * This is a holder class for the physics joint created by the physics plugin
  24233. * It holds a set of functions to control the underlying joint
  24234. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24235. */
  24236. export class PhysicsJoint {
  24237. /**
  24238. * The type of the physics joint
  24239. */
  24240. type: number;
  24241. /**
  24242. * The data for the physics joint
  24243. */
  24244. jointData: PhysicsJointData;
  24245. private _physicsJoint;
  24246. protected _physicsPlugin: IPhysicsEnginePlugin;
  24247. /**
  24248. * Initializes the physics joint
  24249. * @param type The type of the physics joint
  24250. * @param jointData The data for the physics joint
  24251. */
  24252. constructor(
  24253. /**
  24254. * The type of the physics joint
  24255. */
  24256. type: number,
  24257. /**
  24258. * The data for the physics joint
  24259. */
  24260. jointData: PhysicsJointData);
  24261. /**
  24262. * Gets the physics joint
  24263. */
  24264. get physicsJoint(): any;
  24265. /**
  24266. * Sets the physics joint
  24267. */
  24268. set physicsJoint(newJoint: any);
  24269. /**
  24270. * Sets the physics plugin
  24271. */
  24272. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  24273. /**
  24274. * Execute a function that is physics-plugin specific.
  24275. * @param {Function} func the function that will be executed.
  24276. * It accepts two parameters: the physics world and the physics joint
  24277. */
  24278. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  24279. /**
  24280. * Distance-Joint type
  24281. */
  24282. static DistanceJoint: number;
  24283. /**
  24284. * Hinge-Joint type
  24285. */
  24286. static HingeJoint: number;
  24287. /**
  24288. * Ball-and-Socket joint type
  24289. */
  24290. static BallAndSocketJoint: number;
  24291. /**
  24292. * Wheel-Joint type
  24293. */
  24294. static WheelJoint: number;
  24295. /**
  24296. * Slider-Joint type
  24297. */
  24298. static SliderJoint: number;
  24299. /**
  24300. * Prismatic-Joint type
  24301. */
  24302. static PrismaticJoint: number;
  24303. /**
  24304. * Universal-Joint type
  24305. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  24306. */
  24307. static UniversalJoint: number;
  24308. /**
  24309. * Hinge-Joint 2 type
  24310. */
  24311. static Hinge2Joint: number;
  24312. /**
  24313. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  24314. */
  24315. static PointToPointJoint: number;
  24316. /**
  24317. * Spring-Joint type
  24318. */
  24319. static SpringJoint: number;
  24320. /**
  24321. * Lock-Joint type
  24322. */
  24323. static LockJoint: number;
  24324. }
  24325. /**
  24326. * A class representing a physics distance joint
  24327. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24328. */
  24329. export class DistanceJoint extends PhysicsJoint {
  24330. /**
  24331. *
  24332. * @param jointData The data for the Distance-Joint
  24333. */
  24334. constructor(jointData: DistanceJointData);
  24335. /**
  24336. * Update the predefined distance.
  24337. * @param maxDistance The maximum preferred distance
  24338. * @param minDistance The minimum preferred distance
  24339. */
  24340. updateDistance(maxDistance: number, minDistance?: number): void;
  24341. }
  24342. /**
  24343. * Represents a Motor-Enabled Joint
  24344. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24345. */
  24346. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  24347. /**
  24348. * Initializes the Motor-Enabled Joint
  24349. * @param type The type of the joint
  24350. * @param jointData The physica joint data for the joint
  24351. */
  24352. constructor(type: number, jointData: PhysicsJointData);
  24353. /**
  24354. * Set the motor values.
  24355. * Attention, this function is plugin specific. Engines won't react 100% the same.
  24356. * @param force the force to apply
  24357. * @param maxForce max force for this motor.
  24358. */
  24359. setMotor(force?: number, maxForce?: number): void;
  24360. /**
  24361. * Set the motor's limits.
  24362. * Attention, this function is plugin specific. Engines won't react 100% the same.
  24363. * @param upperLimit The upper limit of the motor
  24364. * @param lowerLimit The lower limit of the motor
  24365. */
  24366. setLimit(upperLimit: number, lowerLimit?: number): void;
  24367. }
  24368. /**
  24369. * This class represents a single physics Hinge-Joint
  24370. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24371. */
  24372. export class HingeJoint extends MotorEnabledJoint {
  24373. /**
  24374. * Initializes the Hinge-Joint
  24375. * @param jointData The joint data for the Hinge-Joint
  24376. */
  24377. constructor(jointData: PhysicsJointData);
  24378. /**
  24379. * Set the motor values.
  24380. * Attention, this function is plugin specific. Engines won't react 100% the same.
  24381. * @param {number} force the force to apply
  24382. * @param {number} maxForce max force for this motor.
  24383. */
  24384. setMotor(force?: number, maxForce?: number): void;
  24385. /**
  24386. * Set the motor's limits.
  24387. * Attention, this function is plugin specific. Engines won't react 100% the same.
  24388. * @param upperLimit The upper limit of the motor
  24389. * @param lowerLimit The lower limit of the motor
  24390. */
  24391. setLimit(upperLimit: number, lowerLimit?: number): void;
  24392. }
  24393. /**
  24394. * This class represents a dual hinge physics joint (same as wheel joint)
  24395. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24396. */
  24397. export class Hinge2Joint extends MotorEnabledJoint {
  24398. /**
  24399. * Initializes the Hinge2-Joint
  24400. * @param jointData The joint data for the Hinge2-Joint
  24401. */
  24402. constructor(jointData: PhysicsJointData);
  24403. /**
  24404. * Set the motor values.
  24405. * Attention, this function is plugin specific. Engines won't react 100% the same.
  24406. * @param {number} targetSpeed the speed the motor is to reach
  24407. * @param {number} maxForce max force for this motor.
  24408. * @param {motorIndex} the motor's index, 0 or 1.
  24409. */
  24410. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  24411. /**
  24412. * Set the motor limits.
  24413. * Attention, this function is plugin specific. Engines won't react 100% the same.
  24414. * @param {number} upperLimit the upper limit
  24415. * @param {number} lowerLimit lower limit
  24416. * @param {motorIndex} the motor's index, 0 or 1.
  24417. */
  24418. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  24419. }
  24420. /**
  24421. * Interface for a motor enabled joint
  24422. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24423. */
  24424. export interface IMotorEnabledJoint {
  24425. /**
  24426. * Physics joint
  24427. */
  24428. physicsJoint: any;
  24429. /**
  24430. * Sets the motor of the motor-enabled joint
  24431. * @param force The force of the motor
  24432. * @param maxForce The maximum force of the motor
  24433. * @param motorIndex The index of the motor
  24434. */
  24435. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  24436. /**
  24437. * Sets the limit of the motor
  24438. * @param upperLimit The upper limit of the motor
  24439. * @param lowerLimit The lower limit of the motor
  24440. * @param motorIndex The index of the motor
  24441. */
  24442. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  24443. }
  24444. /**
  24445. * Joint data for a Distance-Joint
  24446. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24447. */
  24448. export interface DistanceJointData extends PhysicsJointData {
  24449. /**
  24450. * Max distance the 2 joint objects can be apart
  24451. */
  24452. maxDistance: number;
  24453. }
  24454. /**
  24455. * Joint data from a spring joint
  24456. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24457. */
  24458. export interface SpringJointData extends PhysicsJointData {
  24459. /**
  24460. * Length of the spring
  24461. */
  24462. length: number;
  24463. /**
  24464. * Stiffness of the spring
  24465. */
  24466. stiffness: number;
  24467. /**
  24468. * Damping of the spring
  24469. */
  24470. damping: number;
  24471. /** this callback will be called when applying the force to the impostors. */
  24472. forceApplicationCallback: () => void;
  24473. }
  24474. }
  24475. declare module "babylonjs/Physics/physicsRaycastResult" {
  24476. import { Vector3 } from "babylonjs/Maths/math.vector";
  24477. /**
  24478. * Holds the data for the raycast result
  24479. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24480. */
  24481. export class PhysicsRaycastResult {
  24482. private _hasHit;
  24483. private _hitDistance;
  24484. private _hitNormalWorld;
  24485. private _hitPointWorld;
  24486. private _rayFromWorld;
  24487. private _rayToWorld;
  24488. /**
  24489. * Gets if there was a hit
  24490. */
  24491. get hasHit(): boolean;
  24492. /**
  24493. * Gets the distance from the hit
  24494. */
  24495. get hitDistance(): number;
  24496. /**
  24497. * Gets the hit normal/direction in the world
  24498. */
  24499. get hitNormalWorld(): Vector3;
  24500. /**
  24501. * Gets the hit point in the world
  24502. */
  24503. get hitPointWorld(): Vector3;
  24504. /**
  24505. * Gets the ray "start point" of the ray in the world
  24506. */
  24507. get rayFromWorld(): Vector3;
  24508. /**
  24509. * Gets the ray "end point" of the ray in the world
  24510. */
  24511. get rayToWorld(): Vector3;
  24512. /**
  24513. * Sets the hit data (normal & point in world space)
  24514. * @param hitNormalWorld defines the normal in world space
  24515. * @param hitPointWorld defines the point in world space
  24516. */
  24517. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  24518. /**
  24519. * Sets the distance from the start point to the hit point
  24520. * @param distance
  24521. */
  24522. setHitDistance(distance: number): void;
  24523. /**
  24524. * Calculates the distance manually
  24525. */
  24526. calculateHitDistance(): void;
  24527. /**
  24528. * Resets all the values to default
  24529. * @param from The from point on world space
  24530. * @param to The to point on world space
  24531. */
  24532. reset(from?: Vector3, to?: Vector3): void;
  24533. }
  24534. /**
  24535. * Interface for the size containing width and height
  24536. */
  24537. interface IXYZ {
  24538. /**
  24539. * X
  24540. */
  24541. x: number;
  24542. /**
  24543. * Y
  24544. */
  24545. y: number;
  24546. /**
  24547. * Z
  24548. */
  24549. z: number;
  24550. }
  24551. }
  24552. declare module "babylonjs/Physics/IPhysicsEngine" {
  24553. import { Nullable } from "babylonjs/types";
  24554. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  24555. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24556. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  24557. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  24558. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  24559. /**
  24560. * Interface used to describe a physics joint
  24561. */
  24562. export interface PhysicsImpostorJoint {
  24563. /** Defines the main impostor to which the joint is linked */
  24564. mainImpostor: PhysicsImpostor;
  24565. /** Defines the impostor that is connected to the main impostor using this joint */
  24566. connectedImpostor: PhysicsImpostor;
  24567. /** Defines the joint itself */
  24568. joint: PhysicsJoint;
  24569. }
  24570. /** @hidden */
  24571. export interface IPhysicsEnginePlugin {
  24572. world: any;
  24573. name: string;
  24574. setGravity(gravity: Vector3): void;
  24575. setTimeStep(timeStep: number): void;
  24576. getTimeStep(): number;
  24577. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  24578. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  24579. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  24580. generatePhysicsBody(impostor: PhysicsImpostor): void;
  24581. removePhysicsBody(impostor: PhysicsImpostor): void;
  24582. generateJoint(joint: PhysicsImpostorJoint): void;
  24583. removeJoint(joint: PhysicsImpostorJoint): void;
  24584. isSupported(): boolean;
  24585. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  24586. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  24587. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  24588. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  24589. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  24590. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  24591. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  24592. getBodyMass(impostor: PhysicsImpostor): number;
  24593. getBodyFriction(impostor: PhysicsImpostor): number;
  24594. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  24595. getBodyRestitution(impostor: PhysicsImpostor): number;
  24596. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  24597. getBodyPressure?(impostor: PhysicsImpostor): number;
  24598. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  24599. getBodyStiffness?(impostor: PhysicsImpostor): number;
  24600. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  24601. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  24602. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  24603. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  24604. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  24605. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  24606. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  24607. sleepBody(impostor: PhysicsImpostor): void;
  24608. wakeUpBody(impostor: PhysicsImpostor): void;
  24609. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  24610. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  24611. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  24612. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  24613. getRadius(impostor: PhysicsImpostor): number;
  24614. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  24615. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  24616. dispose(): void;
  24617. }
  24618. /**
  24619. * Interface used to define a physics engine
  24620. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  24621. */
  24622. export interface IPhysicsEngine {
  24623. /**
  24624. * Gets the gravity vector used by the simulation
  24625. */
  24626. gravity: Vector3;
  24627. /**
  24628. * Sets the gravity vector used by the simulation
  24629. * @param gravity defines the gravity vector to use
  24630. */
  24631. setGravity(gravity: Vector3): void;
  24632. /**
  24633. * Set the time step of the physics engine.
  24634. * Default is 1/60.
  24635. * To slow it down, enter 1/600 for example.
  24636. * To speed it up, 1/30
  24637. * @param newTimeStep the new timestep to apply to this world.
  24638. */
  24639. setTimeStep(newTimeStep: number): void;
  24640. /**
  24641. * Get the time step of the physics engine.
  24642. * @returns the current time step
  24643. */
  24644. getTimeStep(): number;
  24645. /**
  24646. * Set the sub time step of the physics engine.
  24647. * Default is 0 meaning there is no sub steps
  24648. * To increase physics resolution precision, set a small value (like 1 ms)
  24649. * @param subTimeStep defines the new sub timestep used for physics resolution.
  24650. */
  24651. setSubTimeStep(subTimeStep: number): void;
  24652. /**
  24653. * Get the sub time step of the physics engine.
  24654. * @returns the current sub time step
  24655. */
  24656. getSubTimeStep(): number;
  24657. /**
  24658. * Release all resources
  24659. */
  24660. dispose(): void;
  24661. /**
  24662. * Gets the name of the current physics plugin
  24663. * @returns the name of the plugin
  24664. */
  24665. getPhysicsPluginName(): string;
  24666. /**
  24667. * Adding a new impostor for the impostor tracking.
  24668. * This will be done by the impostor itself.
  24669. * @param impostor the impostor to add
  24670. */
  24671. addImpostor(impostor: PhysicsImpostor): void;
  24672. /**
  24673. * Remove an impostor from the engine.
  24674. * This impostor and its mesh will not longer be updated by the physics engine.
  24675. * @param impostor the impostor to remove
  24676. */
  24677. removeImpostor(impostor: PhysicsImpostor): void;
  24678. /**
  24679. * Add a joint to the physics engine
  24680. * @param mainImpostor defines the main impostor to which the joint is added.
  24681. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  24682. * @param joint defines the joint that will connect both impostors.
  24683. */
  24684. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  24685. /**
  24686. * Removes a joint from the simulation
  24687. * @param mainImpostor defines the impostor used with the joint
  24688. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  24689. * @param joint defines the joint to remove
  24690. */
  24691. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  24692. /**
  24693. * Gets the current plugin used to run the simulation
  24694. * @returns current plugin
  24695. */
  24696. getPhysicsPlugin(): IPhysicsEnginePlugin;
  24697. /**
  24698. * Gets the list of physic impostors
  24699. * @returns an array of PhysicsImpostor
  24700. */
  24701. getImpostors(): Array<PhysicsImpostor>;
  24702. /**
  24703. * Gets the impostor for a physics enabled object
  24704. * @param object defines the object impersonated by the impostor
  24705. * @returns the PhysicsImpostor or null if not found
  24706. */
  24707. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  24708. /**
  24709. * Gets the impostor for a physics body object
  24710. * @param body defines physics body used by the impostor
  24711. * @returns the PhysicsImpostor or null if not found
  24712. */
  24713. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  24714. /**
  24715. * Does a raycast in the physics world
  24716. * @param from when should the ray start?
  24717. * @param to when should the ray end?
  24718. * @returns PhysicsRaycastResult
  24719. */
  24720. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  24721. /**
  24722. * Called by the scene. No need to call it.
  24723. * @param delta defines the timespam between frames
  24724. */
  24725. _step(delta: number): void;
  24726. }
  24727. }
  24728. declare module "babylonjs/Physics/physicsImpostor" {
  24729. import { Nullable, IndicesArray } from "babylonjs/types";
  24730. import { Vector3, Matrix, Quaternion } from "babylonjs/Maths/math.vector";
  24731. import { TransformNode } from "babylonjs/Meshes/transformNode";
  24732. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24733. import { Scene } from "babylonjs/scene";
  24734. import { Bone } from "babylonjs/Bones/bone";
  24735. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  24736. import { PhysicsJoint, PhysicsJointData } from "babylonjs/Physics/physicsJoint";
  24737. import { Space } from "babylonjs/Maths/math.axis";
  24738. /**
  24739. * The interface for the physics imposter parameters
  24740. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24741. */
  24742. export interface PhysicsImpostorParameters {
  24743. /**
  24744. * The mass of the physics imposter
  24745. */
  24746. mass: number;
  24747. /**
  24748. * The friction of the physics imposter
  24749. */
  24750. friction?: number;
  24751. /**
  24752. * The coefficient of restitution of the physics imposter
  24753. */
  24754. restitution?: number;
  24755. /**
  24756. * The native options of the physics imposter
  24757. */
  24758. nativeOptions?: any;
  24759. /**
  24760. * Specifies if the parent should be ignored
  24761. */
  24762. ignoreParent?: boolean;
  24763. /**
  24764. * Specifies if bi-directional transformations should be disabled
  24765. */
  24766. disableBidirectionalTransformation?: boolean;
  24767. /**
  24768. * The pressure inside the physics imposter, soft object only
  24769. */
  24770. pressure?: number;
  24771. /**
  24772. * The stiffness the physics imposter, soft object only
  24773. */
  24774. stiffness?: number;
  24775. /**
  24776. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  24777. */
  24778. velocityIterations?: number;
  24779. /**
  24780. * The number of iterations used in maintaining consistent vertex positions, soft object only
  24781. */
  24782. positionIterations?: number;
  24783. /**
  24784. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  24785. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  24786. * Add to fix multiple points
  24787. */
  24788. fixedPoints?: number;
  24789. /**
  24790. * The collision margin around a soft object
  24791. */
  24792. margin?: number;
  24793. /**
  24794. * The collision margin around a soft object
  24795. */
  24796. damping?: number;
  24797. /**
  24798. * The path for a rope based on an extrusion
  24799. */
  24800. path?: any;
  24801. /**
  24802. * The shape of an extrusion used for a rope based on an extrusion
  24803. */
  24804. shape?: any;
  24805. }
  24806. /**
  24807. * Interface for a physics-enabled object
  24808. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24809. */
  24810. export interface IPhysicsEnabledObject {
  24811. /**
  24812. * The position of the physics-enabled object
  24813. */
  24814. position: Vector3;
  24815. /**
  24816. * The rotation of the physics-enabled object
  24817. */
  24818. rotationQuaternion: Nullable<Quaternion>;
  24819. /**
  24820. * The scale of the physics-enabled object
  24821. */
  24822. scaling: Vector3;
  24823. /**
  24824. * The rotation of the physics-enabled object
  24825. */
  24826. rotation?: Vector3;
  24827. /**
  24828. * The parent of the physics-enabled object
  24829. */
  24830. parent?: any;
  24831. /**
  24832. * The bounding info of the physics-enabled object
  24833. * @returns The bounding info of the physics-enabled object
  24834. */
  24835. getBoundingInfo(): BoundingInfo;
  24836. /**
  24837. * Computes the world matrix
  24838. * @param force Specifies if the world matrix should be computed by force
  24839. * @returns A world matrix
  24840. */
  24841. computeWorldMatrix(force: boolean): Matrix;
  24842. /**
  24843. * Gets the world matrix
  24844. * @returns A world matrix
  24845. */
  24846. getWorldMatrix?(): Matrix;
  24847. /**
  24848. * Gets the child meshes
  24849. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  24850. * @returns An array of abstract meshes
  24851. */
  24852. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  24853. /**
  24854. * Gets the vertex data
  24855. * @param kind The type of vertex data
  24856. * @returns A nullable array of numbers, or a float32 array
  24857. */
  24858. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  24859. /**
  24860. * Gets the indices from the mesh
  24861. * @returns A nullable array of index arrays
  24862. */
  24863. getIndices?(): Nullable<IndicesArray>;
  24864. /**
  24865. * Gets the scene from the mesh
  24866. * @returns the indices array or null
  24867. */
  24868. getScene?(): Scene;
  24869. /**
  24870. * Gets the absolute position from the mesh
  24871. * @returns the absolute position
  24872. */
  24873. getAbsolutePosition(): Vector3;
  24874. /**
  24875. * Gets the absolute pivot point from the mesh
  24876. * @returns the absolute pivot point
  24877. */
  24878. getAbsolutePivotPoint(): Vector3;
  24879. /**
  24880. * Rotates the mesh
  24881. * @param axis The axis of rotation
  24882. * @param amount The amount of rotation
  24883. * @param space The space of the rotation
  24884. * @returns The rotation transform node
  24885. */
  24886. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  24887. /**
  24888. * Translates the mesh
  24889. * @param axis The axis of translation
  24890. * @param distance The distance of translation
  24891. * @param space The space of the translation
  24892. * @returns The transform node
  24893. */
  24894. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  24895. /**
  24896. * Sets the absolute position of the mesh
  24897. * @param absolutePosition The absolute position of the mesh
  24898. * @returns The transform node
  24899. */
  24900. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  24901. /**
  24902. * Gets the class name of the mesh
  24903. * @returns The class name
  24904. */
  24905. getClassName(): string;
  24906. }
  24907. /**
  24908. * Represents a physics imposter
  24909. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24910. */
  24911. export class PhysicsImpostor {
  24912. /**
  24913. * The physics-enabled object used as the physics imposter
  24914. */
  24915. object: IPhysicsEnabledObject;
  24916. /**
  24917. * The type of the physics imposter
  24918. */
  24919. type: number;
  24920. private _options;
  24921. private _scene?;
  24922. /**
  24923. * The default object size of the imposter
  24924. */
  24925. static DEFAULT_OBJECT_SIZE: Vector3;
  24926. /**
  24927. * The identity quaternion of the imposter
  24928. */
  24929. static IDENTITY_QUATERNION: Quaternion;
  24930. /** @hidden */
  24931. _pluginData: any;
  24932. private _physicsEngine;
  24933. private _physicsBody;
  24934. private _bodyUpdateRequired;
  24935. private _onBeforePhysicsStepCallbacks;
  24936. private _onAfterPhysicsStepCallbacks;
  24937. /** @hidden */
  24938. _onPhysicsCollideCallbacks: Array<{
  24939. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  24940. otherImpostors: Array<PhysicsImpostor>;
  24941. }>;
  24942. private _deltaPosition;
  24943. private _deltaRotation;
  24944. private _deltaRotationConjugated;
  24945. /** @hidden */
  24946. _isFromLine: boolean;
  24947. private _parent;
  24948. private _isDisposed;
  24949. private static _tmpVecs;
  24950. private static _tmpQuat;
  24951. /**
  24952. * Specifies if the physics imposter is disposed
  24953. */
  24954. get isDisposed(): boolean;
  24955. /**
  24956. * Gets the mass of the physics imposter
  24957. */
  24958. get mass(): number;
  24959. set mass(value: number);
  24960. /**
  24961. * Gets the coefficient of friction
  24962. */
  24963. get friction(): number;
  24964. /**
  24965. * Sets the coefficient of friction
  24966. */
  24967. set friction(value: number);
  24968. /**
  24969. * Gets the coefficient of restitution
  24970. */
  24971. get restitution(): number;
  24972. /**
  24973. * Sets the coefficient of restitution
  24974. */
  24975. set restitution(value: number);
  24976. /**
  24977. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  24978. */
  24979. get pressure(): number;
  24980. /**
  24981. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  24982. */
  24983. set pressure(value: number);
  24984. /**
  24985. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  24986. */
  24987. get stiffness(): number;
  24988. /**
  24989. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  24990. */
  24991. set stiffness(value: number);
  24992. /**
  24993. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  24994. */
  24995. get velocityIterations(): number;
  24996. /**
  24997. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  24998. */
  24999. set velocityIterations(value: number);
  25000. /**
  25001. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  25002. */
  25003. get positionIterations(): number;
  25004. /**
  25005. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  25006. */
  25007. set positionIterations(value: number);
  25008. /**
  25009. * The unique id of the physics imposter
  25010. * set by the physics engine when adding this impostor to the array
  25011. */
  25012. uniqueId: number;
  25013. /**
  25014. * @hidden
  25015. */
  25016. soft: boolean;
  25017. /**
  25018. * @hidden
  25019. */
  25020. segments: number;
  25021. private _joints;
  25022. /**
  25023. * Initializes the physics imposter
  25024. * @param object The physics-enabled object used as the physics imposter
  25025. * @param type The type of the physics imposter
  25026. * @param _options The options for the physics imposter
  25027. * @param _scene The Babylon scene
  25028. */
  25029. constructor(
  25030. /**
  25031. * The physics-enabled object used as the physics imposter
  25032. */
  25033. object: IPhysicsEnabledObject,
  25034. /**
  25035. * The type of the physics imposter
  25036. */
  25037. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  25038. /**
  25039. * This function will completly initialize this impostor.
  25040. * It will create a new body - but only if this mesh has no parent.
  25041. * If it has, this impostor will not be used other than to define the impostor
  25042. * of the child mesh.
  25043. * @hidden
  25044. */
  25045. _init(): void;
  25046. private _getPhysicsParent;
  25047. /**
  25048. * Should a new body be generated.
  25049. * @returns boolean specifying if body initialization is required
  25050. */
  25051. isBodyInitRequired(): boolean;
  25052. /**
  25053. * Sets the updated scaling
  25054. * @param updated Specifies if the scaling is updated
  25055. */
  25056. setScalingUpdated(): void;
  25057. /**
  25058. * Force a regeneration of this or the parent's impostor's body.
  25059. * Use under cautious - This will remove all joints already implemented.
  25060. */
  25061. forceUpdate(): void;
  25062. /**
  25063. * Gets the body that holds this impostor. Either its own, or its parent.
  25064. */
  25065. get physicsBody(): any;
  25066. /**
  25067. * Get the parent of the physics imposter
  25068. * @returns Physics imposter or null
  25069. */
  25070. get parent(): Nullable<PhysicsImpostor>;
  25071. /**
  25072. * Sets the parent of the physics imposter
  25073. */
  25074. set parent(value: Nullable<PhysicsImpostor>);
  25075. /**
  25076. * Set the physics body. Used mainly by the physics engine/plugin
  25077. */
  25078. set physicsBody(physicsBody: any);
  25079. /**
  25080. * Resets the update flags
  25081. */
  25082. resetUpdateFlags(): void;
  25083. /**
  25084. * Gets the object extend size
  25085. * @returns the object extend size
  25086. */
  25087. getObjectExtendSize(): Vector3;
  25088. /**
  25089. * Gets the object center
  25090. * @returns The object center
  25091. */
  25092. getObjectCenter(): Vector3;
  25093. /**
  25094. * Get a specific parameter from the options parameters
  25095. * @param paramName The object parameter name
  25096. * @returns The object parameter
  25097. */
  25098. getParam(paramName: string): any;
  25099. /**
  25100. * Sets a specific parameter in the options given to the physics plugin
  25101. * @param paramName The parameter name
  25102. * @param value The value of the parameter
  25103. */
  25104. setParam(paramName: string, value: number): void;
  25105. /**
  25106. * Specifically change the body's mass option. Won't recreate the physics body object
  25107. * @param mass The mass of the physics imposter
  25108. */
  25109. setMass(mass: number): void;
  25110. /**
  25111. * Gets the linear velocity
  25112. * @returns linear velocity or null
  25113. */
  25114. getLinearVelocity(): Nullable<Vector3>;
  25115. /**
  25116. * Sets the linear velocity
  25117. * @param velocity linear velocity or null
  25118. */
  25119. setLinearVelocity(velocity: Nullable<Vector3>): void;
  25120. /**
  25121. * Gets the angular velocity
  25122. * @returns angular velocity or null
  25123. */
  25124. getAngularVelocity(): Nullable<Vector3>;
  25125. /**
  25126. * Sets the angular velocity
  25127. * @param velocity The velocity or null
  25128. */
  25129. setAngularVelocity(velocity: Nullable<Vector3>): void;
  25130. /**
  25131. * Execute a function with the physics plugin native code
  25132. * Provide a function the will have two variables - the world object and the physics body object
  25133. * @param func The function to execute with the physics plugin native code
  25134. */
  25135. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  25136. /**
  25137. * Register a function that will be executed before the physics world is stepping forward
  25138. * @param func The function to execute before the physics world is stepped forward
  25139. */
  25140. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  25141. /**
  25142. * Unregister a function that will be executed before the physics world is stepping forward
  25143. * @param func The function to execute before the physics world is stepped forward
  25144. */
  25145. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  25146. /**
  25147. * Register a function that will be executed after the physics step
  25148. * @param func The function to execute after physics step
  25149. */
  25150. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  25151. /**
  25152. * Unregisters a function that will be executed after the physics step
  25153. * @param func The function to execute after physics step
  25154. */
  25155. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  25156. /**
  25157. * register a function that will be executed when this impostor collides against a different body
  25158. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  25159. * @param func Callback that is executed on collision
  25160. */
  25161. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  25162. /**
  25163. * Unregisters the physics imposter on contact
  25164. * @param collideAgainst The physics object to collide against
  25165. * @param func Callback to execute on collision
  25166. */
  25167. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  25168. private _tmpQuat;
  25169. private _tmpQuat2;
  25170. /**
  25171. * Get the parent rotation
  25172. * @returns The parent rotation
  25173. */
  25174. getParentsRotation(): Quaternion;
  25175. /**
  25176. * this function is executed by the physics engine.
  25177. */
  25178. beforeStep: () => void;
  25179. /**
  25180. * this function is executed by the physics engine
  25181. */
  25182. afterStep: () => void;
  25183. /**
  25184. * Legacy collision detection event support
  25185. */
  25186. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  25187. /**
  25188. * event and body object due to cannon's event-based architecture.
  25189. */
  25190. onCollide: (e: {
  25191. body: any;
  25192. }) => void;
  25193. /**
  25194. * Apply a force
  25195. * @param force The force to apply
  25196. * @param contactPoint The contact point for the force
  25197. * @returns The physics imposter
  25198. */
  25199. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  25200. /**
  25201. * Apply an impulse
  25202. * @param force The impulse force
  25203. * @param contactPoint The contact point for the impulse force
  25204. * @returns The physics imposter
  25205. */
  25206. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  25207. /**
  25208. * A help function to create a joint
  25209. * @param otherImpostor A physics imposter used to create a joint
  25210. * @param jointType The type of joint
  25211. * @param jointData The data for the joint
  25212. * @returns The physics imposter
  25213. */
  25214. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  25215. /**
  25216. * Add a joint to this impostor with a different impostor
  25217. * @param otherImpostor A physics imposter used to add a joint
  25218. * @param joint The joint to add
  25219. * @returns The physics imposter
  25220. */
  25221. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  25222. /**
  25223. * Add an anchor to a cloth impostor
  25224. * @param otherImpostor rigid impostor to anchor to
  25225. * @param width ratio across width from 0 to 1
  25226. * @param height ratio up height from 0 to 1
  25227. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  25228. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  25229. * @returns impostor the soft imposter
  25230. */
  25231. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  25232. /**
  25233. * Add a hook to a rope impostor
  25234. * @param otherImpostor rigid impostor to anchor to
  25235. * @param length ratio across rope from 0 to 1
  25236. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  25237. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  25238. * @returns impostor the rope imposter
  25239. */
  25240. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  25241. /**
  25242. * Will keep this body still, in a sleep mode.
  25243. * @returns the physics imposter
  25244. */
  25245. sleep(): PhysicsImpostor;
  25246. /**
  25247. * Wake the body up.
  25248. * @returns The physics imposter
  25249. */
  25250. wakeUp(): PhysicsImpostor;
  25251. /**
  25252. * Clones the physics imposter
  25253. * @param newObject The physics imposter clones to this physics-enabled object
  25254. * @returns A nullable physics imposter
  25255. */
  25256. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  25257. /**
  25258. * Disposes the physics imposter
  25259. */
  25260. dispose(): void;
  25261. /**
  25262. * Sets the delta position
  25263. * @param position The delta position amount
  25264. */
  25265. setDeltaPosition(position: Vector3): void;
  25266. /**
  25267. * Sets the delta rotation
  25268. * @param rotation The delta rotation amount
  25269. */
  25270. setDeltaRotation(rotation: Quaternion): void;
  25271. /**
  25272. * Gets the box size of the physics imposter and stores the result in the input parameter
  25273. * @param result Stores the box size
  25274. * @returns The physics imposter
  25275. */
  25276. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  25277. /**
  25278. * Gets the radius of the physics imposter
  25279. * @returns Radius of the physics imposter
  25280. */
  25281. getRadius(): number;
  25282. /**
  25283. * Sync a bone with this impostor
  25284. * @param bone The bone to sync to the impostor.
  25285. * @param boneMesh The mesh that the bone is influencing.
  25286. * @param jointPivot The pivot of the joint / bone in local space.
  25287. * @param distToJoint Optional distance from the impostor to the joint.
  25288. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  25289. */
  25290. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  25291. /**
  25292. * Sync impostor to a bone
  25293. * @param bone The bone that the impostor will be synced to.
  25294. * @param boneMesh The mesh that the bone is influencing.
  25295. * @param jointPivot The pivot of the joint / bone in local space.
  25296. * @param distToJoint Optional distance from the impostor to the joint.
  25297. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  25298. * @param boneAxis Optional vector3 axis the bone is aligned with
  25299. */
  25300. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  25301. /**
  25302. * No-Imposter type
  25303. */
  25304. static NoImpostor: number;
  25305. /**
  25306. * Sphere-Imposter type
  25307. */
  25308. static SphereImpostor: number;
  25309. /**
  25310. * Box-Imposter type
  25311. */
  25312. static BoxImpostor: number;
  25313. /**
  25314. * Plane-Imposter type
  25315. */
  25316. static PlaneImpostor: number;
  25317. /**
  25318. * Mesh-imposter type
  25319. */
  25320. static MeshImpostor: number;
  25321. /**
  25322. * Capsule-Impostor type (Ammo.js plugin only)
  25323. */
  25324. static CapsuleImpostor: number;
  25325. /**
  25326. * Cylinder-Imposter type
  25327. */
  25328. static CylinderImpostor: number;
  25329. /**
  25330. * Particle-Imposter type
  25331. */
  25332. static ParticleImpostor: number;
  25333. /**
  25334. * Heightmap-Imposter type
  25335. */
  25336. static HeightmapImpostor: number;
  25337. /**
  25338. * ConvexHull-Impostor type (Ammo.js plugin only)
  25339. */
  25340. static ConvexHullImpostor: number;
  25341. /**
  25342. * Custom-Imposter type (Ammo.js plugin only)
  25343. */
  25344. static CustomImpostor: number;
  25345. /**
  25346. * Rope-Imposter type
  25347. */
  25348. static RopeImpostor: number;
  25349. /**
  25350. * Cloth-Imposter type
  25351. */
  25352. static ClothImpostor: number;
  25353. /**
  25354. * Softbody-Imposter type
  25355. */
  25356. static SoftbodyImpostor: number;
  25357. }
  25358. }
  25359. declare module "babylonjs/Meshes/mesh" {
  25360. import { Observable } from "babylonjs/Misc/observable";
  25361. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  25362. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  25363. import { Camera } from "babylonjs/Cameras/camera";
  25364. import { Scene } from "babylonjs/scene";
  25365. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  25366. import { Color4 } from "babylonjs/Maths/math.color";
  25367. import { Engine } from "babylonjs/Engines/engine";
  25368. import { Node } from "babylonjs/node";
  25369. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  25370. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  25371. import { Buffer } from "babylonjs/Meshes/buffer";
  25372. import { Geometry } from "babylonjs/Meshes/geometry";
  25373. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25374. import { SubMesh } from "babylonjs/Meshes/subMesh";
  25375. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  25376. import { Effect } from "babylonjs/Materials/effect";
  25377. import { Material } from "babylonjs/Materials/material";
  25378. import { Skeleton } from "babylonjs/Bones/skeleton";
  25379. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  25380. import { MeshLODLevel } from "babylonjs/Meshes/meshLODLevel";
  25381. import { Path3D } from "babylonjs/Maths/math.path";
  25382. import { Plane } from "babylonjs/Maths/math.plane";
  25383. import { TransformNode } from "babylonjs/Meshes/transformNode";
  25384. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  25385. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  25386. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  25387. import { IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  25388. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  25389. /**
  25390. * @hidden
  25391. **/
  25392. export class _CreationDataStorage {
  25393. closePath?: boolean;
  25394. closeArray?: boolean;
  25395. idx: number[];
  25396. dashSize: number;
  25397. gapSize: number;
  25398. path3D: Path3D;
  25399. pathArray: Vector3[][];
  25400. arc: number;
  25401. radius: number;
  25402. cap: number;
  25403. tessellation: number;
  25404. }
  25405. /**
  25406. * @hidden
  25407. **/
  25408. class _InstanceDataStorage {
  25409. visibleInstances: any;
  25410. batchCache: _InstancesBatch;
  25411. instancesBufferSize: number;
  25412. instancesBuffer: Nullable<Buffer>;
  25413. instancesData: Float32Array;
  25414. overridenInstanceCount: number;
  25415. isFrozen: boolean;
  25416. previousBatch: Nullable<_InstancesBatch>;
  25417. hardwareInstancedRendering: boolean;
  25418. sideOrientation: number;
  25419. manualUpdate: boolean;
  25420. }
  25421. /**
  25422. * @hidden
  25423. **/
  25424. export class _InstancesBatch {
  25425. mustReturn: boolean;
  25426. visibleInstances: Nullable<import("babylonjs/Meshes/instancedMesh").InstancedMesh[]>[];
  25427. renderSelf: boolean[];
  25428. hardwareInstancedRendering: boolean[];
  25429. }
  25430. /**
  25431. * Class used to represent renderable models
  25432. */
  25433. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  25434. /**
  25435. * Mesh side orientation : usually the external or front surface
  25436. */
  25437. static readonly FRONTSIDE: number;
  25438. /**
  25439. * Mesh side orientation : usually the internal or back surface
  25440. */
  25441. static readonly BACKSIDE: number;
  25442. /**
  25443. * Mesh side orientation : both internal and external or front and back surfaces
  25444. */
  25445. static readonly DOUBLESIDE: number;
  25446. /**
  25447. * Mesh side orientation : by default, `FRONTSIDE`
  25448. */
  25449. static readonly DEFAULTSIDE: number;
  25450. /**
  25451. * Mesh cap setting : no cap
  25452. */
  25453. static readonly NO_CAP: number;
  25454. /**
  25455. * Mesh cap setting : one cap at the beginning of the mesh
  25456. */
  25457. static readonly CAP_START: number;
  25458. /**
  25459. * Mesh cap setting : one cap at the end of the mesh
  25460. */
  25461. static readonly CAP_END: number;
  25462. /**
  25463. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  25464. */
  25465. static readonly CAP_ALL: number;
  25466. /**
  25467. * Mesh pattern setting : no flip or rotate
  25468. */
  25469. static readonly NO_FLIP: number;
  25470. /**
  25471. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  25472. */
  25473. static readonly FLIP_TILE: number;
  25474. /**
  25475. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  25476. */
  25477. static readonly ROTATE_TILE: number;
  25478. /**
  25479. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  25480. */
  25481. static readonly FLIP_ROW: number;
  25482. /**
  25483. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  25484. */
  25485. static readonly ROTATE_ROW: number;
  25486. /**
  25487. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  25488. */
  25489. static readonly FLIP_N_ROTATE_TILE: number;
  25490. /**
  25491. * Mesh pattern setting : rotate pattern and rotate
  25492. */
  25493. static readonly FLIP_N_ROTATE_ROW: number;
  25494. /**
  25495. * Mesh tile positioning : part tiles same on left/right or top/bottom
  25496. */
  25497. static readonly CENTER: number;
  25498. /**
  25499. * Mesh tile positioning : part tiles on left
  25500. */
  25501. static readonly LEFT: number;
  25502. /**
  25503. * Mesh tile positioning : part tiles on right
  25504. */
  25505. static readonly RIGHT: number;
  25506. /**
  25507. * Mesh tile positioning : part tiles on top
  25508. */
  25509. static readonly TOP: number;
  25510. /**
  25511. * Mesh tile positioning : part tiles on bottom
  25512. */
  25513. static readonly BOTTOM: number;
  25514. /**
  25515. * Gets the default side orientation.
  25516. * @param orientation the orientation to value to attempt to get
  25517. * @returns the default orientation
  25518. * @hidden
  25519. */
  25520. static _GetDefaultSideOrientation(orientation?: number): number;
  25521. private _internalMeshDataInfo;
  25522. /**
  25523. * An event triggered before rendering the mesh
  25524. */
  25525. get onBeforeRenderObservable(): Observable<Mesh>;
  25526. /**
  25527. * An event triggered before binding the mesh
  25528. */
  25529. get onBeforeBindObservable(): Observable<Mesh>;
  25530. /**
  25531. * An event triggered after rendering the mesh
  25532. */
  25533. get onAfterRenderObservable(): Observable<Mesh>;
  25534. /**
  25535. * An event triggered before drawing the mesh
  25536. */
  25537. get onBeforeDrawObservable(): Observable<Mesh>;
  25538. private _onBeforeDrawObserver;
  25539. /**
  25540. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  25541. */
  25542. set onBeforeDraw(callback: () => void);
  25543. get hasInstances(): boolean;
  25544. /**
  25545. * Gets the delay loading state of the mesh (when delay loading is turned on)
  25546. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  25547. */
  25548. delayLoadState: number;
  25549. /**
  25550. * Gets the list of instances created from this mesh
  25551. * it is not supposed to be modified manually.
  25552. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  25553. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  25554. */
  25555. instances: import("babylonjs/Meshes/instancedMesh").InstancedMesh[];
  25556. /**
  25557. * Gets the file containing delay loading data for this mesh
  25558. */
  25559. delayLoadingFile: string;
  25560. /** @hidden */
  25561. _binaryInfo: any;
  25562. /**
  25563. * User defined function used to change how LOD level selection is done
  25564. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  25565. */
  25566. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  25567. /**
  25568. * Gets or sets the morph target manager
  25569. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  25570. */
  25571. get morphTargetManager(): Nullable<MorphTargetManager>;
  25572. set morphTargetManager(value: Nullable<MorphTargetManager>);
  25573. /** @hidden */
  25574. _creationDataStorage: Nullable<_CreationDataStorage>;
  25575. /** @hidden */
  25576. _geometry: Nullable<Geometry>;
  25577. /** @hidden */
  25578. _delayInfo: Array<string>;
  25579. /** @hidden */
  25580. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  25581. /** @hidden */
  25582. _instanceDataStorage: _InstanceDataStorage;
  25583. private _effectiveMaterial;
  25584. /** @hidden */
  25585. _shouldGenerateFlatShading: boolean;
  25586. /** @hidden */
  25587. _originalBuilderSideOrientation: number;
  25588. /**
  25589. * Use this property to change the original side orientation defined at construction time
  25590. */
  25591. overrideMaterialSideOrientation: Nullable<number>;
  25592. /**
  25593. * Gets the source mesh (the one used to clone this one from)
  25594. */
  25595. get source(): Nullable<Mesh>;
  25596. /**
  25597. * Gets or sets a boolean indicating that this mesh does not use index buffer
  25598. */
  25599. get isUnIndexed(): boolean;
  25600. set isUnIndexed(value: boolean);
  25601. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  25602. get worldMatrixInstancedBuffer(): Float32Array;
  25603. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  25604. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  25605. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  25606. /**
  25607. * @constructor
  25608. * @param name The value used by scene.getMeshByName() to do a lookup.
  25609. * @param scene The scene to add this mesh to.
  25610. * @param parent The parent of this mesh, if it has one
  25611. * @param source An optional Mesh from which geometry is shared, cloned.
  25612. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  25613. * When false, achieved by calling a clone(), also passing False.
  25614. * This will make creation of children, recursive.
  25615. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  25616. */
  25617. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  25618. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  25619. doNotInstantiate: boolean;
  25620. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  25621. /**
  25622. * Gets the class name
  25623. * @returns the string "Mesh".
  25624. */
  25625. getClassName(): string;
  25626. /** @hidden */
  25627. get _isMesh(): boolean;
  25628. /**
  25629. * Returns a description of this mesh
  25630. * @param fullDetails define if full details about this mesh must be used
  25631. * @returns a descriptive string representing this mesh
  25632. */
  25633. toString(fullDetails?: boolean): string;
  25634. /** @hidden */
  25635. _unBindEffect(): void;
  25636. /**
  25637. * Gets a boolean indicating if this mesh has LOD
  25638. */
  25639. get hasLODLevels(): boolean;
  25640. /**
  25641. * Gets the list of MeshLODLevel associated with the current mesh
  25642. * @returns an array of MeshLODLevel
  25643. */
  25644. getLODLevels(): MeshLODLevel[];
  25645. private _sortLODLevels;
  25646. /**
  25647. * Add a mesh as LOD level triggered at the given distance.
  25648. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  25649. * @param distance The distance from the center of the object to show this level
  25650. * @param mesh The mesh to be added as LOD level (can be null)
  25651. * @return This mesh (for chaining)
  25652. */
  25653. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  25654. /**
  25655. * Returns the LOD level mesh at the passed distance or null if not found.
  25656. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  25657. * @param distance The distance from the center of the object to show this level
  25658. * @returns a Mesh or `null`
  25659. */
  25660. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  25661. /**
  25662. * Remove a mesh from the LOD array
  25663. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  25664. * @param mesh defines the mesh to be removed
  25665. * @return This mesh (for chaining)
  25666. */
  25667. removeLODLevel(mesh: Mesh): Mesh;
  25668. /**
  25669. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  25670. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  25671. * @param camera defines the camera to use to compute distance
  25672. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  25673. * @return This mesh (for chaining)
  25674. */
  25675. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  25676. /**
  25677. * Gets the mesh internal Geometry object
  25678. */
  25679. get geometry(): Nullable<Geometry>;
  25680. /**
  25681. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  25682. * @returns the total number of vertices
  25683. */
  25684. getTotalVertices(): number;
  25685. /**
  25686. * Returns the content of an associated vertex buffer
  25687. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  25688. * - VertexBuffer.PositionKind
  25689. * - VertexBuffer.UVKind
  25690. * - VertexBuffer.UV2Kind
  25691. * - VertexBuffer.UV3Kind
  25692. * - VertexBuffer.UV4Kind
  25693. * - VertexBuffer.UV5Kind
  25694. * - VertexBuffer.UV6Kind
  25695. * - VertexBuffer.ColorKind
  25696. * - VertexBuffer.MatricesIndicesKind
  25697. * - VertexBuffer.MatricesIndicesExtraKind
  25698. * - VertexBuffer.MatricesWeightsKind
  25699. * - VertexBuffer.MatricesWeightsExtraKind
  25700. * @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
  25701. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  25702. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  25703. */
  25704. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  25705. /**
  25706. * Returns the mesh VertexBuffer object from the requested `kind`
  25707. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  25708. * - VertexBuffer.PositionKind
  25709. * - VertexBuffer.NormalKind
  25710. * - VertexBuffer.UVKind
  25711. * - VertexBuffer.UV2Kind
  25712. * - VertexBuffer.UV3Kind
  25713. * - VertexBuffer.UV4Kind
  25714. * - VertexBuffer.UV5Kind
  25715. * - VertexBuffer.UV6Kind
  25716. * - VertexBuffer.ColorKind
  25717. * - VertexBuffer.MatricesIndicesKind
  25718. * - VertexBuffer.MatricesIndicesExtraKind
  25719. * - VertexBuffer.MatricesWeightsKind
  25720. * - VertexBuffer.MatricesWeightsExtraKind
  25721. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  25722. */
  25723. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  25724. /**
  25725. * Tests if a specific vertex buffer is associated with this mesh
  25726. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  25727. * - VertexBuffer.PositionKind
  25728. * - VertexBuffer.NormalKind
  25729. * - VertexBuffer.UVKind
  25730. * - VertexBuffer.UV2Kind
  25731. * - VertexBuffer.UV3Kind
  25732. * - VertexBuffer.UV4Kind
  25733. * - VertexBuffer.UV5Kind
  25734. * - VertexBuffer.UV6Kind
  25735. * - VertexBuffer.ColorKind
  25736. * - VertexBuffer.MatricesIndicesKind
  25737. * - VertexBuffer.MatricesIndicesExtraKind
  25738. * - VertexBuffer.MatricesWeightsKind
  25739. * - VertexBuffer.MatricesWeightsExtraKind
  25740. * @returns a boolean
  25741. */
  25742. isVerticesDataPresent(kind: string): boolean;
  25743. /**
  25744. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  25745. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  25746. * - VertexBuffer.PositionKind
  25747. * - VertexBuffer.UVKind
  25748. * - VertexBuffer.UV2Kind
  25749. * - VertexBuffer.UV3Kind
  25750. * - VertexBuffer.UV4Kind
  25751. * - VertexBuffer.UV5Kind
  25752. * - VertexBuffer.UV6Kind
  25753. * - VertexBuffer.ColorKind
  25754. * - VertexBuffer.MatricesIndicesKind
  25755. * - VertexBuffer.MatricesIndicesExtraKind
  25756. * - VertexBuffer.MatricesWeightsKind
  25757. * - VertexBuffer.MatricesWeightsExtraKind
  25758. * @returns a boolean
  25759. */
  25760. isVertexBufferUpdatable(kind: string): boolean;
  25761. /**
  25762. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  25763. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  25764. * - VertexBuffer.PositionKind
  25765. * - VertexBuffer.NormalKind
  25766. * - VertexBuffer.UVKind
  25767. * - VertexBuffer.UV2Kind
  25768. * - VertexBuffer.UV3Kind
  25769. * - VertexBuffer.UV4Kind
  25770. * - VertexBuffer.UV5Kind
  25771. * - VertexBuffer.UV6Kind
  25772. * - VertexBuffer.ColorKind
  25773. * - VertexBuffer.MatricesIndicesKind
  25774. * - VertexBuffer.MatricesIndicesExtraKind
  25775. * - VertexBuffer.MatricesWeightsKind
  25776. * - VertexBuffer.MatricesWeightsExtraKind
  25777. * @returns an array of strings
  25778. */
  25779. getVerticesDataKinds(): string[];
  25780. /**
  25781. * Returns a positive integer : the total number of indices in this mesh geometry.
  25782. * @returns the numner of indices or zero if the mesh has no geometry.
  25783. */
  25784. getTotalIndices(): number;
  25785. /**
  25786. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  25787. * @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.
  25788. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25789. * @returns the indices array or an empty array if the mesh has no geometry
  25790. */
  25791. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  25792. get isBlocked(): boolean;
  25793. /**
  25794. * Determine if the current mesh is ready to be rendered
  25795. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  25796. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  25797. * @returns true if all associated assets are ready (material, textures, shaders)
  25798. */
  25799. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  25800. /**
  25801. * 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.
  25802. */
  25803. get areNormalsFrozen(): boolean;
  25804. /**
  25805. * 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.
  25806. * @returns the current mesh
  25807. */
  25808. freezeNormals(): Mesh;
  25809. /**
  25810. * 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
  25811. * @returns the current mesh
  25812. */
  25813. unfreezeNormals(): Mesh;
  25814. /**
  25815. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  25816. */
  25817. set overridenInstanceCount(count: number);
  25818. /** @hidden */
  25819. _preActivate(): Mesh;
  25820. /** @hidden */
  25821. _preActivateForIntermediateRendering(renderId: number): Mesh;
  25822. /** @hidden */
  25823. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  25824. /**
  25825. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  25826. * This means the mesh underlying bounding box and sphere are recomputed.
  25827. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  25828. * @returns the current mesh
  25829. */
  25830. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  25831. /** @hidden */
  25832. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  25833. /**
  25834. * This function will subdivide the mesh into multiple submeshes
  25835. * @param count defines the expected number of submeshes
  25836. */
  25837. subdivide(count: number): void;
  25838. /**
  25839. * Copy a FloatArray into a specific associated vertex buffer
  25840. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  25841. * - VertexBuffer.PositionKind
  25842. * - VertexBuffer.UVKind
  25843. * - VertexBuffer.UV2Kind
  25844. * - VertexBuffer.UV3Kind
  25845. * - VertexBuffer.UV4Kind
  25846. * - VertexBuffer.UV5Kind
  25847. * - VertexBuffer.UV6Kind
  25848. * - VertexBuffer.ColorKind
  25849. * - VertexBuffer.MatricesIndicesKind
  25850. * - VertexBuffer.MatricesIndicesExtraKind
  25851. * - VertexBuffer.MatricesWeightsKind
  25852. * - VertexBuffer.MatricesWeightsExtraKind
  25853. * @param data defines the data source
  25854. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  25855. * @param stride defines the data stride size (can be null)
  25856. * @returns the current mesh
  25857. */
  25858. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  25859. /**
  25860. * Delete a vertex buffer associated with this mesh
  25861. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  25862. * - VertexBuffer.PositionKind
  25863. * - VertexBuffer.UVKind
  25864. * - VertexBuffer.UV2Kind
  25865. * - VertexBuffer.UV3Kind
  25866. * - VertexBuffer.UV4Kind
  25867. * - VertexBuffer.UV5Kind
  25868. * - VertexBuffer.UV6Kind
  25869. * - VertexBuffer.ColorKind
  25870. * - VertexBuffer.MatricesIndicesKind
  25871. * - VertexBuffer.MatricesIndicesExtraKind
  25872. * - VertexBuffer.MatricesWeightsKind
  25873. * - VertexBuffer.MatricesWeightsExtraKind
  25874. */
  25875. removeVerticesData(kind: string): void;
  25876. /**
  25877. * Flags an associated vertex buffer as updatable
  25878. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  25879. * - VertexBuffer.PositionKind
  25880. * - VertexBuffer.UVKind
  25881. * - VertexBuffer.UV2Kind
  25882. * - VertexBuffer.UV3Kind
  25883. * - VertexBuffer.UV4Kind
  25884. * - VertexBuffer.UV5Kind
  25885. * - VertexBuffer.UV6Kind
  25886. * - VertexBuffer.ColorKind
  25887. * - VertexBuffer.MatricesIndicesKind
  25888. * - VertexBuffer.MatricesIndicesExtraKind
  25889. * - VertexBuffer.MatricesWeightsKind
  25890. * - VertexBuffer.MatricesWeightsExtraKind
  25891. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  25892. */
  25893. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  25894. /**
  25895. * Sets the mesh global Vertex Buffer
  25896. * @param buffer defines the buffer to use
  25897. * @returns the current mesh
  25898. */
  25899. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  25900. /**
  25901. * Update a specific associated vertex buffer
  25902. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  25903. * - VertexBuffer.PositionKind
  25904. * - VertexBuffer.UVKind
  25905. * - VertexBuffer.UV2Kind
  25906. * - VertexBuffer.UV3Kind
  25907. * - VertexBuffer.UV4Kind
  25908. * - VertexBuffer.UV5Kind
  25909. * - VertexBuffer.UV6Kind
  25910. * - VertexBuffer.ColorKind
  25911. * - VertexBuffer.MatricesIndicesKind
  25912. * - VertexBuffer.MatricesIndicesExtraKind
  25913. * - VertexBuffer.MatricesWeightsKind
  25914. * - VertexBuffer.MatricesWeightsExtraKind
  25915. * @param data defines the data source
  25916. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  25917. * @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)
  25918. * @returns the current mesh
  25919. */
  25920. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  25921. /**
  25922. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  25923. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  25924. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  25925. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  25926. * @returns the current mesh
  25927. */
  25928. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  25929. /**
  25930. * Creates a un-shared specific occurence of the geometry for the mesh.
  25931. * @returns the current mesh
  25932. */
  25933. makeGeometryUnique(): Mesh;
  25934. /**
  25935. * Set the index buffer of this mesh
  25936. * @param indices defines the source data
  25937. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  25938. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  25939. * @returns the current mesh
  25940. */
  25941. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  25942. /**
  25943. * Update the current index buffer
  25944. * @param indices defines the source data
  25945. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  25946. * @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)
  25947. * @returns the current mesh
  25948. */
  25949. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  25950. /**
  25951. * Invert the geometry to move from a right handed system to a left handed one.
  25952. * @returns the current mesh
  25953. */
  25954. toLeftHanded(): Mesh;
  25955. /** @hidden */
  25956. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  25957. /** @hidden */
  25958. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  25959. /**
  25960. * Registers for this mesh a javascript function called just before the rendering process
  25961. * @param func defines the function to call before rendering this mesh
  25962. * @returns the current mesh
  25963. */
  25964. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  25965. /**
  25966. * Disposes a previously registered javascript function called before the rendering
  25967. * @param func defines the function to remove
  25968. * @returns the current mesh
  25969. */
  25970. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  25971. /**
  25972. * Registers for this mesh a javascript function called just after the rendering is complete
  25973. * @param func defines the function to call after rendering this mesh
  25974. * @returns the current mesh
  25975. */
  25976. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  25977. /**
  25978. * Disposes a previously registered javascript function called after the rendering.
  25979. * @param func defines the function to remove
  25980. * @returns the current mesh
  25981. */
  25982. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  25983. /** @hidden */
  25984. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  25985. /** @hidden */
  25986. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  25987. /** @hidden */
  25988. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  25989. /** @hidden */
  25990. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  25991. /** @hidden */
  25992. _rebuild(): void;
  25993. /** @hidden */
  25994. _freeze(): void;
  25995. /** @hidden */
  25996. _unFreeze(): void;
  25997. /**
  25998. * 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
  25999. * @param subMesh defines the subMesh to render
  26000. * @param enableAlphaMode defines if alpha mode can be changed
  26001. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  26002. * @returns the current mesh
  26003. */
  26004. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  26005. private _onBeforeDraw;
  26006. /**
  26007. * Renormalize the mesh and patch it up if there are no weights
  26008. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  26009. * However in the case of zero weights then we set just a single influence to 1.
  26010. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  26011. */
  26012. cleanMatrixWeights(): void;
  26013. private normalizeSkinFourWeights;
  26014. private normalizeSkinWeightsAndExtra;
  26015. /**
  26016. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  26017. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  26018. * the user know there was an issue with importing the mesh
  26019. * @returns a validation object with skinned, valid and report string
  26020. */
  26021. validateSkinning(): {
  26022. skinned: boolean;
  26023. valid: boolean;
  26024. report: string;
  26025. };
  26026. /** @hidden */
  26027. _checkDelayState(): Mesh;
  26028. private _queueLoad;
  26029. /**
  26030. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  26031. * A mesh is in the frustum if its bounding box intersects the frustum
  26032. * @param frustumPlanes defines the frustum to test
  26033. * @returns true if the mesh is in the frustum planes
  26034. */
  26035. isInFrustum(frustumPlanes: Plane[]): boolean;
  26036. /**
  26037. * Sets the mesh material by the material or multiMaterial `id` property
  26038. * @param id is a string identifying the material or the multiMaterial
  26039. * @returns the current mesh
  26040. */
  26041. setMaterialByID(id: string): Mesh;
  26042. /**
  26043. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  26044. * @returns an array of IAnimatable
  26045. */
  26046. getAnimatables(): IAnimatable[];
  26047. /**
  26048. * Modifies the mesh geometry according to the passed transformation matrix.
  26049. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  26050. * The mesh normals are modified using the same transformation.
  26051. * Note that, under the hood, this method sets a new VertexBuffer each call.
  26052. * @param transform defines the transform matrix to use
  26053. * @see http://doc.babylonjs.com/resources/baking_transformations
  26054. * @returns the current mesh
  26055. */
  26056. bakeTransformIntoVertices(transform: Matrix): Mesh;
  26057. /**
  26058. * Modifies the mesh geometry according to its own current World Matrix.
  26059. * The mesh World Matrix is then reset.
  26060. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  26061. * Note that, under the hood, this method sets a new VertexBuffer each call.
  26062. * @see http://doc.babylonjs.com/resources/baking_transformations
  26063. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  26064. * @returns the current mesh
  26065. */
  26066. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  26067. /** @hidden */
  26068. get _positions(): Nullable<Vector3[]>;
  26069. /** @hidden */
  26070. _resetPointsArrayCache(): Mesh;
  26071. /** @hidden */
  26072. _generatePointsArray(): boolean;
  26073. /**
  26074. * Returns a new Mesh object generated from the current mesh properties.
  26075. * This method must not get confused with createInstance()
  26076. * @param name is a string, the name given to the new mesh
  26077. * @param newParent can be any Node object (default `null`)
  26078. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  26079. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  26080. * @returns a new mesh
  26081. */
  26082. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  26083. /**
  26084. * Releases resources associated with this mesh.
  26085. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  26086. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  26087. */
  26088. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  26089. /** @hidden */
  26090. _disposeInstanceSpecificData(): void;
  26091. /**
  26092. * Modifies the mesh geometry according to a displacement map.
  26093. * 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.
  26094. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  26095. * @param url is a string, the URL from the image file is to be downloaded.
  26096. * @param minHeight is the lower limit of the displacement.
  26097. * @param maxHeight is the upper limit of the displacement.
  26098. * @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.
  26099. * @param uvOffset is an optional vector2 used to offset UV.
  26100. * @param uvScale is an optional vector2 used to scale UV.
  26101. * @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.
  26102. * @returns the Mesh.
  26103. */
  26104. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  26105. /**
  26106. * Modifies the mesh geometry according to a displacementMap buffer.
  26107. * 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.
  26108. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  26109. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  26110. * @param heightMapWidth is the width of the buffer image.
  26111. * @param heightMapHeight is the height of the buffer image.
  26112. * @param minHeight is the lower limit of the displacement.
  26113. * @param maxHeight is the upper limit of the displacement.
  26114. * @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.
  26115. * @param uvOffset is an optional vector2 used to offset UV.
  26116. * @param uvScale is an optional vector2 used to scale UV.
  26117. * @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.
  26118. * @returns the Mesh.
  26119. */
  26120. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  26121. /**
  26122. * Modify the mesh to get a flat shading rendering.
  26123. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  26124. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  26125. * @returns current mesh
  26126. */
  26127. convertToFlatShadedMesh(): Mesh;
  26128. /**
  26129. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  26130. * In other words, more vertices, no more indices and a single bigger VBO.
  26131. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  26132. * @returns current mesh
  26133. */
  26134. convertToUnIndexedMesh(): Mesh;
  26135. /**
  26136. * Inverses facet orientations.
  26137. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  26138. * @param flipNormals will also inverts the normals
  26139. * @returns current mesh
  26140. */
  26141. flipFaces(flipNormals?: boolean): Mesh;
  26142. /**
  26143. * Increase the number of facets and hence vertices in a mesh
  26144. * Vertex normals are interpolated from existing vertex normals
  26145. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  26146. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  26147. */
  26148. increaseVertices(numberPerEdge: number): void;
  26149. /**
  26150. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  26151. * This will undo any application of covertToFlatShadedMesh
  26152. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  26153. */
  26154. forceSharedVertices(): void;
  26155. /** @hidden */
  26156. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  26157. /** @hidden */
  26158. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  26159. /**
  26160. * Creates a new InstancedMesh object from the mesh model.
  26161. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  26162. * @param name defines the name of the new instance
  26163. * @returns a new InstancedMesh
  26164. */
  26165. createInstance(name: string): InstancedMesh;
  26166. /**
  26167. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  26168. * After this call, all the mesh instances have the same submeshes than the current mesh.
  26169. * @returns the current mesh
  26170. */
  26171. synchronizeInstances(): Mesh;
  26172. /**
  26173. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  26174. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  26175. * This should be used together with the simplification to avoid disappearing triangles.
  26176. * @param successCallback an optional success callback to be called after the optimization finished.
  26177. * @returns the current mesh
  26178. */
  26179. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  26180. /**
  26181. * Serialize current mesh
  26182. * @param serializationObject defines the object which will receive the serialization data
  26183. */
  26184. serialize(serializationObject: any): void;
  26185. /** @hidden */
  26186. _syncGeometryWithMorphTargetManager(): void;
  26187. /** @hidden */
  26188. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  26189. /**
  26190. * Returns a new Mesh object parsed from the source provided.
  26191. * @param parsedMesh is the source
  26192. * @param scene defines the hosting scene
  26193. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  26194. * @returns a new Mesh
  26195. */
  26196. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  26197. /**
  26198. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  26199. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  26200. * @param name defines the name of the mesh to create
  26201. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  26202. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  26203. * @param closePath creates a seam between the first and the last points of each path of the path array
  26204. * @param offset is taken in account only if the `pathArray` is containing a single path
  26205. * @param scene defines the hosting scene
  26206. * @param updatable defines if the mesh must be flagged as updatable
  26207. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26208. * @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)
  26209. * @returns a new Mesh
  26210. */
  26211. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  26212. /**
  26213. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  26214. * @param name defines the name of the mesh to create
  26215. * @param radius sets the radius size (float) of the polygon (default 0.5)
  26216. * @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
  26217. * @param scene defines the hosting scene
  26218. * @param updatable defines if the mesh must be flagged as updatable
  26219. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26220. * @returns a new Mesh
  26221. */
  26222. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  26223. /**
  26224. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  26225. * @param name defines the name of the mesh to create
  26226. * @param size sets the size (float) of each box side (default 1)
  26227. * @param scene defines the hosting scene
  26228. * @param updatable defines if the mesh must be flagged as updatable
  26229. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26230. * @returns a new Mesh
  26231. */
  26232. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  26233. /**
  26234. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  26235. * @param name defines the name of the mesh to create
  26236. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  26237. * @param diameter sets the diameter size (float) of the sphere (default 1)
  26238. * @param scene defines the hosting scene
  26239. * @param updatable defines if the mesh must be flagged as updatable
  26240. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26241. * @returns a new Mesh
  26242. */
  26243. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  26244. /**
  26245. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  26246. * @param name defines the name of the mesh to create
  26247. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  26248. * @param diameter sets the diameter size (float) of the sphere (default 1)
  26249. * @param scene defines the hosting scene
  26250. * @returns a new Mesh
  26251. */
  26252. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  26253. /**
  26254. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  26255. * @param name defines the name of the mesh to create
  26256. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  26257. * @param diameterTop set the top cap diameter (floats, default 1)
  26258. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  26259. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  26260. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  26261. * @param scene defines the hosting scene
  26262. * @param updatable defines if the mesh must be flagged as updatable
  26263. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26264. * @returns a new Mesh
  26265. */
  26266. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  26267. /**
  26268. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  26269. * @param name defines the name of the mesh to create
  26270. * @param diameter sets the diameter size (float) of the torus (default 1)
  26271. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  26272. * @param tessellation sets the number of torus sides (postive integer, default 16)
  26273. * @param scene defines the hosting scene
  26274. * @param updatable defines if the mesh must be flagged as updatable
  26275. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26276. * @returns a new Mesh
  26277. */
  26278. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  26279. /**
  26280. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  26281. * @param name defines the name of the mesh to create
  26282. * @param radius sets the global radius size (float) of the torus knot (default 2)
  26283. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  26284. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  26285. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  26286. * @param p the number of windings on X axis (positive integers, default 2)
  26287. * @param q the number of windings on Y axis (positive integers, default 3)
  26288. * @param scene defines the hosting scene
  26289. * @param updatable defines if the mesh must be flagged as updatable
  26290. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26291. * @returns a new Mesh
  26292. */
  26293. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  26294. /**
  26295. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  26296. * @param name defines the name of the mesh to create
  26297. * @param points is an array successive Vector3
  26298. * @param scene defines the hosting scene
  26299. * @param updatable defines if the mesh must be flagged as updatable
  26300. * @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).
  26301. * @returns a new Mesh
  26302. */
  26303. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  26304. /**
  26305. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  26306. * @param name defines the name of the mesh to create
  26307. * @param points is an array successive Vector3
  26308. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  26309. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  26310. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  26311. * @param scene defines the hosting scene
  26312. * @param updatable defines if the mesh must be flagged as updatable
  26313. * @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)
  26314. * @returns a new Mesh
  26315. */
  26316. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  26317. /**
  26318. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  26319. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  26320. * 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.
  26321. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26322. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  26323. * Remember you can only change the shape positions, not their number when updating a polygon.
  26324. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  26325. * @param name defines the name of the mesh to create
  26326. * @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
  26327. * @param scene defines the hosting scene
  26328. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  26329. * @param updatable defines if the mesh must be flagged as updatable
  26330. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26331. * @param earcutInjection can be used to inject your own earcut reference
  26332. * @returns a new Mesh
  26333. */
  26334. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  26335. /**
  26336. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  26337. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  26338. * @param name defines the name of the mesh to create
  26339. * @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
  26340. * @param depth defines the height of extrusion
  26341. * @param scene defines the hosting scene
  26342. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  26343. * @param updatable defines if the mesh must be flagged as updatable
  26344. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26345. * @param earcutInjection can be used to inject your own earcut reference
  26346. * @returns a new Mesh
  26347. */
  26348. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  26349. /**
  26350. * Creates an extruded shape mesh.
  26351. * 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
  26352. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  26353. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  26354. * @param name defines the name of the mesh to create
  26355. * @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
  26356. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  26357. * @param scale is the value to scale the shape
  26358. * @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
  26359. * @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
  26360. * @param scene defines the hosting scene
  26361. * @param updatable defines if the mesh must be flagged as updatable
  26362. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26363. * @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)
  26364. * @returns a new Mesh
  26365. */
  26366. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  26367. /**
  26368. * Creates an custom extruded shape mesh.
  26369. * The custom extrusion is a parametric shape.
  26370. * It has no predefined shape. Its final shape will depend on the input parameters.
  26371. * Please consider using the same method from the MeshBuilder class instead
  26372. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  26373. * @param name defines the name of the mesh to create
  26374. * @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
  26375. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  26376. * @param scaleFunction is a custom Javascript function called on each path point
  26377. * @param rotationFunction is a custom Javascript function called on each path point
  26378. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  26379. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  26380. * @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
  26381. * @param scene defines the hosting scene
  26382. * @param updatable defines if the mesh must be flagged as updatable
  26383. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26384. * @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)
  26385. * @returns a new Mesh
  26386. */
  26387. 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;
  26388. /**
  26389. * Creates lathe mesh.
  26390. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  26391. * Please consider using the same method from the MeshBuilder class instead
  26392. * @param name defines the name of the mesh to create
  26393. * @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
  26394. * @param radius is the radius value of the lathe
  26395. * @param tessellation is the side number of the lathe.
  26396. * @param scene defines the hosting scene
  26397. * @param updatable defines if the mesh must be flagged as updatable
  26398. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26399. * @returns a new Mesh
  26400. */
  26401. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  26402. /**
  26403. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  26404. * @param name defines the name of the mesh to create
  26405. * @param size sets the size (float) of both sides of the plane at once (default 1)
  26406. * @param scene defines the hosting scene
  26407. * @param updatable defines if the mesh must be flagged as updatable
  26408. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26409. * @returns a new Mesh
  26410. */
  26411. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  26412. /**
  26413. * Creates a ground mesh.
  26414. * Please consider using the same method from the MeshBuilder class instead
  26415. * @param name defines the name of the mesh to create
  26416. * @param width set the width of the ground
  26417. * @param height set the height of the ground
  26418. * @param subdivisions sets the number of subdivisions per side
  26419. * @param scene defines the hosting scene
  26420. * @param updatable defines if the mesh must be flagged as updatable
  26421. * @returns a new Mesh
  26422. */
  26423. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  26424. /**
  26425. * Creates a tiled ground mesh.
  26426. * Please consider using the same method from the MeshBuilder class instead
  26427. * @param name defines the name of the mesh to create
  26428. * @param xmin set the ground minimum X coordinate
  26429. * @param zmin set the ground minimum Y coordinate
  26430. * @param xmax set the ground maximum X coordinate
  26431. * @param zmax set the ground maximum Z coordinate
  26432. * @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
  26433. * @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
  26434. * @param scene defines the hosting scene
  26435. * @param updatable defines if the mesh must be flagged as updatable
  26436. * @returns a new Mesh
  26437. */
  26438. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  26439. w: number;
  26440. h: number;
  26441. }, precision: {
  26442. w: number;
  26443. h: number;
  26444. }, scene: Scene, updatable?: boolean): Mesh;
  26445. /**
  26446. * Creates a ground mesh from a height map.
  26447. * Please consider using the same method from the MeshBuilder class instead
  26448. * @see http://doc.babylonjs.com/babylon101/height_map
  26449. * @param name defines the name of the mesh to create
  26450. * @param url sets the URL of the height map image resource
  26451. * @param width set the ground width size
  26452. * @param height set the ground height size
  26453. * @param subdivisions sets the number of subdivision per side
  26454. * @param minHeight is the minimum altitude on the ground
  26455. * @param maxHeight is the maximum altitude on the ground
  26456. * @param scene defines the hosting scene
  26457. * @param updatable defines if the mesh must be flagged as updatable
  26458. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  26459. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  26460. * @returns a new Mesh
  26461. */
  26462. 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;
  26463. /**
  26464. * Creates a tube mesh.
  26465. * The tube is a parametric shape.
  26466. * It has no predefined shape. Its final shape will depend on the input parameters.
  26467. * Please consider using the same method from the MeshBuilder class instead
  26468. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  26469. * @param name defines the name of the mesh to create
  26470. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  26471. * @param radius sets the tube radius size
  26472. * @param tessellation is the number of sides on the tubular surface
  26473. * @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
  26474. * @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
  26475. * @param scene defines the hosting scene
  26476. * @param updatable defines if the mesh must be flagged as updatable
  26477. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26478. * @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)
  26479. * @returns a new Mesh
  26480. */
  26481. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  26482. (i: number, distance: number): number;
  26483. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  26484. /**
  26485. * Creates a polyhedron mesh.
  26486. * Please consider using the same method from the MeshBuilder class instead.
  26487. * * 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
  26488. * * The parameter `size` (positive float, default 1) sets the polygon size
  26489. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  26490. * * 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`
  26491. * * 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
  26492. * * 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)`)
  26493. * * 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
  26494. * * 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
  26495. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26496. * * If you create a double-sided mesh, you can choose what parts of 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
  26497. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  26498. * @param name defines the name of the mesh to create
  26499. * @param options defines the options used to create the mesh
  26500. * @param scene defines the hosting scene
  26501. * @returns a new Mesh
  26502. */
  26503. static CreatePolyhedron(name: string, options: {
  26504. type?: number;
  26505. size?: number;
  26506. sizeX?: number;
  26507. sizeY?: number;
  26508. sizeZ?: number;
  26509. custom?: any;
  26510. faceUV?: Vector4[];
  26511. faceColors?: Color4[];
  26512. updatable?: boolean;
  26513. sideOrientation?: number;
  26514. }, scene: Scene): Mesh;
  26515. /**
  26516. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  26517. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  26518. * * 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`)
  26519. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  26520. * * 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
  26521. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26522. * * If you create a double-sided mesh, you can choose what parts of 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
  26523. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  26524. * @param name defines the name of the mesh
  26525. * @param options defines the options used to create the mesh
  26526. * @param scene defines the hosting scene
  26527. * @returns a new Mesh
  26528. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  26529. */
  26530. static CreateIcoSphere(name: string, options: {
  26531. radius?: number;
  26532. flat?: boolean;
  26533. subdivisions?: number;
  26534. sideOrientation?: number;
  26535. updatable?: boolean;
  26536. }, scene: Scene): Mesh;
  26537. /**
  26538. * Creates a decal mesh.
  26539. * Please consider using the same method from the MeshBuilder class instead.
  26540. * A decal is a mesh usually applied as a model onto the surface of another mesh
  26541. * @param name defines the name of the mesh
  26542. * @param sourceMesh defines the mesh receiving the decal
  26543. * @param position sets the position of the decal in world coordinates
  26544. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  26545. * @param size sets the decal scaling
  26546. * @param angle sets the angle to rotate the decal
  26547. * @returns a new Mesh
  26548. */
  26549. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  26550. /**
  26551. * Prepare internal position array for software CPU skinning
  26552. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  26553. */
  26554. setPositionsForCPUSkinning(): Float32Array;
  26555. /**
  26556. * Prepare internal normal array for software CPU skinning
  26557. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  26558. */
  26559. setNormalsForCPUSkinning(): Float32Array;
  26560. /**
  26561. * Updates the vertex buffer by applying transformation from the bones
  26562. * @param skeleton defines the skeleton to apply to current mesh
  26563. * @returns the current mesh
  26564. */
  26565. applySkeleton(skeleton: Skeleton): Mesh;
  26566. /**
  26567. * 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
  26568. * @param meshes defines the list of meshes to scan
  26569. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  26570. */
  26571. static MinMax(meshes: AbstractMesh[]): {
  26572. min: Vector3;
  26573. max: Vector3;
  26574. };
  26575. /**
  26576. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  26577. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  26578. * @returns a vector3
  26579. */
  26580. static Center(meshesOrMinMaxVector: {
  26581. min: Vector3;
  26582. max: Vector3;
  26583. } | AbstractMesh[]): Vector3;
  26584. /**
  26585. * Merge the array of meshes into a single mesh for performance reasons.
  26586. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  26587. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  26588. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  26589. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  26590. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  26591. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  26592. * @returns a new mesh
  26593. */
  26594. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  26595. /** @hidden */
  26596. addInstance(instance: InstancedMesh): void;
  26597. /** @hidden */
  26598. removeInstance(instance: InstancedMesh): void;
  26599. }
  26600. }
  26601. declare module "babylonjs/Cameras/camera" {
  26602. import { SmartArray } from "babylonjs/Misc/smartArray";
  26603. import { Observable } from "babylonjs/Misc/observable";
  26604. import { Nullable } from "babylonjs/types";
  26605. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  26606. import { Scene } from "babylonjs/scene";
  26607. import { Matrix, Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  26608. import { Node } from "babylonjs/node";
  26609. import { Mesh } from "babylonjs/Meshes/mesh";
  26610. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26611. import { ICullable } from "babylonjs/Culling/boundingInfo";
  26612. import { Viewport } from "babylonjs/Maths/math.viewport";
  26613. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  26614. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  26615. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  26616. import { Ray } from "babylonjs/Culling/ray";
  26617. /**
  26618. * This is the base class of all the camera used in the application.
  26619. * @see http://doc.babylonjs.com/features/cameras
  26620. */
  26621. export class Camera extends Node {
  26622. /** @hidden */
  26623. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  26624. /**
  26625. * This is the default projection mode used by the cameras.
  26626. * It helps recreating a feeling of perspective and better appreciate depth.
  26627. * This is the best way to simulate real life cameras.
  26628. */
  26629. static readonly PERSPECTIVE_CAMERA: number;
  26630. /**
  26631. * This helps creating camera with an orthographic mode.
  26632. * 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.
  26633. */
  26634. static readonly ORTHOGRAPHIC_CAMERA: number;
  26635. /**
  26636. * This is the default FOV mode for perspective cameras.
  26637. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  26638. */
  26639. static readonly FOVMODE_VERTICAL_FIXED: number;
  26640. /**
  26641. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  26642. */
  26643. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  26644. /**
  26645. * This specifies ther is no need for a camera rig.
  26646. * Basically only one eye is rendered corresponding to the camera.
  26647. */
  26648. static readonly RIG_MODE_NONE: number;
  26649. /**
  26650. * Simulates a camera Rig with one blue eye and one red eye.
  26651. * This can be use with 3d blue and red glasses.
  26652. */
  26653. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  26654. /**
  26655. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  26656. */
  26657. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  26658. /**
  26659. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  26660. */
  26661. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  26662. /**
  26663. * Defines that both eyes of the camera will be rendered over under each other.
  26664. */
  26665. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  26666. /**
  26667. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  26668. */
  26669. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  26670. /**
  26671. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  26672. */
  26673. static readonly RIG_MODE_VR: number;
  26674. /**
  26675. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  26676. */
  26677. static readonly RIG_MODE_WEBVR: number;
  26678. /**
  26679. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  26680. */
  26681. static readonly RIG_MODE_CUSTOM: number;
  26682. /**
  26683. * Defines if by default attaching controls should prevent the default javascript event to continue.
  26684. */
  26685. static ForceAttachControlToAlwaysPreventDefault: boolean;
  26686. /**
  26687. * Define the input manager associated with the camera.
  26688. */
  26689. inputs: CameraInputsManager<Camera>;
  26690. /** @hidden */
  26691. _position: Vector3;
  26692. /**
  26693. * Define the current local position of the camera in the scene
  26694. */
  26695. get position(): Vector3;
  26696. set position(newPosition: Vector3);
  26697. /**
  26698. * The vector the camera should consider as up.
  26699. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  26700. */
  26701. upVector: Vector3;
  26702. /**
  26703. * Define the current limit on the left side for an orthographic camera
  26704. * In scene unit
  26705. */
  26706. orthoLeft: Nullable<number>;
  26707. /**
  26708. * Define the current limit on the right side for an orthographic camera
  26709. * In scene unit
  26710. */
  26711. orthoRight: Nullable<number>;
  26712. /**
  26713. * Define the current limit on the bottom side for an orthographic camera
  26714. * In scene unit
  26715. */
  26716. orthoBottom: Nullable<number>;
  26717. /**
  26718. * Define the current limit on the top side for an orthographic camera
  26719. * In scene unit
  26720. */
  26721. orthoTop: Nullable<number>;
  26722. /**
  26723. * Field Of View is set in Radians. (default is 0.8)
  26724. */
  26725. fov: number;
  26726. /**
  26727. * Define the minimum distance the camera can see from.
  26728. * This is important to note that the depth buffer are not infinite and the closer it starts
  26729. * the more your scene might encounter depth fighting issue.
  26730. */
  26731. minZ: number;
  26732. /**
  26733. * Define the maximum distance the camera can see to.
  26734. * This is important to note that the depth buffer are not infinite and the further it end
  26735. * the more your scene might encounter depth fighting issue.
  26736. */
  26737. maxZ: number;
  26738. /**
  26739. * Define the default inertia of the camera.
  26740. * This helps giving a smooth feeling to the camera movement.
  26741. */
  26742. inertia: number;
  26743. /**
  26744. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  26745. */
  26746. mode: number;
  26747. /**
  26748. * Define whether the camera is intermediate.
  26749. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  26750. */
  26751. isIntermediate: boolean;
  26752. /**
  26753. * Define the viewport of the camera.
  26754. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  26755. */
  26756. viewport: Viewport;
  26757. /**
  26758. * Restricts the camera to viewing objects with the same layerMask.
  26759. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  26760. */
  26761. layerMask: number;
  26762. /**
  26763. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  26764. */
  26765. fovMode: number;
  26766. /**
  26767. * Rig mode of the camera.
  26768. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  26769. * This is normally controlled byt the camera themselves as internal use.
  26770. */
  26771. cameraRigMode: number;
  26772. /**
  26773. * Defines the distance between both "eyes" in case of a RIG
  26774. */
  26775. interaxialDistance: number;
  26776. /**
  26777. * Defines if stereoscopic rendering is done side by side or over under.
  26778. */
  26779. isStereoscopicSideBySide: boolean;
  26780. /**
  26781. * 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
  26782. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  26783. * else in the scene. (Eg. security camera)
  26784. *
  26785. * 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)
  26786. */
  26787. customRenderTargets: import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture[];
  26788. /**
  26789. * When set, the camera will render to this render target instead of the default canvas
  26790. *
  26791. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  26792. */
  26793. outputRenderTarget: Nullable<RenderTargetTexture>;
  26794. /**
  26795. * Observable triggered when the camera view matrix has changed.
  26796. */
  26797. onViewMatrixChangedObservable: Observable<Camera>;
  26798. /**
  26799. * Observable triggered when the camera Projection matrix has changed.
  26800. */
  26801. onProjectionMatrixChangedObservable: Observable<Camera>;
  26802. /**
  26803. * Observable triggered when the inputs have been processed.
  26804. */
  26805. onAfterCheckInputsObservable: Observable<Camera>;
  26806. /**
  26807. * Observable triggered when reset has been called and applied to the camera.
  26808. */
  26809. onRestoreStateObservable: Observable<Camera>;
  26810. /**
  26811. * Is this camera a part of a rig system?
  26812. */
  26813. isRigCamera: boolean;
  26814. /**
  26815. * If isRigCamera set to true this will be set with the parent camera.
  26816. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  26817. */
  26818. rigParent?: Camera;
  26819. /** @hidden */
  26820. _cameraRigParams: any;
  26821. /** @hidden */
  26822. _rigCameras: Camera[];
  26823. /** @hidden */
  26824. _rigPostProcess: Nullable<PostProcess>;
  26825. protected _webvrViewMatrix: Matrix;
  26826. /** @hidden */
  26827. _skipRendering: boolean;
  26828. /** @hidden */
  26829. _projectionMatrix: Matrix;
  26830. /** @hidden */
  26831. _postProcesses: Nullable<import("babylonjs/PostProcesses/postProcess").PostProcess>[];
  26832. /** @hidden */
  26833. _activeMeshes: SmartArray<AbstractMesh>;
  26834. protected _globalPosition: Vector3;
  26835. /** @hidden */
  26836. _computedViewMatrix: Matrix;
  26837. private _doNotComputeProjectionMatrix;
  26838. private _transformMatrix;
  26839. private _frustumPlanes;
  26840. private _refreshFrustumPlanes;
  26841. private _storedFov;
  26842. private _stateStored;
  26843. /**
  26844. * Instantiates a new camera object.
  26845. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  26846. * @see http://doc.babylonjs.com/features/cameras
  26847. * @param name Defines the name of the camera in the scene
  26848. * @param position Defines the position of the camera
  26849. * @param scene Defines the scene the camera belongs too
  26850. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  26851. */
  26852. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  26853. /**
  26854. * Store current camera state (fov, position, etc..)
  26855. * @returns the camera
  26856. */
  26857. storeState(): Camera;
  26858. /**
  26859. * Restores the camera state values if it has been stored. You must call storeState() first
  26860. */
  26861. protected _restoreStateValues(): boolean;
  26862. /**
  26863. * Restored camera state. You must call storeState() first.
  26864. * @returns true if restored and false otherwise
  26865. */
  26866. restoreState(): boolean;
  26867. /**
  26868. * Gets the class name of the camera.
  26869. * @returns the class name
  26870. */
  26871. getClassName(): string;
  26872. /** @hidden */
  26873. readonly _isCamera: boolean;
  26874. /**
  26875. * Gets a string representation of the camera useful for debug purpose.
  26876. * @param fullDetails Defines that a more verboe level of logging is required
  26877. * @returns the string representation
  26878. */
  26879. toString(fullDetails?: boolean): string;
  26880. /**
  26881. * Gets the current world space position of the camera.
  26882. */
  26883. get globalPosition(): Vector3;
  26884. /**
  26885. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  26886. * @returns the active meshe list
  26887. */
  26888. getActiveMeshes(): SmartArray<AbstractMesh>;
  26889. /**
  26890. * Check whether a mesh is part of the current active mesh list of the camera
  26891. * @param mesh Defines the mesh to check
  26892. * @returns true if active, false otherwise
  26893. */
  26894. isActiveMesh(mesh: Mesh): boolean;
  26895. /**
  26896. * Is this camera ready to be used/rendered
  26897. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  26898. * @return true if the camera is ready
  26899. */
  26900. isReady(completeCheck?: boolean): boolean;
  26901. /** @hidden */
  26902. _initCache(): void;
  26903. /** @hidden */
  26904. _updateCache(ignoreParentClass?: boolean): void;
  26905. /** @hidden */
  26906. _isSynchronized(): boolean;
  26907. /** @hidden */
  26908. _isSynchronizedViewMatrix(): boolean;
  26909. /** @hidden */
  26910. _isSynchronizedProjectionMatrix(): boolean;
  26911. /**
  26912. * Attach the input controls to a specific dom element to get the input from.
  26913. * @param element Defines the element the controls should be listened from
  26914. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  26915. */
  26916. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  26917. /**
  26918. * Detach the current controls from the specified dom element.
  26919. * @param element Defines the element to stop listening the inputs from
  26920. */
  26921. detachControl(element: HTMLElement): void;
  26922. /**
  26923. * Update the camera state according to the different inputs gathered during the frame.
  26924. */
  26925. update(): void;
  26926. /** @hidden */
  26927. _checkInputs(): void;
  26928. /** @hidden */
  26929. get rigCameras(): Camera[];
  26930. /**
  26931. * Gets the post process used by the rig cameras
  26932. */
  26933. get rigPostProcess(): Nullable<PostProcess>;
  26934. /**
  26935. * Internal, gets the first post proces.
  26936. * @returns the first post process to be run on this camera.
  26937. */
  26938. _getFirstPostProcess(): Nullable<PostProcess>;
  26939. private _cascadePostProcessesToRigCams;
  26940. /**
  26941. * Attach a post process to the camera.
  26942. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  26943. * @param postProcess The post process to attach to the camera
  26944. * @param insertAt The position of the post process in case several of them are in use in the scene
  26945. * @returns the position the post process has been inserted at
  26946. */
  26947. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  26948. /**
  26949. * Detach a post process to the camera.
  26950. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  26951. * @param postProcess The post process to detach from the camera
  26952. */
  26953. detachPostProcess(postProcess: PostProcess): void;
  26954. /**
  26955. * Gets the current world matrix of the camera
  26956. */
  26957. getWorldMatrix(): Matrix;
  26958. /** @hidden */
  26959. _getViewMatrix(): Matrix;
  26960. /**
  26961. * Gets the current view matrix of the camera.
  26962. * @param force forces the camera to recompute the matrix without looking at the cached state
  26963. * @returns the view matrix
  26964. */
  26965. getViewMatrix(force?: boolean): Matrix;
  26966. /**
  26967. * Freeze the projection matrix.
  26968. * It will prevent the cache check of the camera projection compute and can speed up perf
  26969. * if no parameter of the camera are meant to change
  26970. * @param projection Defines manually a projection if necessary
  26971. */
  26972. freezeProjectionMatrix(projection?: Matrix): void;
  26973. /**
  26974. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  26975. */
  26976. unfreezeProjectionMatrix(): void;
  26977. /**
  26978. * Gets the current projection matrix of the camera.
  26979. * @param force forces the camera to recompute the matrix without looking at the cached state
  26980. * @returns the projection matrix
  26981. */
  26982. getProjectionMatrix(force?: boolean): Matrix;
  26983. /**
  26984. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  26985. * @returns a Matrix
  26986. */
  26987. getTransformationMatrix(): Matrix;
  26988. private _updateFrustumPlanes;
  26989. /**
  26990. * Checks if a cullable object (mesh...) is in the camera frustum
  26991. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  26992. * @param target The object to check
  26993. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  26994. * @returns true if the object is in frustum otherwise false
  26995. */
  26996. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  26997. /**
  26998. * Checks if a cullable object (mesh...) is in the camera frustum
  26999. * Unlike isInFrustum this cheks the full bounding box
  27000. * @param target The object to check
  27001. * @returns true if the object is in frustum otherwise false
  27002. */
  27003. isCompletelyInFrustum(target: ICullable): boolean;
  27004. /**
  27005. * Gets a ray in the forward direction from the camera.
  27006. * @param length Defines the length of the ray to create
  27007. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  27008. * @param origin Defines the start point of the ray which defaults to the camera position
  27009. * @returns the forward ray
  27010. */
  27011. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  27012. /**
  27013. * Releases resources associated with this node.
  27014. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  27015. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  27016. */
  27017. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  27018. /** @hidden */
  27019. _isLeftCamera: boolean;
  27020. /**
  27021. * Gets the left camera of a rig setup in case of Rigged Camera
  27022. */
  27023. get isLeftCamera(): boolean;
  27024. /** @hidden */
  27025. _isRightCamera: boolean;
  27026. /**
  27027. * Gets the right camera of a rig setup in case of Rigged Camera
  27028. */
  27029. get isRightCamera(): boolean;
  27030. /**
  27031. * Gets the left camera of a rig setup in case of Rigged Camera
  27032. */
  27033. get leftCamera(): Nullable<FreeCamera>;
  27034. /**
  27035. * Gets the right camera of a rig setup in case of Rigged Camera
  27036. */
  27037. get rightCamera(): Nullable<FreeCamera>;
  27038. /**
  27039. * Gets the left camera target of a rig setup in case of Rigged Camera
  27040. * @returns the target position
  27041. */
  27042. getLeftTarget(): Nullable<Vector3>;
  27043. /**
  27044. * Gets the right camera target of a rig setup in case of Rigged Camera
  27045. * @returns the target position
  27046. */
  27047. getRightTarget(): Nullable<Vector3>;
  27048. /**
  27049. * @hidden
  27050. */
  27051. setCameraRigMode(mode: number, rigParams: any): void;
  27052. /** @hidden */
  27053. static _setStereoscopicRigMode(camera: Camera): void;
  27054. /** @hidden */
  27055. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  27056. /** @hidden */
  27057. static _setVRRigMode(camera: Camera, rigParams: any): void;
  27058. /** @hidden */
  27059. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  27060. /** @hidden */
  27061. _getVRProjectionMatrix(): Matrix;
  27062. protected _updateCameraRotationMatrix(): void;
  27063. protected _updateWebVRCameraRotationMatrix(): void;
  27064. /**
  27065. * This function MUST be overwritten by the different WebVR cameras available.
  27066. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  27067. * @hidden
  27068. */
  27069. _getWebVRProjectionMatrix(): Matrix;
  27070. /**
  27071. * This function MUST be overwritten by the different WebVR cameras available.
  27072. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  27073. * @hidden
  27074. */
  27075. _getWebVRViewMatrix(): Matrix;
  27076. /** @hidden */
  27077. setCameraRigParameter(name: string, value: any): void;
  27078. /**
  27079. * needs to be overridden by children so sub has required properties to be copied
  27080. * @hidden
  27081. */
  27082. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  27083. /**
  27084. * May need to be overridden by children
  27085. * @hidden
  27086. */
  27087. _updateRigCameras(): void;
  27088. /** @hidden */
  27089. _setupInputs(): void;
  27090. /**
  27091. * Serialiaze the camera setup to a json represention
  27092. * @returns the JSON representation
  27093. */
  27094. serialize(): any;
  27095. /**
  27096. * Clones the current camera.
  27097. * @param name The cloned camera name
  27098. * @returns the cloned camera
  27099. */
  27100. clone(name: string): Camera;
  27101. /**
  27102. * Gets the direction of the camera relative to a given local axis.
  27103. * @param localAxis Defines the reference axis to provide a relative direction.
  27104. * @return the direction
  27105. */
  27106. getDirection(localAxis: Vector3): Vector3;
  27107. /**
  27108. * Returns the current camera absolute rotation
  27109. */
  27110. get absoluteRotation(): Quaternion;
  27111. /**
  27112. * Gets the direction of the camera relative to a given local axis into a passed vector.
  27113. * @param localAxis Defines the reference axis to provide a relative direction.
  27114. * @param result Defines the vector to store the result in
  27115. */
  27116. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  27117. /**
  27118. * Gets a camera constructor for a given camera type
  27119. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  27120. * @param name The name of the camera the result will be able to instantiate
  27121. * @param scene The scene the result will construct the camera in
  27122. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  27123. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  27124. * @returns a factory method to construc the camera
  27125. */
  27126. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  27127. /**
  27128. * Compute the world matrix of the camera.
  27129. * @returns the camera world matrix
  27130. */
  27131. computeWorldMatrix(): Matrix;
  27132. /**
  27133. * Parse a JSON and creates the camera from the parsed information
  27134. * @param parsedCamera The JSON to parse
  27135. * @param scene The scene to instantiate the camera in
  27136. * @returns the newly constructed camera
  27137. */
  27138. static Parse(parsedCamera: any, scene: Scene): Camera;
  27139. }
  27140. }
  27141. declare module "babylonjs/Meshes/Builders/discBuilder" {
  27142. import { Nullable } from "babylonjs/types";
  27143. import { Scene } from "babylonjs/scene";
  27144. import { Vector4 } from "babylonjs/Maths/math.vector";
  27145. import { Mesh } from "babylonjs/Meshes/mesh";
  27146. /**
  27147. * Class containing static functions to help procedurally build meshes
  27148. */
  27149. export class DiscBuilder {
  27150. /**
  27151. * Creates a plane polygonal mesh. By default, this is a disc
  27152. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  27153. * * 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
  27154. * * 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
  27155. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27156. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  27157. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  27158. * @param name defines the name of the mesh
  27159. * @param options defines the options used to create the mesh
  27160. * @param scene defines the hosting scene
  27161. * @returns the plane polygonal mesh
  27162. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  27163. */
  27164. static CreateDisc(name: string, options: {
  27165. radius?: number;
  27166. tessellation?: number;
  27167. arc?: number;
  27168. updatable?: boolean;
  27169. sideOrientation?: number;
  27170. frontUVs?: Vector4;
  27171. backUVs?: Vector4;
  27172. }, scene?: Nullable<Scene>): Mesh;
  27173. }
  27174. }
  27175. declare module "babylonjs/Materials/fresnelParameters" {
  27176. import { DeepImmutable } from "babylonjs/types";
  27177. import { Color3 } from "babylonjs/Maths/math.color";
  27178. /**
  27179. * Options to be used when creating a FresnelParameters.
  27180. */
  27181. export type IFresnelParametersCreationOptions = {
  27182. /**
  27183. * Define the color used on edges (grazing angle)
  27184. */
  27185. leftColor?: Color3;
  27186. /**
  27187. * Define the color used on center
  27188. */
  27189. rightColor?: Color3;
  27190. /**
  27191. * Define bias applied to computed fresnel term
  27192. */
  27193. bias?: number;
  27194. /**
  27195. * Defined the power exponent applied to fresnel term
  27196. */
  27197. power?: number;
  27198. /**
  27199. * Define if the fresnel effect is enable or not.
  27200. */
  27201. isEnabled?: boolean;
  27202. };
  27203. /**
  27204. * Serialized format for FresnelParameters.
  27205. */
  27206. export type IFresnelParametersSerialized = {
  27207. /**
  27208. * Define the color used on edges (grazing angle) [as an array]
  27209. */
  27210. leftColor: number[];
  27211. /**
  27212. * Define the color used on center [as an array]
  27213. */
  27214. rightColor: number[];
  27215. /**
  27216. * Define bias applied to computed fresnel term
  27217. */
  27218. bias: number;
  27219. /**
  27220. * Defined the power exponent applied to fresnel term
  27221. */
  27222. power?: number;
  27223. /**
  27224. * Define if the fresnel effect is enable or not.
  27225. */
  27226. isEnabled: boolean;
  27227. };
  27228. /**
  27229. * This represents all the required information to add a fresnel effect on a material:
  27230. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27231. */
  27232. export class FresnelParameters {
  27233. private _isEnabled;
  27234. /**
  27235. * Define if the fresnel effect is enable or not.
  27236. */
  27237. get isEnabled(): boolean;
  27238. set isEnabled(value: boolean);
  27239. /**
  27240. * Define the color used on edges (grazing angle)
  27241. */
  27242. leftColor: Color3;
  27243. /**
  27244. * Define the color used on center
  27245. */
  27246. rightColor: Color3;
  27247. /**
  27248. * Define bias applied to computed fresnel term
  27249. */
  27250. bias: number;
  27251. /**
  27252. * Defined the power exponent applied to fresnel term
  27253. */
  27254. power: number;
  27255. /**
  27256. * Creates a new FresnelParameters object.
  27257. *
  27258. * @param options provide your own settings to optionally to override defaults
  27259. */
  27260. constructor(options?: IFresnelParametersCreationOptions);
  27261. /**
  27262. * Clones the current fresnel and its valuues
  27263. * @returns a clone fresnel configuration
  27264. */
  27265. clone(): FresnelParameters;
  27266. /**
  27267. * Determines equality between FresnelParameters objects
  27268. * @param otherFresnelParameters defines the second operand
  27269. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  27270. */
  27271. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  27272. /**
  27273. * Serializes the current fresnel parameters to a JSON representation.
  27274. * @return the JSON serialization
  27275. */
  27276. serialize(): IFresnelParametersSerialized;
  27277. /**
  27278. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  27279. * @param parsedFresnelParameters Define the JSON representation
  27280. * @returns the parsed parameters
  27281. */
  27282. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  27283. }
  27284. }
  27285. declare module "babylonjs/Materials/pushMaterial" {
  27286. import { Nullable } from "babylonjs/types";
  27287. import { Scene } from "babylonjs/scene";
  27288. import { Matrix } from "babylonjs/Maths/math.vector";
  27289. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  27290. import { Mesh } from "babylonjs/Meshes/mesh";
  27291. import { Material } from "babylonjs/Materials/material";
  27292. import { Effect } from "babylonjs/Materials/effect";
  27293. import { SubMesh } from "babylonjs/Meshes/subMesh";
  27294. /**
  27295. * Base class of materials working in push mode in babylon JS
  27296. * @hidden
  27297. */
  27298. export class PushMaterial extends Material {
  27299. protected _activeEffect: Effect;
  27300. protected _normalMatrix: Matrix;
  27301. /**
  27302. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  27303. * This means that the material can keep using a previous shader while a new one is being compiled.
  27304. * This is mostly used when shader parallel compilation is supported (true by default)
  27305. */
  27306. allowShaderHotSwapping: boolean;
  27307. constructor(name: string, scene: Scene);
  27308. getEffect(): Effect;
  27309. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  27310. protected _isReadyForSubMesh(subMesh: SubMesh): boolean;
  27311. /**
  27312. * Binds the given world matrix to the active effect
  27313. *
  27314. * @param world the matrix to bind
  27315. */
  27316. bindOnlyWorldMatrix(world: Matrix): void;
  27317. /**
  27318. * Binds the given normal matrix to the active effect
  27319. *
  27320. * @param normalMatrix the matrix to bind
  27321. */
  27322. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  27323. bind(world: Matrix, mesh?: Mesh): void;
  27324. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  27325. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  27326. }
  27327. }
  27328. declare module "babylonjs/Materials/materialFlags" {
  27329. /**
  27330. * This groups all the flags used to control the materials channel.
  27331. */
  27332. export class MaterialFlags {
  27333. private static _DiffuseTextureEnabled;
  27334. /**
  27335. * Are diffuse textures enabled in the application.
  27336. */
  27337. static get DiffuseTextureEnabled(): boolean;
  27338. static set DiffuseTextureEnabled(value: boolean);
  27339. private static _AmbientTextureEnabled;
  27340. /**
  27341. * Are ambient textures enabled in the application.
  27342. */
  27343. static get AmbientTextureEnabled(): boolean;
  27344. static set AmbientTextureEnabled(value: boolean);
  27345. private static _OpacityTextureEnabled;
  27346. /**
  27347. * Are opacity textures enabled in the application.
  27348. */
  27349. static get OpacityTextureEnabled(): boolean;
  27350. static set OpacityTextureEnabled(value: boolean);
  27351. private static _ReflectionTextureEnabled;
  27352. /**
  27353. * Are reflection textures enabled in the application.
  27354. */
  27355. static get ReflectionTextureEnabled(): boolean;
  27356. static set ReflectionTextureEnabled(value: boolean);
  27357. private static _EmissiveTextureEnabled;
  27358. /**
  27359. * Are emissive textures enabled in the application.
  27360. */
  27361. static get EmissiveTextureEnabled(): boolean;
  27362. static set EmissiveTextureEnabled(value: boolean);
  27363. private static _SpecularTextureEnabled;
  27364. /**
  27365. * Are specular textures enabled in the application.
  27366. */
  27367. static get SpecularTextureEnabled(): boolean;
  27368. static set SpecularTextureEnabled(value: boolean);
  27369. private static _BumpTextureEnabled;
  27370. /**
  27371. * Are bump textures enabled in the application.
  27372. */
  27373. static get BumpTextureEnabled(): boolean;
  27374. static set BumpTextureEnabled(value: boolean);
  27375. private static _LightmapTextureEnabled;
  27376. /**
  27377. * Are lightmap textures enabled in the application.
  27378. */
  27379. static get LightmapTextureEnabled(): boolean;
  27380. static set LightmapTextureEnabled(value: boolean);
  27381. private static _RefractionTextureEnabled;
  27382. /**
  27383. * Are refraction textures enabled in the application.
  27384. */
  27385. static get RefractionTextureEnabled(): boolean;
  27386. static set RefractionTextureEnabled(value: boolean);
  27387. private static _ColorGradingTextureEnabled;
  27388. /**
  27389. * Are color grading textures enabled in the application.
  27390. */
  27391. static get ColorGradingTextureEnabled(): boolean;
  27392. static set ColorGradingTextureEnabled(value: boolean);
  27393. private static _FresnelEnabled;
  27394. /**
  27395. * Are fresnels enabled in the application.
  27396. */
  27397. static get FresnelEnabled(): boolean;
  27398. static set FresnelEnabled(value: boolean);
  27399. private static _ClearCoatTextureEnabled;
  27400. /**
  27401. * Are clear coat textures enabled in the application.
  27402. */
  27403. static get ClearCoatTextureEnabled(): boolean;
  27404. static set ClearCoatTextureEnabled(value: boolean);
  27405. private static _ClearCoatBumpTextureEnabled;
  27406. /**
  27407. * Are clear coat bump textures enabled in the application.
  27408. */
  27409. static get ClearCoatBumpTextureEnabled(): boolean;
  27410. static set ClearCoatBumpTextureEnabled(value: boolean);
  27411. private static _ClearCoatTintTextureEnabled;
  27412. /**
  27413. * Are clear coat tint textures enabled in the application.
  27414. */
  27415. static get ClearCoatTintTextureEnabled(): boolean;
  27416. static set ClearCoatTintTextureEnabled(value: boolean);
  27417. private static _SheenTextureEnabled;
  27418. /**
  27419. * Are sheen textures enabled in the application.
  27420. */
  27421. static get SheenTextureEnabled(): boolean;
  27422. static set SheenTextureEnabled(value: boolean);
  27423. private static _AnisotropicTextureEnabled;
  27424. /**
  27425. * Are anisotropic textures enabled in the application.
  27426. */
  27427. static get AnisotropicTextureEnabled(): boolean;
  27428. static set AnisotropicTextureEnabled(value: boolean);
  27429. private static _ThicknessTextureEnabled;
  27430. /**
  27431. * Are thickness textures enabled in the application.
  27432. */
  27433. static get ThicknessTextureEnabled(): boolean;
  27434. static set ThicknessTextureEnabled(value: boolean);
  27435. }
  27436. }
  27437. declare module "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration" {
  27438. /** @hidden */
  27439. export var defaultFragmentDeclaration: {
  27440. name: string;
  27441. shader: string;
  27442. };
  27443. }
  27444. declare module "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration" {
  27445. /** @hidden */
  27446. export var defaultUboDeclaration: {
  27447. name: string;
  27448. shader: string;
  27449. };
  27450. }
  27451. declare module "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration" {
  27452. /** @hidden */
  27453. export var lightFragmentDeclaration: {
  27454. name: string;
  27455. shader: string;
  27456. };
  27457. }
  27458. declare module "babylonjs/Shaders/ShadersInclude/lightUboDeclaration" {
  27459. /** @hidden */
  27460. export var lightUboDeclaration: {
  27461. name: string;
  27462. shader: string;
  27463. };
  27464. }
  27465. declare module "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions" {
  27466. /** @hidden */
  27467. export var lightsFragmentFunctions: {
  27468. name: string;
  27469. shader: string;
  27470. };
  27471. }
  27472. declare module "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions" {
  27473. /** @hidden */
  27474. export var shadowsFragmentFunctions: {
  27475. name: string;
  27476. shader: string;
  27477. };
  27478. }
  27479. declare module "babylonjs/Shaders/ShadersInclude/fresnelFunction" {
  27480. /** @hidden */
  27481. export var fresnelFunction: {
  27482. name: string;
  27483. shader: string;
  27484. };
  27485. }
  27486. declare module "babylonjs/Shaders/ShadersInclude/reflectionFunction" {
  27487. /** @hidden */
  27488. export var reflectionFunction: {
  27489. name: string;
  27490. shader: string;
  27491. };
  27492. }
  27493. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions" {
  27494. /** @hidden */
  27495. export var bumpFragmentMainFunctions: {
  27496. name: string;
  27497. shader: string;
  27498. };
  27499. }
  27500. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions" {
  27501. /** @hidden */
  27502. export var bumpFragmentFunctions: {
  27503. name: string;
  27504. shader: string;
  27505. };
  27506. }
  27507. declare module "babylonjs/Shaders/ShadersInclude/logDepthDeclaration" {
  27508. /** @hidden */
  27509. export var logDepthDeclaration: {
  27510. name: string;
  27511. shader: string;
  27512. };
  27513. }
  27514. declare module "babylonjs/Shaders/ShadersInclude/bumpFragment" {
  27515. /** @hidden */
  27516. export var bumpFragment: {
  27517. name: string;
  27518. shader: string;
  27519. };
  27520. }
  27521. declare module "babylonjs/Shaders/ShadersInclude/depthPrePass" {
  27522. /** @hidden */
  27523. export var depthPrePass: {
  27524. name: string;
  27525. shader: string;
  27526. };
  27527. }
  27528. declare module "babylonjs/Shaders/ShadersInclude/lightFragment" {
  27529. /** @hidden */
  27530. export var lightFragment: {
  27531. name: string;
  27532. shader: string;
  27533. };
  27534. }
  27535. declare module "babylonjs/Shaders/ShadersInclude/logDepthFragment" {
  27536. /** @hidden */
  27537. export var logDepthFragment: {
  27538. name: string;
  27539. shader: string;
  27540. };
  27541. }
  27542. declare module "babylonjs/Shaders/default.fragment" {
  27543. import "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration";
  27544. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  27545. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  27546. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  27547. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  27548. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  27549. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  27550. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  27551. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  27552. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  27553. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  27554. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  27555. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  27556. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  27557. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  27558. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  27559. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  27560. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  27561. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  27562. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  27563. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  27564. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  27565. /** @hidden */
  27566. export var defaultPixelShader: {
  27567. name: string;
  27568. shader: string;
  27569. };
  27570. }
  27571. declare module "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration" {
  27572. /** @hidden */
  27573. export var defaultVertexDeclaration: {
  27574. name: string;
  27575. shader: string;
  27576. };
  27577. }
  27578. declare module "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration" {
  27579. /** @hidden */
  27580. export var bumpVertexDeclaration: {
  27581. name: string;
  27582. shader: string;
  27583. };
  27584. }
  27585. declare module "babylonjs/Shaders/ShadersInclude/bumpVertex" {
  27586. /** @hidden */
  27587. export var bumpVertex: {
  27588. name: string;
  27589. shader: string;
  27590. };
  27591. }
  27592. declare module "babylonjs/Shaders/ShadersInclude/fogVertex" {
  27593. /** @hidden */
  27594. export var fogVertex: {
  27595. name: string;
  27596. shader: string;
  27597. };
  27598. }
  27599. declare module "babylonjs/Shaders/ShadersInclude/shadowsVertex" {
  27600. /** @hidden */
  27601. export var shadowsVertex: {
  27602. name: string;
  27603. shader: string;
  27604. };
  27605. }
  27606. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertex" {
  27607. /** @hidden */
  27608. export var pointCloudVertex: {
  27609. name: string;
  27610. shader: string;
  27611. };
  27612. }
  27613. declare module "babylonjs/Shaders/ShadersInclude/logDepthVertex" {
  27614. /** @hidden */
  27615. export var logDepthVertex: {
  27616. name: string;
  27617. shader: string;
  27618. };
  27619. }
  27620. declare module "babylonjs/Shaders/default.vertex" {
  27621. import "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration";
  27622. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  27623. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  27624. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  27625. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  27626. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  27627. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  27628. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  27629. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  27630. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  27631. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  27632. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  27633. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  27634. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  27635. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  27636. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  27637. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  27638. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  27639. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  27640. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  27641. import "babylonjs/Shaders/ShadersInclude/pointCloudVertex";
  27642. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  27643. /** @hidden */
  27644. export var defaultVertexShader: {
  27645. name: string;
  27646. shader: string;
  27647. };
  27648. }
  27649. declare module "babylonjs/Materials/standardMaterial" {
  27650. import { SmartArray } from "babylonjs/Misc/smartArray";
  27651. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  27652. import { Nullable } from "babylonjs/types";
  27653. import { Scene } from "babylonjs/scene";
  27654. import { Matrix } from "babylonjs/Maths/math.vector";
  27655. import { Color3 } from "babylonjs/Maths/math.color";
  27656. import { SubMesh } from "babylonjs/Meshes/subMesh";
  27657. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  27658. import { Mesh } from "babylonjs/Meshes/mesh";
  27659. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  27660. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  27661. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  27662. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  27663. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  27664. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  27665. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  27666. import "babylonjs/Shaders/default.fragment";
  27667. import "babylonjs/Shaders/default.vertex";
  27668. /** @hidden */
  27669. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  27670. MAINUV1: boolean;
  27671. MAINUV2: boolean;
  27672. DIFFUSE: boolean;
  27673. DIFFUSEDIRECTUV: number;
  27674. AMBIENT: boolean;
  27675. AMBIENTDIRECTUV: number;
  27676. OPACITY: boolean;
  27677. OPACITYDIRECTUV: number;
  27678. OPACITYRGB: boolean;
  27679. REFLECTION: boolean;
  27680. EMISSIVE: boolean;
  27681. EMISSIVEDIRECTUV: number;
  27682. SPECULAR: boolean;
  27683. SPECULARDIRECTUV: number;
  27684. BUMP: boolean;
  27685. BUMPDIRECTUV: number;
  27686. PARALLAX: boolean;
  27687. PARALLAXOCCLUSION: boolean;
  27688. SPECULAROVERALPHA: boolean;
  27689. CLIPPLANE: boolean;
  27690. CLIPPLANE2: boolean;
  27691. CLIPPLANE3: boolean;
  27692. CLIPPLANE4: boolean;
  27693. CLIPPLANE5: boolean;
  27694. CLIPPLANE6: boolean;
  27695. ALPHATEST: boolean;
  27696. DEPTHPREPASS: boolean;
  27697. ALPHAFROMDIFFUSE: boolean;
  27698. POINTSIZE: boolean;
  27699. FOG: boolean;
  27700. SPECULARTERM: boolean;
  27701. DIFFUSEFRESNEL: boolean;
  27702. OPACITYFRESNEL: boolean;
  27703. REFLECTIONFRESNEL: boolean;
  27704. REFRACTIONFRESNEL: boolean;
  27705. EMISSIVEFRESNEL: boolean;
  27706. FRESNEL: boolean;
  27707. NORMAL: boolean;
  27708. UV1: boolean;
  27709. UV2: boolean;
  27710. VERTEXCOLOR: boolean;
  27711. VERTEXALPHA: boolean;
  27712. NUM_BONE_INFLUENCERS: number;
  27713. BonesPerMesh: number;
  27714. BONETEXTURE: boolean;
  27715. INSTANCES: boolean;
  27716. GLOSSINESS: boolean;
  27717. ROUGHNESS: boolean;
  27718. EMISSIVEASILLUMINATION: boolean;
  27719. LINKEMISSIVEWITHDIFFUSE: boolean;
  27720. REFLECTIONFRESNELFROMSPECULAR: boolean;
  27721. LIGHTMAP: boolean;
  27722. LIGHTMAPDIRECTUV: number;
  27723. OBJECTSPACE_NORMALMAP: boolean;
  27724. USELIGHTMAPASSHADOWMAP: boolean;
  27725. REFLECTIONMAP_3D: boolean;
  27726. REFLECTIONMAP_SPHERICAL: boolean;
  27727. REFLECTIONMAP_PLANAR: boolean;
  27728. REFLECTIONMAP_CUBIC: boolean;
  27729. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  27730. REFLECTIONMAP_PROJECTION: boolean;
  27731. REFLECTIONMAP_SKYBOX: boolean;
  27732. REFLECTIONMAP_EXPLICIT: boolean;
  27733. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  27734. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  27735. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  27736. INVERTCUBICMAP: boolean;
  27737. LOGARITHMICDEPTH: boolean;
  27738. REFRACTION: boolean;
  27739. REFRACTIONMAP_3D: boolean;
  27740. REFLECTIONOVERALPHA: boolean;
  27741. TWOSIDEDLIGHTING: boolean;
  27742. SHADOWFLOAT: boolean;
  27743. MORPHTARGETS: boolean;
  27744. MORPHTARGETS_NORMAL: boolean;
  27745. MORPHTARGETS_TANGENT: boolean;
  27746. MORPHTARGETS_UV: boolean;
  27747. NUM_MORPH_INFLUENCERS: number;
  27748. NONUNIFORMSCALING: boolean;
  27749. PREMULTIPLYALPHA: boolean;
  27750. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  27751. ALPHABLEND: boolean;
  27752. IMAGEPROCESSING: boolean;
  27753. VIGNETTE: boolean;
  27754. VIGNETTEBLENDMODEMULTIPLY: boolean;
  27755. VIGNETTEBLENDMODEOPAQUE: boolean;
  27756. TONEMAPPING: boolean;
  27757. TONEMAPPING_ACES: boolean;
  27758. CONTRAST: boolean;
  27759. COLORCURVES: boolean;
  27760. COLORGRADING: boolean;
  27761. COLORGRADING3D: boolean;
  27762. SAMPLER3DGREENDEPTH: boolean;
  27763. SAMPLER3DBGRMAP: boolean;
  27764. IMAGEPROCESSINGPOSTPROCESS: boolean;
  27765. MULTIVIEW: boolean;
  27766. /**
  27767. * If the reflection texture on this material is in linear color space
  27768. * @hidden
  27769. */
  27770. IS_REFLECTION_LINEAR: boolean;
  27771. /**
  27772. * If the refraction texture on this material is in linear color space
  27773. * @hidden
  27774. */
  27775. IS_REFRACTION_LINEAR: boolean;
  27776. EXPOSURE: boolean;
  27777. constructor();
  27778. setReflectionMode(modeToEnable: string): void;
  27779. }
  27780. /**
  27781. * This is the default material used in Babylon. It is the best trade off between quality
  27782. * and performances.
  27783. * @see http://doc.babylonjs.com/babylon101/materials
  27784. */
  27785. export class StandardMaterial extends PushMaterial {
  27786. private _diffuseTexture;
  27787. /**
  27788. * The basic texture of the material as viewed under a light.
  27789. */
  27790. diffuseTexture: Nullable<BaseTexture>;
  27791. private _ambientTexture;
  27792. /**
  27793. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  27794. */
  27795. ambientTexture: Nullable<BaseTexture>;
  27796. private _opacityTexture;
  27797. /**
  27798. * Define the transparency of the material from a texture.
  27799. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  27800. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  27801. */
  27802. opacityTexture: Nullable<BaseTexture>;
  27803. private _reflectionTexture;
  27804. /**
  27805. * Define the texture used to display the reflection.
  27806. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  27807. */
  27808. reflectionTexture: Nullable<BaseTexture>;
  27809. private _emissiveTexture;
  27810. /**
  27811. * Define texture of the material as if self lit.
  27812. * This will be mixed in the final result even in the absence of light.
  27813. */
  27814. emissiveTexture: Nullable<BaseTexture>;
  27815. private _specularTexture;
  27816. /**
  27817. * Define how the color and intensity of the highlight given by the light in the material.
  27818. */
  27819. specularTexture: Nullable<BaseTexture>;
  27820. private _bumpTexture;
  27821. /**
  27822. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  27823. * 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.
  27824. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  27825. */
  27826. bumpTexture: Nullable<BaseTexture>;
  27827. private _lightmapTexture;
  27828. /**
  27829. * Complex lighting can be computationally expensive to compute at runtime.
  27830. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  27831. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  27832. */
  27833. lightmapTexture: Nullable<BaseTexture>;
  27834. private _refractionTexture;
  27835. /**
  27836. * Define the texture used to display the refraction.
  27837. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  27838. */
  27839. refractionTexture: Nullable<BaseTexture>;
  27840. /**
  27841. * The color of the material lit by the environmental background lighting.
  27842. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  27843. */
  27844. ambientColor: Color3;
  27845. /**
  27846. * The basic color of the material as viewed under a light.
  27847. */
  27848. diffuseColor: Color3;
  27849. /**
  27850. * Define how the color and intensity of the highlight given by the light in the material.
  27851. */
  27852. specularColor: Color3;
  27853. /**
  27854. * Define the color of the material as if self lit.
  27855. * This will be mixed in the final result even in the absence of light.
  27856. */
  27857. emissiveColor: Color3;
  27858. /**
  27859. * Defines how sharp are the highlights in the material.
  27860. * The bigger the value the sharper giving a more glossy feeling to the result.
  27861. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  27862. */
  27863. specularPower: number;
  27864. private _useAlphaFromDiffuseTexture;
  27865. /**
  27866. * Does the transparency come from the diffuse texture alpha channel.
  27867. */
  27868. useAlphaFromDiffuseTexture: boolean;
  27869. private _useEmissiveAsIllumination;
  27870. /**
  27871. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  27872. */
  27873. useEmissiveAsIllumination: boolean;
  27874. private _linkEmissiveWithDiffuse;
  27875. /**
  27876. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  27877. * the emissive level when the final color is close to one.
  27878. */
  27879. linkEmissiveWithDiffuse: boolean;
  27880. private _useSpecularOverAlpha;
  27881. /**
  27882. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  27883. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  27884. */
  27885. useSpecularOverAlpha: boolean;
  27886. private _useReflectionOverAlpha;
  27887. /**
  27888. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  27889. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  27890. */
  27891. useReflectionOverAlpha: boolean;
  27892. private _disableLighting;
  27893. /**
  27894. * Does lights from the scene impacts this material.
  27895. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  27896. */
  27897. disableLighting: boolean;
  27898. private _useObjectSpaceNormalMap;
  27899. /**
  27900. * Allows using an object space normal map (instead of tangent space).
  27901. */
  27902. useObjectSpaceNormalMap: boolean;
  27903. private _useParallax;
  27904. /**
  27905. * Is parallax enabled or not.
  27906. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  27907. */
  27908. useParallax: boolean;
  27909. private _useParallaxOcclusion;
  27910. /**
  27911. * Is parallax occlusion enabled or not.
  27912. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  27913. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  27914. */
  27915. useParallaxOcclusion: boolean;
  27916. /**
  27917. * 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.
  27918. */
  27919. parallaxScaleBias: number;
  27920. private _roughness;
  27921. /**
  27922. * Helps to define how blurry the reflections should appears in the material.
  27923. */
  27924. roughness: number;
  27925. /**
  27926. * In case of refraction, define the value of the index of refraction.
  27927. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  27928. */
  27929. indexOfRefraction: number;
  27930. /**
  27931. * Invert the refraction texture alongside the y axis.
  27932. * It can be useful with procedural textures or probe for instance.
  27933. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  27934. */
  27935. invertRefractionY: boolean;
  27936. /**
  27937. * Defines the alpha limits in alpha test mode.
  27938. */
  27939. alphaCutOff: number;
  27940. private _useLightmapAsShadowmap;
  27941. /**
  27942. * In case of light mapping, define whether the map contains light or shadow informations.
  27943. */
  27944. useLightmapAsShadowmap: boolean;
  27945. private _diffuseFresnelParameters;
  27946. /**
  27947. * Define the diffuse fresnel parameters of the material.
  27948. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27949. */
  27950. diffuseFresnelParameters: FresnelParameters;
  27951. private _opacityFresnelParameters;
  27952. /**
  27953. * Define the opacity fresnel parameters of the material.
  27954. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27955. */
  27956. opacityFresnelParameters: FresnelParameters;
  27957. private _reflectionFresnelParameters;
  27958. /**
  27959. * Define the reflection fresnel parameters of the material.
  27960. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27961. */
  27962. reflectionFresnelParameters: FresnelParameters;
  27963. private _refractionFresnelParameters;
  27964. /**
  27965. * Define the refraction fresnel parameters of the material.
  27966. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27967. */
  27968. refractionFresnelParameters: FresnelParameters;
  27969. private _emissiveFresnelParameters;
  27970. /**
  27971. * Define the emissive fresnel parameters of the material.
  27972. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27973. */
  27974. emissiveFresnelParameters: FresnelParameters;
  27975. private _useReflectionFresnelFromSpecular;
  27976. /**
  27977. * If true automatically deducts the fresnels values from the material specularity.
  27978. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27979. */
  27980. useReflectionFresnelFromSpecular: boolean;
  27981. private _useGlossinessFromSpecularMapAlpha;
  27982. /**
  27983. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  27984. */
  27985. useGlossinessFromSpecularMapAlpha: boolean;
  27986. private _maxSimultaneousLights;
  27987. /**
  27988. * Defines the maximum number of lights that can be used in the material
  27989. */
  27990. maxSimultaneousLights: number;
  27991. private _invertNormalMapX;
  27992. /**
  27993. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  27994. */
  27995. invertNormalMapX: boolean;
  27996. private _invertNormalMapY;
  27997. /**
  27998. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  27999. */
  28000. invertNormalMapY: boolean;
  28001. private _twoSidedLighting;
  28002. /**
  28003. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  28004. */
  28005. twoSidedLighting: boolean;
  28006. /**
  28007. * Default configuration related to image processing available in the standard Material.
  28008. */
  28009. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  28010. /**
  28011. * Gets the image processing configuration used either in this material.
  28012. */
  28013. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  28014. /**
  28015. * Sets the Default image processing configuration used either in the this material.
  28016. *
  28017. * If sets to null, the scene one is in use.
  28018. */
  28019. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  28020. /**
  28021. * Keep track of the image processing observer to allow dispose and replace.
  28022. */
  28023. private _imageProcessingObserver;
  28024. /**
  28025. * Attaches a new image processing configuration to the Standard Material.
  28026. * @param configuration
  28027. */
  28028. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  28029. /**
  28030. * Gets wether the color curves effect is enabled.
  28031. */
  28032. get cameraColorCurvesEnabled(): boolean;
  28033. /**
  28034. * Sets wether the color curves effect is enabled.
  28035. */
  28036. set cameraColorCurvesEnabled(value: boolean);
  28037. /**
  28038. * Gets wether the color grading effect is enabled.
  28039. */
  28040. get cameraColorGradingEnabled(): boolean;
  28041. /**
  28042. * Gets wether the color grading effect is enabled.
  28043. */
  28044. set cameraColorGradingEnabled(value: boolean);
  28045. /**
  28046. * Gets wether tonemapping is enabled or not.
  28047. */
  28048. get cameraToneMappingEnabled(): boolean;
  28049. /**
  28050. * Sets wether tonemapping is enabled or not
  28051. */
  28052. set cameraToneMappingEnabled(value: boolean);
  28053. /**
  28054. * The camera exposure used on this material.
  28055. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  28056. * This corresponds to a photographic exposure.
  28057. */
  28058. get cameraExposure(): number;
  28059. /**
  28060. * The camera exposure used on this material.
  28061. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  28062. * This corresponds to a photographic exposure.
  28063. */
  28064. set cameraExposure(value: number);
  28065. /**
  28066. * Gets The camera contrast used on this material.
  28067. */
  28068. get cameraContrast(): number;
  28069. /**
  28070. * Sets The camera contrast used on this material.
  28071. */
  28072. set cameraContrast(value: number);
  28073. /**
  28074. * Gets the Color Grading 2D Lookup Texture.
  28075. */
  28076. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  28077. /**
  28078. * Sets the Color Grading 2D Lookup Texture.
  28079. */
  28080. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  28081. /**
  28082. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  28083. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  28084. * 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;
  28085. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  28086. */
  28087. get cameraColorCurves(): Nullable<ColorCurves>;
  28088. /**
  28089. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  28090. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  28091. * 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;
  28092. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  28093. */
  28094. set cameraColorCurves(value: Nullable<ColorCurves>);
  28095. protected _renderTargets: SmartArray<RenderTargetTexture>;
  28096. protected _worldViewProjectionMatrix: Matrix;
  28097. protected _globalAmbientColor: Color3;
  28098. protected _useLogarithmicDepth: boolean;
  28099. protected _rebuildInParallel: boolean;
  28100. /**
  28101. * Instantiates a new standard material.
  28102. * This is the default material used in Babylon. It is the best trade off between quality
  28103. * and performances.
  28104. * @see http://doc.babylonjs.com/babylon101/materials
  28105. * @param name Define the name of the material in the scene
  28106. * @param scene Define the scene the material belong to
  28107. */
  28108. constructor(name: string, scene: Scene);
  28109. /**
  28110. * Gets a boolean indicating that current material needs to register RTT
  28111. */
  28112. get hasRenderTargetTextures(): boolean;
  28113. /**
  28114. * Gets the current class name of the material e.g. "StandardMaterial"
  28115. * Mainly use in serialization.
  28116. * @returns the class name
  28117. */
  28118. getClassName(): string;
  28119. /**
  28120. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  28121. * You can try switching to logarithmic depth.
  28122. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  28123. */
  28124. get useLogarithmicDepth(): boolean;
  28125. set useLogarithmicDepth(value: boolean);
  28126. /**
  28127. * Specifies if the material will require alpha blending
  28128. * @returns a boolean specifying if alpha blending is needed
  28129. */
  28130. needAlphaBlending(): boolean;
  28131. /**
  28132. * Specifies if this material should be rendered in alpha test mode
  28133. * @returns a boolean specifying if an alpha test is needed.
  28134. */
  28135. needAlphaTesting(): boolean;
  28136. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  28137. /**
  28138. * Get the texture used for alpha test purpose.
  28139. * @returns the diffuse texture in case of the standard material.
  28140. */
  28141. getAlphaTestTexture(): Nullable<BaseTexture>;
  28142. /**
  28143. * Get if the submesh is ready to be used and all its information available.
  28144. * Child classes can use it to update shaders
  28145. * @param mesh defines the mesh to check
  28146. * @param subMesh defines which submesh to check
  28147. * @param useInstances specifies that instances should be used
  28148. * @returns a boolean indicating that the submesh is ready or not
  28149. */
  28150. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  28151. /**
  28152. * Builds the material UBO layouts.
  28153. * Used internally during the effect preparation.
  28154. */
  28155. buildUniformLayout(): void;
  28156. /**
  28157. * Unbinds the material from the mesh
  28158. */
  28159. unbind(): void;
  28160. /**
  28161. * Binds the submesh to this material by preparing the effect and shader to draw
  28162. * @param world defines the world transformation matrix
  28163. * @param mesh defines the mesh containing the submesh
  28164. * @param subMesh defines the submesh to bind the material to
  28165. */
  28166. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  28167. /**
  28168. * Get the list of animatables in the material.
  28169. * @returns the list of animatables object used in the material
  28170. */
  28171. getAnimatables(): IAnimatable[];
  28172. /**
  28173. * Gets the active textures from the material
  28174. * @returns an array of textures
  28175. */
  28176. getActiveTextures(): BaseTexture[];
  28177. /**
  28178. * Specifies if the material uses a texture
  28179. * @param texture defines the texture to check against the material
  28180. * @returns a boolean specifying if the material uses the texture
  28181. */
  28182. hasTexture(texture: BaseTexture): boolean;
  28183. /**
  28184. * Disposes the material
  28185. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  28186. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  28187. */
  28188. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  28189. /**
  28190. * Makes a duplicate of the material, and gives it a new name
  28191. * @param name defines the new name for the duplicated material
  28192. * @returns the cloned material
  28193. */
  28194. clone(name: string): StandardMaterial;
  28195. /**
  28196. * Serializes this material in a JSON representation
  28197. * @returns the serialized material object
  28198. */
  28199. serialize(): any;
  28200. /**
  28201. * Creates a standard material from parsed material data
  28202. * @param source defines the JSON representation of the material
  28203. * @param scene defines the hosting scene
  28204. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  28205. * @returns a new standard material
  28206. */
  28207. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  28208. /**
  28209. * Are diffuse textures enabled in the application.
  28210. */
  28211. static get DiffuseTextureEnabled(): boolean;
  28212. static set DiffuseTextureEnabled(value: boolean);
  28213. /**
  28214. * Are ambient textures enabled in the application.
  28215. */
  28216. static get AmbientTextureEnabled(): boolean;
  28217. static set AmbientTextureEnabled(value: boolean);
  28218. /**
  28219. * Are opacity textures enabled in the application.
  28220. */
  28221. static get OpacityTextureEnabled(): boolean;
  28222. static set OpacityTextureEnabled(value: boolean);
  28223. /**
  28224. * Are reflection textures enabled in the application.
  28225. */
  28226. static get ReflectionTextureEnabled(): boolean;
  28227. static set ReflectionTextureEnabled(value: boolean);
  28228. /**
  28229. * Are emissive textures enabled in the application.
  28230. */
  28231. static get EmissiveTextureEnabled(): boolean;
  28232. static set EmissiveTextureEnabled(value: boolean);
  28233. /**
  28234. * Are specular textures enabled in the application.
  28235. */
  28236. static get SpecularTextureEnabled(): boolean;
  28237. static set SpecularTextureEnabled(value: boolean);
  28238. /**
  28239. * Are bump textures enabled in the application.
  28240. */
  28241. static get BumpTextureEnabled(): boolean;
  28242. static set BumpTextureEnabled(value: boolean);
  28243. /**
  28244. * Are lightmap textures enabled in the application.
  28245. */
  28246. static get LightmapTextureEnabled(): boolean;
  28247. static set LightmapTextureEnabled(value: boolean);
  28248. /**
  28249. * Are refraction textures enabled in the application.
  28250. */
  28251. static get RefractionTextureEnabled(): boolean;
  28252. static set RefractionTextureEnabled(value: boolean);
  28253. /**
  28254. * Are color grading textures enabled in the application.
  28255. */
  28256. static get ColorGradingTextureEnabled(): boolean;
  28257. static set ColorGradingTextureEnabled(value: boolean);
  28258. /**
  28259. * Are fresnels enabled in the application.
  28260. */
  28261. static get FresnelEnabled(): boolean;
  28262. static set FresnelEnabled(value: boolean);
  28263. }
  28264. }
  28265. declare module "babylonjs/Particles/solidParticleSystem" {
  28266. import { Nullable } from "babylonjs/types";
  28267. import { Mesh } from "babylonjs/Meshes/mesh";
  28268. import { Scene, IDisposable } from "babylonjs/scene";
  28269. import { DepthSortedParticle, SolidParticle, SolidParticleVertex } from "babylonjs/Particles/solidParticle";
  28270. import { Material } from "babylonjs/Materials/material";
  28271. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  28272. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  28273. /**
  28274. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  28275. *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.
  28276. * The SPS is also a particle system. It provides some methods to manage the particles.
  28277. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  28278. *
  28279. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  28280. */
  28281. export class SolidParticleSystem implements IDisposable {
  28282. /**
  28283. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  28284. * Example : var p = SPS.particles[i];
  28285. */
  28286. particles: SolidParticle[];
  28287. /**
  28288. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  28289. */
  28290. nbParticles: number;
  28291. /**
  28292. * If the particles must ever face the camera (default false). Useful for planar particles.
  28293. */
  28294. billboard: boolean;
  28295. /**
  28296. * Recompute normals when adding a shape
  28297. */
  28298. recomputeNormals: boolean;
  28299. /**
  28300. * This a counter ofr your own usage. It's not set by any SPS functions.
  28301. */
  28302. counter: number;
  28303. /**
  28304. * The SPS name. This name is also given to the underlying mesh.
  28305. */
  28306. name: string;
  28307. /**
  28308. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  28309. */
  28310. mesh: Mesh;
  28311. /**
  28312. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  28313. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  28314. */
  28315. vars: any;
  28316. /**
  28317. * This array is populated when the SPS is set as 'pickable'.
  28318. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  28319. * Each element of this array is an object `{idx: int, faceId: int}`.
  28320. * `idx` is the picked particle index in the `SPS.particles` array
  28321. * `faceId` is the picked face index counted within this particle.
  28322. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  28323. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  28324. * Use the method SPS.pickedParticle(pickingInfo) instead.
  28325. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  28326. */
  28327. pickedParticles: {
  28328. idx: number;
  28329. faceId: number;
  28330. }[];
  28331. /**
  28332. * This array is populated when the SPS is set as 'pickable'
  28333. * Each key of this array is a submesh index.
  28334. * Each element of this array is a second array defined like this :
  28335. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  28336. * Each element of this second array is an object `{idx: int, faceId: int}`.
  28337. * `idx` is the picked particle index in the `SPS.particles` array
  28338. * `faceId` is the picked face index counted within this particle.
  28339. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  28340. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  28341. */
  28342. pickedBySubMesh: {
  28343. idx: number;
  28344. faceId: number;
  28345. }[][];
  28346. /**
  28347. * This array is populated when `enableDepthSort` is set to true.
  28348. * Each element of this array is an instance of the class DepthSortedParticle.
  28349. */
  28350. depthSortedParticles: DepthSortedParticle[];
  28351. /**
  28352. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  28353. * @hidden
  28354. */
  28355. _bSphereOnly: boolean;
  28356. /**
  28357. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  28358. * @hidden
  28359. */
  28360. _bSphereRadiusFactor: number;
  28361. private _scene;
  28362. private _positions;
  28363. private _indices;
  28364. private _normals;
  28365. private _colors;
  28366. private _uvs;
  28367. private _indices32;
  28368. private _positions32;
  28369. private _normals32;
  28370. private _fixedNormal32;
  28371. private _colors32;
  28372. private _uvs32;
  28373. private _index;
  28374. private _updatable;
  28375. private _pickable;
  28376. private _isVisibilityBoxLocked;
  28377. private _alwaysVisible;
  28378. private _depthSort;
  28379. private _expandable;
  28380. private _shapeCounter;
  28381. private _copy;
  28382. private _color;
  28383. private _computeParticleColor;
  28384. private _computeParticleTexture;
  28385. private _computeParticleRotation;
  28386. private _computeParticleVertex;
  28387. private _computeBoundingBox;
  28388. private _depthSortParticles;
  28389. private _camera;
  28390. private _mustUnrotateFixedNormals;
  28391. private _particlesIntersect;
  28392. private _needs32Bits;
  28393. private _isNotBuilt;
  28394. private _lastParticleId;
  28395. private _idxOfId;
  28396. private _multimaterialEnabled;
  28397. private _useModelMaterial;
  28398. private _indicesByMaterial;
  28399. private _materialIndexes;
  28400. private _depthSortFunction;
  28401. private _materialSortFunction;
  28402. private _materials;
  28403. private _multimaterial;
  28404. private _materialIndexesById;
  28405. private _defaultMaterial;
  28406. private _autoUpdateSubMeshes;
  28407. private _tmpVertex;
  28408. /**
  28409. * Creates a SPS (Solid Particle System) object.
  28410. * @param name (String) is the SPS name, this will be the underlying mesh name.
  28411. * @param scene (Scene) is the scene in which the SPS is added.
  28412. * @param options defines the options of the sps e.g.
  28413. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  28414. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  28415. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  28416. * * 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.
  28417. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  28418. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  28419. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  28420. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  28421. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  28422. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  28423. */
  28424. constructor(name: string, scene: Scene, options?: {
  28425. updatable?: boolean;
  28426. isPickable?: boolean;
  28427. enableDepthSort?: boolean;
  28428. particleIntersection?: boolean;
  28429. boundingSphereOnly?: boolean;
  28430. bSphereRadiusFactor?: number;
  28431. expandable?: boolean;
  28432. useModelMaterial?: boolean;
  28433. enableMultiMaterial?: boolean;
  28434. });
  28435. /**
  28436. * Builds the SPS underlying mesh. Returns a standard Mesh.
  28437. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  28438. * @returns the created mesh
  28439. */
  28440. buildMesh(): Mesh;
  28441. /**
  28442. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  28443. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  28444. * Thus the particles generated from `digest()` have their property `position` set yet.
  28445. * @param mesh ( Mesh ) is the mesh to be digested
  28446. * @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
  28447. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  28448. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  28449. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  28450. * @returns the current SPS
  28451. */
  28452. digest(mesh: Mesh, options?: {
  28453. facetNb?: number;
  28454. number?: number;
  28455. delta?: number;
  28456. storage?: [];
  28457. }): SolidParticleSystem;
  28458. /**
  28459. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  28460. * @hidden
  28461. */
  28462. private _unrotateFixedNormals;
  28463. /**
  28464. * Resets the temporary working copy particle
  28465. * @hidden
  28466. */
  28467. private _resetCopy;
  28468. /**
  28469. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  28470. * @param p the current index in the positions array to be updated
  28471. * @param ind the current index in the indices array
  28472. * @param shape a Vector3 array, the shape geometry
  28473. * @param positions the positions array to be updated
  28474. * @param meshInd the shape indices array
  28475. * @param indices the indices array to be updated
  28476. * @param meshUV the shape uv array
  28477. * @param uvs the uv array to be updated
  28478. * @param meshCol the shape color array
  28479. * @param colors the color array to be updated
  28480. * @param meshNor the shape normals array
  28481. * @param normals the normals array to be updated
  28482. * @param idx the particle index
  28483. * @param idxInShape the particle index in its shape
  28484. * @param options the addShape() method passed options
  28485. * @model the particle model
  28486. * @hidden
  28487. */
  28488. private _meshBuilder;
  28489. /**
  28490. * Returns a shape Vector3 array from positions float array
  28491. * @param positions float array
  28492. * @returns a vector3 array
  28493. * @hidden
  28494. */
  28495. private _posToShape;
  28496. /**
  28497. * Returns a shapeUV array from a float uvs (array deep copy)
  28498. * @param uvs as a float array
  28499. * @returns a shapeUV array
  28500. * @hidden
  28501. */
  28502. private _uvsToShapeUV;
  28503. /**
  28504. * Adds a new particle object in the particles array
  28505. * @param idx particle index in particles array
  28506. * @param id particle id
  28507. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  28508. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  28509. * @param model particle ModelShape object
  28510. * @param shapeId model shape identifier
  28511. * @param idxInShape index of the particle in the current model
  28512. * @param bInfo model bounding info object
  28513. * @param storage target storage array, if any
  28514. * @hidden
  28515. */
  28516. private _addParticle;
  28517. /**
  28518. * Adds some particles to the SPS from the model shape. Returns the shape id.
  28519. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  28520. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  28521. * @param nb (positive integer) the number of particles to be created from this model
  28522. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  28523. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  28524. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  28525. * @returns the number of shapes in the system
  28526. */
  28527. addShape(mesh: Mesh, nb: number, options?: {
  28528. positionFunction?: any;
  28529. vertexFunction?: any;
  28530. storage?: [];
  28531. }): number;
  28532. /**
  28533. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  28534. * @hidden
  28535. */
  28536. private _rebuildParticle;
  28537. /**
  28538. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  28539. * @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.
  28540. * @returns the SPS.
  28541. */
  28542. rebuildMesh(reset?: boolean): SolidParticleSystem;
  28543. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  28544. * Returns an array with the removed particles.
  28545. * 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.
  28546. * The SPS can't be empty so at least one particle needs to remain in place.
  28547. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  28548. * @param start index of the first particle to remove
  28549. * @param end index of the last particle to remove (included)
  28550. * @returns an array populated with the removed particles
  28551. */
  28552. removeParticles(start: number, end: number): SolidParticle[];
  28553. /**
  28554. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  28555. * @param solidParticleArray an array populated with Solid Particles objects
  28556. * @returns the SPS
  28557. */
  28558. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  28559. /**
  28560. * Creates a new particle and modifies the SPS mesh geometry :
  28561. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  28562. * - calls _addParticle() to populate the particle array
  28563. * factorized code from addShape() and insertParticlesFromArray()
  28564. * @param idx particle index in the particles array
  28565. * @param i particle index in its shape
  28566. * @param modelShape particle ModelShape object
  28567. * @param shape shape vertex array
  28568. * @param meshInd shape indices array
  28569. * @param meshUV shape uv array
  28570. * @param meshCol shape color array
  28571. * @param meshNor shape normals array
  28572. * @param bbInfo shape bounding info
  28573. * @param storage target particle storage
  28574. * @options addShape() passed options
  28575. * @hidden
  28576. */
  28577. private _insertNewParticle;
  28578. /**
  28579. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  28580. * This method calls `updateParticle()` for each particle of the SPS.
  28581. * For an animated SPS, it is usually called within the render loop.
  28582. * 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.
  28583. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  28584. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  28585. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  28586. * @returns the SPS.
  28587. */
  28588. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  28589. /**
  28590. * Disposes the SPS.
  28591. */
  28592. dispose(): void;
  28593. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  28594. * idx is the particle index in the SPS
  28595. * faceId is the picked face index counted within this particle.
  28596. * Returns null if the pickInfo can't identify a picked particle.
  28597. * @param pickingInfo (PickingInfo object)
  28598. * @returns {idx: number, faceId: number} or null
  28599. */
  28600. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  28601. idx: number;
  28602. faceId: number;
  28603. }>;
  28604. /**
  28605. * Returns a SolidParticle object from its identifier : particle.id
  28606. * @param id (integer) the particle Id
  28607. * @returns the searched particle or null if not found in the SPS.
  28608. */
  28609. getParticleById(id: number): Nullable<SolidParticle>;
  28610. /**
  28611. * Returns a new array populated with the particles having the passed shapeId.
  28612. * @param shapeId (integer) the shape identifier
  28613. * @returns a new solid particle array
  28614. */
  28615. getParticlesByShapeId(shapeId: number): SolidParticle[];
  28616. /**
  28617. * Populates the passed array "ref" with the particles having the passed shapeId.
  28618. * @param shapeId the shape identifier
  28619. * @returns the SPS
  28620. * @param ref
  28621. */
  28622. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  28623. /**
  28624. * Computes the required SubMeshes according the materials assigned to the particles.
  28625. * @returns the solid particle system.
  28626. * Does nothing if called before the SPS mesh is built.
  28627. */
  28628. computeSubMeshes(): SolidParticleSystem;
  28629. /**
  28630. * Sorts the solid particles by material when MultiMaterial is enabled.
  28631. * Updates the indices32 array.
  28632. * Updates the indicesByMaterial array.
  28633. * Updates the mesh indices array.
  28634. * @returns the SPS
  28635. * @hidden
  28636. */
  28637. private _sortParticlesByMaterial;
  28638. /**
  28639. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  28640. * @hidden
  28641. */
  28642. private _setMaterialIndexesById;
  28643. /**
  28644. * Returns an array with unique values of Materials from the passed array
  28645. * @param array the material array to be checked and filtered
  28646. * @hidden
  28647. */
  28648. private _filterUniqueMaterialId;
  28649. /**
  28650. * Sets a new Standard Material as _defaultMaterial if not already set.
  28651. * @hidden
  28652. */
  28653. private _setDefaultMaterial;
  28654. /**
  28655. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  28656. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  28657. * @returns the SPS.
  28658. */
  28659. refreshVisibleSize(): SolidParticleSystem;
  28660. /**
  28661. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  28662. * @param size the size (float) of the visibility box
  28663. * note : this doesn't lock the SPS mesh bounding box.
  28664. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  28665. */
  28666. setVisibilityBox(size: number): void;
  28667. /**
  28668. * Gets whether the SPS as always visible or not
  28669. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  28670. */
  28671. get isAlwaysVisible(): boolean;
  28672. /**
  28673. * Sets the SPS as always visible or not
  28674. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  28675. */
  28676. set isAlwaysVisible(val: boolean);
  28677. /**
  28678. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  28679. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  28680. */
  28681. set isVisibilityBoxLocked(val: boolean);
  28682. /**
  28683. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  28684. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  28685. */
  28686. get isVisibilityBoxLocked(): boolean;
  28687. /**
  28688. * Tells to `setParticles()` to compute the particle rotations or not.
  28689. * Default value : true. The SPS is faster when it's set to false.
  28690. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  28691. */
  28692. set computeParticleRotation(val: boolean);
  28693. /**
  28694. * Tells to `setParticles()` to compute the particle colors or not.
  28695. * Default value : true. The SPS is faster when it's set to false.
  28696. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  28697. */
  28698. set computeParticleColor(val: boolean);
  28699. set computeParticleTexture(val: boolean);
  28700. /**
  28701. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  28702. * Default value : false. The SPS is faster when it's set to false.
  28703. * Note : the particle custom vertex positions aren't stored values.
  28704. */
  28705. set computeParticleVertex(val: boolean);
  28706. /**
  28707. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  28708. */
  28709. set computeBoundingBox(val: boolean);
  28710. /**
  28711. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  28712. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  28713. * Default : `true`
  28714. */
  28715. set depthSortParticles(val: boolean);
  28716. /**
  28717. * Gets if `setParticles()` computes the particle rotations or not.
  28718. * Default value : true. The SPS is faster when it's set to false.
  28719. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  28720. */
  28721. get computeParticleRotation(): boolean;
  28722. /**
  28723. * Gets if `setParticles()` computes the particle colors or not.
  28724. * Default value : true. The SPS is faster when it's set to false.
  28725. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  28726. */
  28727. get computeParticleColor(): boolean;
  28728. /**
  28729. * Gets if `setParticles()` computes the particle textures or not.
  28730. * Default value : true. The SPS is faster when it's set to false.
  28731. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  28732. */
  28733. get computeParticleTexture(): boolean;
  28734. /**
  28735. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  28736. * Default value : false. The SPS is faster when it's set to false.
  28737. * Note : the particle custom vertex positions aren't stored values.
  28738. */
  28739. get computeParticleVertex(): boolean;
  28740. /**
  28741. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  28742. */
  28743. get computeBoundingBox(): boolean;
  28744. /**
  28745. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  28746. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  28747. * Default : `true`
  28748. */
  28749. get depthSortParticles(): boolean;
  28750. /**
  28751. * Gets if the SPS is created as expandable at construction time.
  28752. * Default : `false`
  28753. */
  28754. get expandable(): boolean;
  28755. /**
  28756. * Gets if the SPS supports the Multi Materials
  28757. */
  28758. get multimaterialEnabled(): boolean;
  28759. /**
  28760. * Gets if the SPS uses the model materials for its own multimaterial.
  28761. */
  28762. get useModelMaterial(): boolean;
  28763. /**
  28764. * The SPS used material array.
  28765. */
  28766. get materials(): Material[];
  28767. /**
  28768. * Sets the SPS MultiMaterial from the passed materials.
  28769. * Note : the passed array is internally copied and not used then by reference.
  28770. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  28771. */
  28772. setMultiMaterial(materials: Material[]): void;
  28773. /**
  28774. * The SPS computed multimaterial object
  28775. */
  28776. get multimaterial(): MultiMaterial;
  28777. set multimaterial(mm: MultiMaterial);
  28778. /**
  28779. * If the subMeshes must be updated on the next call to setParticles()
  28780. */
  28781. get autoUpdateSubMeshes(): boolean;
  28782. set autoUpdateSubMeshes(val: boolean);
  28783. /**
  28784. * This function does nothing. It may be overwritten to set all the particle first values.
  28785. * The SPS doesn't call this function, you may have to call it by your own.
  28786. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  28787. */
  28788. initParticles(): void;
  28789. /**
  28790. * This function does nothing. It may be overwritten to recycle a particle.
  28791. * The SPS doesn't call this function, you may have to call it by your own.
  28792. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  28793. * @param particle The particle to recycle
  28794. * @returns the recycled particle
  28795. */
  28796. recycleParticle(particle: SolidParticle): SolidParticle;
  28797. /**
  28798. * Updates a particle : this function should be overwritten by the user.
  28799. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  28800. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  28801. * @example : just set a particle position or velocity and recycle conditions
  28802. * @param particle The particle to update
  28803. * @returns the updated particle
  28804. */
  28805. updateParticle(particle: SolidParticle): SolidParticle;
  28806. /**
  28807. * Updates a vertex of a particle : it can be overwritten by the user.
  28808. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  28809. * @param particle the current particle
  28810. * @param vertex the current vertex of the current particle : a SolidParticleVertex object
  28811. * @param pt the index of the current vertex in the particle shape
  28812. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  28813. * @example : just set a vertex particle position or color
  28814. * @returns the sps
  28815. */
  28816. updateParticleVertex(particle: SolidParticle, vertex: SolidParticleVertex, pt: number): SolidParticleSystem;
  28817. /**
  28818. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  28819. * This does nothing and may be overwritten by the user.
  28820. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  28821. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  28822. * @param update the boolean update value actually passed to setParticles()
  28823. */
  28824. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  28825. /**
  28826. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  28827. * This will be passed three parameters.
  28828. * This does nothing and may be overwritten by the user.
  28829. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  28830. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  28831. * @param update the boolean update value actually passed to setParticles()
  28832. */
  28833. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  28834. }
  28835. }
  28836. declare module "babylonjs/Particles/solidParticle" {
  28837. import { Nullable } from "babylonjs/types";
  28838. import { Vector3, Matrix, Quaternion, Vector4, Vector2 } from "babylonjs/Maths/math.vector";
  28839. import { Color4 } from "babylonjs/Maths/math.color";
  28840. import { Mesh } from "babylonjs/Meshes/mesh";
  28841. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  28842. import { SolidParticleSystem } from "babylonjs/Particles/solidParticleSystem";
  28843. import { Plane } from "babylonjs/Maths/math.plane";
  28844. import { Material } from "babylonjs/Materials/material";
  28845. /**
  28846. * Represents one particle of a solid particle system.
  28847. */
  28848. export class SolidParticle {
  28849. /**
  28850. * particle global index
  28851. */
  28852. idx: number;
  28853. /**
  28854. * particle identifier
  28855. */
  28856. id: number;
  28857. /**
  28858. * The color of the particle
  28859. */
  28860. color: Nullable<Color4>;
  28861. /**
  28862. * The world space position of the particle.
  28863. */
  28864. position: Vector3;
  28865. /**
  28866. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  28867. */
  28868. rotation: Vector3;
  28869. /**
  28870. * The world space rotation quaternion of the particle.
  28871. */
  28872. rotationQuaternion: Nullable<Quaternion>;
  28873. /**
  28874. * The scaling of the particle.
  28875. */
  28876. scaling: Vector3;
  28877. /**
  28878. * The uvs of the particle.
  28879. */
  28880. uvs: Vector4;
  28881. /**
  28882. * The current speed of the particle.
  28883. */
  28884. velocity: Vector3;
  28885. /**
  28886. * The pivot point in the particle local space.
  28887. */
  28888. pivot: Vector3;
  28889. /**
  28890. * Must the particle be translated from its pivot point in its local space ?
  28891. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  28892. * Default : false
  28893. */
  28894. translateFromPivot: boolean;
  28895. /**
  28896. * Is the particle active or not ?
  28897. */
  28898. alive: boolean;
  28899. /**
  28900. * Is the particle visible or not ?
  28901. */
  28902. isVisible: boolean;
  28903. /**
  28904. * Index of this particle in the global "positions" array (Internal use)
  28905. * @hidden
  28906. */
  28907. _pos: number;
  28908. /**
  28909. * @hidden Index of this particle in the global "indices" array (Internal use)
  28910. */
  28911. _ind: number;
  28912. /**
  28913. * @hidden ModelShape of this particle (Internal use)
  28914. */
  28915. _model: ModelShape;
  28916. /**
  28917. * ModelShape id of this particle
  28918. */
  28919. shapeId: number;
  28920. /**
  28921. * Index of the particle in its shape id
  28922. */
  28923. idxInShape: number;
  28924. /**
  28925. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  28926. */
  28927. _modelBoundingInfo: BoundingInfo;
  28928. /**
  28929. * @hidden Particle BoundingInfo object (Internal use)
  28930. */
  28931. _boundingInfo: BoundingInfo;
  28932. /**
  28933. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  28934. */
  28935. _sps: SolidParticleSystem;
  28936. /**
  28937. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  28938. */
  28939. _stillInvisible: boolean;
  28940. /**
  28941. * @hidden Last computed particle rotation matrix
  28942. */
  28943. _rotationMatrix: number[];
  28944. /**
  28945. * Parent particle Id, if any.
  28946. * Default null.
  28947. */
  28948. parentId: Nullable<number>;
  28949. /**
  28950. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  28951. */
  28952. materialIndex: Nullable<number>;
  28953. /**
  28954. * Custom object or properties.
  28955. */
  28956. props: Nullable<any>;
  28957. /**
  28958. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  28959. * The possible values are :
  28960. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  28961. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  28962. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  28963. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  28964. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  28965. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  28966. * */
  28967. cullingStrategy: number;
  28968. /**
  28969. * @hidden Internal global position in the SPS.
  28970. */
  28971. _globalPosition: Vector3;
  28972. /**
  28973. * Creates a Solid Particle object.
  28974. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  28975. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  28976. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  28977. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  28978. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  28979. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  28980. * @param shapeId (integer) is the model shape identifier in the SPS.
  28981. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  28982. * @param sps defines the sps it is associated to
  28983. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  28984. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  28985. */
  28986. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  28987. /**
  28988. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  28989. * @param target the particle target
  28990. * @returns the current particle
  28991. */
  28992. copyToRef(target: SolidParticle): SolidParticle;
  28993. /**
  28994. * Legacy support, changed scale to scaling
  28995. */
  28996. get scale(): Vector3;
  28997. /**
  28998. * Legacy support, changed scale to scaling
  28999. */
  29000. set scale(scale: Vector3);
  29001. /**
  29002. * Legacy support, changed quaternion to rotationQuaternion
  29003. */
  29004. get quaternion(): Nullable<Quaternion>;
  29005. /**
  29006. * Legacy support, changed quaternion to rotationQuaternion
  29007. */
  29008. set quaternion(q: Nullable<Quaternion>);
  29009. /**
  29010. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  29011. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  29012. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  29013. * @returns true if it intersects
  29014. */
  29015. intersectsMesh(target: Mesh | SolidParticle): boolean;
  29016. /**
  29017. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  29018. * A particle is in the frustum if its bounding box intersects the frustum
  29019. * @param frustumPlanes defines the frustum to test
  29020. * @returns true if the particle is in the frustum planes
  29021. */
  29022. isInFrustum(frustumPlanes: Plane[]): boolean;
  29023. /**
  29024. * get the rotation matrix of the particle
  29025. * @hidden
  29026. */
  29027. getRotationMatrix(m: Matrix): void;
  29028. }
  29029. /**
  29030. * Represents the shape of the model used by one particle of a solid particle system.
  29031. * SPS internal tool, don't use it manually.
  29032. */
  29033. export class ModelShape {
  29034. /**
  29035. * The shape id
  29036. * @hidden
  29037. */
  29038. shapeID: number;
  29039. /**
  29040. * flat array of model positions (internal use)
  29041. * @hidden
  29042. */
  29043. _shape: Vector3[];
  29044. /**
  29045. * flat array of model UVs (internal use)
  29046. * @hidden
  29047. */
  29048. _shapeUV: number[];
  29049. /**
  29050. * color array of the model
  29051. * @hidden
  29052. */
  29053. _shapeColors: number[];
  29054. /**
  29055. * indices array of the model
  29056. * @hidden
  29057. */
  29058. _indices: number[];
  29059. /**
  29060. * normals array of the model
  29061. * @hidden
  29062. */
  29063. _normals: number[];
  29064. /**
  29065. * length of the shape in the model indices array (internal use)
  29066. * @hidden
  29067. */
  29068. _indicesLength: number;
  29069. /**
  29070. * Custom position function (internal use)
  29071. * @hidden
  29072. */
  29073. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  29074. /**
  29075. * Custom vertex function (internal use)
  29076. * @hidden
  29077. */
  29078. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  29079. /**
  29080. * Model material (internal use)
  29081. * @hidden
  29082. */
  29083. _material: Nullable<Material>;
  29084. /**
  29085. * 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.
  29086. * SPS internal tool, don't use it manually.
  29087. * @hidden
  29088. */
  29089. 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>);
  29090. }
  29091. /**
  29092. * Represents a Depth Sorted Particle in the solid particle system.
  29093. * @hidden
  29094. */
  29095. export class DepthSortedParticle {
  29096. /**
  29097. * Particle index
  29098. */
  29099. idx: number;
  29100. /**
  29101. * Index of the particle in the "indices" array
  29102. */
  29103. ind: number;
  29104. /**
  29105. * Length of the particle shape in the "indices" array
  29106. */
  29107. indicesLength: number;
  29108. /**
  29109. * Squared distance from the particle to the camera
  29110. */
  29111. sqDistance: number;
  29112. /**
  29113. * Material index when used with MultiMaterials
  29114. */
  29115. materialIndex: number;
  29116. /**
  29117. * Creates a new sorted particle
  29118. * @param materialIndex
  29119. */
  29120. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  29121. }
  29122. /**
  29123. * Represents a solid particle vertex
  29124. */
  29125. export class SolidParticleVertex {
  29126. /**
  29127. * Vertex position
  29128. */
  29129. position: Vector3;
  29130. /**
  29131. * Vertex color
  29132. */
  29133. color: Color4;
  29134. /**
  29135. * Vertex UV
  29136. */
  29137. uv: Vector2;
  29138. /**
  29139. * Creates a new solid particle vertex
  29140. */
  29141. constructor();
  29142. /** Vertex x coordinate */
  29143. get x(): number;
  29144. set x(val: number);
  29145. /** Vertex y coordinate */
  29146. get y(): number;
  29147. set y(val: number);
  29148. /** Vertex z coordinate */
  29149. get z(): number;
  29150. set z(val: number);
  29151. }
  29152. }
  29153. declare module "babylonjs/Collisions/meshCollisionData" {
  29154. import { Collider } from "babylonjs/Collisions/collider";
  29155. import { Vector3 } from "babylonjs/Maths/math.vector";
  29156. import { Nullable } from "babylonjs/types";
  29157. import { Observer } from "babylonjs/Misc/observable";
  29158. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  29159. /**
  29160. * @hidden
  29161. */
  29162. export class _MeshCollisionData {
  29163. _checkCollisions: boolean;
  29164. _collisionMask: number;
  29165. _collisionGroup: number;
  29166. _surroundingMeshes: Nullable<AbstractMesh[]>;
  29167. _collider: Nullable<Collider>;
  29168. _oldPositionForCollisions: Vector3;
  29169. _diffPositionForCollisions: Vector3;
  29170. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  29171. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  29172. }
  29173. }
  29174. declare module "babylonjs/Meshes/abstractMesh" {
  29175. import { Observable } from "babylonjs/Misc/observable";
  29176. import { Nullable, FloatArray, IndicesArray, DeepImmutable } from "babylonjs/types";
  29177. import { Camera } from "babylonjs/Cameras/camera";
  29178. import { Scene, IDisposable } from "babylonjs/scene";
  29179. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  29180. import { Node } from "babylonjs/node";
  29181. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  29182. import { TransformNode } from "babylonjs/Meshes/transformNode";
  29183. import { SubMesh } from "babylonjs/Meshes/subMesh";
  29184. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  29185. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  29186. import { Material } from "babylonjs/Materials/material";
  29187. import { Light } from "babylonjs/Lights/light";
  29188. import { Skeleton } from "babylonjs/Bones/skeleton";
  29189. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  29190. import { SolidParticle } from "babylonjs/Particles/solidParticle";
  29191. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  29192. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  29193. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  29194. import { Plane } from "babylonjs/Maths/math.plane";
  29195. import { Ray } from "babylonjs/Culling/ray";
  29196. import { Collider } from "babylonjs/Collisions/collider";
  29197. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  29198. import { RenderingGroup } from "babylonjs/Rendering/renderingGroup";
  29199. /** @hidden */
  29200. class _FacetDataStorage {
  29201. facetPositions: Vector3[];
  29202. facetNormals: Vector3[];
  29203. facetPartitioning: number[][];
  29204. facetNb: number;
  29205. partitioningSubdivisions: number;
  29206. partitioningBBoxRatio: number;
  29207. facetDataEnabled: boolean;
  29208. facetParameters: any;
  29209. bbSize: Vector3;
  29210. subDiv: {
  29211. max: number;
  29212. X: number;
  29213. Y: number;
  29214. Z: number;
  29215. };
  29216. facetDepthSort: boolean;
  29217. facetDepthSortEnabled: boolean;
  29218. depthSortedIndices: IndicesArray;
  29219. depthSortedFacets: {
  29220. ind: number;
  29221. sqDistance: number;
  29222. }[];
  29223. facetDepthSortFunction: (f1: {
  29224. ind: number;
  29225. sqDistance: number;
  29226. }, f2: {
  29227. ind: number;
  29228. sqDistance: number;
  29229. }) => number;
  29230. facetDepthSortFrom: Vector3;
  29231. facetDepthSortOrigin: Vector3;
  29232. invertedMatrix: Matrix;
  29233. }
  29234. /**
  29235. * @hidden
  29236. **/
  29237. class _InternalAbstractMeshDataInfo {
  29238. _hasVertexAlpha: boolean;
  29239. _useVertexColors: boolean;
  29240. _numBoneInfluencers: number;
  29241. _applyFog: boolean;
  29242. _receiveShadows: boolean;
  29243. _facetData: _FacetDataStorage;
  29244. _visibility: number;
  29245. _skeleton: Nullable<Skeleton>;
  29246. _layerMask: number;
  29247. _computeBonesUsingShaders: boolean;
  29248. _isActive: boolean;
  29249. _onlyForInstances: boolean;
  29250. _isActiveIntermediate: boolean;
  29251. _onlyForInstancesIntermediate: boolean;
  29252. _actAsRegularMesh: boolean;
  29253. }
  29254. /**
  29255. * Class used to store all common mesh properties
  29256. */
  29257. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  29258. /** No occlusion */
  29259. static OCCLUSION_TYPE_NONE: number;
  29260. /** Occlusion set to optimisitic */
  29261. static OCCLUSION_TYPE_OPTIMISTIC: number;
  29262. /** Occlusion set to strict */
  29263. static OCCLUSION_TYPE_STRICT: number;
  29264. /** Use an accurante occlusion algorithm */
  29265. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  29266. /** Use a conservative occlusion algorithm */
  29267. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  29268. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  29269. * Test order :
  29270. * Is the bounding sphere outside the frustum ?
  29271. * If not, are the bounding box vertices outside the frustum ?
  29272. * It not, then the cullable object is in the frustum.
  29273. */
  29274. static readonly CULLINGSTRATEGY_STANDARD: number;
  29275. /** Culling strategy : Bounding Sphere Only.
  29276. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  29277. * It's also less accurate than the standard because some not visible objects can still be selected.
  29278. * Test : is the bounding sphere outside the frustum ?
  29279. * If not, then the cullable object is in the frustum.
  29280. */
  29281. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  29282. /** Culling strategy : Optimistic Inclusion.
  29283. * This in an inclusion test first, then the standard exclusion test.
  29284. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  29285. * 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.
  29286. * Anyway, it's as accurate as the standard strategy.
  29287. * Test :
  29288. * Is the cullable object bounding sphere center in the frustum ?
  29289. * If not, apply the default culling strategy.
  29290. */
  29291. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  29292. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  29293. * This in an inclusion test first, then the bounding sphere only exclusion test.
  29294. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  29295. * 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.
  29296. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  29297. * Test :
  29298. * Is the cullable object bounding sphere center in the frustum ?
  29299. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  29300. */
  29301. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  29302. /**
  29303. * No billboard
  29304. */
  29305. static get BILLBOARDMODE_NONE(): number;
  29306. /** Billboard on X axis */
  29307. static get BILLBOARDMODE_X(): number;
  29308. /** Billboard on Y axis */
  29309. static get BILLBOARDMODE_Y(): number;
  29310. /** Billboard on Z axis */
  29311. static get BILLBOARDMODE_Z(): number;
  29312. /** Billboard on all axes */
  29313. static get BILLBOARDMODE_ALL(): number;
  29314. /** Billboard on using position instead of orientation */
  29315. static get BILLBOARDMODE_USE_POSITION(): number;
  29316. /** @hidden */
  29317. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  29318. /**
  29319. * The culling strategy to use to check whether the mesh must be rendered or not.
  29320. * This value can be changed at any time and will be used on the next render mesh selection.
  29321. * The possible values are :
  29322. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  29323. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  29324. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  29325. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  29326. * Please read each static variable documentation to get details about the culling process.
  29327. * */
  29328. cullingStrategy: number;
  29329. /**
  29330. * Gets the number of facets in the mesh
  29331. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  29332. */
  29333. get facetNb(): number;
  29334. /**
  29335. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  29336. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  29337. */
  29338. get partitioningSubdivisions(): number;
  29339. set partitioningSubdivisions(nb: number);
  29340. /**
  29341. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  29342. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  29343. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  29344. */
  29345. get partitioningBBoxRatio(): number;
  29346. set partitioningBBoxRatio(ratio: number);
  29347. /**
  29348. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  29349. * Works only for updatable meshes.
  29350. * Doesn't work with multi-materials
  29351. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  29352. */
  29353. get mustDepthSortFacets(): boolean;
  29354. set mustDepthSortFacets(sort: boolean);
  29355. /**
  29356. * The location (Vector3) where the facet depth sort must be computed from.
  29357. * By default, the active camera position.
  29358. * Used only when facet depth sort is enabled
  29359. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  29360. */
  29361. get facetDepthSortFrom(): Vector3;
  29362. set facetDepthSortFrom(location: Vector3);
  29363. /**
  29364. * gets a boolean indicating if facetData is enabled
  29365. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  29366. */
  29367. get isFacetDataEnabled(): boolean;
  29368. /** @hidden */
  29369. _updateNonUniformScalingState(value: boolean): boolean;
  29370. /**
  29371. * An event triggered when this mesh collides with another one
  29372. */
  29373. onCollideObservable: Observable<AbstractMesh>;
  29374. /** Set a function to call when this mesh collides with another one */
  29375. set onCollide(callback: () => void);
  29376. /**
  29377. * An event triggered when the collision's position changes
  29378. */
  29379. onCollisionPositionChangeObservable: Observable<Vector3>;
  29380. /** Set a function to call when the collision's position changes */
  29381. set onCollisionPositionChange(callback: () => void);
  29382. /**
  29383. * An event triggered when material is changed
  29384. */
  29385. onMaterialChangedObservable: Observable<AbstractMesh>;
  29386. /**
  29387. * Gets or sets the orientation for POV movement & rotation
  29388. */
  29389. definedFacingForward: boolean;
  29390. /** @hidden */
  29391. _occlusionQuery: Nullable<WebGLQuery>;
  29392. /** @hidden */
  29393. _renderingGroup: Nullable<RenderingGroup>;
  29394. /**
  29395. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  29396. */
  29397. get visibility(): number;
  29398. /**
  29399. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  29400. */
  29401. set visibility(value: number);
  29402. /** Gets or sets the alpha index used to sort transparent meshes
  29403. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  29404. */
  29405. alphaIndex: number;
  29406. /**
  29407. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  29408. */
  29409. isVisible: boolean;
  29410. /**
  29411. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  29412. */
  29413. isPickable: boolean;
  29414. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  29415. showSubMeshesBoundingBox: boolean;
  29416. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  29417. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  29418. */
  29419. isBlocker: boolean;
  29420. /**
  29421. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  29422. */
  29423. enablePointerMoveEvents: boolean;
  29424. /**
  29425. * Specifies the rendering group id for this mesh (0 by default)
  29426. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  29427. */
  29428. renderingGroupId: number;
  29429. private _material;
  29430. /** Gets or sets current material */
  29431. get material(): Nullable<Material>;
  29432. set material(value: Nullable<Material>);
  29433. /**
  29434. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  29435. * @see http://doc.babylonjs.com/babylon101/shadows
  29436. */
  29437. get receiveShadows(): boolean;
  29438. set receiveShadows(value: boolean);
  29439. /** Defines color to use when rendering outline */
  29440. outlineColor: Color3;
  29441. /** Define width to use when rendering outline */
  29442. outlineWidth: number;
  29443. /** Defines color to use when rendering overlay */
  29444. overlayColor: Color3;
  29445. /** Defines alpha to use when rendering overlay */
  29446. overlayAlpha: number;
  29447. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  29448. get hasVertexAlpha(): boolean;
  29449. set hasVertexAlpha(value: boolean);
  29450. /** 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) */
  29451. get useVertexColors(): boolean;
  29452. set useVertexColors(value: boolean);
  29453. /**
  29454. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  29455. */
  29456. get computeBonesUsingShaders(): boolean;
  29457. set computeBonesUsingShaders(value: boolean);
  29458. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  29459. get numBoneInfluencers(): number;
  29460. set numBoneInfluencers(value: number);
  29461. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  29462. get applyFog(): boolean;
  29463. set applyFog(value: boolean);
  29464. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  29465. useOctreeForRenderingSelection: boolean;
  29466. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  29467. useOctreeForPicking: boolean;
  29468. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  29469. useOctreeForCollisions: boolean;
  29470. /**
  29471. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  29472. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  29473. */
  29474. get layerMask(): number;
  29475. set layerMask(value: number);
  29476. /**
  29477. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  29478. */
  29479. alwaysSelectAsActiveMesh: boolean;
  29480. /**
  29481. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  29482. */
  29483. doNotSyncBoundingInfo: boolean;
  29484. /**
  29485. * Gets or sets the current action manager
  29486. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  29487. */
  29488. actionManager: Nullable<AbstractActionManager>;
  29489. private _meshCollisionData;
  29490. /**
  29491. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  29492. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  29493. */
  29494. ellipsoid: Vector3;
  29495. /**
  29496. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  29497. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  29498. */
  29499. ellipsoidOffset: Vector3;
  29500. /**
  29501. * Gets or sets a collision mask used to mask collisions (default is -1).
  29502. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  29503. */
  29504. get collisionMask(): number;
  29505. set collisionMask(mask: number);
  29506. /**
  29507. * Gets or sets the current collision group mask (-1 by default).
  29508. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  29509. */
  29510. get collisionGroup(): number;
  29511. set collisionGroup(mask: number);
  29512. /**
  29513. * Gets or sets current surrounding meshes (null by default).
  29514. *
  29515. * By default collision detection is tested against every mesh in the scene.
  29516. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  29517. * meshes will be tested for the collision.
  29518. *
  29519. * Note: if set to an empty array no collision will happen when this mesh is moved.
  29520. */
  29521. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  29522. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  29523. /**
  29524. * Defines edge width used when edgesRenderer is enabled
  29525. * @see https://www.babylonjs-playground.com/#10OJSG#13
  29526. */
  29527. edgesWidth: number;
  29528. /**
  29529. * Defines edge color used when edgesRenderer is enabled
  29530. * @see https://www.babylonjs-playground.com/#10OJSG#13
  29531. */
  29532. edgesColor: Color4;
  29533. /** @hidden */
  29534. _edgesRenderer: Nullable<IEdgesRenderer>;
  29535. /** @hidden */
  29536. _masterMesh: Nullable<AbstractMesh>;
  29537. /** @hidden */
  29538. _boundingInfo: Nullable<BoundingInfo>;
  29539. /** @hidden */
  29540. _renderId: number;
  29541. /**
  29542. * Gets or sets the list of subMeshes
  29543. * @see http://doc.babylonjs.com/how_to/multi_materials
  29544. */
  29545. subMeshes: SubMesh[];
  29546. /** @hidden */
  29547. _intersectionsInProgress: AbstractMesh[];
  29548. /** @hidden */
  29549. _unIndexed: boolean;
  29550. /** @hidden */
  29551. _lightSources: Light[];
  29552. /** Gets the list of lights affecting that mesh */
  29553. get lightSources(): Light[];
  29554. /** @hidden */
  29555. get _positions(): Nullable<Vector3[]>;
  29556. /** @hidden */
  29557. _waitingData: {
  29558. lods: Nullable<any>;
  29559. actions: Nullable<any>;
  29560. freezeWorldMatrix: Nullable<boolean>;
  29561. };
  29562. /** @hidden */
  29563. _bonesTransformMatrices: Nullable<Float32Array>;
  29564. /** @hidden */
  29565. _transformMatrixTexture: Nullable<RawTexture>;
  29566. /**
  29567. * Gets or sets a skeleton to apply skining transformations
  29568. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  29569. */
  29570. set skeleton(value: Nullable<Skeleton>);
  29571. get skeleton(): Nullable<Skeleton>;
  29572. /**
  29573. * An event triggered when the mesh is rebuilt.
  29574. */
  29575. onRebuildObservable: Observable<AbstractMesh>;
  29576. /**
  29577. * Creates a new AbstractMesh
  29578. * @param name defines the name of the mesh
  29579. * @param scene defines the hosting scene
  29580. */
  29581. constructor(name: string, scene?: Nullable<Scene>);
  29582. /**
  29583. * Returns the string "AbstractMesh"
  29584. * @returns "AbstractMesh"
  29585. */
  29586. getClassName(): string;
  29587. /**
  29588. * Gets a string representation of the current mesh
  29589. * @param fullDetails defines a boolean indicating if full details must be included
  29590. * @returns a string representation of the current mesh
  29591. */
  29592. toString(fullDetails?: boolean): string;
  29593. /**
  29594. * @hidden
  29595. */
  29596. protected _getEffectiveParent(): Nullable<Node>;
  29597. /** @hidden */
  29598. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  29599. /** @hidden */
  29600. _rebuild(): void;
  29601. /** @hidden */
  29602. _resyncLightSources(): void;
  29603. /** @hidden */
  29604. _resyncLightSource(light: Light): void;
  29605. /** @hidden */
  29606. _unBindEffect(): void;
  29607. /** @hidden */
  29608. _removeLightSource(light: Light, dispose: boolean): void;
  29609. private _markSubMeshesAsDirty;
  29610. /** @hidden */
  29611. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  29612. /** @hidden */
  29613. _markSubMeshesAsAttributesDirty(): void;
  29614. /** @hidden */
  29615. _markSubMeshesAsMiscDirty(): void;
  29616. /**
  29617. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  29618. */
  29619. get scaling(): Vector3;
  29620. set scaling(newScaling: Vector3);
  29621. /**
  29622. * Returns true if the mesh is blocked. Implemented by child classes
  29623. */
  29624. get isBlocked(): boolean;
  29625. /**
  29626. * Returns the mesh itself by default. Implemented by child classes
  29627. * @param camera defines the camera to use to pick the right LOD level
  29628. * @returns the currentAbstractMesh
  29629. */
  29630. getLOD(camera: Camera): Nullable<AbstractMesh>;
  29631. /**
  29632. * Returns 0 by default. Implemented by child classes
  29633. * @returns an integer
  29634. */
  29635. getTotalVertices(): number;
  29636. /**
  29637. * Returns a positive integer : the total number of indices in this mesh geometry.
  29638. * @returns the numner of indices or zero if the mesh has no geometry.
  29639. */
  29640. getTotalIndices(): number;
  29641. /**
  29642. * Returns null by default. Implemented by child classes
  29643. * @returns null
  29644. */
  29645. getIndices(): Nullable<IndicesArray>;
  29646. /**
  29647. * Returns the array of the requested vertex data kind. Implemented by child classes
  29648. * @param kind defines the vertex data kind to use
  29649. * @returns null
  29650. */
  29651. getVerticesData(kind: string): Nullable<FloatArray>;
  29652. /**
  29653. * Sets the vertex data of the mesh geometry for the requested `kind`.
  29654. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  29655. * Note that a new underlying VertexBuffer object is created each call.
  29656. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  29657. * @param kind defines vertex data kind:
  29658. * * VertexBuffer.PositionKind
  29659. * * VertexBuffer.UVKind
  29660. * * VertexBuffer.UV2Kind
  29661. * * VertexBuffer.UV3Kind
  29662. * * VertexBuffer.UV4Kind
  29663. * * VertexBuffer.UV5Kind
  29664. * * VertexBuffer.UV6Kind
  29665. * * VertexBuffer.ColorKind
  29666. * * VertexBuffer.MatricesIndicesKind
  29667. * * VertexBuffer.MatricesIndicesExtraKind
  29668. * * VertexBuffer.MatricesWeightsKind
  29669. * * VertexBuffer.MatricesWeightsExtraKind
  29670. * @param data defines the data source
  29671. * @param updatable defines if the data must be flagged as updatable (or static)
  29672. * @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
  29673. * @returns the current mesh
  29674. */
  29675. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  29676. /**
  29677. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  29678. * If the mesh has no geometry, it is simply returned as it is.
  29679. * @param kind defines vertex data kind:
  29680. * * VertexBuffer.PositionKind
  29681. * * VertexBuffer.UVKind
  29682. * * VertexBuffer.UV2Kind
  29683. * * VertexBuffer.UV3Kind
  29684. * * VertexBuffer.UV4Kind
  29685. * * VertexBuffer.UV5Kind
  29686. * * VertexBuffer.UV6Kind
  29687. * * VertexBuffer.ColorKind
  29688. * * VertexBuffer.MatricesIndicesKind
  29689. * * VertexBuffer.MatricesIndicesExtraKind
  29690. * * VertexBuffer.MatricesWeightsKind
  29691. * * VertexBuffer.MatricesWeightsExtraKind
  29692. * @param data defines the data source
  29693. * @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
  29694. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  29695. * @returns the current mesh
  29696. */
  29697. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  29698. /**
  29699. * Sets the mesh indices,
  29700. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  29701. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  29702. * @param totalVertices Defines the total number of vertices
  29703. * @returns the current mesh
  29704. */
  29705. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  29706. /**
  29707. * Gets a boolean indicating if specific vertex data is present
  29708. * @param kind defines the vertex data kind to use
  29709. * @returns true is data kind is present
  29710. */
  29711. isVerticesDataPresent(kind: string): boolean;
  29712. /**
  29713. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  29714. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  29715. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  29716. * @returns a BoundingInfo
  29717. */
  29718. getBoundingInfo(): BoundingInfo;
  29719. /**
  29720. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  29721. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  29722. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  29723. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  29724. * @returns the current mesh
  29725. */
  29726. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  29727. /**
  29728. * Overwrite the current bounding info
  29729. * @param boundingInfo defines the new bounding info
  29730. * @returns the current mesh
  29731. */
  29732. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  29733. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  29734. get useBones(): boolean;
  29735. /** @hidden */
  29736. _preActivate(): void;
  29737. /** @hidden */
  29738. _preActivateForIntermediateRendering(renderId: number): void;
  29739. /** @hidden */
  29740. _activate(renderId: number, intermediateRendering: boolean): boolean;
  29741. /** @hidden */
  29742. _postActivate(): void;
  29743. /** @hidden */
  29744. _freeze(): void;
  29745. /** @hidden */
  29746. _unFreeze(): void;
  29747. /**
  29748. * Gets the current world matrix
  29749. * @returns a Matrix
  29750. */
  29751. getWorldMatrix(): Matrix;
  29752. /** @hidden */
  29753. _getWorldMatrixDeterminant(): number;
  29754. /**
  29755. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  29756. */
  29757. get isAnInstance(): boolean;
  29758. /**
  29759. * Gets a boolean indicating if this mesh has instances
  29760. */
  29761. get hasInstances(): boolean;
  29762. /**
  29763. * Perform relative position change from the point of view of behind the front of the mesh.
  29764. * This is performed taking into account the meshes current rotation, so you do not have to care.
  29765. * Supports definition of mesh facing forward or backward
  29766. * @param amountRight defines the distance on the right axis
  29767. * @param amountUp defines the distance on the up axis
  29768. * @param amountForward defines the distance on the forward axis
  29769. * @returns the current mesh
  29770. */
  29771. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  29772. /**
  29773. * Calculate relative position change from the point of view of behind the front of the mesh.
  29774. * This is performed taking into account the meshes current rotation, so you do not have to care.
  29775. * Supports definition of mesh facing forward or backward
  29776. * @param amountRight defines the distance on the right axis
  29777. * @param amountUp defines the distance on the up axis
  29778. * @param amountForward defines the distance on the forward axis
  29779. * @returns the new displacement vector
  29780. */
  29781. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  29782. /**
  29783. * Perform relative rotation change from the point of view of behind the front of the mesh.
  29784. * Supports definition of mesh facing forward or backward
  29785. * @param flipBack defines the flip
  29786. * @param twirlClockwise defines the twirl
  29787. * @param tiltRight defines the tilt
  29788. * @returns the current mesh
  29789. */
  29790. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  29791. /**
  29792. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  29793. * Supports definition of mesh facing forward or backward.
  29794. * @param flipBack defines the flip
  29795. * @param twirlClockwise defines the twirl
  29796. * @param tiltRight defines the tilt
  29797. * @returns the new rotation vector
  29798. */
  29799. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  29800. /**
  29801. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  29802. * This means the mesh underlying bounding box and sphere are recomputed.
  29803. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  29804. * @returns the current mesh
  29805. */
  29806. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  29807. /** @hidden */
  29808. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  29809. /** @hidden */
  29810. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  29811. /** @hidden */
  29812. _updateBoundingInfo(): AbstractMesh;
  29813. /** @hidden */
  29814. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  29815. /** @hidden */
  29816. protected _afterComputeWorldMatrix(): void;
  29817. /** @hidden */
  29818. get _effectiveMesh(): AbstractMesh;
  29819. /**
  29820. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  29821. * A mesh is in the frustum if its bounding box intersects the frustum
  29822. * @param frustumPlanes defines the frustum to test
  29823. * @returns true if the mesh is in the frustum planes
  29824. */
  29825. isInFrustum(frustumPlanes: Plane[]): boolean;
  29826. /**
  29827. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  29828. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  29829. * @param frustumPlanes defines the frustum to test
  29830. * @returns true if the mesh is completely in the frustum planes
  29831. */
  29832. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  29833. /**
  29834. * True if the mesh intersects another mesh or a SolidParticle object
  29835. * @param mesh defines a target mesh or SolidParticle to test
  29836. * @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)
  29837. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  29838. * @returns true if there is an intersection
  29839. */
  29840. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  29841. /**
  29842. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  29843. * @param point defines the point to test
  29844. * @returns true if there is an intersection
  29845. */
  29846. intersectsPoint(point: Vector3): boolean;
  29847. /**
  29848. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  29849. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  29850. */
  29851. get checkCollisions(): boolean;
  29852. set checkCollisions(collisionEnabled: boolean);
  29853. /**
  29854. * Gets Collider object used to compute collisions (not physics)
  29855. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  29856. */
  29857. get collider(): Nullable<Collider>;
  29858. /**
  29859. * Move the mesh using collision engine
  29860. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  29861. * @param displacement defines the requested displacement vector
  29862. * @returns the current mesh
  29863. */
  29864. moveWithCollisions(displacement: Vector3): AbstractMesh;
  29865. private _onCollisionPositionChange;
  29866. /** @hidden */
  29867. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  29868. /** @hidden */
  29869. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  29870. /** @hidden */
  29871. _checkCollision(collider: Collider): AbstractMesh;
  29872. /** @hidden */
  29873. _generatePointsArray(): boolean;
  29874. /**
  29875. * Checks if the passed Ray intersects with the mesh
  29876. * @param ray defines the ray to use
  29877. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  29878. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  29879. * @param onlyBoundingInfo defines a boolean indicating if picking should only happen using bounding info (false by default)
  29880. * @returns the picking info
  29881. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  29882. */
  29883. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate, onlyBoundingInfo?: boolean): PickingInfo;
  29884. /**
  29885. * Clones the current mesh
  29886. * @param name defines the mesh name
  29887. * @param newParent defines the new mesh parent
  29888. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  29889. * @returns the new mesh
  29890. */
  29891. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  29892. /**
  29893. * Disposes all the submeshes of the current meshnp
  29894. * @returns the current mesh
  29895. */
  29896. releaseSubMeshes(): AbstractMesh;
  29897. /**
  29898. * Releases resources associated with this abstract mesh.
  29899. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  29900. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  29901. */
  29902. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  29903. /**
  29904. * Adds the passed mesh as a child to the current mesh
  29905. * @param mesh defines the child mesh
  29906. * @returns the current mesh
  29907. */
  29908. addChild(mesh: AbstractMesh): AbstractMesh;
  29909. /**
  29910. * Removes the passed mesh from the current mesh children list
  29911. * @param mesh defines the child mesh
  29912. * @returns the current mesh
  29913. */
  29914. removeChild(mesh: AbstractMesh): AbstractMesh;
  29915. /** @hidden */
  29916. private _initFacetData;
  29917. /**
  29918. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  29919. * This method can be called within the render loop.
  29920. * 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
  29921. * @returns the current mesh
  29922. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29923. */
  29924. updateFacetData(): AbstractMesh;
  29925. /**
  29926. * Returns the facetLocalNormals array.
  29927. * The normals are expressed in the mesh local spac
  29928. * @returns an array of Vector3
  29929. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29930. */
  29931. getFacetLocalNormals(): Vector3[];
  29932. /**
  29933. * Returns the facetLocalPositions array.
  29934. * The facet positions are expressed in the mesh local space
  29935. * @returns an array of Vector3
  29936. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29937. */
  29938. getFacetLocalPositions(): Vector3[];
  29939. /**
  29940. * Returns the facetLocalPartioning array
  29941. * @returns an array of array of numbers
  29942. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29943. */
  29944. getFacetLocalPartitioning(): number[][];
  29945. /**
  29946. * Returns the i-th facet position in the world system.
  29947. * This method allocates a new Vector3 per call
  29948. * @param i defines the facet index
  29949. * @returns a new Vector3
  29950. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29951. */
  29952. getFacetPosition(i: number): Vector3;
  29953. /**
  29954. * Sets the reference Vector3 with the i-th facet position in the world system
  29955. * @param i defines the facet index
  29956. * @param ref defines the target vector
  29957. * @returns the current mesh
  29958. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29959. */
  29960. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  29961. /**
  29962. * Returns the i-th facet normal in the world system.
  29963. * This method allocates a new Vector3 per call
  29964. * @param i defines the facet index
  29965. * @returns a new Vector3
  29966. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29967. */
  29968. getFacetNormal(i: number): Vector3;
  29969. /**
  29970. * Sets the reference Vector3 with the i-th facet normal in the world system
  29971. * @param i defines the facet index
  29972. * @param ref defines the target vector
  29973. * @returns the current mesh
  29974. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29975. */
  29976. getFacetNormalToRef(i: number, ref: Vector3): this;
  29977. /**
  29978. * 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)
  29979. * @param x defines x coordinate
  29980. * @param y defines y coordinate
  29981. * @param z defines z coordinate
  29982. * @returns the array of facet indexes
  29983. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29984. */
  29985. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  29986. /**
  29987. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  29988. * @param projected sets as the (x,y,z) world projection on the facet
  29989. * @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
  29990. * @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
  29991. * @param x defines x coordinate
  29992. * @param y defines y coordinate
  29993. * @param z defines z coordinate
  29994. * @returns the face index if found (or null instead)
  29995. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29996. */
  29997. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  29998. /**
  29999. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  30000. * @param projected sets as the (x,y,z) local projection on the facet
  30001. * @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
  30002. * @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
  30003. * @param x defines x coordinate
  30004. * @param y defines y coordinate
  30005. * @param z defines z coordinate
  30006. * @returns the face index if found (or null instead)
  30007. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  30008. */
  30009. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  30010. /**
  30011. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  30012. * @returns the parameters
  30013. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  30014. */
  30015. getFacetDataParameters(): any;
  30016. /**
  30017. * Disables the feature FacetData and frees the related memory
  30018. * @returns the current mesh
  30019. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  30020. */
  30021. disableFacetData(): AbstractMesh;
  30022. /**
  30023. * Updates the AbstractMesh indices array
  30024. * @param indices defines the data source
  30025. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  30026. * @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)
  30027. * @returns the current mesh
  30028. */
  30029. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  30030. /**
  30031. * Creates new normals data for the mesh
  30032. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  30033. * @returns the current mesh
  30034. */
  30035. createNormals(updatable: boolean): AbstractMesh;
  30036. /**
  30037. * Align the mesh with a normal
  30038. * @param normal defines the normal to use
  30039. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  30040. * @returns the current mesh
  30041. */
  30042. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  30043. /** @hidden */
  30044. _checkOcclusionQuery(): boolean;
  30045. /**
  30046. * Disables the mesh edge rendering mode
  30047. * @returns the currentAbstractMesh
  30048. */
  30049. disableEdgesRendering(): AbstractMesh;
  30050. /**
  30051. * Enables the edge rendering mode on the mesh.
  30052. * This mode makes the mesh edges visible
  30053. * @param epsilon defines the maximal distance between two angles to detect a face
  30054. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  30055. * @returns the currentAbstractMesh
  30056. * @see https://www.babylonjs-playground.com/#19O9TU#0
  30057. */
  30058. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  30059. }
  30060. }
  30061. declare module "babylonjs/Actions/actionEvent" {
  30062. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  30063. import { Nullable } from "babylonjs/types";
  30064. import { Sprite } from "babylonjs/Sprites/sprite";
  30065. import { Scene } from "babylonjs/scene";
  30066. import { Vector2 } from "babylonjs/Maths/math.vector";
  30067. /**
  30068. * Interface used to define ActionEvent
  30069. */
  30070. export interface IActionEvent {
  30071. /** The mesh or sprite that triggered the action */
  30072. source: any;
  30073. /** The X mouse cursor position at the time of the event */
  30074. pointerX: number;
  30075. /** The Y mouse cursor position at the time of the event */
  30076. pointerY: number;
  30077. /** The mesh that is currently pointed at (can be null) */
  30078. meshUnderPointer: Nullable<AbstractMesh>;
  30079. /** the original (browser) event that triggered the ActionEvent */
  30080. sourceEvent?: any;
  30081. /** additional data for the event */
  30082. additionalData?: any;
  30083. }
  30084. /**
  30085. * ActionEvent is the event being sent when an action is triggered.
  30086. */
  30087. export class ActionEvent implements IActionEvent {
  30088. /** The mesh or sprite that triggered the action */
  30089. source: any;
  30090. /** The X mouse cursor position at the time of the event */
  30091. pointerX: number;
  30092. /** The Y mouse cursor position at the time of the event */
  30093. pointerY: number;
  30094. /** The mesh that is currently pointed at (can be null) */
  30095. meshUnderPointer: Nullable<AbstractMesh>;
  30096. /** the original (browser) event that triggered the ActionEvent */
  30097. sourceEvent?: any;
  30098. /** additional data for the event */
  30099. additionalData?: any;
  30100. /**
  30101. * Creates a new ActionEvent
  30102. * @param source The mesh or sprite that triggered the action
  30103. * @param pointerX The X mouse cursor position at the time of the event
  30104. * @param pointerY The Y mouse cursor position at the time of the event
  30105. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  30106. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  30107. * @param additionalData additional data for the event
  30108. */
  30109. constructor(
  30110. /** The mesh or sprite that triggered the action */
  30111. source: any,
  30112. /** The X mouse cursor position at the time of the event */
  30113. pointerX: number,
  30114. /** The Y mouse cursor position at the time of the event */
  30115. pointerY: number,
  30116. /** The mesh that is currently pointed at (can be null) */
  30117. meshUnderPointer: Nullable<AbstractMesh>,
  30118. /** the original (browser) event that triggered the ActionEvent */
  30119. sourceEvent?: any,
  30120. /** additional data for the event */
  30121. additionalData?: any);
  30122. /**
  30123. * Helper function to auto-create an ActionEvent from a source mesh.
  30124. * @param source The source mesh that triggered the event
  30125. * @param evt The original (browser) event
  30126. * @param additionalData additional data for the event
  30127. * @returns the new ActionEvent
  30128. */
  30129. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  30130. /**
  30131. * Helper function to auto-create an ActionEvent from a source sprite
  30132. * @param source The source sprite that triggered the event
  30133. * @param scene Scene associated with the sprite
  30134. * @param evt The original (browser) event
  30135. * @param additionalData additional data for the event
  30136. * @returns the new ActionEvent
  30137. */
  30138. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  30139. /**
  30140. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  30141. * @param scene the scene where the event occurred
  30142. * @param evt The original (browser) event
  30143. * @returns the new ActionEvent
  30144. */
  30145. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  30146. /**
  30147. * Helper function to auto-create an ActionEvent from a primitive
  30148. * @param prim defines the target primitive
  30149. * @param pointerPos defines the pointer position
  30150. * @param evt The original (browser) event
  30151. * @param additionalData additional data for the event
  30152. * @returns the new ActionEvent
  30153. */
  30154. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  30155. }
  30156. }
  30157. declare module "babylonjs/Actions/abstractActionManager" {
  30158. import { IDisposable } from "babylonjs/scene";
  30159. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  30160. import { IAction } from "babylonjs/Actions/action";
  30161. import { Nullable } from "babylonjs/types";
  30162. /**
  30163. * Abstract class used to decouple action Manager from scene and meshes.
  30164. * Do not instantiate.
  30165. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  30166. */
  30167. export abstract class AbstractActionManager implements IDisposable {
  30168. /** Gets the list of active triggers */
  30169. static Triggers: {
  30170. [key: string]: number;
  30171. };
  30172. /** Gets the cursor to use when hovering items */
  30173. hoverCursor: string;
  30174. /** Gets the list of actions */
  30175. actions: IAction[];
  30176. /**
  30177. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  30178. */
  30179. isRecursive: boolean;
  30180. /**
  30181. * Releases all associated resources
  30182. */
  30183. abstract dispose(): void;
  30184. /**
  30185. * Does this action manager has pointer triggers
  30186. */
  30187. abstract get hasPointerTriggers(): boolean;
  30188. /**
  30189. * Does this action manager has pick triggers
  30190. */
  30191. abstract get hasPickTriggers(): boolean;
  30192. /**
  30193. * Process a specific trigger
  30194. * @param trigger defines the trigger to process
  30195. * @param evt defines the event details to be processed
  30196. */
  30197. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  30198. /**
  30199. * Does this action manager handles actions of any of the given triggers
  30200. * @param triggers defines the triggers to be tested
  30201. * @return a boolean indicating whether one (or more) of the triggers is handled
  30202. */
  30203. abstract hasSpecificTriggers(triggers: number[]): boolean;
  30204. /**
  30205. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  30206. * speed.
  30207. * @param triggerA defines the trigger to be tested
  30208. * @param triggerB defines the trigger to be tested
  30209. * @return a boolean indicating whether one (or more) of the triggers is handled
  30210. */
  30211. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  30212. /**
  30213. * Does this action manager handles actions of a given trigger
  30214. * @param trigger defines the trigger to be tested
  30215. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  30216. * @return whether the trigger is handled
  30217. */
  30218. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  30219. /**
  30220. * Serialize this manager to a JSON object
  30221. * @param name defines the property name to store this manager
  30222. * @returns a JSON representation of this manager
  30223. */
  30224. abstract serialize(name: string): any;
  30225. /**
  30226. * Registers an action to this action manager
  30227. * @param action defines the action to be registered
  30228. * @return the action amended (prepared) after registration
  30229. */
  30230. abstract registerAction(action: IAction): Nullable<IAction>;
  30231. /**
  30232. * Unregisters an action to this action manager
  30233. * @param action defines the action to be unregistered
  30234. * @return a boolean indicating whether the action has been unregistered
  30235. */
  30236. abstract unregisterAction(action: IAction): Boolean;
  30237. /**
  30238. * Does exist one action manager with at least one trigger
  30239. **/
  30240. static get HasTriggers(): boolean;
  30241. /**
  30242. * Does exist one action manager with at least one pick trigger
  30243. **/
  30244. static get HasPickTriggers(): boolean;
  30245. /**
  30246. * Does exist one action manager that handles actions of a given trigger
  30247. * @param trigger defines the trigger to be tested
  30248. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  30249. **/
  30250. static HasSpecificTrigger(trigger: number): boolean;
  30251. }
  30252. }
  30253. declare module "babylonjs/node" {
  30254. import { Scene } from "babylonjs/scene";
  30255. import { Nullable } from "babylonjs/types";
  30256. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  30257. import { Engine } from "babylonjs/Engines/engine";
  30258. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  30259. import { Observable } from "babylonjs/Misc/observable";
  30260. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  30261. import { IInspectable } from "babylonjs/Misc/iInspectable";
  30262. import { Animatable } from "babylonjs/Animations/animatable";
  30263. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  30264. import { Animation } from "babylonjs/Animations/animation";
  30265. import { AnimationRange } from "babylonjs/Animations/animationRange";
  30266. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  30267. /**
  30268. * Defines how a node can be built from a string name.
  30269. */
  30270. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  30271. /**
  30272. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  30273. */
  30274. export class Node implements IBehaviorAware<Node> {
  30275. /** @hidden */
  30276. static _AnimationRangeFactory: (name: string, from: number, to: number) => import("babylonjs/Animations/animationRange").AnimationRange;
  30277. private static _NodeConstructors;
  30278. /**
  30279. * Add a new node constructor
  30280. * @param type defines the type name of the node to construct
  30281. * @param constructorFunc defines the constructor function
  30282. */
  30283. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  30284. /**
  30285. * Returns a node constructor based on type name
  30286. * @param type defines the type name
  30287. * @param name defines the new node name
  30288. * @param scene defines the hosting scene
  30289. * @param options defines optional options to transmit to constructors
  30290. * @returns the new constructor or null
  30291. */
  30292. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  30293. /**
  30294. * Gets or sets the name of the node
  30295. */
  30296. name: string;
  30297. /**
  30298. * Gets or sets the id of the node
  30299. */
  30300. id: string;
  30301. /**
  30302. * Gets or sets the unique id of the node
  30303. */
  30304. uniqueId: number;
  30305. /**
  30306. * Gets or sets a string used to store user defined state for the node
  30307. */
  30308. state: string;
  30309. /**
  30310. * Gets or sets an object used to store user defined information for the node
  30311. */
  30312. metadata: any;
  30313. /**
  30314. * For internal use only. Please do not use.
  30315. */
  30316. reservedDataStore: any;
  30317. /**
  30318. * List of inspectable custom properties (used by the Inspector)
  30319. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  30320. */
  30321. inspectableCustomProperties: IInspectable[];
  30322. private _doNotSerialize;
  30323. /**
  30324. * Gets or sets a boolean used to define if the node must be serialized
  30325. */
  30326. get doNotSerialize(): boolean;
  30327. set doNotSerialize(value: boolean);
  30328. /** @hidden */
  30329. _isDisposed: boolean;
  30330. /**
  30331. * Gets a list of Animations associated with the node
  30332. */
  30333. animations: import("babylonjs/Animations/animation").Animation[];
  30334. protected _ranges: {
  30335. [name: string]: Nullable<AnimationRange>;
  30336. };
  30337. /**
  30338. * Callback raised when the node is ready to be used
  30339. */
  30340. onReady: Nullable<(node: Node) => void>;
  30341. private _isEnabled;
  30342. private _isParentEnabled;
  30343. private _isReady;
  30344. /** @hidden */
  30345. _currentRenderId: number;
  30346. private _parentUpdateId;
  30347. /** @hidden */
  30348. _childUpdateId: number;
  30349. /** @hidden */
  30350. _waitingParentId: Nullable<string>;
  30351. /** @hidden */
  30352. _scene: Scene;
  30353. /** @hidden */
  30354. _cache: any;
  30355. private _parentNode;
  30356. private _children;
  30357. /** @hidden */
  30358. _worldMatrix: Matrix;
  30359. /** @hidden */
  30360. _worldMatrixDeterminant: number;
  30361. /** @hidden */
  30362. _worldMatrixDeterminantIsDirty: boolean;
  30363. /** @hidden */
  30364. private _sceneRootNodesIndex;
  30365. /**
  30366. * Gets a boolean indicating if the node has been disposed
  30367. * @returns true if the node was disposed
  30368. */
  30369. isDisposed(): boolean;
  30370. /**
  30371. * Gets or sets the parent of the node (without keeping the current position in the scene)
  30372. * @see https://doc.babylonjs.com/how_to/parenting
  30373. */
  30374. set parent(parent: Nullable<Node>);
  30375. get parent(): Nullable<Node>;
  30376. /** @hidden */
  30377. _addToSceneRootNodes(): void;
  30378. /** @hidden */
  30379. _removeFromSceneRootNodes(): void;
  30380. private _animationPropertiesOverride;
  30381. /**
  30382. * Gets or sets the animation properties override
  30383. */
  30384. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  30385. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  30386. /**
  30387. * Gets a string idenfifying the name of the class
  30388. * @returns "Node" string
  30389. */
  30390. getClassName(): string;
  30391. /** @hidden */
  30392. readonly _isNode: boolean;
  30393. /**
  30394. * An event triggered when the mesh is disposed
  30395. */
  30396. onDisposeObservable: Observable<Node>;
  30397. private _onDisposeObserver;
  30398. /**
  30399. * Sets a callback that will be raised when the node will be disposed
  30400. */
  30401. set onDispose(callback: () => void);
  30402. /**
  30403. * Creates a new Node
  30404. * @param name the name and id to be given to this node
  30405. * @param scene the scene this node will be added to
  30406. */
  30407. constructor(name: string, scene?: Nullable<Scene>);
  30408. /**
  30409. * Gets the scene of the node
  30410. * @returns a scene
  30411. */
  30412. getScene(): Scene;
  30413. /**
  30414. * Gets the engine of the node
  30415. * @returns a Engine
  30416. */
  30417. getEngine(): Engine;
  30418. private _behaviors;
  30419. /**
  30420. * Attach a behavior to the node
  30421. * @see http://doc.babylonjs.com/features/behaviour
  30422. * @param behavior defines the behavior to attach
  30423. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  30424. * @returns the current Node
  30425. */
  30426. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  30427. /**
  30428. * Remove an attached behavior
  30429. * @see http://doc.babylonjs.com/features/behaviour
  30430. * @param behavior defines the behavior to attach
  30431. * @returns the current Node
  30432. */
  30433. removeBehavior(behavior: Behavior<Node>): Node;
  30434. /**
  30435. * Gets the list of attached behaviors
  30436. * @see http://doc.babylonjs.com/features/behaviour
  30437. */
  30438. get behaviors(): Behavior<Node>[];
  30439. /**
  30440. * Gets an attached behavior by name
  30441. * @param name defines the name of the behavior to look for
  30442. * @see http://doc.babylonjs.com/features/behaviour
  30443. * @returns null if behavior was not found else the requested behavior
  30444. */
  30445. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  30446. /**
  30447. * Returns the latest update of the World matrix
  30448. * @returns a Matrix
  30449. */
  30450. getWorldMatrix(): Matrix;
  30451. /** @hidden */
  30452. _getWorldMatrixDeterminant(): number;
  30453. /**
  30454. * Returns directly the latest state of the mesh World matrix.
  30455. * A Matrix is returned.
  30456. */
  30457. get worldMatrixFromCache(): Matrix;
  30458. /** @hidden */
  30459. _initCache(): void;
  30460. /** @hidden */
  30461. updateCache(force?: boolean): void;
  30462. /** @hidden */
  30463. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  30464. /** @hidden */
  30465. _updateCache(ignoreParentClass?: boolean): void;
  30466. /** @hidden */
  30467. _isSynchronized(): boolean;
  30468. /** @hidden */
  30469. _markSyncedWithParent(): void;
  30470. /** @hidden */
  30471. isSynchronizedWithParent(): boolean;
  30472. /** @hidden */
  30473. isSynchronized(): boolean;
  30474. /**
  30475. * Is this node ready to be used/rendered
  30476. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  30477. * @return true if the node is ready
  30478. */
  30479. isReady(completeCheck?: boolean): boolean;
  30480. /**
  30481. * Is this node enabled?
  30482. * 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
  30483. * @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
  30484. * @return whether this node (and its parent) is enabled
  30485. */
  30486. isEnabled(checkAncestors?: boolean): boolean;
  30487. /** @hidden */
  30488. protected _syncParentEnabledState(): void;
  30489. /**
  30490. * Set the enabled state of this node
  30491. * @param value defines the new enabled state
  30492. */
  30493. setEnabled(value: boolean): void;
  30494. /**
  30495. * Is this node a descendant of the given node?
  30496. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  30497. * @param ancestor defines the parent node to inspect
  30498. * @returns a boolean indicating if this node is a descendant of the given node
  30499. */
  30500. isDescendantOf(ancestor: Node): boolean;
  30501. /** @hidden */
  30502. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  30503. /**
  30504. * Will return all nodes that have this node as ascendant
  30505. * @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
  30506. * @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
  30507. * @return all children nodes of all types
  30508. */
  30509. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  30510. /**
  30511. * Get all child-meshes of this node
  30512. * @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)
  30513. * @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
  30514. * @returns an array of AbstractMesh
  30515. */
  30516. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  30517. /**
  30518. * Get all direct children of this node
  30519. * @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
  30520. * @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)
  30521. * @returns an array of Node
  30522. */
  30523. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  30524. /** @hidden */
  30525. _setReady(state: boolean): void;
  30526. /**
  30527. * Get an animation by name
  30528. * @param name defines the name of the animation to look for
  30529. * @returns null if not found else the requested animation
  30530. */
  30531. getAnimationByName(name: string): Nullable<Animation>;
  30532. /**
  30533. * Creates an animation range for this node
  30534. * @param name defines the name of the range
  30535. * @param from defines the starting key
  30536. * @param to defines the end key
  30537. */
  30538. createAnimationRange(name: string, from: number, to: number): void;
  30539. /**
  30540. * Delete a specific animation range
  30541. * @param name defines the name of the range to delete
  30542. * @param deleteFrames defines if animation frames from the range must be deleted as well
  30543. */
  30544. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  30545. /**
  30546. * Get an animation range by name
  30547. * @param name defines the name of the animation range to look for
  30548. * @returns null if not found else the requested animation range
  30549. */
  30550. getAnimationRange(name: string): Nullable<AnimationRange>;
  30551. /**
  30552. * Gets the list of all animation ranges defined on this node
  30553. * @returns an array
  30554. */
  30555. getAnimationRanges(): Nullable<AnimationRange>[];
  30556. /**
  30557. * Will start the animation sequence
  30558. * @param name defines the range frames for animation sequence
  30559. * @param loop defines if the animation should loop (false by default)
  30560. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  30561. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  30562. * @returns the object created for this animation. If range does not exist, it will return null
  30563. */
  30564. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  30565. /**
  30566. * Serialize animation ranges into a JSON compatible object
  30567. * @returns serialization object
  30568. */
  30569. serializeAnimationRanges(): any;
  30570. /**
  30571. * Computes the world matrix of the node
  30572. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  30573. * @returns the world matrix
  30574. */
  30575. computeWorldMatrix(force?: boolean): Matrix;
  30576. /**
  30577. * Releases resources associated with this node.
  30578. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  30579. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  30580. */
  30581. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  30582. /**
  30583. * Parse animation range data from a serialization object and store them into a given node
  30584. * @param node defines where to store the animation ranges
  30585. * @param parsedNode defines the serialization object to read data from
  30586. * @param scene defines the hosting scene
  30587. */
  30588. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  30589. /**
  30590. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  30591. * @param includeDescendants Include bounding info from descendants as well (true by default)
  30592. * @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
  30593. * @returns the new bounding vectors
  30594. */
  30595. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  30596. min: Vector3;
  30597. max: Vector3;
  30598. };
  30599. }
  30600. }
  30601. declare module "babylonjs/Animations/animation" {
  30602. import { IEasingFunction, EasingFunction } from "babylonjs/Animations/easing";
  30603. import { Vector3, Quaternion, Vector2, Matrix } from "babylonjs/Maths/math.vector";
  30604. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  30605. import { Nullable } from "babylonjs/types";
  30606. import { Scene } from "babylonjs/scene";
  30607. import { IAnimationKey } from "babylonjs/Animations/animationKey";
  30608. import { AnimationRange } from "babylonjs/Animations/animationRange";
  30609. import { AnimationEvent } from "babylonjs/Animations/animationEvent";
  30610. import { Node } from "babylonjs/node";
  30611. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  30612. import { Size } from "babylonjs/Maths/math.size";
  30613. import { Animatable } from "babylonjs/Animations/animatable";
  30614. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  30615. /**
  30616. * @hidden
  30617. */
  30618. export class _IAnimationState {
  30619. key: number;
  30620. repeatCount: number;
  30621. workValue?: any;
  30622. loopMode?: number;
  30623. offsetValue?: any;
  30624. highLimitValue?: any;
  30625. }
  30626. /**
  30627. * Class used to store any kind of animation
  30628. */
  30629. export class Animation {
  30630. /**Name of the animation */
  30631. name: string;
  30632. /**Property to animate */
  30633. targetProperty: string;
  30634. /**The frames per second of the animation */
  30635. framePerSecond: number;
  30636. /**The data type of the animation */
  30637. dataType: number;
  30638. /**The loop mode of the animation */
  30639. loopMode?: number | undefined;
  30640. /**Specifies if blending should be enabled */
  30641. enableBlending?: boolean | undefined;
  30642. /**
  30643. * Use matrix interpolation instead of using direct key value when animating matrices
  30644. */
  30645. static AllowMatricesInterpolation: boolean;
  30646. /**
  30647. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  30648. */
  30649. static AllowMatrixDecomposeForInterpolation: boolean;
  30650. /**
  30651. * Stores the key frames of the animation
  30652. */
  30653. private _keys;
  30654. /**
  30655. * Stores the easing function of the animation
  30656. */
  30657. private _easingFunction;
  30658. /**
  30659. * @hidden Internal use only
  30660. */
  30661. _runtimeAnimations: import("babylonjs/Animations/runtimeAnimation").RuntimeAnimation[];
  30662. /**
  30663. * The set of event that will be linked to this animation
  30664. */
  30665. private _events;
  30666. /**
  30667. * Stores an array of target property paths
  30668. */
  30669. targetPropertyPath: string[];
  30670. /**
  30671. * Stores the blending speed of the animation
  30672. */
  30673. blendingSpeed: number;
  30674. /**
  30675. * Stores the animation ranges for the animation
  30676. */
  30677. private _ranges;
  30678. /**
  30679. * @hidden Internal use
  30680. */
  30681. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  30682. /**
  30683. * Sets up an animation
  30684. * @param property The property to animate
  30685. * @param animationType The animation type to apply
  30686. * @param framePerSecond The frames per second of the animation
  30687. * @param easingFunction The easing function used in the animation
  30688. * @returns The created animation
  30689. */
  30690. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  30691. /**
  30692. * Create and start an animation on a node
  30693. * @param name defines the name of the global animation that will be run on all nodes
  30694. * @param node defines the root node where the animation will take place
  30695. * @param targetProperty defines property to animate
  30696. * @param framePerSecond defines the number of frame per second yo use
  30697. * @param totalFrame defines the number of frames in total
  30698. * @param from defines the initial value
  30699. * @param to defines the final value
  30700. * @param loopMode defines which loop mode you want to use (off by default)
  30701. * @param easingFunction defines the easing function to use (linear by default)
  30702. * @param onAnimationEnd defines the callback to call when animation end
  30703. * @returns the animatable created for this animation
  30704. */
  30705. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  30706. /**
  30707. * Create and start an animation on a node and its descendants
  30708. * @param name defines the name of the global animation that will be run on all nodes
  30709. * @param node defines the root node where the animation will take place
  30710. * @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
  30711. * @param targetProperty defines property to animate
  30712. * @param framePerSecond defines the number of frame per second to use
  30713. * @param totalFrame defines the number of frames in total
  30714. * @param from defines the initial value
  30715. * @param to defines the final value
  30716. * @param loopMode defines which loop mode you want to use (off by default)
  30717. * @param easingFunction defines the easing function to use (linear by default)
  30718. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  30719. * @returns the list of animatables created for all nodes
  30720. * @example https://www.babylonjs-playground.com/#MH0VLI
  30721. */
  30722. 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[]>;
  30723. /**
  30724. * Creates a new animation, merges it with the existing animations and starts it
  30725. * @param name Name of the animation
  30726. * @param node Node which contains the scene that begins the animations
  30727. * @param targetProperty Specifies which property to animate
  30728. * @param framePerSecond The frames per second of the animation
  30729. * @param totalFrame The total number of frames
  30730. * @param from The frame at the beginning of the animation
  30731. * @param to The frame at the end of the animation
  30732. * @param loopMode Specifies the loop mode of the animation
  30733. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  30734. * @param onAnimationEnd Callback to run once the animation is complete
  30735. * @returns Nullable animation
  30736. */
  30737. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  30738. /**
  30739. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  30740. * @param sourceAnimation defines the Animation containing keyframes to convert
  30741. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  30742. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  30743. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  30744. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  30745. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  30746. */
  30747. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  30748. /**
  30749. * Transition property of an host to the target Value
  30750. * @param property The property to transition
  30751. * @param targetValue The target Value of the property
  30752. * @param host The object where the property to animate belongs
  30753. * @param scene Scene used to run the animation
  30754. * @param frameRate Framerate (in frame/s) to use
  30755. * @param transition The transition type we want to use
  30756. * @param duration The duration of the animation, in milliseconds
  30757. * @param onAnimationEnd Callback trigger at the end of the animation
  30758. * @returns Nullable animation
  30759. */
  30760. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  30761. /**
  30762. * Return the array of runtime animations currently using this animation
  30763. */
  30764. get runtimeAnimations(): RuntimeAnimation[];
  30765. /**
  30766. * Specifies if any of the runtime animations are currently running
  30767. */
  30768. get hasRunningRuntimeAnimations(): boolean;
  30769. /**
  30770. * Initializes the animation
  30771. * @param name Name of the animation
  30772. * @param targetProperty Property to animate
  30773. * @param framePerSecond The frames per second of the animation
  30774. * @param dataType The data type of the animation
  30775. * @param loopMode The loop mode of the animation
  30776. * @param enableBlending Specifies if blending should be enabled
  30777. */
  30778. constructor(
  30779. /**Name of the animation */
  30780. name: string,
  30781. /**Property to animate */
  30782. targetProperty: string,
  30783. /**The frames per second of the animation */
  30784. framePerSecond: number,
  30785. /**The data type of the animation */
  30786. dataType: number,
  30787. /**The loop mode of the animation */
  30788. loopMode?: number | undefined,
  30789. /**Specifies if blending should be enabled */
  30790. enableBlending?: boolean | undefined);
  30791. /**
  30792. * Converts the animation to a string
  30793. * @param fullDetails support for multiple levels of logging within scene loading
  30794. * @returns String form of the animation
  30795. */
  30796. toString(fullDetails?: boolean): string;
  30797. /**
  30798. * Add an event to this animation
  30799. * @param event Event to add
  30800. */
  30801. addEvent(event: AnimationEvent): void;
  30802. /**
  30803. * Remove all events found at the given frame
  30804. * @param frame The frame to remove events from
  30805. */
  30806. removeEvents(frame: number): void;
  30807. /**
  30808. * Retrieves all the events from the animation
  30809. * @returns Events from the animation
  30810. */
  30811. getEvents(): AnimationEvent[];
  30812. /**
  30813. * Creates an animation range
  30814. * @param name Name of the animation range
  30815. * @param from Starting frame of the animation range
  30816. * @param to Ending frame of the animation
  30817. */
  30818. createRange(name: string, from: number, to: number): void;
  30819. /**
  30820. * Deletes an animation range by name
  30821. * @param name Name of the animation range to delete
  30822. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  30823. */
  30824. deleteRange(name: string, deleteFrames?: boolean): void;
  30825. /**
  30826. * Gets the animation range by name, or null if not defined
  30827. * @param name Name of the animation range
  30828. * @returns Nullable animation range
  30829. */
  30830. getRange(name: string): Nullable<AnimationRange>;
  30831. /**
  30832. * Gets the key frames from the animation
  30833. * @returns The key frames of the animation
  30834. */
  30835. getKeys(): Array<IAnimationKey>;
  30836. /**
  30837. * Gets the highest frame rate of the animation
  30838. * @returns Highest frame rate of the animation
  30839. */
  30840. getHighestFrame(): number;
  30841. /**
  30842. * Gets the easing function of the animation
  30843. * @returns Easing function of the animation
  30844. */
  30845. getEasingFunction(): IEasingFunction;
  30846. /**
  30847. * Sets the easing function of the animation
  30848. * @param easingFunction A custom mathematical formula for animation
  30849. */
  30850. setEasingFunction(easingFunction: EasingFunction): void;
  30851. /**
  30852. * Interpolates a scalar linearly
  30853. * @param startValue Start value of the animation curve
  30854. * @param endValue End value of the animation curve
  30855. * @param gradient Scalar amount to interpolate
  30856. * @returns Interpolated scalar value
  30857. */
  30858. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  30859. /**
  30860. * Interpolates a scalar cubically
  30861. * @param startValue Start value of the animation curve
  30862. * @param outTangent End tangent of the animation
  30863. * @param endValue End value of the animation curve
  30864. * @param inTangent Start tangent of the animation curve
  30865. * @param gradient Scalar amount to interpolate
  30866. * @returns Interpolated scalar value
  30867. */
  30868. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  30869. /**
  30870. * Interpolates a quaternion using a spherical linear interpolation
  30871. * @param startValue Start value of the animation curve
  30872. * @param endValue End value of the animation curve
  30873. * @param gradient Scalar amount to interpolate
  30874. * @returns Interpolated quaternion value
  30875. */
  30876. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  30877. /**
  30878. * Interpolates a quaternion cubically
  30879. * @param startValue Start value of the animation curve
  30880. * @param outTangent End tangent of the animation curve
  30881. * @param endValue End value of the animation curve
  30882. * @param inTangent Start tangent of the animation curve
  30883. * @param gradient Scalar amount to interpolate
  30884. * @returns Interpolated quaternion value
  30885. */
  30886. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  30887. /**
  30888. * Interpolates a Vector3 linearl
  30889. * @param startValue Start value of the animation curve
  30890. * @param endValue End value of the animation curve
  30891. * @param gradient Scalar amount to interpolate
  30892. * @returns Interpolated scalar value
  30893. */
  30894. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  30895. /**
  30896. * Interpolates a Vector3 cubically
  30897. * @param startValue Start value of the animation curve
  30898. * @param outTangent End tangent of the animation
  30899. * @param endValue End value of the animation curve
  30900. * @param inTangent Start tangent of the animation curve
  30901. * @param gradient Scalar amount to interpolate
  30902. * @returns InterpolatedVector3 value
  30903. */
  30904. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  30905. /**
  30906. * Interpolates a Vector2 linearly
  30907. * @param startValue Start value of the animation curve
  30908. * @param endValue End value of the animation curve
  30909. * @param gradient Scalar amount to interpolate
  30910. * @returns Interpolated Vector2 value
  30911. */
  30912. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  30913. /**
  30914. * Interpolates a Vector2 cubically
  30915. * @param startValue Start value of the animation curve
  30916. * @param outTangent End tangent of the animation
  30917. * @param endValue End value of the animation curve
  30918. * @param inTangent Start tangent of the animation curve
  30919. * @param gradient Scalar amount to interpolate
  30920. * @returns Interpolated Vector2 value
  30921. */
  30922. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  30923. /**
  30924. * Interpolates a size linearly
  30925. * @param startValue Start value of the animation curve
  30926. * @param endValue End value of the animation curve
  30927. * @param gradient Scalar amount to interpolate
  30928. * @returns Interpolated Size value
  30929. */
  30930. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  30931. /**
  30932. * Interpolates a Color3 linearly
  30933. * @param startValue Start value of the animation curve
  30934. * @param endValue End value of the animation curve
  30935. * @param gradient Scalar amount to interpolate
  30936. * @returns Interpolated Color3 value
  30937. */
  30938. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  30939. /**
  30940. * Interpolates a Color4 linearly
  30941. * @param startValue Start value of the animation curve
  30942. * @param endValue End value of the animation curve
  30943. * @param gradient Scalar amount to interpolate
  30944. * @returns Interpolated Color3 value
  30945. */
  30946. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  30947. /**
  30948. * @hidden Internal use only
  30949. */
  30950. _getKeyValue(value: any): any;
  30951. /**
  30952. * @hidden Internal use only
  30953. */
  30954. _interpolate(currentFrame: number, state: _IAnimationState): any;
  30955. /**
  30956. * Defines the function to use to interpolate matrices
  30957. * @param startValue defines the start matrix
  30958. * @param endValue defines the end matrix
  30959. * @param gradient defines the gradient between both matrices
  30960. * @param result defines an optional target matrix where to store the interpolation
  30961. * @returns the interpolated matrix
  30962. */
  30963. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  30964. /**
  30965. * Makes a copy of the animation
  30966. * @returns Cloned animation
  30967. */
  30968. clone(): Animation;
  30969. /**
  30970. * Sets the key frames of the animation
  30971. * @param values The animation key frames to set
  30972. */
  30973. setKeys(values: Array<IAnimationKey>): void;
  30974. /**
  30975. * Serializes the animation to an object
  30976. * @returns Serialized object
  30977. */
  30978. serialize(): any;
  30979. /**
  30980. * Float animation type
  30981. */
  30982. static readonly ANIMATIONTYPE_FLOAT: number;
  30983. /**
  30984. * Vector3 animation type
  30985. */
  30986. static readonly ANIMATIONTYPE_VECTOR3: number;
  30987. /**
  30988. * Quaternion animation type
  30989. */
  30990. static readonly ANIMATIONTYPE_QUATERNION: number;
  30991. /**
  30992. * Matrix animation type
  30993. */
  30994. static readonly ANIMATIONTYPE_MATRIX: number;
  30995. /**
  30996. * Color3 animation type
  30997. */
  30998. static readonly ANIMATIONTYPE_COLOR3: number;
  30999. /**
  31000. * Color3 animation type
  31001. */
  31002. static readonly ANIMATIONTYPE_COLOR4: number;
  31003. /**
  31004. * Vector2 animation type
  31005. */
  31006. static readonly ANIMATIONTYPE_VECTOR2: number;
  31007. /**
  31008. * Size animation type
  31009. */
  31010. static readonly ANIMATIONTYPE_SIZE: number;
  31011. /**
  31012. * Relative Loop Mode
  31013. */
  31014. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  31015. /**
  31016. * Cycle Loop Mode
  31017. */
  31018. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  31019. /**
  31020. * Constant Loop Mode
  31021. */
  31022. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  31023. /** @hidden */
  31024. static _UniversalLerp(left: any, right: any, amount: number): any;
  31025. /**
  31026. * Parses an animation object and creates an animation
  31027. * @param parsedAnimation Parsed animation object
  31028. * @returns Animation object
  31029. */
  31030. static Parse(parsedAnimation: any): Animation;
  31031. /**
  31032. * Appends the serialized animations from the source animations
  31033. * @param source Source containing the animations
  31034. * @param destination Target to store the animations
  31035. */
  31036. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  31037. }
  31038. }
  31039. declare module "babylonjs/Animations/animatable.interface" {
  31040. import { Nullable } from "babylonjs/types";
  31041. import { Animation } from "babylonjs/Animations/animation";
  31042. /**
  31043. * Interface containing an array of animations
  31044. */
  31045. export interface IAnimatable {
  31046. /**
  31047. * Array of animations
  31048. */
  31049. animations: Nullable<Array<Animation>>;
  31050. }
  31051. }
  31052. declare module "babylonjs/Misc/decorators" {
  31053. import { Nullable } from "babylonjs/types";
  31054. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  31055. import { Scene } from "babylonjs/scene";
  31056. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  31057. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31058. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31059. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31060. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31061. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31062. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31063. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31064. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31065. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31066. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31067. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31068. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31069. /**
  31070. * Decorator used to define property that can be serialized as reference to a camera
  31071. * @param sourceName defines the name of the property to decorate
  31072. */
  31073. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31074. /**
  31075. * Class used to help serialization objects
  31076. */
  31077. export class SerializationHelper {
  31078. /** @hidden */
  31079. static _ImageProcessingConfigurationParser: (sourceProperty: any) => import("babylonjs/Materials/imageProcessingConfiguration").ImageProcessingConfiguration;
  31080. /** @hidden */
  31081. static _FresnelParametersParser: (sourceProperty: any) => import("babylonjs/Materials/fresnelParameters").FresnelParameters;
  31082. /** @hidden */
  31083. static _ColorCurvesParser: (sourceProperty: any) => import("babylonjs/Materials/colorCurves").ColorCurves;
  31084. /** @hidden */
  31085. static _TextureParser: (sourceProperty: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => Nullable<import("babylonjs/Materials/Textures/baseTexture").BaseTexture>;
  31086. /**
  31087. * Appends the serialized animations from the source animations
  31088. * @param source Source containing the animations
  31089. * @param destination Target to store the animations
  31090. */
  31091. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  31092. /**
  31093. * Static function used to serialized a specific entity
  31094. * @param entity defines the entity to serialize
  31095. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  31096. * @returns a JSON compatible object representing the serialization of the entity
  31097. */
  31098. static Serialize<T>(entity: T, serializationObject?: any): any;
  31099. /**
  31100. * Creates a new entity from a serialization data object
  31101. * @param creationFunction defines a function used to instanciated the new entity
  31102. * @param source defines the source serialization data
  31103. * @param scene defines the hosting scene
  31104. * @param rootUrl defines the root url for resources
  31105. * @returns a new entity
  31106. */
  31107. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  31108. /**
  31109. * Clones an object
  31110. * @param creationFunction defines the function used to instanciate the new object
  31111. * @param source defines the source object
  31112. * @returns the cloned object
  31113. */
  31114. static Clone<T>(creationFunction: () => T, source: T): T;
  31115. /**
  31116. * Instanciates a new object based on a source one (some data will be shared between both object)
  31117. * @param creationFunction defines the function used to instanciate the new object
  31118. * @param source defines the source object
  31119. * @returns the new object
  31120. */
  31121. static Instanciate<T>(creationFunction: () => T, source: T): T;
  31122. }
  31123. }
  31124. declare module "babylonjs/Materials/Textures/baseTexture" {
  31125. import { Observable } from "babylonjs/Misc/observable";
  31126. import { Nullable } from "babylonjs/types";
  31127. import { Scene } from "babylonjs/scene";
  31128. import { Matrix } from "babylonjs/Maths/math.vector";
  31129. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  31130. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  31131. import { ISize } from "babylonjs/Maths/math.size";
  31132. import "babylonjs/Misc/fileTools";
  31133. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  31134. /**
  31135. * Base class of all the textures in babylon.
  31136. * It groups all the common properties the materials, post process, lights... might need
  31137. * in order to make a correct use of the texture.
  31138. */
  31139. export class BaseTexture implements IAnimatable {
  31140. /**
  31141. * Default anisotropic filtering level for the application.
  31142. * It is set to 4 as a good tradeoff between perf and quality.
  31143. */
  31144. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  31145. /**
  31146. * Gets or sets the unique id of the texture
  31147. */
  31148. uniqueId: number;
  31149. /**
  31150. * Define the name of the texture.
  31151. */
  31152. name: string;
  31153. /**
  31154. * Gets or sets an object used to store user defined information.
  31155. */
  31156. metadata: any;
  31157. /**
  31158. * For internal use only. Please do not use.
  31159. */
  31160. reservedDataStore: any;
  31161. private _hasAlpha;
  31162. /**
  31163. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  31164. */
  31165. set hasAlpha(value: boolean);
  31166. get hasAlpha(): boolean;
  31167. /**
  31168. * Defines if the alpha value should be determined via the rgb values.
  31169. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  31170. */
  31171. getAlphaFromRGB: boolean;
  31172. /**
  31173. * Intensity or strength of the texture.
  31174. * It is commonly used by materials to fine tune the intensity of the texture
  31175. */
  31176. level: number;
  31177. /**
  31178. * Define the UV chanel to use starting from 0 and defaulting to 0.
  31179. * This is part of the texture as textures usually maps to one uv set.
  31180. */
  31181. coordinatesIndex: number;
  31182. private _coordinatesMode;
  31183. /**
  31184. * How a texture is mapped.
  31185. *
  31186. * | Value | Type | Description |
  31187. * | ----- | ----------------------------------- | ----------- |
  31188. * | 0 | EXPLICIT_MODE | |
  31189. * | 1 | SPHERICAL_MODE | |
  31190. * | 2 | PLANAR_MODE | |
  31191. * | 3 | CUBIC_MODE | |
  31192. * | 4 | PROJECTION_MODE | |
  31193. * | 5 | SKYBOX_MODE | |
  31194. * | 6 | INVCUBIC_MODE | |
  31195. * | 7 | EQUIRECTANGULAR_MODE | |
  31196. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  31197. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  31198. */
  31199. set coordinatesMode(value: number);
  31200. get coordinatesMode(): number;
  31201. /**
  31202. * | Value | Type | Description |
  31203. * | ----- | ------------------ | ----------- |
  31204. * | 0 | CLAMP_ADDRESSMODE | |
  31205. * | 1 | WRAP_ADDRESSMODE | |
  31206. * | 2 | MIRROR_ADDRESSMODE | |
  31207. */
  31208. wrapU: number;
  31209. /**
  31210. * | Value | Type | Description |
  31211. * | ----- | ------------------ | ----------- |
  31212. * | 0 | CLAMP_ADDRESSMODE | |
  31213. * | 1 | WRAP_ADDRESSMODE | |
  31214. * | 2 | MIRROR_ADDRESSMODE | |
  31215. */
  31216. wrapV: number;
  31217. /**
  31218. * | Value | Type | Description |
  31219. * | ----- | ------------------ | ----------- |
  31220. * | 0 | CLAMP_ADDRESSMODE | |
  31221. * | 1 | WRAP_ADDRESSMODE | |
  31222. * | 2 | MIRROR_ADDRESSMODE | |
  31223. */
  31224. wrapR: number;
  31225. /**
  31226. * With compliant hardware and browser (supporting anisotropic filtering)
  31227. * this defines the level of anisotropic filtering in the texture.
  31228. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  31229. */
  31230. anisotropicFilteringLevel: number;
  31231. /**
  31232. * Define if the texture is a cube texture or if false a 2d texture.
  31233. */
  31234. get isCube(): boolean;
  31235. set isCube(value: boolean);
  31236. /**
  31237. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  31238. */
  31239. get is3D(): boolean;
  31240. set is3D(value: boolean);
  31241. /**
  31242. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  31243. */
  31244. get is2DArray(): boolean;
  31245. set is2DArray(value: boolean);
  31246. /**
  31247. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  31248. * HDR texture are usually stored in linear space.
  31249. * This only impacts the PBR and Background materials
  31250. */
  31251. gammaSpace: boolean;
  31252. /**
  31253. * Gets or sets whether or not the texture contains RGBD data.
  31254. */
  31255. get isRGBD(): boolean;
  31256. set isRGBD(value: boolean);
  31257. /**
  31258. * Is Z inverted in the texture (useful in a cube texture).
  31259. */
  31260. invertZ: boolean;
  31261. /**
  31262. * Are mip maps generated for this texture or not.
  31263. */
  31264. get noMipmap(): boolean;
  31265. /**
  31266. * @hidden
  31267. */
  31268. lodLevelInAlpha: boolean;
  31269. /**
  31270. * With prefiltered texture, defined the offset used during the prefiltering steps.
  31271. */
  31272. get lodGenerationOffset(): number;
  31273. set lodGenerationOffset(value: number);
  31274. /**
  31275. * With prefiltered texture, defined the scale used during the prefiltering steps.
  31276. */
  31277. get lodGenerationScale(): number;
  31278. set lodGenerationScale(value: number);
  31279. /**
  31280. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  31281. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  31282. * average roughness values.
  31283. */
  31284. get linearSpecularLOD(): boolean;
  31285. set linearSpecularLOD(value: boolean);
  31286. /**
  31287. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  31288. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  31289. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  31290. */
  31291. get irradianceTexture(): Nullable<BaseTexture>;
  31292. set irradianceTexture(value: Nullable<BaseTexture>);
  31293. /**
  31294. * Define if the texture is a render target.
  31295. */
  31296. isRenderTarget: boolean;
  31297. /**
  31298. * Define the unique id of the texture in the scene.
  31299. */
  31300. get uid(): string;
  31301. /**
  31302. * Return a string representation of the texture.
  31303. * @returns the texture as a string
  31304. */
  31305. toString(): string;
  31306. /**
  31307. * Get the class name of the texture.
  31308. * @returns "BaseTexture"
  31309. */
  31310. getClassName(): string;
  31311. /**
  31312. * Define the list of animation attached to the texture.
  31313. */
  31314. animations: import("babylonjs/Animations/animation").Animation[];
  31315. /**
  31316. * An event triggered when the texture is disposed.
  31317. */
  31318. onDisposeObservable: Observable<BaseTexture>;
  31319. private _onDisposeObserver;
  31320. /**
  31321. * Callback triggered when the texture has been disposed.
  31322. * Kept for back compatibility, you can use the onDisposeObservable instead.
  31323. */
  31324. set onDispose(callback: () => void);
  31325. /**
  31326. * Define the current state of the loading sequence when in delayed load mode.
  31327. */
  31328. delayLoadState: number;
  31329. private _scene;
  31330. private _engine;
  31331. /** @hidden */
  31332. _texture: Nullable<InternalTexture>;
  31333. private _uid;
  31334. /**
  31335. * Define if the texture is preventinga material to render or not.
  31336. * If not and the texture is not ready, the engine will use a default black texture instead.
  31337. */
  31338. get isBlocking(): boolean;
  31339. /**
  31340. * Instantiates a new BaseTexture.
  31341. * Base class of all the textures in babylon.
  31342. * It groups all the common properties the materials, post process, lights... might need
  31343. * in order to make a correct use of the texture.
  31344. * @param sceneOrEngine Define the scene or engine the texture blongs to
  31345. */
  31346. constructor(sceneOrEngine: Nullable<Scene | ThinEngine>);
  31347. /**
  31348. * Get the scene the texture belongs to.
  31349. * @returns the scene or null if undefined
  31350. */
  31351. getScene(): Nullable<Scene>;
  31352. /** @hidden */
  31353. protected _getEngine(): Nullable<ThinEngine>;
  31354. /**
  31355. * Get the texture transform matrix used to offset tile the texture for istance.
  31356. * @returns the transformation matrix
  31357. */
  31358. getTextureMatrix(): Matrix;
  31359. /**
  31360. * Get the texture reflection matrix used to rotate/transform the reflection.
  31361. * @returns the reflection matrix
  31362. */
  31363. getReflectionTextureMatrix(): Matrix;
  31364. /**
  31365. * Get the underlying lower level texture from Babylon.
  31366. * @returns the insternal texture
  31367. */
  31368. getInternalTexture(): Nullable<InternalTexture>;
  31369. /**
  31370. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  31371. * @returns true if ready or not blocking
  31372. */
  31373. isReadyOrNotBlocking(): boolean;
  31374. /**
  31375. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  31376. * @returns true if fully ready
  31377. */
  31378. isReady(): boolean;
  31379. private _cachedSize;
  31380. /**
  31381. * Get the size of the texture.
  31382. * @returns the texture size.
  31383. */
  31384. getSize(): ISize;
  31385. /**
  31386. * Get the base size of the texture.
  31387. * It can be different from the size if the texture has been resized for POT for instance
  31388. * @returns the base size
  31389. */
  31390. getBaseSize(): ISize;
  31391. /**
  31392. * Update the sampling mode of the texture.
  31393. * Default is Trilinear mode.
  31394. *
  31395. * | Value | Type | Description |
  31396. * | ----- | ------------------ | ----------- |
  31397. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  31398. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  31399. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  31400. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  31401. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  31402. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  31403. * | 7 | NEAREST_LINEAR | |
  31404. * | 8 | NEAREST_NEAREST | |
  31405. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  31406. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  31407. * | 11 | LINEAR_LINEAR | |
  31408. * | 12 | LINEAR_NEAREST | |
  31409. *
  31410. * > _mag_: magnification filter (close to the viewer)
  31411. * > _min_: minification filter (far from the viewer)
  31412. * > _mip_: filter used between mip map levels
  31413. *@param samplingMode Define the new sampling mode of the texture
  31414. */
  31415. updateSamplingMode(samplingMode: number): void;
  31416. /**
  31417. * Scales the texture if is `canRescale()`
  31418. * @param ratio the resize factor we want to use to rescale
  31419. */
  31420. scale(ratio: number): void;
  31421. /**
  31422. * Get if the texture can rescale.
  31423. */
  31424. get canRescale(): boolean;
  31425. /** @hidden */
  31426. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  31427. /** @hidden */
  31428. _rebuild(): void;
  31429. /**
  31430. * Triggers the load sequence in delayed load mode.
  31431. */
  31432. delayLoad(): void;
  31433. /**
  31434. * Clones the texture.
  31435. * @returns the cloned texture
  31436. */
  31437. clone(): Nullable<BaseTexture>;
  31438. /**
  31439. * Get the texture underlying type (INT, FLOAT...)
  31440. */
  31441. get textureType(): number;
  31442. /**
  31443. * Get the texture underlying format (RGB, RGBA...)
  31444. */
  31445. get textureFormat(): number;
  31446. /**
  31447. * Indicates that textures need to be re-calculated for all materials
  31448. */
  31449. protected _markAllSubMeshesAsTexturesDirty(): void;
  31450. /**
  31451. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  31452. * This will returns an RGBA array buffer containing either in values (0-255) or
  31453. * float values (0-1) depending of the underlying buffer type.
  31454. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  31455. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  31456. * @param buffer defines a user defined buffer to fill with data (can be null)
  31457. * @returns The Array buffer containing the pixels data.
  31458. */
  31459. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  31460. /**
  31461. * Release and destroy the underlying lower level texture aka internalTexture.
  31462. */
  31463. releaseInternalTexture(): void;
  31464. /** @hidden */
  31465. get _lodTextureHigh(): Nullable<BaseTexture>;
  31466. /** @hidden */
  31467. get _lodTextureMid(): Nullable<BaseTexture>;
  31468. /** @hidden */
  31469. get _lodTextureLow(): Nullable<BaseTexture>;
  31470. /**
  31471. * Dispose the texture and release its associated resources.
  31472. */
  31473. dispose(): void;
  31474. /**
  31475. * Serialize the texture into a JSON representation that can be parsed later on.
  31476. * @returns the JSON representation of the texture
  31477. */
  31478. serialize(): any;
  31479. /**
  31480. * Helper function to be called back once a list of texture contains only ready textures.
  31481. * @param textures Define the list of textures to wait for
  31482. * @param callback Define the callback triggered once the entire list will be ready
  31483. */
  31484. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  31485. private static _isScene;
  31486. }
  31487. }
  31488. declare module "babylonjs/Materials/effect" {
  31489. import { Observable } from "babylonjs/Misc/observable";
  31490. import { Nullable } from "babylonjs/types";
  31491. import { IDisposable } from "babylonjs/scene";
  31492. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  31493. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  31494. import { IMatrixLike, IVector2Like, IVector3Like, IVector4Like, IColor3Like, IColor4Like } from "babylonjs/Maths/math.like";
  31495. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  31496. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  31497. import { Engine } from "babylonjs/Engines/engine";
  31498. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  31499. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  31500. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  31501. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  31502. /**
  31503. * Options to be used when creating an effect.
  31504. */
  31505. export interface IEffectCreationOptions {
  31506. /**
  31507. * Atrributes that will be used in the shader.
  31508. */
  31509. attributes: string[];
  31510. /**
  31511. * Uniform varible names that will be set in the shader.
  31512. */
  31513. uniformsNames: string[];
  31514. /**
  31515. * Uniform buffer variable names that will be set in the shader.
  31516. */
  31517. uniformBuffersNames: string[];
  31518. /**
  31519. * Sampler texture variable names that will be set in the shader.
  31520. */
  31521. samplers: string[];
  31522. /**
  31523. * Define statements that will be set in the shader.
  31524. */
  31525. defines: any;
  31526. /**
  31527. * Possible fallbacks for this effect to improve performance when needed.
  31528. */
  31529. fallbacks: Nullable<IEffectFallbacks>;
  31530. /**
  31531. * Callback that will be called when the shader is compiled.
  31532. */
  31533. onCompiled: Nullable<(effect: Effect) => void>;
  31534. /**
  31535. * Callback that will be called if an error occurs during shader compilation.
  31536. */
  31537. onError: Nullable<(effect: Effect, errors: string) => void>;
  31538. /**
  31539. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  31540. */
  31541. indexParameters?: any;
  31542. /**
  31543. * Max number of lights that can be used in the shader.
  31544. */
  31545. maxSimultaneousLights?: number;
  31546. /**
  31547. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  31548. */
  31549. transformFeedbackVaryings?: Nullable<string[]>;
  31550. }
  31551. /**
  31552. * Effect containing vertex and fragment shader that can be executed on an object.
  31553. */
  31554. export class Effect implements IDisposable {
  31555. /**
  31556. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  31557. */
  31558. static ShadersRepository: string;
  31559. /**
  31560. * Enable logging of the shader code when a compilation error occurs
  31561. */
  31562. static LogShaderCodeOnCompilationError: boolean;
  31563. /**
  31564. * Name of the effect.
  31565. */
  31566. name: any;
  31567. /**
  31568. * String container all the define statements that should be set on the shader.
  31569. */
  31570. defines: string;
  31571. /**
  31572. * Callback that will be called when the shader is compiled.
  31573. */
  31574. onCompiled: Nullable<(effect: Effect) => void>;
  31575. /**
  31576. * Callback that will be called if an error occurs during shader compilation.
  31577. */
  31578. onError: Nullable<(effect: Effect, errors: string) => void>;
  31579. /**
  31580. * Callback that will be called when effect is bound.
  31581. */
  31582. onBind: Nullable<(effect: Effect) => void>;
  31583. /**
  31584. * Unique ID of the effect.
  31585. */
  31586. uniqueId: number;
  31587. /**
  31588. * Observable that will be called when the shader is compiled.
  31589. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  31590. */
  31591. onCompileObservable: Observable<Effect>;
  31592. /**
  31593. * Observable that will be called if an error occurs during shader compilation.
  31594. */
  31595. onErrorObservable: Observable<Effect>;
  31596. /** @hidden */
  31597. _onBindObservable: Nullable<Observable<Effect>>;
  31598. /**
  31599. * @hidden
  31600. * Specifies if the effect was previously ready
  31601. */
  31602. _wasPreviouslyReady: boolean;
  31603. /**
  31604. * Observable that will be called when effect is bound.
  31605. */
  31606. get onBindObservable(): Observable<Effect>;
  31607. /** @hidden */
  31608. _bonesComputationForcedToCPU: boolean;
  31609. private static _uniqueIdSeed;
  31610. private _engine;
  31611. private _uniformBuffersNames;
  31612. private _uniformBuffersNamesList;
  31613. private _uniformsNames;
  31614. private _samplerList;
  31615. private _samplers;
  31616. private _isReady;
  31617. private _compilationError;
  31618. private _allFallbacksProcessed;
  31619. private _attributesNames;
  31620. private _attributes;
  31621. private _attributeLocationByName;
  31622. private _uniforms;
  31623. /**
  31624. * Key for the effect.
  31625. * @hidden
  31626. */
  31627. _key: string;
  31628. private _indexParameters;
  31629. private _fallbacks;
  31630. private _vertexSourceCode;
  31631. private _fragmentSourceCode;
  31632. private _vertexSourceCodeOverride;
  31633. private _fragmentSourceCodeOverride;
  31634. private _transformFeedbackVaryings;
  31635. /**
  31636. * Compiled shader to webGL program.
  31637. * @hidden
  31638. */
  31639. _pipelineContext: Nullable<IPipelineContext>;
  31640. private _valueCache;
  31641. private static _baseCache;
  31642. /**
  31643. * Instantiates an effect.
  31644. * An effect can be used to create/manage/execute vertex and fragment shaders.
  31645. * @param baseName Name of the effect.
  31646. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  31647. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  31648. * @param samplers List of sampler variables that will be passed to the shader.
  31649. * @param engine Engine to be used to render the effect
  31650. * @param defines Define statements to be added to the shader.
  31651. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  31652. * @param onCompiled Callback that will be called when the shader is compiled.
  31653. * @param onError Callback that will be called if an error occurs during shader compilation.
  31654. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  31655. */
  31656. 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);
  31657. private _useFinalCode;
  31658. /**
  31659. * Unique key for this effect
  31660. */
  31661. get key(): string;
  31662. /**
  31663. * If the effect has been compiled and prepared.
  31664. * @returns if the effect is compiled and prepared.
  31665. */
  31666. isReady(): boolean;
  31667. private _isReadyInternal;
  31668. /**
  31669. * The engine the effect was initialized with.
  31670. * @returns the engine.
  31671. */
  31672. getEngine(): Engine;
  31673. /**
  31674. * The pipeline context for this effect
  31675. * @returns the associated pipeline context
  31676. */
  31677. getPipelineContext(): Nullable<IPipelineContext>;
  31678. /**
  31679. * The set of names of attribute variables for the shader.
  31680. * @returns An array of attribute names.
  31681. */
  31682. getAttributesNames(): string[];
  31683. /**
  31684. * Returns the attribute at the given index.
  31685. * @param index The index of the attribute.
  31686. * @returns The location of the attribute.
  31687. */
  31688. getAttributeLocation(index: number): number;
  31689. /**
  31690. * Returns the attribute based on the name of the variable.
  31691. * @param name of the attribute to look up.
  31692. * @returns the attribute location.
  31693. */
  31694. getAttributeLocationByName(name: string): number;
  31695. /**
  31696. * The number of attributes.
  31697. * @returns the numnber of attributes.
  31698. */
  31699. getAttributesCount(): number;
  31700. /**
  31701. * Gets the index of a uniform variable.
  31702. * @param uniformName of the uniform to look up.
  31703. * @returns the index.
  31704. */
  31705. getUniformIndex(uniformName: string): number;
  31706. /**
  31707. * Returns the attribute based on the name of the variable.
  31708. * @param uniformName of the uniform to look up.
  31709. * @returns the location of the uniform.
  31710. */
  31711. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  31712. /**
  31713. * Returns an array of sampler variable names
  31714. * @returns The array of sampler variable names.
  31715. */
  31716. getSamplers(): string[];
  31717. /**
  31718. * Returns an array of uniform variable names
  31719. * @returns The array of uniform variable names.
  31720. */
  31721. getUniformNames(): string[];
  31722. /**
  31723. * Returns an array of uniform buffer variable names
  31724. * @returns The array of uniform buffer variable names.
  31725. */
  31726. getUniformBuffersNames(): string[];
  31727. /**
  31728. * Returns the index parameters used to create the effect
  31729. * @returns The index parameters object
  31730. */
  31731. getIndexParameters(): any;
  31732. /**
  31733. * The error from the last compilation.
  31734. * @returns the error string.
  31735. */
  31736. getCompilationError(): string;
  31737. /**
  31738. * Gets a boolean indicating that all fallbacks were used during compilation
  31739. * @returns true if all fallbacks were used
  31740. */
  31741. allFallbacksProcessed(): boolean;
  31742. /**
  31743. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  31744. * @param func The callback to be used.
  31745. */
  31746. executeWhenCompiled(func: (effect: Effect) => void): void;
  31747. private _checkIsReady;
  31748. private _loadShader;
  31749. /**
  31750. * Gets the vertex shader source code of this effect
  31751. */
  31752. get vertexSourceCode(): string;
  31753. /**
  31754. * Gets the fragment shader source code of this effect
  31755. */
  31756. get fragmentSourceCode(): string;
  31757. /**
  31758. * Recompiles the webGL program
  31759. * @param vertexSourceCode The source code for the vertex shader.
  31760. * @param fragmentSourceCode The source code for the fragment shader.
  31761. * @param onCompiled Callback called when completed.
  31762. * @param onError Callback called on error.
  31763. * @hidden
  31764. */
  31765. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  31766. /**
  31767. * Prepares the effect
  31768. * @hidden
  31769. */
  31770. _prepareEffect(): void;
  31771. private _getShaderCodeAndErrorLine;
  31772. private _processCompilationErrors;
  31773. /**
  31774. * Checks if the effect is supported. (Must be called after compilation)
  31775. */
  31776. get isSupported(): boolean;
  31777. /**
  31778. * Binds a texture to the engine to be used as output of the shader.
  31779. * @param channel Name of the output variable.
  31780. * @param texture Texture to bind.
  31781. * @hidden
  31782. */
  31783. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  31784. /**
  31785. * Sets a texture on the engine to be used in the shader.
  31786. * @param channel Name of the sampler variable.
  31787. * @param texture Texture to set.
  31788. */
  31789. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  31790. /**
  31791. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  31792. * @param channel Name of the sampler variable.
  31793. * @param texture Texture to set.
  31794. */
  31795. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  31796. /**
  31797. * Sets an array of textures on the engine to be used in the shader.
  31798. * @param channel Name of the variable.
  31799. * @param textures Textures to set.
  31800. */
  31801. setTextureArray(channel: string, textures: BaseTexture[]): void;
  31802. /**
  31803. * 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)
  31804. * @param channel Name of the sampler variable.
  31805. * @param postProcess Post process to get the input texture from.
  31806. */
  31807. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  31808. /**
  31809. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  31810. * 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)
  31811. * @param channel Name of the sampler variable.
  31812. * @param postProcess Post process to get the output texture from.
  31813. */
  31814. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  31815. /** @hidden */
  31816. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  31817. /** @hidden */
  31818. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  31819. /** @hidden */
  31820. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  31821. /** @hidden */
  31822. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  31823. /**
  31824. * Binds a buffer to a uniform.
  31825. * @param buffer Buffer to bind.
  31826. * @param name Name of the uniform variable to bind to.
  31827. */
  31828. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  31829. /**
  31830. * Binds block to a uniform.
  31831. * @param blockName Name of the block to bind.
  31832. * @param index Index to bind.
  31833. */
  31834. bindUniformBlock(blockName: string, index: number): void;
  31835. /**
  31836. * Sets an interger value on a uniform variable.
  31837. * @param uniformName Name of the variable.
  31838. * @param value Value to be set.
  31839. * @returns this effect.
  31840. */
  31841. setInt(uniformName: string, value: number): Effect;
  31842. /**
  31843. * Sets an int array on a uniform variable.
  31844. * @param uniformName Name of the variable.
  31845. * @param array array to be set.
  31846. * @returns this effect.
  31847. */
  31848. setIntArray(uniformName: string, array: Int32Array): Effect;
  31849. /**
  31850. * 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)
  31851. * @param uniformName Name of the variable.
  31852. * @param array array to be set.
  31853. * @returns this effect.
  31854. */
  31855. setIntArray2(uniformName: string, array: Int32Array): Effect;
  31856. /**
  31857. * 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)
  31858. * @param uniformName Name of the variable.
  31859. * @param array array to be set.
  31860. * @returns this effect.
  31861. */
  31862. setIntArray3(uniformName: string, array: Int32Array): Effect;
  31863. /**
  31864. * 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)
  31865. * @param uniformName Name of the variable.
  31866. * @param array array to be set.
  31867. * @returns this effect.
  31868. */
  31869. setIntArray4(uniformName: string, array: Int32Array): Effect;
  31870. /**
  31871. * Sets an float array on a uniform variable.
  31872. * @param uniformName Name of the variable.
  31873. * @param array array to be set.
  31874. * @returns this effect.
  31875. */
  31876. setFloatArray(uniformName: string, array: Float32Array): Effect;
  31877. /**
  31878. * 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)
  31879. * @param uniformName Name of the variable.
  31880. * @param array array to be set.
  31881. * @returns this effect.
  31882. */
  31883. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  31884. /**
  31885. * 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)
  31886. * @param uniformName Name of the variable.
  31887. * @param array array to be set.
  31888. * @returns this effect.
  31889. */
  31890. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  31891. /**
  31892. * 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)
  31893. * @param uniformName Name of the variable.
  31894. * @param array array to be set.
  31895. * @returns this effect.
  31896. */
  31897. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  31898. /**
  31899. * Sets an array on a uniform variable.
  31900. * @param uniformName Name of the variable.
  31901. * @param array array to be set.
  31902. * @returns this effect.
  31903. */
  31904. setArray(uniformName: string, array: number[]): Effect;
  31905. /**
  31906. * 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)
  31907. * @param uniformName Name of the variable.
  31908. * @param array array to be set.
  31909. * @returns this effect.
  31910. */
  31911. setArray2(uniformName: string, array: number[]): Effect;
  31912. /**
  31913. * 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)
  31914. * @param uniformName Name of the variable.
  31915. * @param array array to be set.
  31916. * @returns this effect.
  31917. */
  31918. setArray3(uniformName: string, array: number[]): Effect;
  31919. /**
  31920. * 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)
  31921. * @param uniformName Name of the variable.
  31922. * @param array array to be set.
  31923. * @returns this effect.
  31924. */
  31925. setArray4(uniformName: string, array: number[]): Effect;
  31926. /**
  31927. * Sets matrices on a uniform variable.
  31928. * @param uniformName Name of the variable.
  31929. * @param matrices matrices to be set.
  31930. * @returns this effect.
  31931. */
  31932. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  31933. /**
  31934. * Sets matrix on a uniform variable.
  31935. * @param uniformName Name of the variable.
  31936. * @param matrix matrix to be set.
  31937. * @returns this effect.
  31938. */
  31939. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  31940. /**
  31941. * 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)
  31942. * @param uniformName Name of the variable.
  31943. * @param matrix matrix to be set.
  31944. * @returns this effect.
  31945. */
  31946. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  31947. /**
  31948. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  31949. * @param uniformName Name of the variable.
  31950. * @param matrix matrix to be set.
  31951. * @returns this effect.
  31952. */
  31953. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  31954. /**
  31955. * Sets a float on a uniform variable.
  31956. * @param uniformName Name of the variable.
  31957. * @param value value to be set.
  31958. * @returns this effect.
  31959. */
  31960. setFloat(uniformName: string, value: number): Effect;
  31961. /**
  31962. * Sets a boolean on a uniform variable.
  31963. * @param uniformName Name of the variable.
  31964. * @param bool value to be set.
  31965. * @returns this effect.
  31966. */
  31967. setBool(uniformName: string, bool: boolean): Effect;
  31968. /**
  31969. * Sets a Vector2 on a uniform variable.
  31970. * @param uniformName Name of the variable.
  31971. * @param vector2 vector2 to be set.
  31972. * @returns this effect.
  31973. */
  31974. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  31975. /**
  31976. * Sets a float2 on a uniform variable.
  31977. * @param uniformName Name of the variable.
  31978. * @param x First float in float2.
  31979. * @param y Second float in float2.
  31980. * @returns this effect.
  31981. */
  31982. setFloat2(uniformName: string, x: number, y: number): Effect;
  31983. /**
  31984. * Sets a Vector3 on a uniform variable.
  31985. * @param uniformName Name of the variable.
  31986. * @param vector3 Value to be set.
  31987. * @returns this effect.
  31988. */
  31989. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  31990. /**
  31991. * Sets a float3 on a uniform variable.
  31992. * @param uniformName Name of the variable.
  31993. * @param x First float in float3.
  31994. * @param y Second float in float3.
  31995. * @param z Third float in float3.
  31996. * @returns this effect.
  31997. */
  31998. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  31999. /**
  32000. * Sets a Vector4 on a uniform variable.
  32001. * @param uniformName Name of the variable.
  32002. * @param vector4 Value to be set.
  32003. * @returns this effect.
  32004. */
  32005. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  32006. /**
  32007. * Sets a float4 on a uniform variable.
  32008. * @param uniformName Name of the variable.
  32009. * @param x First float in float4.
  32010. * @param y Second float in float4.
  32011. * @param z Third float in float4.
  32012. * @param w Fourth float in float4.
  32013. * @returns this effect.
  32014. */
  32015. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  32016. /**
  32017. * Sets a Color3 on a uniform variable.
  32018. * @param uniformName Name of the variable.
  32019. * @param color3 Value to be set.
  32020. * @returns this effect.
  32021. */
  32022. setColor3(uniformName: string, color3: IColor3Like): Effect;
  32023. /**
  32024. * Sets a Color4 on a uniform variable.
  32025. * @param uniformName Name of the variable.
  32026. * @param color3 Value to be set.
  32027. * @param alpha Alpha value to be set.
  32028. * @returns this effect.
  32029. */
  32030. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  32031. /**
  32032. * Sets a Color4 on a uniform variable
  32033. * @param uniformName defines the name of the variable
  32034. * @param color4 defines the value to be set
  32035. * @returns this effect.
  32036. */
  32037. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  32038. /** Release all associated resources */
  32039. dispose(): void;
  32040. /**
  32041. * This function will add a new shader to the shader store
  32042. * @param name the name of the shader
  32043. * @param pixelShader optional pixel shader content
  32044. * @param vertexShader optional vertex shader content
  32045. */
  32046. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  32047. /**
  32048. * Store of each shader (The can be looked up using effect.key)
  32049. */
  32050. static ShadersStore: {
  32051. [key: string]: string;
  32052. };
  32053. /**
  32054. * Store of each included file for a shader (The can be looked up using effect.key)
  32055. */
  32056. static IncludesShadersStore: {
  32057. [key: string]: string;
  32058. };
  32059. /**
  32060. * Resets the cache of effects.
  32061. */
  32062. static ResetCache(): void;
  32063. }
  32064. }
  32065. declare module "babylonjs/Engines/engineCapabilities" {
  32066. /**
  32067. * Interface used to describe the capabilities of the engine relatively to the current browser
  32068. */
  32069. export interface EngineCapabilities {
  32070. /** Maximum textures units per fragment shader */
  32071. maxTexturesImageUnits: number;
  32072. /** Maximum texture units per vertex shader */
  32073. maxVertexTextureImageUnits: number;
  32074. /** Maximum textures units in the entire pipeline */
  32075. maxCombinedTexturesImageUnits: number;
  32076. /** Maximum texture size */
  32077. maxTextureSize: number;
  32078. /** Maximum texture samples */
  32079. maxSamples?: number;
  32080. /** Maximum cube texture size */
  32081. maxCubemapTextureSize: number;
  32082. /** Maximum render texture size */
  32083. maxRenderTextureSize: number;
  32084. /** Maximum number of vertex attributes */
  32085. maxVertexAttribs: number;
  32086. /** Maximum number of varyings */
  32087. maxVaryingVectors: number;
  32088. /** Maximum number of uniforms per vertex shader */
  32089. maxVertexUniformVectors: number;
  32090. /** Maximum number of uniforms per fragment shader */
  32091. maxFragmentUniformVectors: number;
  32092. /** Defines if standard derivates (dx/dy) are supported */
  32093. standardDerivatives: boolean;
  32094. /** Defines if s3tc texture compression is supported */
  32095. s3tc?: WEBGL_compressed_texture_s3tc;
  32096. /** Defines if pvrtc texture compression is supported */
  32097. pvrtc: any;
  32098. /** Defines if etc1 texture compression is supported */
  32099. etc1: any;
  32100. /** Defines if etc2 texture compression is supported */
  32101. etc2: any;
  32102. /** Defines if astc texture compression is supported */
  32103. astc: any;
  32104. /** Defines if float textures are supported */
  32105. textureFloat: boolean;
  32106. /** Defines if vertex array objects are supported */
  32107. vertexArrayObject: boolean;
  32108. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  32109. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  32110. /** Gets the maximum level of anisotropy supported */
  32111. maxAnisotropy: number;
  32112. /** Defines if instancing is supported */
  32113. instancedArrays: boolean;
  32114. /** Defines if 32 bits indices are supported */
  32115. uintIndices: boolean;
  32116. /** Defines if high precision shaders are supported */
  32117. highPrecisionShaderSupported: boolean;
  32118. /** Defines if depth reading in the fragment shader is supported */
  32119. fragmentDepthSupported: boolean;
  32120. /** Defines if float texture linear filtering is supported*/
  32121. textureFloatLinearFiltering: boolean;
  32122. /** Defines if rendering to float textures is supported */
  32123. textureFloatRender: boolean;
  32124. /** Defines if half float textures are supported*/
  32125. textureHalfFloat: boolean;
  32126. /** Defines if half float texture linear filtering is supported*/
  32127. textureHalfFloatLinearFiltering: boolean;
  32128. /** Defines if rendering to half float textures is supported */
  32129. textureHalfFloatRender: boolean;
  32130. /** Defines if textureLOD shader command is supported */
  32131. textureLOD: boolean;
  32132. /** Defines if draw buffers extension is supported */
  32133. drawBuffersExtension: boolean;
  32134. /** Defines if depth textures are supported */
  32135. depthTextureExtension: boolean;
  32136. /** Defines if float color buffer are supported */
  32137. colorBufferFloat: boolean;
  32138. /** Gets disjoint timer query extension (null if not supported) */
  32139. timerQuery?: EXT_disjoint_timer_query;
  32140. /** Defines if timestamp can be used with timer query */
  32141. canUseTimestampForTimerQuery: boolean;
  32142. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  32143. multiview?: any;
  32144. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  32145. oculusMultiview?: any;
  32146. /** Function used to let the system compiles shaders in background */
  32147. parallelShaderCompile?: {
  32148. COMPLETION_STATUS_KHR: number;
  32149. };
  32150. /** Max number of texture samples for MSAA */
  32151. maxMSAASamples: number;
  32152. /** Defines if the blend min max extension is supported */
  32153. blendMinMax: boolean;
  32154. }
  32155. }
  32156. declare module "babylonjs/States/depthCullingState" {
  32157. import { Nullable } from "babylonjs/types";
  32158. /**
  32159. * @hidden
  32160. **/
  32161. export class DepthCullingState {
  32162. private _isDepthTestDirty;
  32163. private _isDepthMaskDirty;
  32164. private _isDepthFuncDirty;
  32165. private _isCullFaceDirty;
  32166. private _isCullDirty;
  32167. private _isZOffsetDirty;
  32168. private _isFrontFaceDirty;
  32169. private _depthTest;
  32170. private _depthMask;
  32171. private _depthFunc;
  32172. private _cull;
  32173. private _cullFace;
  32174. private _zOffset;
  32175. private _frontFace;
  32176. /**
  32177. * Initializes the state.
  32178. */
  32179. constructor();
  32180. get isDirty(): boolean;
  32181. get zOffset(): number;
  32182. set zOffset(value: number);
  32183. get cullFace(): Nullable<number>;
  32184. set cullFace(value: Nullable<number>);
  32185. get cull(): Nullable<boolean>;
  32186. set cull(value: Nullable<boolean>);
  32187. get depthFunc(): Nullable<number>;
  32188. set depthFunc(value: Nullable<number>);
  32189. get depthMask(): boolean;
  32190. set depthMask(value: boolean);
  32191. get depthTest(): boolean;
  32192. set depthTest(value: boolean);
  32193. get frontFace(): Nullable<number>;
  32194. set frontFace(value: Nullable<number>);
  32195. reset(): void;
  32196. apply(gl: WebGLRenderingContext): void;
  32197. }
  32198. }
  32199. declare module "babylonjs/States/stencilState" {
  32200. /**
  32201. * @hidden
  32202. **/
  32203. export class StencilState {
  32204. /** 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 */
  32205. static readonly ALWAYS: number;
  32206. /** Passed to stencilOperation to specify that stencil value must be kept */
  32207. static readonly KEEP: number;
  32208. /** Passed to stencilOperation to specify that stencil value must be replaced */
  32209. static readonly REPLACE: number;
  32210. private _isStencilTestDirty;
  32211. private _isStencilMaskDirty;
  32212. private _isStencilFuncDirty;
  32213. private _isStencilOpDirty;
  32214. private _stencilTest;
  32215. private _stencilMask;
  32216. private _stencilFunc;
  32217. private _stencilFuncRef;
  32218. private _stencilFuncMask;
  32219. private _stencilOpStencilFail;
  32220. private _stencilOpDepthFail;
  32221. private _stencilOpStencilDepthPass;
  32222. get isDirty(): boolean;
  32223. get stencilFunc(): number;
  32224. set stencilFunc(value: number);
  32225. get stencilFuncRef(): number;
  32226. set stencilFuncRef(value: number);
  32227. get stencilFuncMask(): number;
  32228. set stencilFuncMask(value: number);
  32229. get stencilOpStencilFail(): number;
  32230. set stencilOpStencilFail(value: number);
  32231. get stencilOpDepthFail(): number;
  32232. set stencilOpDepthFail(value: number);
  32233. get stencilOpStencilDepthPass(): number;
  32234. set stencilOpStencilDepthPass(value: number);
  32235. get stencilMask(): number;
  32236. set stencilMask(value: number);
  32237. get stencilTest(): boolean;
  32238. set stencilTest(value: boolean);
  32239. constructor();
  32240. reset(): void;
  32241. apply(gl: WebGLRenderingContext): void;
  32242. }
  32243. }
  32244. declare module "babylonjs/States/alphaCullingState" {
  32245. /**
  32246. * @hidden
  32247. **/
  32248. export class AlphaState {
  32249. private _isAlphaBlendDirty;
  32250. private _isBlendFunctionParametersDirty;
  32251. private _isBlendEquationParametersDirty;
  32252. private _isBlendConstantsDirty;
  32253. private _alphaBlend;
  32254. private _blendFunctionParameters;
  32255. private _blendEquationParameters;
  32256. private _blendConstants;
  32257. /**
  32258. * Initializes the state.
  32259. */
  32260. constructor();
  32261. get isDirty(): boolean;
  32262. get alphaBlend(): boolean;
  32263. set alphaBlend(value: boolean);
  32264. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  32265. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  32266. setAlphaEquationParameters(rgb: number, alpha: number): void;
  32267. reset(): void;
  32268. apply(gl: WebGLRenderingContext): void;
  32269. }
  32270. }
  32271. declare module "babylonjs/Engines/WebGL/webGL2ShaderProcessors" {
  32272. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  32273. /** @hidden */
  32274. export class WebGL2ShaderProcessor implements IShaderProcessor {
  32275. attributeProcessor(attribute: string): string;
  32276. varyingProcessor(varying: string, isFragment: boolean): string;
  32277. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  32278. }
  32279. }
  32280. declare module "babylonjs/Engines/instancingAttributeInfo" {
  32281. /**
  32282. * Interface for attribute information associated with buffer instanciation
  32283. */
  32284. export interface InstancingAttributeInfo {
  32285. /**
  32286. * Name of the GLSL attribute
  32287. * if attribute index is not specified, this is used to retrieve the index from the effect
  32288. */
  32289. attributeName: string;
  32290. /**
  32291. * Index/offset of the attribute in the vertex shader
  32292. * if not specified, this will be computes from the name.
  32293. */
  32294. index?: number;
  32295. /**
  32296. * size of the attribute, 1, 2, 3 or 4
  32297. */
  32298. attributeSize: number;
  32299. /**
  32300. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  32301. */
  32302. offset: number;
  32303. /**
  32304. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  32305. * default to 1
  32306. */
  32307. divisor?: number;
  32308. /**
  32309. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  32310. * default is FLOAT
  32311. */
  32312. attributeType?: number;
  32313. /**
  32314. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  32315. */
  32316. normalized?: boolean;
  32317. }
  32318. }
  32319. declare module "babylonjs/Engines/Extensions/engine.videoTexture" {
  32320. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  32321. import { Nullable } from "babylonjs/types";
  32322. module "babylonjs/Engines/thinEngine" {
  32323. interface ThinEngine {
  32324. /**
  32325. * Update a video texture
  32326. * @param texture defines the texture to update
  32327. * @param video defines the video element to use
  32328. * @param invertY defines if data must be stored with Y axis inverted
  32329. */
  32330. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  32331. }
  32332. }
  32333. }
  32334. declare module "babylonjs/Materials/Textures/videoTexture" {
  32335. import { Observable } from "babylonjs/Misc/observable";
  32336. import { Nullable } from "babylonjs/types";
  32337. import { Scene } from "babylonjs/scene";
  32338. import { Texture } from "babylonjs/Materials/Textures/texture";
  32339. import "babylonjs/Engines/Extensions/engine.videoTexture";
  32340. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  32341. /**
  32342. * Settings for finer control over video usage
  32343. */
  32344. export interface VideoTextureSettings {
  32345. /**
  32346. * Applies `autoplay` to video, if specified
  32347. */
  32348. autoPlay?: boolean;
  32349. /**
  32350. * Applies `loop` to video, if specified
  32351. */
  32352. loop?: boolean;
  32353. /**
  32354. * Automatically updates internal texture from video at every frame in the render loop
  32355. */
  32356. autoUpdateTexture: boolean;
  32357. /**
  32358. * Image src displayed during the video loading or until the user interacts with the video.
  32359. */
  32360. poster?: string;
  32361. }
  32362. /**
  32363. * If you want to display a video in your scene, this is the special texture for that.
  32364. * This special texture works similar to other textures, with the exception of a few parameters.
  32365. * @see https://doc.babylonjs.com/how_to/video_texture
  32366. */
  32367. export class VideoTexture extends Texture {
  32368. /**
  32369. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  32370. */
  32371. readonly autoUpdateTexture: boolean;
  32372. /**
  32373. * The video instance used by the texture internally
  32374. */
  32375. readonly video: HTMLVideoElement;
  32376. private _onUserActionRequestedObservable;
  32377. /**
  32378. * Event triggerd when a dom action is required by the user to play the video.
  32379. * This happens due to recent changes in browser policies preventing video to auto start.
  32380. */
  32381. get onUserActionRequestedObservable(): Observable<Texture>;
  32382. private _generateMipMaps;
  32383. private _stillImageCaptured;
  32384. private _displayingPosterTexture;
  32385. private _settings;
  32386. private _createInternalTextureOnEvent;
  32387. private _frameId;
  32388. private _currentSrc;
  32389. /**
  32390. * Creates a video texture.
  32391. * If you want to display a video in your scene, this is the special texture for that.
  32392. * This special texture works similar to other textures, with the exception of a few parameters.
  32393. * @see https://doc.babylonjs.com/how_to/video_texture
  32394. * @param name optional name, will detect from video source, if not defined
  32395. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  32396. * @param scene is obviously the current scene.
  32397. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  32398. * @param invertY is false by default but can be used to invert video on Y axis
  32399. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  32400. * @param settings allows finer control over video usage
  32401. */
  32402. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  32403. private _getName;
  32404. private _getVideo;
  32405. private _createInternalTexture;
  32406. private reset;
  32407. /**
  32408. * @hidden Internal method to initiate `update`.
  32409. */
  32410. _rebuild(): void;
  32411. /**
  32412. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  32413. */
  32414. update(): void;
  32415. /**
  32416. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  32417. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  32418. */
  32419. updateTexture(isVisible: boolean): void;
  32420. protected _updateInternalTexture: () => void;
  32421. /**
  32422. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  32423. * @param url New url.
  32424. */
  32425. updateURL(url: string): void;
  32426. /**
  32427. * Clones the texture.
  32428. * @returns the cloned texture
  32429. */
  32430. clone(): VideoTexture;
  32431. /**
  32432. * Dispose the texture and release its associated resources.
  32433. */
  32434. dispose(): void;
  32435. /**
  32436. * Creates a video texture straight from a stream.
  32437. * @param scene Define the scene the texture should be created in
  32438. * @param stream Define the stream the texture should be created from
  32439. * @returns The created video texture as a promise
  32440. */
  32441. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  32442. /**
  32443. * Creates a video texture straight from your WebCam video feed.
  32444. * @param scene Define the scene the texture should be created in
  32445. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  32446. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  32447. * @returns The created video texture as a promise
  32448. */
  32449. static CreateFromWebCamAsync(scene: Scene, constraints: {
  32450. minWidth: number;
  32451. maxWidth: number;
  32452. minHeight: number;
  32453. maxHeight: number;
  32454. deviceId: string;
  32455. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  32456. /**
  32457. * Creates a video texture straight from your WebCam video feed.
  32458. * @param scene Define the scene the texture should be created in
  32459. * @param onReady Define a callback to triggered once the texture will be ready
  32460. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  32461. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  32462. */
  32463. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  32464. minWidth: number;
  32465. maxWidth: number;
  32466. minHeight: number;
  32467. maxHeight: number;
  32468. deviceId: string;
  32469. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  32470. }
  32471. }
  32472. declare module "babylonjs/Engines/thinEngine" {
  32473. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  32474. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  32475. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  32476. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  32477. import { Nullable, DataArray, IndicesArray } from "babylonjs/types";
  32478. import { EngineCapabilities } from "babylonjs/Engines/engineCapabilities";
  32479. import { Observable } from "babylonjs/Misc/observable";
  32480. import { DepthCullingState } from "babylonjs/States/depthCullingState";
  32481. import { StencilState } from "babylonjs/States/stencilState";
  32482. import { AlphaState } from "babylonjs/States/alphaCullingState";
  32483. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  32484. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  32485. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  32486. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  32487. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  32488. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  32489. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  32490. import { InstancingAttributeInfo } from "babylonjs/Engines/instancingAttributeInfo";
  32491. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  32492. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  32493. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  32494. import { IWebRequest } from "babylonjs/Misc/interfaces/iWebRequest";
  32495. import { WebRequest } from "babylonjs/Misc/webRequest";
  32496. import { LoadFileError } from "babylonjs/Misc/fileTools";
  32497. /**
  32498. * Defines the interface used by objects working like Scene
  32499. * @hidden
  32500. */
  32501. export interface ISceneLike {
  32502. _addPendingData(data: any): void;
  32503. _removePendingData(data: any): void;
  32504. offlineProvider: IOfflineProvider;
  32505. }
  32506. /** Interface defining initialization parameters for Engine class */
  32507. export interface EngineOptions extends WebGLContextAttributes {
  32508. /**
  32509. * Defines if the engine should no exceed a specified device ratio
  32510. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  32511. */
  32512. limitDeviceRatio?: number;
  32513. /**
  32514. * Defines if webvr should be enabled automatically
  32515. * @see http://doc.babylonjs.com/how_to/webvr_camera
  32516. */
  32517. autoEnableWebVR?: boolean;
  32518. /**
  32519. * Defines if webgl2 should be turned off even if supported
  32520. * @see http://doc.babylonjs.com/features/webgl2
  32521. */
  32522. disableWebGL2Support?: boolean;
  32523. /**
  32524. * Defines if webaudio should be initialized as well
  32525. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  32526. */
  32527. audioEngine?: boolean;
  32528. /**
  32529. * Defines if animations should run using a deterministic lock step
  32530. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32531. */
  32532. deterministicLockstep?: boolean;
  32533. /** Defines the maximum steps to use with deterministic lock step mode */
  32534. lockstepMaxSteps?: number;
  32535. /** Defines the seconds between each deterministic lock step */
  32536. timeStep?: number;
  32537. /**
  32538. * Defines that engine should ignore context lost events
  32539. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  32540. */
  32541. doNotHandleContextLost?: boolean;
  32542. /**
  32543. * Defines that engine should ignore modifying touch action attribute and style
  32544. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  32545. */
  32546. doNotHandleTouchAction?: boolean;
  32547. /**
  32548. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  32549. */
  32550. useHighPrecisionFloats?: boolean;
  32551. }
  32552. /**
  32553. * The base engine class (root of all engines)
  32554. */
  32555. export class ThinEngine {
  32556. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  32557. static ExceptionList: ({
  32558. key: string;
  32559. capture: string;
  32560. captureConstraint: number;
  32561. targets: string[];
  32562. } | {
  32563. key: string;
  32564. capture: null;
  32565. captureConstraint: null;
  32566. targets: string[];
  32567. })[];
  32568. /** @hidden */
  32569. static _TextureLoaders: IInternalTextureLoader[];
  32570. /**
  32571. * Returns the current npm package of the sdk
  32572. */
  32573. static get NpmPackage(): string;
  32574. /**
  32575. * Returns the current version of the framework
  32576. */
  32577. static get Version(): string;
  32578. /**
  32579. * Returns a string describing the current engine
  32580. */
  32581. get description(): string;
  32582. /**
  32583. * Gets or sets the epsilon value used by collision engine
  32584. */
  32585. static CollisionsEpsilon: number;
  32586. /**
  32587. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  32588. */
  32589. static get ShadersRepository(): string;
  32590. static set ShadersRepository(value: string);
  32591. /** @hidden */
  32592. _shaderProcessor: IShaderProcessor;
  32593. /**
  32594. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  32595. */
  32596. forcePOTTextures: boolean;
  32597. /**
  32598. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  32599. */
  32600. isFullscreen: boolean;
  32601. /**
  32602. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  32603. */
  32604. cullBackFaces: boolean;
  32605. /**
  32606. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  32607. */
  32608. renderEvenInBackground: boolean;
  32609. /**
  32610. * Gets or sets a boolean indicating that cache can be kept between frames
  32611. */
  32612. preventCacheWipeBetweenFrames: boolean;
  32613. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  32614. validateShaderPrograms: boolean;
  32615. /**
  32616. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  32617. * This can provide greater z depth for distant objects.
  32618. */
  32619. useReverseDepthBuffer: boolean;
  32620. /**
  32621. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  32622. */
  32623. disableUniformBuffers: boolean;
  32624. /** @hidden */
  32625. _uniformBuffers: UniformBuffer[];
  32626. /**
  32627. * Gets a boolean indicating that the engine supports uniform buffers
  32628. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  32629. */
  32630. get supportsUniformBuffers(): boolean;
  32631. /** @hidden */
  32632. _gl: WebGLRenderingContext;
  32633. /** @hidden */
  32634. _webGLVersion: number;
  32635. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  32636. protected _windowIsBackground: boolean;
  32637. protected _creationOptions: EngineOptions;
  32638. protected _highPrecisionShadersAllowed: boolean;
  32639. /** @hidden */
  32640. get _shouldUseHighPrecisionShader(): boolean;
  32641. /**
  32642. * Gets a boolean indicating that only power of 2 textures are supported
  32643. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  32644. */
  32645. get needPOTTextures(): boolean;
  32646. /** @hidden */
  32647. _badOS: boolean;
  32648. /** @hidden */
  32649. _badDesktopOS: boolean;
  32650. private _hardwareScalingLevel;
  32651. /** @hidden */
  32652. _caps: EngineCapabilities;
  32653. private _isStencilEnable;
  32654. private _glVersion;
  32655. private _glRenderer;
  32656. private _glVendor;
  32657. /** @hidden */
  32658. _videoTextureSupported: boolean;
  32659. protected _renderingQueueLaunched: boolean;
  32660. protected _activeRenderLoops: (() => void)[];
  32661. /**
  32662. * Observable signaled when a context lost event is raised
  32663. */
  32664. onContextLostObservable: Observable<ThinEngine>;
  32665. /**
  32666. * Observable signaled when a context restored event is raised
  32667. */
  32668. onContextRestoredObservable: Observable<ThinEngine>;
  32669. private _onContextLost;
  32670. private _onContextRestored;
  32671. protected _contextWasLost: boolean;
  32672. /** @hidden */
  32673. _doNotHandleContextLost: boolean;
  32674. /**
  32675. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  32676. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  32677. */
  32678. get doNotHandleContextLost(): boolean;
  32679. set doNotHandleContextLost(value: boolean);
  32680. /**
  32681. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  32682. */
  32683. disableVertexArrayObjects: boolean;
  32684. /** @hidden */
  32685. protected _colorWrite: boolean;
  32686. /** @hidden */
  32687. protected _colorWriteChanged: boolean;
  32688. /** @hidden */
  32689. protected _depthCullingState: DepthCullingState;
  32690. /** @hidden */
  32691. protected _stencilState: StencilState;
  32692. /** @hidden */
  32693. _alphaState: AlphaState;
  32694. /** @hidden */
  32695. _alphaMode: number;
  32696. /** @hidden */
  32697. _alphaEquation: number;
  32698. /** @hidden */
  32699. _internalTexturesCache: InternalTexture[];
  32700. /** @hidden */
  32701. protected _activeChannel: number;
  32702. private _currentTextureChannel;
  32703. /** @hidden */
  32704. protected _boundTexturesCache: {
  32705. [key: string]: Nullable<InternalTexture>;
  32706. };
  32707. /** @hidden */
  32708. protected _currentEffect: Nullable<Effect>;
  32709. /** @hidden */
  32710. protected _currentProgram: Nullable<WebGLProgram>;
  32711. private _compiledEffects;
  32712. private _vertexAttribArraysEnabled;
  32713. /** @hidden */
  32714. protected _cachedViewport: Nullable<IViewportLike>;
  32715. private _cachedVertexArrayObject;
  32716. /** @hidden */
  32717. protected _cachedVertexBuffers: any;
  32718. /** @hidden */
  32719. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  32720. /** @hidden */
  32721. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  32722. /** @hidden */
  32723. _currentRenderTarget: Nullable<InternalTexture>;
  32724. private _uintIndicesCurrentlySet;
  32725. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  32726. /** @hidden */
  32727. _currentFramebuffer: Nullable<WebGLFramebuffer>;
  32728. /** @hidden */
  32729. _dummyFramebuffer: Nullable<WebGLFramebuffer>;
  32730. private _currentBufferPointers;
  32731. private _currentInstanceLocations;
  32732. private _currentInstanceBuffers;
  32733. private _textureUnits;
  32734. /** @hidden */
  32735. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  32736. /** @hidden */
  32737. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  32738. /** @hidden */
  32739. _boundRenderFunction: any;
  32740. private _vaoRecordInProgress;
  32741. private _mustWipeVertexAttributes;
  32742. private _emptyTexture;
  32743. private _emptyCubeTexture;
  32744. private _emptyTexture3D;
  32745. private _emptyTexture2DArray;
  32746. /** @hidden */
  32747. _frameHandler: number;
  32748. private _nextFreeTextureSlots;
  32749. private _maxSimultaneousTextures;
  32750. private _activeRequests;
  32751. /** @hidden */
  32752. _transformTextureUrl: Nullable<(url: string) => string>;
  32753. protected get _supportsHardwareTextureRescaling(): boolean;
  32754. private _framebufferDimensionsObject;
  32755. /**
  32756. * sets the object from which width and height will be taken from when getting render width and height
  32757. * Will fallback to the gl object
  32758. * @param dimensions the framebuffer width and height that will be used.
  32759. */
  32760. set framebufferDimensionsObject(dimensions: Nullable<{
  32761. framebufferWidth: number;
  32762. framebufferHeight: number;
  32763. }>);
  32764. /**
  32765. * Gets the current viewport
  32766. */
  32767. get currentViewport(): Nullable<IViewportLike>;
  32768. /**
  32769. * Gets the default empty texture
  32770. */
  32771. get emptyTexture(): InternalTexture;
  32772. /**
  32773. * Gets the default empty 3D texture
  32774. */
  32775. get emptyTexture3D(): InternalTexture;
  32776. /**
  32777. * Gets the default empty 2D array texture
  32778. */
  32779. get emptyTexture2DArray(): InternalTexture;
  32780. /**
  32781. * Gets the default empty cube texture
  32782. */
  32783. get emptyCubeTexture(): InternalTexture;
  32784. /**
  32785. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  32786. */
  32787. readonly premultipliedAlpha: boolean;
  32788. /**
  32789. * Observable event triggered before each texture is initialized
  32790. */
  32791. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  32792. /**
  32793. * Creates a new engine
  32794. * @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
  32795. * @param antialias defines enable antialiasing (default: false)
  32796. * @param options defines further options to be sent to the getContext() function
  32797. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  32798. */
  32799. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  32800. private _rebuildInternalTextures;
  32801. private _rebuildEffects;
  32802. /**
  32803. * Gets a boolean indicating if all created effects are ready
  32804. * @returns true if all effects are ready
  32805. */
  32806. areAllEffectsReady(): boolean;
  32807. protected _rebuildBuffers(): void;
  32808. protected _initGLContext(): void;
  32809. /**
  32810. * Gets version of the current webGL context
  32811. */
  32812. get webGLVersion(): number;
  32813. /**
  32814. * Gets a string idenfifying the name of the class
  32815. * @returns "Engine" string
  32816. */
  32817. getClassName(): string;
  32818. /**
  32819. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  32820. */
  32821. get isStencilEnable(): boolean;
  32822. /** @hidden */
  32823. _prepareWorkingCanvas(): void;
  32824. /**
  32825. * Reset the texture cache to empty state
  32826. */
  32827. resetTextureCache(): void;
  32828. /**
  32829. * Gets an object containing information about the current webGL context
  32830. * @returns an object containing the vender, the renderer and the version of the current webGL context
  32831. */
  32832. getGlInfo(): {
  32833. vendor: string;
  32834. renderer: string;
  32835. version: string;
  32836. };
  32837. /**
  32838. * Defines the hardware scaling level.
  32839. * By default the hardware scaling level is computed from the window device ratio.
  32840. * 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.
  32841. * @param level defines the level to use
  32842. */
  32843. setHardwareScalingLevel(level: number): void;
  32844. /**
  32845. * Gets the current hardware scaling level.
  32846. * By default the hardware scaling level is computed from the window device ratio.
  32847. * 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.
  32848. * @returns a number indicating the current hardware scaling level
  32849. */
  32850. getHardwareScalingLevel(): number;
  32851. /**
  32852. * Gets the list of loaded textures
  32853. * @returns an array containing all loaded textures
  32854. */
  32855. getLoadedTexturesCache(): InternalTexture[];
  32856. /**
  32857. * Gets the object containing all engine capabilities
  32858. * @returns the EngineCapabilities object
  32859. */
  32860. getCaps(): EngineCapabilities;
  32861. /**
  32862. * stop executing a render loop function and remove it from the execution array
  32863. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  32864. */
  32865. stopRenderLoop(renderFunction?: () => void): void;
  32866. /** @hidden */
  32867. _renderLoop(): void;
  32868. /**
  32869. * Gets the HTML canvas attached with the current webGL context
  32870. * @returns a HTML canvas
  32871. */
  32872. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  32873. /**
  32874. * Gets host window
  32875. * @returns the host window object
  32876. */
  32877. getHostWindow(): Nullable<Window>;
  32878. /**
  32879. * Gets the current render width
  32880. * @param useScreen defines if screen size must be used (or the current render target if any)
  32881. * @returns a number defining the current render width
  32882. */
  32883. getRenderWidth(useScreen?: boolean): number;
  32884. /**
  32885. * Gets the current render height
  32886. * @param useScreen defines if screen size must be used (or the current render target if any)
  32887. * @returns a number defining the current render height
  32888. */
  32889. getRenderHeight(useScreen?: boolean): number;
  32890. /**
  32891. * Can be used to override the current requestAnimationFrame requester.
  32892. * @hidden
  32893. */
  32894. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  32895. /**
  32896. * Register and execute a render loop. The engine can have more than one render function
  32897. * @param renderFunction defines the function to continuously execute
  32898. */
  32899. runRenderLoop(renderFunction: () => void): void;
  32900. /**
  32901. * Clear the current render buffer or the current render target (if any is set up)
  32902. * @param color defines the color to use
  32903. * @param backBuffer defines if the back buffer must be cleared
  32904. * @param depth defines if the depth buffer must be cleared
  32905. * @param stencil defines if the stencil buffer must be cleared
  32906. */
  32907. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  32908. private _viewportCached;
  32909. /** @hidden */
  32910. _viewport(x: number, y: number, width: number, height: number): void;
  32911. /**
  32912. * Set the WebGL's viewport
  32913. * @param viewport defines the viewport element to be used
  32914. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  32915. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  32916. */
  32917. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  32918. /**
  32919. * Begin a new frame
  32920. */
  32921. beginFrame(): void;
  32922. /**
  32923. * Enf the current frame
  32924. */
  32925. endFrame(): void;
  32926. /**
  32927. * Resize the view according to the canvas' size
  32928. */
  32929. resize(): void;
  32930. /**
  32931. * Force a specific size of the canvas
  32932. * @param width defines the new canvas' width
  32933. * @param height defines the new canvas' height
  32934. */
  32935. setSize(width: number, height: number): void;
  32936. /**
  32937. * Binds the frame buffer to the specified texture.
  32938. * @param texture The texture to render to or null for the default canvas
  32939. * @param faceIndex The face of the texture to render to in case of cube texture
  32940. * @param requiredWidth The width of the target to render to
  32941. * @param requiredHeight The height of the target to render to
  32942. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  32943. * @param lodLevel defines the lod level to bind to the frame buffer
  32944. * @param layer defines the 2d array index to bind to frame buffer to
  32945. */
  32946. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  32947. /** @hidden */
  32948. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  32949. /**
  32950. * Unbind the current render target texture from the webGL context
  32951. * @param texture defines the render target texture to unbind
  32952. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  32953. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  32954. */
  32955. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  32956. /**
  32957. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  32958. */
  32959. flushFramebuffer(): void;
  32960. /**
  32961. * Unbind the current render target and bind the default framebuffer
  32962. */
  32963. restoreDefaultFramebuffer(): void;
  32964. /** @hidden */
  32965. protected _resetVertexBufferBinding(): void;
  32966. /**
  32967. * Creates a vertex buffer
  32968. * @param data the data for the vertex buffer
  32969. * @returns the new WebGL static buffer
  32970. */
  32971. createVertexBuffer(data: DataArray): DataBuffer;
  32972. private _createVertexBuffer;
  32973. /**
  32974. * Creates a dynamic vertex buffer
  32975. * @param data the data for the dynamic vertex buffer
  32976. * @returns the new WebGL dynamic buffer
  32977. */
  32978. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  32979. protected _resetIndexBufferBinding(): void;
  32980. /**
  32981. * Creates a new index buffer
  32982. * @param indices defines the content of the index buffer
  32983. * @param updatable defines if the index buffer must be updatable
  32984. * @returns a new webGL buffer
  32985. */
  32986. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  32987. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  32988. /**
  32989. * Bind a webGL buffer to the webGL context
  32990. * @param buffer defines the buffer to bind
  32991. */
  32992. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  32993. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  32994. private bindBuffer;
  32995. /**
  32996. * update the bound buffer with the given data
  32997. * @param data defines the data to update
  32998. */
  32999. updateArrayBuffer(data: Float32Array): void;
  33000. private _vertexAttribPointer;
  33001. /** @hidden */
  33002. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  33003. private _bindVertexBuffersAttributes;
  33004. /**
  33005. * Records a vertex array object
  33006. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  33007. * @param vertexBuffers defines the list of vertex buffers to store
  33008. * @param indexBuffer defines the index buffer to store
  33009. * @param effect defines the effect to store
  33010. * @returns the new vertex array object
  33011. */
  33012. recordVertexArrayObject(vertexBuffers: {
  33013. [key: string]: VertexBuffer;
  33014. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  33015. /**
  33016. * Bind a specific vertex array object
  33017. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  33018. * @param vertexArrayObject defines the vertex array object to bind
  33019. * @param indexBuffer defines the index buffer to bind
  33020. */
  33021. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  33022. /**
  33023. * Bind webGl buffers directly to the webGL context
  33024. * @param vertexBuffer defines the vertex buffer to bind
  33025. * @param indexBuffer defines the index buffer to bind
  33026. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  33027. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  33028. * @param effect defines the effect associated with the vertex buffer
  33029. */
  33030. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  33031. private _unbindVertexArrayObject;
  33032. /**
  33033. * Bind a list of vertex buffers to the webGL context
  33034. * @param vertexBuffers defines the list of vertex buffers to bind
  33035. * @param indexBuffer defines the index buffer to bind
  33036. * @param effect defines the effect associated with the vertex buffers
  33037. */
  33038. bindBuffers(vertexBuffers: {
  33039. [key: string]: Nullable<VertexBuffer>;
  33040. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  33041. /**
  33042. * Unbind all instance attributes
  33043. */
  33044. unbindInstanceAttributes(): void;
  33045. /**
  33046. * Release and free the memory of a vertex array object
  33047. * @param vao defines the vertex array object to delete
  33048. */
  33049. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  33050. /** @hidden */
  33051. _releaseBuffer(buffer: DataBuffer): boolean;
  33052. protected _deleteBuffer(buffer: DataBuffer): void;
  33053. /**
  33054. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  33055. * @param instancesBuffer defines the webGL buffer to update and bind
  33056. * @param data defines the data to store in the buffer
  33057. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  33058. */
  33059. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  33060. /**
  33061. * Bind the content of a webGL buffer used with instantiation
  33062. * @param instancesBuffer defines the webGL buffer to bind
  33063. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  33064. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  33065. */
  33066. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  33067. /**
  33068. * Disable the instance attribute corresponding to the name in parameter
  33069. * @param name defines the name of the attribute to disable
  33070. */
  33071. disableInstanceAttributeByName(name: string): void;
  33072. /**
  33073. * Disable the instance attribute corresponding to the location in parameter
  33074. * @param attributeLocation defines the attribute location of the attribute to disable
  33075. */
  33076. disableInstanceAttribute(attributeLocation: number): void;
  33077. /**
  33078. * Disable the attribute corresponding to the location in parameter
  33079. * @param attributeLocation defines the attribute location of the attribute to disable
  33080. */
  33081. disableAttributeByIndex(attributeLocation: number): void;
  33082. /**
  33083. * Send a draw order
  33084. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  33085. * @param indexStart defines the starting index
  33086. * @param indexCount defines the number of index to draw
  33087. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  33088. */
  33089. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  33090. /**
  33091. * Draw a list of points
  33092. * @param verticesStart defines the index of first vertex to draw
  33093. * @param verticesCount defines the count of vertices to draw
  33094. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  33095. */
  33096. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  33097. /**
  33098. * Draw a list of unindexed primitives
  33099. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  33100. * @param verticesStart defines the index of first vertex to draw
  33101. * @param verticesCount defines the count of vertices to draw
  33102. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  33103. */
  33104. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  33105. /**
  33106. * Draw a list of indexed primitives
  33107. * @param fillMode defines the primitive to use
  33108. * @param indexStart defines the starting index
  33109. * @param indexCount defines the number of index to draw
  33110. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  33111. */
  33112. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  33113. /**
  33114. * Draw a list of unindexed primitives
  33115. * @param fillMode defines the primitive to use
  33116. * @param verticesStart defines the index of first vertex to draw
  33117. * @param verticesCount defines the count of vertices to draw
  33118. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  33119. */
  33120. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  33121. private _drawMode;
  33122. /** @hidden */
  33123. protected _reportDrawCall(): void;
  33124. /** @hidden */
  33125. _releaseEffect(effect: Effect): void;
  33126. /** @hidden */
  33127. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  33128. /**
  33129. * Create a new effect (used to store vertex/fragment shaders)
  33130. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  33131. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  33132. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  33133. * @param samplers defines an array of string used to represent textures
  33134. * @param defines defines the string containing the defines to use to compile the shaders
  33135. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  33136. * @param onCompiled defines a function to call when the effect creation is successful
  33137. * @param onError defines a function to call when the effect creation has failed
  33138. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  33139. * @returns the new Effect
  33140. */
  33141. 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;
  33142. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  33143. private _compileShader;
  33144. private _compileRawShader;
  33145. /** @hidden */
  33146. _getShaderSource(shader: WebGLShader): Nullable<string>;
  33147. /**
  33148. * Directly creates a webGL program
  33149. * @param pipelineContext defines the pipeline context to attach to
  33150. * @param vertexCode defines the vertex shader code to use
  33151. * @param fragmentCode defines the fragment shader code to use
  33152. * @param context defines the webGL context to use (if not set, the current one will be used)
  33153. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  33154. * @returns the new webGL program
  33155. */
  33156. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  33157. /**
  33158. * Creates a webGL program
  33159. * @param pipelineContext defines the pipeline context to attach to
  33160. * @param vertexCode defines the vertex shader code to use
  33161. * @param fragmentCode defines the fragment shader code to use
  33162. * @param defines defines the string containing the defines to use to compile the shaders
  33163. * @param context defines the webGL context to use (if not set, the current one will be used)
  33164. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  33165. * @returns the new webGL program
  33166. */
  33167. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  33168. /**
  33169. * Creates a new pipeline context
  33170. * @returns the new pipeline
  33171. */
  33172. createPipelineContext(): IPipelineContext;
  33173. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  33174. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  33175. /** @hidden */
  33176. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  33177. /** @hidden */
  33178. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  33179. /** @hidden */
  33180. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  33181. /**
  33182. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  33183. * @param pipelineContext defines the pipeline context to use
  33184. * @param uniformsNames defines the list of uniform names
  33185. * @returns an array of webGL uniform locations
  33186. */
  33187. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  33188. /**
  33189. * Gets the lsit of active attributes for a given webGL program
  33190. * @param pipelineContext defines the pipeline context to use
  33191. * @param attributesNames defines the list of attribute names to get
  33192. * @returns an array of indices indicating the offset of each attribute
  33193. */
  33194. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  33195. /**
  33196. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  33197. * @param effect defines the effect to activate
  33198. */
  33199. enableEffect(effect: Nullable<Effect>): void;
  33200. /**
  33201. * Set the value of an uniform to a number (int)
  33202. * @param uniform defines the webGL uniform location where to store the value
  33203. * @param value defines the int number to store
  33204. */
  33205. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  33206. /**
  33207. * Set the value of an uniform to an array of int32
  33208. * @param uniform defines the webGL uniform location where to store the value
  33209. * @param array defines the array of int32 to store
  33210. */
  33211. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  33212. /**
  33213. * Set the value of an uniform to an array of int32 (stored as vec2)
  33214. * @param uniform defines the webGL uniform location where to store the value
  33215. * @param array defines the array of int32 to store
  33216. */
  33217. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  33218. /**
  33219. * Set the value of an uniform to an array of int32 (stored as vec3)
  33220. * @param uniform defines the webGL uniform location where to store the value
  33221. * @param array defines the array of int32 to store
  33222. */
  33223. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  33224. /**
  33225. * Set the value of an uniform to an array of int32 (stored as vec4)
  33226. * @param uniform defines the webGL uniform location where to store the value
  33227. * @param array defines the array of int32 to store
  33228. */
  33229. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  33230. /**
  33231. * Set the value of an uniform to an array of number
  33232. * @param uniform defines the webGL uniform location where to store the value
  33233. * @param array defines the array of number to store
  33234. */
  33235. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  33236. /**
  33237. * Set the value of an uniform to an array of number (stored as vec2)
  33238. * @param uniform defines the webGL uniform location where to store the value
  33239. * @param array defines the array of number to store
  33240. */
  33241. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  33242. /**
  33243. * Set the value of an uniform to an array of number (stored as vec3)
  33244. * @param uniform defines the webGL uniform location where to store the value
  33245. * @param array defines the array of number to store
  33246. */
  33247. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  33248. /**
  33249. * Set the value of an uniform to an array of number (stored as vec4)
  33250. * @param uniform defines the webGL uniform location where to store the value
  33251. * @param array defines the array of number to store
  33252. */
  33253. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  33254. /**
  33255. * Set the value of an uniform to an array of float32 (stored as matrices)
  33256. * @param uniform defines the webGL uniform location where to store the value
  33257. * @param matrices defines the array of float32 to store
  33258. */
  33259. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  33260. /**
  33261. * Set the value of an uniform to a matrix (3x3)
  33262. * @param uniform defines the webGL uniform location where to store the value
  33263. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  33264. */
  33265. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  33266. /**
  33267. * Set the value of an uniform to a matrix (2x2)
  33268. * @param uniform defines the webGL uniform location where to store the value
  33269. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  33270. */
  33271. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  33272. /**
  33273. * Set the value of an uniform to a number (float)
  33274. * @param uniform defines the webGL uniform location where to store the value
  33275. * @param value defines the float number to store
  33276. */
  33277. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  33278. /**
  33279. * Set the value of an uniform to a vec2
  33280. * @param uniform defines the webGL uniform location where to store the value
  33281. * @param x defines the 1st component of the value
  33282. * @param y defines the 2nd component of the value
  33283. */
  33284. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  33285. /**
  33286. * Set the value of an uniform to a vec3
  33287. * @param uniform defines the webGL uniform location where to store the value
  33288. * @param x defines the 1st component of the value
  33289. * @param y defines the 2nd component of the value
  33290. * @param z defines the 3rd component of the value
  33291. */
  33292. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  33293. /**
  33294. * Set the value of an uniform to a vec4
  33295. * @param uniform defines the webGL uniform location where to store the value
  33296. * @param x defines the 1st component of the value
  33297. * @param y defines the 2nd component of the value
  33298. * @param z defines the 3rd component of the value
  33299. * @param w defines the 4th component of the value
  33300. */
  33301. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  33302. /**
  33303. * Apply all cached states (depth, culling, stencil and alpha)
  33304. */
  33305. applyStates(): void;
  33306. /**
  33307. * Enable or disable color writing
  33308. * @param enable defines the state to set
  33309. */
  33310. setColorWrite(enable: boolean): void;
  33311. /**
  33312. * Gets a boolean indicating if color writing is enabled
  33313. * @returns the current color writing state
  33314. */
  33315. getColorWrite(): boolean;
  33316. /**
  33317. * Gets the depth culling state manager
  33318. */
  33319. get depthCullingState(): DepthCullingState;
  33320. /**
  33321. * Gets the alpha state manager
  33322. */
  33323. get alphaState(): AlphaState;
  33324. /**
  33325. * Gets the stencil state manager
  33326. */
  33327. get stencilState(): StencilState;
  33328. /**
  33329. * Clears the list of texture accessible through engine.
  33330. * This can help preventing texture load conflict due to name collision.
  33331. */
  33332. clearInternalTexturesCache(): void;
  33333. /**
  33334. * Force the entire cache to be cleared
  33335. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  33336. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  33337. */
  33338. wipeCaches(bruteForce?: boolean): void;
  33339. /** @hidden */
  33340. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  33341. min: number;
  33342. mag: number;
  33343. };
  33344. /** @hidden */
  33345. _createTexture(): WebGLTexture;
  33346. /**
  33347. * Usually called from Texture.ts.
  33348. * Passed information to create a WebGLTexture
  33349. * @param url defines a value which contains one of the following:
  33350. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  33351. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  33352. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  33353. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  33354. * @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)
  33355. * @param scene needed for loading to the correct scene
  33356. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  33357. * @param onLoad optional callback to be called upon successful completion
  33358. * @param onError optional callback to be called upon failure
  33359. * @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
  33360. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  33361. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  33362. * @param forcedExtension defines the extension to use to pick the right loader
  33363. * @param mimeType defines an optional mime type
  33364. * @returns a InternalTexture for assignment back into BABYLON.Texture
  33365. */
  33366. 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;
  33367. /**
  33368. * Loads an image as an HTMLImageElement.
  33369. * @param input url string, ArrayBuffer, or Blob to load
  33370. * @param onLoad callback called when the image successfully loads
  33371. * @param onError callback called when the image fails to load
  33372. * @param offlineProvider offline provider for caching
  33373. * @param mimeType optional mime type
  33374. * @returns the HTMLImageElement of the loaded image
  33375. * @hidden
  33376. */
  33377. 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>;
  33378. /**
  33379. * @hidden
  33380. */
  33381. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  33382. private _unpackFlipYCached;
  33383. /**
  33384. * In case you are sharing the context with other applications, it might
  33385. * be interested to not cache the unpack flip y state to ensure a consistent
  33386. * value would be set.
  33387. */
  33388. enableUnpackFlipYCached: boolean;
  33389. /** @hidden */
  33390. _unpackFlipY(value: boolean): void;
  33391. /** @hidden */
  33392. _getUnpackAlignement(): number;
  33393. private _getTextureTarget;
  33394. /**
  33395. * Update the sampling mode of a given texture
  33396. * @param samplingMode defines the required sampling mode
  33397. * @param texture defines the texture to update
  33398. * @param generateMipMaps defines whether to generate mipmaps for the texture
  33399. */
  33400. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  33401. /**
  33402. * Update the sampling mode of a given texture
  33403. * @param texture defines the texture to update
  33404. * @param wrapU defines the texture wrap mode of the u coordinates
  33405. * @param wrapV defines the texture wrap mode of the v coordinates
  33406. * @param wrapR defines the texture wrap mode of the r coordinates
  33407. */
  33408. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  33409. /** @hidden */
  33410. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  33411. width: number;
  33412. height: number;
  33413. layers?: number;
  33414. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  33415. /** @hidden */
  33416. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  33417. /** @hidden */
  33418. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  33419. /**
  33420. * Update a portion of an internal texture
  33421. * @param texture defines the texture to update
  33422. * @param imageData defines the data to store into the texture
  33423. * @param xOffset defines the x coordinates of the update rectangle
  33424. * @param yOffset defines the y coordinates of the update rectangle
  33425. * @param width defines the width of the update rectangle
  33426. * @param height defines the height of the update rectangle
  33427. * @param faceIndex defines the face index if texture is a cube (0 by default)
  33428. * @param lod defines the lod level to update (0 by default)
  33429. */
  33430. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  33431. /** @hidden */
  33432. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  33433. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  33434. private _prepareWebGLTexture;
  33435. /** @hidden */
  33436. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  33437. private _getDepthStencilBuffer;
  33438. /** @hidden */
  33439. _releaseFramebufferObjects(texture: InternalTexture): void;
  33440. /** @hidden */
  33441. _releaseTexture(texture: InternalTexture): void;
  33442. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  33443. protected _setProgram(program: WebGLProgram): void;
  33444. protected _boundUniforms: {
  33445. [key: number]: WebGLUniformLocation;
  33446. };
  33447. /**
  33448. * Binds an effect to the webGL context
  33449. * @param effect defines the effect to bind
  33450. */
  33451. bindSamplers(effect: Effect): void;
  33452. private _activateCurrentTexture;
  33453. /** @hidden */
  33454. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  33455. /** @hidden */
  33456. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  33457. /**
  33458. * Unbind all textures from the webGL context
  33459. */
  33460. unbindAllTextures(): void;
  33461. /**
  33462. * Sets a texture to the according uniform.
  33463. * @param channel The texture channel
  33464. * @param uniform The uniform to set
  33465. * @param texture The texture to apply
  33466. */
  33467. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  33468. private _bindSamplerUniformToChannel;
  33469. private _getTextureWrapMode;
  33470. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  33471. /**
  33472. * Sets an array of texture to the webGL context
  33473. * @param channel defines the channel where the texture array must be set
  33474. * @param uniform defines the associated uniform location
  33475. * @param textures defines the array of textures to bind
  33476. */
  33477. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  33478. /** @hidden */
  33479. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  33480. private _setTextureParameterFloat;
  33481. private _setTextureParameterInteger;
  33482. /**
  33483. * Unbind all vertex attributes from the webGL context
  33484. */
  33485. unbindAllAttributes(): void;
  33486. /**
  33487. * 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
  33488. */
  33489. releaseEffects(): void;
  33490. /**
  33491. * Dispose and release all associated resources
  33492. */
  33493. dispose(): void;
  33494. /**
  33495. * Attach a new callback raised when context lost event is fired
  33496. * @param callback defines the callback to call
  33497. */
  33498. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  33499. /**
  33500. * Attach a new callback raised when context restored event is fired
  33501. * @param callback defines the callback to call
  33502. */
  33503. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  33504. /**
  33505. * Get the current error code of the webGL context
  33506. * @returns the error code
  33507. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  33508. */
  33509. getError(): number;
  33510. private _canRenderToFloatFramebuffer;
  33511. private _canRenderToHalfFloatFramebuffer;
  33512. private _canRenderToFramebuffer;
  33513. /** @hidden */
  33514. _getWebGLTextureType(type: number): number;
  33515. /** @hidden */
  33516. _getInternalFormat(format: number): number;
  33517. /** @hidden */
  33518. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  33519. /** @hidden */
  33520. _getRGBAMultiSampleBufferFormat(type: number): number;
  33521. /** @hidden */
  33522. _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;
  33523. /**
  33524. * Loads a file from a url
  33525. * @param url url to load
  33526. * @param onSuccess callback called when the file successfully loads
  33527. * @param onProgress callback called while file is loading (if the server supports this mode)
  33528. * @param offlineProvider defines the offline provider for caching
  33529. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  33530. * @param onError callback called when the file fails to load
  33531. * @returns a file request object
  33532. * @hidden
  33533. */
  33534. 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;
  33535. /**
  33536. * Reads pixels from the current frame buffer. Please note that this function can be slow
  33537. * @param x defines the x coordinate of the rectangle where pixels must be read
  33538. * @param y defines the y coordinate of the rectangle where pixels must be read
  33539. * @param width defines the width of the rectangle where pixels must be read
  33540. * @param height defines the height of the rectangle where pixels must be read
  33541. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  33542. * @returns a Uint8Array containing RGBA colors
  33543. */
  33544. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  33545. private static _isSupported;
  33546. /**
  33547. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  33548. * @returns true if the engine can be created
  33549. * @ignorenaming
  33550. */
  33551. static isSupported(): boolean;
  33552. /**
  33553. * Find the next highest power of two.
  33554. * @param x Number to start search from.
  33555. * @return Next highest power of two.
  33556. */
  33557. static CeilingPOT(x: number): number;
  33558. /**
  33559. * Find the next lowest power of two.
  33560. * @param x Number to start search from.
  33561. * @return Next lowest power of two.
  33562. */
  33563. static FloorPOT(x: number): number;
  33564. /**
  33565. * Find the nearest power of two.
  33566. * @param x Number to start search from.
  33567. * @return Next nearest power of two.
  33568. */
  33569. static NearestPOT(x: number): number;
  33570. /**
  33571. * Get the closest exponent of two
  33572. * @param value defines the value to approximate
  33573. * @param max defines the maximum value to return
  33574. * @param mode defines how to define the closest value
  33575. * @returns closest exponent of two of the given value
  33576. */
  33577. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  33578. /**
  33579. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  33580. * @param func - the function to be called
  33581. * @param requester - the object that will request the next frame. Falls back to window.
  33582. * @returns frame number
  33583. */
  33584. static QueueNewFrame(func: () => void, requester?: any): number;
  33585. /**
  33586. * Gets host document
  33587. * @returns the host document object
  33588. */
  33589. getHostDocument(): Nullable<Document>;
  33590. }
  33591. }
  33592. declare module "babylonjs/Maths/sphericalPolynomial" {
  33593. import { Vector3 } from "babylonjs/Maths/math.vector";
  33594. import { Color3 } from "babylonjs/Maths/math.color";
  33595. /**
  33596. * Class representing spherical harmonics coefficients to the 3rd degree
  33597. */
  33598. export class SphericalHarmonics {
  33599. /**
  33600. * Defines whether or not the harmonics have been prescaled for rendering.
  33601. */
  33602. preScaled: boolean;
  33603. /**
  33604. * The l0,0 coefficients of the spherical harmonics
  33605. */
  33606. l00: Vector3;
  33607. /**
  33608. * The l1,-1 coefficients of the spherical harmonics
  33609. */
  33610. l1_1: Vector3;
  33611. /**
  33612. * The l1,0 coefficients of the spherical harmonics
  33613. */
  33614. l10: Vector3;
  33615. /**
  33616. * The l1,1 coefficients of the spherical harmonics
  33617. */
  33618. l11: Vector3;
  33619. /**
  33620. * The l2,-2 coefficients of the spherical harmonics
  33621. */
  33622. l2_2: Vector3;
  33623. /**
  33624. * The l2,-1 coefficients of the spherical harmonics
  33625. */
  33626. l2_1: Vector3;
  33627. /**
  33628. * The l2,0 coefficients of the spherical harmonics
  33629. */
  33630. l20: Vector3;
  33631. /**
  33632. * The l2,1 coefficients of the spherical harmonics
  33633. */
  33634. l21: Vector3;
  33635. /**
  33636. * The l2,2 coefficients of the spherical harmonics
  33637. */
  33638. l22: Vector3;
  33639. /**
  33640. * Adds a light to the spherical harmonics
  33641. * @param direction the direction of the light
  33642. * @param color the color of the light
  33643. * @param deltaSolidAngle the delta solid angle of the light
  33644. */
  33645. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  33646. /**
  33647. * Scales the spherical harmonics by the given amount
  33648. * @param scale the amount to scale
  33649. */
  33650. scaleInPlace(scale: number): void;
  33651. /**
  33652. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  33653. *
  33654. * ```
  33655. * E_lm = A_l * L_lm
  33656. * ```
  33657. *
  33658. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  33659. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  33660. * the scaling factors are given in equation 9.
  33661. */
  33662. convertIncidentRadianceToIrradiance(): void;
  33663. /**
  33664. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  33665. *
  33666. * ```
  33667. * L = (1/pi) * E * rho
  33668. * ```
  33669. *
  33670. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  33671. */
  33672. convertIrradianceToLambertianRadiance(): void;
  33673. /**
  33674. * Integrates the reconstruction coefficients directly in to the SH preventing further
  33675. * required operations at run time.
  33676. *
  33677. * This is simply done by scaling back the SH with Ylm constants parameter.
  33678. * The trigonometric part being applied by the shader at run time.
  33679. */
  33680. preScaleForRendering(): void;
  33681. /**
  33682. * Constructs a spherical harmonics from an array.
  33683. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  33684. * @returns the spherical harmonics
  33685. */
  33686. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  33687. /**
  33688. * Gets the spherical harmonics from polynomial
  33689. * @param polynomial the spherical polynomial
  33690. * @returns the spherical harmonics
  33691. */
  33692. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  33693. }
  33694. /**
  33695. * Class representing spherical polynomial coefficients to the 3rd degree
  33696. */
  33697. export class SphericalPolynomial {
  33698. private _harmonics;
  33699. /**
  33700. * The spherical harmonics used to create the polynomials.
  33701. */
  33702. get preScaledHarmonics(): SphericalHarmonics;
  33703. /**
  33704. * The x coefficients of the spherical polynomial
  33705. */
  33706. x: Vector3;
  33707. /**
  33708. * The y coefficients of the spherical polynomial
  33709. */
  33710. y: Vector3;
  33711. /**
  33712. * The z coefficients of the spherical polynomial
  33713. */
  33714. z: Vector3;
  33715. /**
  33716. * The xx coefficients of the spherical polynomial
  33717. */
  33718. xx: Vector3;
  33719. /**
  33720. * The yy coefficients of the spherical polynomial
  33721. */
  33722. yy: Vector3;
  33723. /**
  33724. * The zz coefficients of the spherical polynomial
  33725. */
  33726. zz: Vector3;
  33727. /**
  33728. * The xy coefficients of the spherical polynomial
  33729. */
  33730. xy: Vector3;
  33731. /**
  33732. * The yz coefficients of the spherical polynomial
  33733. */
  33734. yz: Vector3;
  33735. /**
  33736. * The zx coefficients of the spherical polynomial
  33737. */
  33738. zx: Vector3;
  33739. /**
  33740. * Adds an ambient color to the spherical polynomial
  33741. * @param color the color to add
  33742. */
  33743. addAmbient(color: Color3): void;
  33744. /**
  33745. * Scales the spherical polynomial by the given amount
  33746. * @param scale the amount to scale
  33747. */
  33748. scaleInPlace(scale: number): void;
  33749. /**
  33750. * Gets the spherical polynomial from harmonics
  33751. * @param harmonics the spherical harmonics
  33752. * @returns the spherical polynomial
  33753. */
  33754. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  33755. /**
  33756. * Constructs a spherical polynomial from an array.
  33757. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  33758. * @returns the spherical polynomial
  33759. */
  33760. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  33761. }
  33762. }
  33763. declare module "babylonjs/Materials/Textures/internalTexture" {
  33764. import { Observable } from "babylonjs/Misc/observable";
  33765. import { Nullable, int } from "babylonjs/types";
  33766. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  33767. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  33768. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  33769. /**
  33770. * Defines the source of the internal texture
  33771. */
  33772. export enum InternalTextureSource {
  33773. /**
  33774. * The source of the texture data is unknown
  33775. */
  33776. Unknown = 0,
  33777. /**
  33778. * Texture data comes from an URL
  33779. */
  33780. Url = 1,
  33781. /**
  33782. * Texture data is only used for temporary storage
  33783. */
  33784. Temp = 2,
  33785. /**
  33786. * Texture data comes from raw data (ArrayBuffer)
  33787. */
  33788. Raw = 3,
  33789. /**
  33790. * Texture content is dynamic (video or dynamic texture)
  33791. */
  33792. Dynamic = 4,
  33793. /**
  33794. * Texture content is generated by rendering to it
  33795. */
  33796. RenderTarget = 5,
  33797. /**
  33798. * Texture content is part of a multi render target process
  33799. */
  33800. MultiRenderTarget = 6,
  33801. /**
  33802. * Texture data comes from a cube data file
  33803. */
  33804. Cube = 7,
  33805. /**
  33806. * Texture data comes from a raw cube data
  33807. */
  33808. CubeRaw = 8,
  33809. /**
  33810. * Texture data come from a prefiltered cube data file
  33811. */
  33812. CubePrefiltered = 9,
  33813. /**
  33814. * Texture content is raw 3D data
  33815. */
  33816. Raw3D = 10,
  33817. /**
  33818. * Texture content is raw 2D array data
  33819. */
  33820. Raw2DArray = 11,
  33821. /**
  33822. * Texture content is a depth texture
  33823. */
  33824. Depth = 12,
  33825. /**
  33826. * Texture data comes from a raw cube data encoded with RGBD
  33827. */
  33828. CubeRawRGBD = 13
  33829. }
  33830. /**
  33831. * Class used to store data associated with WebGL texture data for the engine
  33832. * This class should not be used directly
  33833. */
  33834. export class InternalTexture {
  33835. /** @hidden */
  33836. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<import("babylonjs/Maths/sphericalPolynomial").SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  33837. /**
  33838. * Defines if the texture is ready
  33839. */
  33840. isReady: boolean;
  33841. /**
  33842. * Defines if the texture is a cube texture
  33843. */
  33844. isCube: boolean;
  33845. /**
  33846. * Defines if the texture contains 3D data
  33847. */
  33848. is3D: boolean;
  33849. /**
  33850. * Defines if the texture contains 2D array data
  33851. */
  33852. is2DArray: boolean;
  33853. /**
  33854. * Defines if the texture contains multiview data
  33855. */
  33856. isMultiview: boolean;
  33857. /**
  33858. * Gets the URL used to load this texture
  33859. */
  33860. url: string;
  33861. /**
  33862. * Gets the sampling mode of the texture
  33863. */
  33864. samplingMode: number;
  33865. /**
  33866. * Gets a boolean indicating if the texture needs mipmaps generation
  33867. */
  33868. generateMipMaps: boolean;
  33869. /**
  33870. * Gets the number of samples used by the texture (WebGL2+ only)
  33871. */
  33872. samples: number;
  33873. /**
  33874. * Gets the type of the texture (int, float...)
  33875. */
  33876. type: number;
  33877. /**
  33878. * Gets the format of the texture (RGB, RGBA...)
  33879. */
  33880. format: number;
  33881. /**
  33882. * Observable called when the texture is loaded
  33883. */
  33884. onLoadedObservable: Observable<InternalTexture>;
  33885. /**
  33886. * Gets the width of the texture
  33887. */
  33888. width: number;
  33889. /**
  33890. * Gets the height of the texture
  33891. */
  33892. height: number;
  33893. /**
  33894. * Gets the depth of the texture
  33895. */
  33896. depth: number;
  33897. /**
  33898. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  33899. */
  33900. baseWidth: number;
  33901. /**
  33902. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  33903. */
  33904. baseHeight: number;
  33905. /**
  33906. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  33907. */
  33908. baseDepth: number;
  33909. /**
  33910. * Gets a boolean indicating if the texture is inverted on Y axis
  33911. */
  33912. invertY: boolean;
  33913. /** @hidden */
  33914. _invertVScale: boolean;
  33915. /** @hidden */
  33916. _associatedChannel: number;
  33917. /** @hidden */
  33918. _source: InternalTextureSource;
  33919. /** @hidden */
  33920. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  33921. /** @hidden */
  33922. _bufferView: Nullable<ArrayBufferView>;
  33923. /** @hidden */
  33924. _bufferViewArray: Nullable<ArrayBufferView[]>;
  33925. /** @hidden */
  33926. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  33927. /** @hidden */
  33928. _size: number;
  33929. /** @hidden */
  33930. _extension: string;
  33931. /** @hidden */
  33932. _files: Nullable<string[]>;
  33933. /** @hidden */
  33934. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  33935. /** @hidden */
  33936. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  33937. /** @hidden */
  33938. _framebuffer: Nullable<WebGLFramebuffer>;
  33939. /** @hidden */
  33940. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  33941. /** @hidden */
  33942. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  33943. /** @hidden */
  33944. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  33945. /** @hidden */
  33946. _attachments: Nullable<number[]>;
  33947. /** @hidden */
  33948. _cachedCoordinatesMode: Nullable<number>;
  33949. /** @hidden */
  33950. _cachedWrapU: Nullable<number>;
  33951. /** @hidden */
  33952. _cachedWrapV: Nullable<number>;
  33953. /** @hidden */
  33954. _cachedWrapR: Nullable<number>;
  33955. /** @hidden */
  33956. _cachedAnisotropicFilteringLevel: Nullable<number>;
  33957. /** @hidden */
  33958. _isDisabled: boolean;
  33959. /** @hidden */
  33960. _compression: Nullable<string>;
  33961. /** @hidden */
  33962. _generateStencilBuffer: boolean;
  33963. /** @hidden */
  33964. _generateDepthBuffer: boolean;
  33965. /** @hidden */
  33966. _comparisonFunction: number;
  33967. /** @hidden */
  33968. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  33969. /** @hidden */
  33970. _lodGenerationScale: number;
  33971. /** @hidden */
  33972. _lodGenerationOffset: number;
  33973. /** @hidden */
  33974. _depthStencilTexture: Nullable<InternalTexture>;
  33975. /** @hidden */
  33976. _colorTextureArray: Nullable<WebGLTexture>;
  33977. /** @hidden */
  33978. _depthStencilTextureArray: Nullable<WebGLTexture>;
  33979. /** @hidden */
  33980. _lodTextureHigh: Nullable<BaseTexture>;
  33981. /** @hidden */
  33982. _lodTextureMid: Nullable<BaseTexture>;
  33983. /** @hidden */
  33984. _lodTextureLow: Nullable<BaseTexture>;
  33985. /** @hidden */
  33986. _isRGBD: boolean;
  33987. /** @hidden */
  33988. _linearSpecularLOD: boolean;
  33989. /** @hidden */
  33990. _irradianceTexture: Nullable<BaseTexture>;
  33991. /** @hidden */
  33992. _webGLTexture: Nullable<WebGLTexture>;
  33993. /** @hidden */
  33994. _references: number;
  33995. private _engine;
  33996. /**
  33997. * Gets the Engine the texture belongs to.
  33998. * @returns The babylon engine
  33999. */
  34000. getEngine(): ThinEngine;
  34001. /**
  34002. * Gets the data source type of the texture
  34003. */
  34004. get source(): InternalTextureSource;
  34005. /**
  34006. * Creates a new InternalTexture
  34007. * @param engine defines the engine to use
  34008. * @param source defines the type of data that will be used
  34009. * @param delayAllocation if the texture allocation should be delayed (default: false)
  34010. */
  34011. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  34012. /**
  34013. * Increments the number of references (ie. the number of Texture that point to it)
  34014. */
  34015. incrementReferences(): void;
  34016. /**
  34017. * Change the size of the texture (not the size of the content)
  34018. * @param width defines the new width
  34019. * @param height defines the new height
  34020. * @param depth defines the new depth (1 by default)
  34021. */
  34022. updateSize(width: int, height: int, depth?: int): void;
  34023. /** @hidden */
  34024. _rebuild(): void;
  34025. /** @hidden */
  34026. _swapAndDie(target: InternalTexture): void;
  34027. /**
  34028. * Dispose the current allocated resources
  34029. */
  34030. dispose(): void;
  34031. }
  34032. }
  34033. declare module "babylonjs/Audio/analyser" {
  34034. import { Scene } from "babylonjs/scene";
  34035. /**
  34036. * Class used to work with sound analyzer using fast fourier transform (FFT)
  34037. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34038. */
  34039. export class Analyser {
  34040. /**
  34041. * Gets or sets the smoothing
  34042. * @ignorenaming
  34043. */
  34044. SMOOTHING: number;
  34045. /**
  34046. * Gets or sets the FFT table size
  34047. * @ignorenaming
  34048. */
  34049. FFT_SIZE: number;
  34050. /**
  34051. * Gets or sets the bar graph amplitude
  34052. * @ignorenaming
  34053. */
  34054. BARGRAPHAMPLITUDE: number;
  34055. /**
  34056. * Gets or sets the position of the debug canvas
  34057. * @ignorenaming
  34058. */
  34059. DEBUGCANVASPOS: {
  34060. x: number;
  34061. y: number;
  34062. };
  34063. /**
  34064. * Gets or sets the debug canvas size
  34065. * @ignorenaming
  34066. */
  34067. DEBUGCANVASSIZE: {
  34068. width: number;
  34069. height: number;
  34070. };
  34071. private _byteFreqs;
  34072. private _byteTime;
  34073. private _floatFreqs;
  34074. private _webAudioAnalyser;
  34075. private _debugCanvas;
  34076. private _debugCanvasContext;
  34077. private _scene;
  34078. private _registerFunc;
  34079. private _audioEngine;
  34080. /**
  34081. * Creates a new analyser
  34082. * @param scene defines hosting scene
  34083. */
  34084. constructor(scene: Scene);
  34085. /**
  34086. * Get the number of data values you will have to play with for the visualization
  34087. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  34088. * @returns a number
  34089. */
  34090. getFrequencyBinCount(): number;
  34091. /**
  34092. * Gets the current frequency data as a byte array
  34093. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  34094. * @returns a Uint8Array
  34095. */
  34096. getByteFrequencyData(): Uint8Array;
  34097. /**
  34098. * Gets the current waveform as a byte array
  34099. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  34100. * @returns a Uint8Array
  34101. */
  34102. getByteTimeDomainData(): Uint8Array;
  34103. /**
  34104. * Gets the current frequency data as a float array
  34105. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  34106. * @returns a Float32Array
  34107. */
  34108. getFloatFrequencyData(): Float32Array;
  34109. /**
  34110. * Renders the debug canvas
  34111. */
  34112. drawDebugCanvas(): void;
  34113. /**
  34114. * Stops rendering the debug canvas and removes it
  34115. */
  34116. stopDebugCanvas(): void;
  34117. /**
  34118. * Connects two audio nodes
  34119. * @param inputAudioNode defines first node to connect
  34120. * @param outputAudioNode defines second node to connect
  34121. */
  34122. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  34123. /**
  34124. * Releases all associated resources
  34125. */
  34126. dispose(): void;
  34127. }
  34128. }
  34129. declare module "babylonjs/Audio/audioEngine" {
  34130. import { IDisposable } from "babylonjs/scene";
  34131. import { Analyser } from "babylonjs/Audio/analyser";
  34132. import { Nullable } from "babylonjs/types";
  34133. import { Observable } from "babylonjs/Misc/observable";
  34134. /**
  34135. * This represents an audio engine and it is responsible
  34136. * to play, synchronize and analyse sounds throughout the application.
  34137. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34138. */
  34139. export interface IAudioEngine extends IDisposable {
  34140. /**
  34141. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  34142. */
  34143. readonly canUseWebAudio: boolean;
  34144. /**
  34145. * Gets the current AudioContext if available.
  34146. */
  34147. readonly audioContext: Nullable<AudioContext>;
  34148. /**
  34149. * The master gain node defines the global audio volume of your audio engine.
  34150. */
  34151. readonly masterGain: GainNode;
  34152. /**
  34153. * Gets whether or not mp3 are supported by your browser.
  34154. */
  34155. readonly isMP3supported: boolean;
  34156. /**
  34157. * Gets whether or not ogg are supported by your browser.
  34158. */
  34159. readonly isOGGsupported: boolean;
  34160. /**
  34161. * Defines if Babylon should emit a warning if WebAudio is not supported.
  34162. * @ignoreNaming
  34163. */
  34164. WarnedWebAudioUnsupported: boolean;
  34165. /**
  34166. * Defines if the audio engine relies on a custom unlocked button.
  34167. * In this case, the embedded button will not be displayed.
  34168. */
  34169. useCustomUnlockedButton: boolean;
  34170. /**
  34171. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  34172. */
  34173. readonly unlocked: boolean;
  34174. /**
  34175. * Event raised when audio has been unlocked on the browser.
  34176. */
  34177. onAudioUnlockedObservable: Observable<AudioEngine>;
  34178. /**
  34179. * Event raised when audio has been locked on the browser.
  34180. */
  34181. onAudioLockedObservable: Observable<AudioEngine>;
  34182. /**
  34183. * Flags the audio engine in Locked state.
  34184. * This happens due to new browser policies preventing audio to autoplay.
  34185. */
  34186. lock(): void;
  34187. /**
  34188. * Unlocks the audio engine once a user action has been done on the dom.
  34189. * This is helpful to resume play once browser policies have been satisfied.
  34190. */
  34191. unlock(): void;
  34192. /**
  34193. * Gets the global volume sets on the master gain.
  34194. * @returns the global volume if set or -1 otherwise
  34195. */
  34196. getGlobalVolume(): number;
  34197. /**
  34198. * Sets the global volume of your experience (sets on the master gain).
  34199. * @param newVolume Defines the new global volume of the application
  34200. */
  34201. setGlobalVolume(newVolume: number): void;
  34202. /**
  34203. * Connect the audio engine to an audio analyser allowing some amazing
  34204. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  34205. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  34206. * @param analyser The analyser to connect to the engine
  34207. */
  34208. connectToAnalyser(analyser: Analyser): void;
  34209. }
  34210. /**
  34211. * This represents the default audio engine used in babylon.
  34212. * It is responsible to play, synchronize and analyse sounds throughout the application.
  34213. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34214. */
  34215. export class AudioEngine implements IAudioEngine {
  34216. private _audioContext;
  34217. private _audioContextInitialized;
  34218. private _muteButton;
  34219. private _hostElement;
  34220. /**
  34221. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  34222. */
  34223. canUseWebAudio: boolean;
  34224. /**
  34225. * The master gain node defines the global audio volume of your audio engine.
  34226. */
  34227. masterGain: GainNode;
  34228. /**
  34229. * Defines if Babylon should emit a warning if WebAudio is not supported.
  34230. * @ignoreNaming
  34231. */
  34232. WarnedWebAudioUnsupported: boolean;
  34233. /**
  34234. * Gets whether or not mp3 are supported by your browser.
  34235. */
  34236. isMP3supported: boolean;
  34237. /**
  34238. * Gets whether or not ogg are supported by your browser.
  34239. */
  34240. isOGGsupported: boolean;
  34241. /**
  34242. * Gets whether audio has been unlocked on the device.
  34243. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  34244. * a user interaction has happened.
  34245. */
  34246. unlocked: boolean;
  34247. /**
  34248. * Defines if the audio engine relies on a custom unlocked button.
  34249. * In this case, the embedded button will not be displayed.
  34250. */
  34251. useCustomUnlockedButton: boolean;
  34252. /**
  34253. * Event raised when audio has been unlocked on the browser.
  34254. */
  34255. onAudioUnlockedObservable: Observable<AudioEngine>;
  34256. /**
  34257. * Event raised when audio has been locked on the browser.
  34258. */
  34259. onAudioLockedObservable: Observable<AudioEngine>;
  34260. /**
  34261. * Gets the current AudioContext if available.
  34262. */
  34263. get audioContext(): Nullable<AudioContext>;
  34264. private _connectedAnalyser;
  34265. /**
  34266. * Instantiates a new audio engine.
  34267. *
  34268. * There should be only one per page as some browsers restrict the number
  34269. * of audio contexts you can create.
  34270. * @param hostElement defines the host element where to display the mute icon if necessary
  34271. */
  34272. constructor(hostElement?: Nullable<HTMLElement>);
  34273. /**
  34274. * Flags the audio engine in Locked state.
  34275. * This happens due to new browser policies preventing audio to autoplay.
  34276. */
  34277. lock(): void;
  34278. /**
  34279. * Unlocks the audio engine once a user action has been done on the dom.
  34280. * This is helpful to resume play once browser policies have been satisfied.
  34281. */
  34282. unlock(): void;
  34283. private _resumeAudioContext;
  34284. private _initializeAudioContext;
  34285. private _tryToRun;
  34286. private _triggerRunningState;
  34287. private _triggerSuspendedState;
  34288. private _displayMuteButton;
  34289. private _moveButtonToTopLeft;
  34290. private _onResize;
  34291. private _hideMuteButton;
  34292. /**
  34293. * Destroy and release the resources associated with the audio ccontext.
  34294. */
  34295. dispose(): void;
  34296. /**
  34297. * Gets the global volume sets on the master gain.
  34298. * @returns the global volume if set or -1 otherwise
  34299. */
  34300. getGlobalVolume(): number;
  34301. /**
  34302. * Sets the global volume of your experience (sets on the master gain).
  34303. * @param newVolume Defines the new global volume of the application
  34304. */
  34305. setGlobalVolume(newVolume: number): void;
  34306. /**
  34307. * Connect the audio engine to an audio analyser allowing some amazing
  34308. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  34309. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  34310. * @param analyser The analyser to connect to the engine
  34311. */
  34312. connectToAnalyser(analyser: Analyser): void;
  34313. }
  34314. }
  34315. declare module "babylonjs/Loading/loadingScreen" {
  34316. /**
  34317. * Interface used to present a loading screen while loading a scene
  34318. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34319. */
  34320. export interface ILoadingScreen {
  34321. /**
  34322. * Function called to display the loading screen
  34323. */
  34324. displayLoadingUI: () => void;
  34325. /**
  34326. * Function called to hide the loading screen
  34327. */
  34328. hideLoadingUI: () => void;
  34329. /**
  34330. * Gets or sets the color to use for the background
  34331. */
  34332. loadingUIBackgroundColor: string;
  34333. /**
  34334. * Gets or sets the text to display while loading
  34335. */
  34336. loadingUIText: string;
  34337. }
  34338. /**
  34339. * Class used for the default loading screen
  34340. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34341. */
  34342. export class DefaultLoadingScreen implements ILoadingScreen {
  34343. private _renderingCanvas;
  34344. private _loadingText;
  34345. private _loadingDivBackgroundColor;
  34346. private _loadingDiv;
  34347. private _loadingTextDiv;
  34348. /** Gets or sets the logo url to use for the default loading screen */
  34349. static DefaultLogoUrl: string;
  34350. /** Gets or sets the spinner url to use for the default loading screen */
  34351. static DefaultSpinnerUrl: string;
  34352. /**
  34353. * Creates a new default loading screen
  34354. * @param _renderingCanvas defines the canvas used to render the scene
  34355. * @param _loadingText defines the default text to display
  34356. * @param _loadingDivBackgroundColor defines the default background color
  34357. */
  34358. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  34359. /**
  34360. * Function called to display the loading screen
  34361. */
  34362. displayLoadingUI(): void;
  34363. /**
  34364. * Function called to hide the loading screen
  34365. */
  34366. hideLoadingUI(): void;
  34367. /**
  34368. * Gets or sets the text to display while loading
  34369. */
  34370. set loadingUIText(text: string);
  34371. get loadingUIText(): string;
  34372. /**
  34373. * Gets or sets the color to use for the background
  34374. */
  34375. get loadingUIBackgroundColor(): string;
  34376. set loadingUIBackgroundColor(color: string);
  34377. private _resizeLoadingUI;
  34378. }
  34379. }
  34380. declare module "babylonjs/Misc/customAnimationFrameRequester" {
  34381. /**
  34382. * Interface for any object that can request an animation frame
  34383. */
  34384. export interface ICustomAnimationFrameRequester {
  34385. /**
  34386. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  34387. */
  34388. renderFunction?: Function;
  34389. /**
  34390. * Called to request the next frame to render to
  34391. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  34392. */
  34393. requestAnimationFrame: Function;
  34394. /**
  34395. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  34396. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  34397. */
  34398. requestID?: number;
  34399. }
  34400. }
  34401. declare module "babylonjs/Misc/performanceMonitor" {
  34402. /**
  34403. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  34404. */
  34405. export class PerformanceMonitor {
  34406. private _enabled;
  34407. private _rollingFrameTime;
  34408. private _lastFrameTimeMs;
  34409. /**
  34410. * constructor
  34411. * @param frameSampleSize The number of samples required to saturate the sliding window
  34412. */
  34413. constructor(frameSampleSize?: number);
  34414. /**
  34415. * Samples current frame
  34416. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  34417. */
  34418. sampleFrame(timeMs?: number): void;
  34419. /**
  34420. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  34421. */
  34422. get averageFrameTime(): number;
  34423. /**
  34424. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  34425. */
  34426. get averageFrameTimeVariance(): number;
  34427. /**
  34428. * Returns the frame time of the most recent frame
  34429. */
  34430. get instantaneousFrameTime(): number;
  34431. /**
  34432. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  34433. */
  34434. get averageFPS(): number;
  34435. /**
  34436. * Returns the average framerate in frames per second using the most recent frame time
  34437. */
  34438. get instantaneousFPS(): number;
  34439. /**
  34440. * Returns true if enough samples have been taken to completely fill the sliding window
  34441. */
  34442. get isSaturated(): boolean;
  34443. /**
  34444. * Enables contributions to the sliding window sample set
  34445. */
  34446. enable(): void;
  34447. /**
  34448. * Disables contributions to the sliding window sample set
  34449. * Samples will not be interpolated over the disabled period
  34450. */
  34451. disable(): void;
  34452. /**
  34453. * Returns true if sampling is enabled
  34454. */
  34455. get isEnabled(): boolean;
  34456. /**
  34457. * Resets performance monitor
  34458. */
  34459. reset(): void;
  34460. }
  34461. /**
  34462. * RollingAverage
  34463. *
  34464. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  34465. */
  34466. export class RollingAverage {
  34467. /**
  34468. * Current average
  34469. */
  34470. average: number;
  34471. /**
  34472. * Current variance
  34473. */
  34474. variance: number;
  34475. protected _samples: Array<number>;
  34476. protected _sampleCount: number;
  34477. protected _pos: number;
  34478. protected _m2: number;
  34479. /**
  34480. * constructor
  34481. * @param length The number of samples required to saturate the sliding window
  34482. */
  34483. constructor(length: number);
  34484. /**
  34485. * Adds a sample to the sample set
  34486. * @param v The sample value
  34487. */
  34488. add(v: number): void;
  34489. /**
  34490. * Returns previously added values or null if outside of history or outside the sliding window domain
  34491. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  34492. * @return Value previously recorded with add() or null if outside of range
  34493. */
  34494. history(i: number): number;
  34495. /**
  34496. * Returns true if enough samples have been taken to completely fill the sliding window
  34497. * @return true if sample-set saturated
  34498. */
  34499. isSaturated(): boolean;
  34500. /**
  34501. * Resets the rolling average (equivalent to 0 samples taken so far)
  34502. */
  34503. reset(): void;
  34504. /**
  34505. * Wraps a value around the sample range boundaries
  34506. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  34507. * @return Wrapped position in sample range
  34508. */
  34509. protected _wrapPosition(i: number): number;
  34510. }
  34511. }
  34512. declare module "babylonjs/Misc/perfCounter" {
  34513. /**
  34514. * This class is used to track a performance counter which is number based.
  34515. * The user has access to many properties which give statistics of different nature.
  34516. *
  34517. * The implementer can track two kinds of Performance Counter: time and count.
  34518. * 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.
  34519. * 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.
  34520. */
  34521. export class PerfCounter {
  34522. /**
  34523. * Gets or sets a global boolean to turn on and off all the counters
  34524. */
  34525. static Enabled: boolean;
  34526. /**
  34527. * Returns the smallest value ever
  34528. */
  34529. get min(): number;
  34530. /**
  34531. * Returns the biggest value ever
  34532. */
  34533. get max(): number;
  34534. /**
  34535. * Returns the average value since the performance counter is running
  34536. */
  34537. get average(): number;
  34538. /**
  34539. * Returns the average value of the last second the counter was monitored
  34540. */
  34541. get lastSecAverage(): number;
  34542. /**
  34543. * Returns the current value
  34544. */
  34545. get current(): number;
  34546. /**
  34547. * Gets the accumulated total
  34548. */
  34549. get total(): number;
  34550. /**
  34551. * Gets the total value count
  34552. */
  34553. get count(): number;
  34554. /**
  34555. * Creates a new counter
  34556. */
  34557. constructor();
  34558. /**
  34559. * Call this method to start monitoring a new frame.
  34560. * 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.
  34561. */
  34562. fetchNewFrame(): void;
  34563. /**
  34564. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  34565. * @param newCount the count value to add to the monitored count
  34566. * @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.
  34567. */
  34568. addCount(newCount: number, fetchResult: boolean): void;
  34569. /**
  34570. * Start monitoring this performance counter
  34571. */
  34572. beginMonitoring(): void;
  34573. /**
  34574. * Compute the time lapsed since the previous beginMonitoring() call.
  34575. * @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
  34576. */
  34577. endMonitoring(newFrame?: boolean): void;
  34578. private _fetchResult;
  34579. private _startMonitoringTime;
  34580. private _min;
  34581. private _max;
  34582. private _average;
  34583. private _current;
  34584. private _totalValueCount;
  34585. private _totalAccumulated;
  34586. private _lastSecAverage;
  34587. private _lastSecAccumulated;
  34588. private _lastSecTime;
  34589. private _lastSecValueCount;
  34590. }
  34591. }
  34592. declare module "babylonjs/Engines/Extensions/engine.alpha" {
  34593. module "babylonjs/Engines/thinEngine" {
  34594. interface ThinEngine {
  34595. /**
  34596. * Sets alpha constants used by some alpha blending modes
  34597. * @param r defines the red component
  34598. * @param g defines the green component
  34599. * @param b defines the blue component
  34600. * @param a defines the alpha component
  34601. */
  34602. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  34603. /**
  34604. * Sets the current alpha mode
  34605. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  34606. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  34607. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  34608. */
  34609. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  34610. /**
  34611. * Gets the current alpha mode
  34612. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  34613. * @returns the current alpha mode
  34614. */
  34615. getAlphaMode(): number;
  34616. /**
  34617. * Sets the current alpha equation
  34618. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  34619. */
  34620. setAlphaEquation(equation: number): void;
  34621. /**
  34622. * Gets the current alpha equation.
  34623. * @returns the current alpha equation
  34624. */
  34625. getAlphaEquation(): number;
  34626. }
  34627. }
  34628. }
  34629. declare module "babylonjs/Engines/Extensions/engine.readTexture" {
  34630. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  34631. import { Nullable } from "babylonjs/types";
  34632. module "babylonjs/Engines/thinEngine" {
  34633. interface ThinEngine {
  34634. /** @hidden */
  34635. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  34636. }
  34637. }
  34638. }
  34639. declare module "babylonjs/Engines/engine" {
  34640. import { Observable } from "babylonjs/Misc/observable";
  34641. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  34642. import { Scene } from "babylonjs/scene";
  34643. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  34644. import { IAudioEngine } from "babylonjs/Audio/audioEngine";
  34645. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  34646. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  34647. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  34648. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  34649. import { ICustomAnimationFrameRequester } from "babylonjs/Misc/customAnimationFrameRequester";
  34650. import { ThinEngine, EngineOptions } from "babylonjs/Engines/thinEngine";
  34651. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  34652. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  34653. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  34654. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  34655. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  34656. import "babylonjs/Engines/Extensions/engine.alpha";
  34657. import "babylonjs/Engines/Extensions/engine.readTexture";
  34658. import { Material } from "babylonjs/Materials/material";
  34659. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  34660. /**
  34661. * Defines the interface used by display changed events
  34662. */
  34663. export interface IDisplayChangedEventArgs {
  34664. /** Gets the vrDisplay object (if any) */
  34665. vrDisplay: Nullable<any>;
  34666. /** Gets a boolean indicating if webVR is supported */
  34667. vrSupported: boolean;
  34668. }
  34669. /**
  34670. * Defines the interface used by objects containing a viewport (like a camera)
  34671. */
  34672. interface IViewportOwnerLike {
  34673. /**
  34674. * Gets or sets the viewport
  34675. */
  34676. viewport: IViewportLike;
  34677. }
  34678. /**
  34679. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  34680. */
  34681. export class Engine extends ThinEngine {
  34682. /** Defines that alpha blending is disabled */
  34683. static readonly ALPHA_DISABLE: number;
  34684. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  34685. static readonly ALPHA_ADD: number;
  34686. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  34687. static readonly ALPHA_COMBINE: number;
  34688. /** Defines that alpha blending to DEST - SRC * DEST */
  34689. static readonly ALPHA_SUBTRACT: number;
  34690. /** Defines that alpha blending to SRC * DEST */
  34691. static readonly ALPHA_MULTIPLY: number;
  34692. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  34693. static readonly ALPHA_MAXIMIZED: number;
  34694. /** Defines that alpha blending to SRC + DEST */
  34695. static readonly ALPHA_ONEONE: number;
  34696. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  34697. static readonly ALPHA_PREMULTIPLIED: number;
  34698. /**
  34699. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  34700. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  34701. */
  34702. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  34703. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  34704. static readonly ALPHA_INTERPOLATE: number;
  34705. /**
  34706. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  34707. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  34708. */
  34709. static readonly ALPHA_SCREENMODE: number;
  34710. /** Defines that the ressource is not delayed*/
  34711. static readonly DELAYLOADSTATE_NONE: number;
  34712. /** Defines that the ressource was successfully delay loaded */
  34713. static readonly DELAYLOADSTATE_LOADED: number;
  34714. /** Defines that the ressource is currently delay loading */
  34715. static readonly DELAYLOADSTATE_LOADING: number;
  34716. /** Defines that the ressource is delayed and has not started loading */
  34717. static readonly DELAYLOADSTATE_NOTLOADED: number;
  34718. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  34719. static readonly NEVER: number;
  34720. /** 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 */
  34721. static readonly ALWAYS: number;
  34722. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  34723. static readonly LESS: number;
  34724. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  34725. static readonly EQUAL: number;
  34726. /** 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 */
  34727. static readonly LEQUAL: number;
  34728. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  34729. static readonly GREATER: number;
  34730. /** 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 */
  34731. static readonly GEQUAL: number;
  34732. /** 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 */
  34733. static readonly NOTEQUAL: number;
  34734. /** Passed to stencilOperation to specify that stencil value must be kept */
  34735. static readonly KEEP: number;
  34736. /** Passed to stencilOperation to specify that stencil value must be replaced */
  34737. static readonly REPLACE: number;
  34738. /** Passed to stencilOperation to specify that stencil value must be incremented */
  34739. static readonly INCR: number;
  34740. /** Passed to stencilOperation to specify that stencil value must be decremented */
  34741. static readonly DECR: number;
  34742. /** Passed to stencilOperation to specify that stencil value must be inverted */
  34743. static readonly INVERT: number;
  34744. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  34745. static readonly INCR_WRAP: number;
  34746. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  34747. static readonly DECR_WRAP: number;
  34748. /** Texture is not repeating outside of 0..1 UVs */
  34749. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  34750. /** Texture is repeating outside of 0..1 UVs */
  34751. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  34752. /** Texture is repeating and mirrored */
  34753. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  34754. /** ALPHA */
  34755. static readonly TEXTUREFORMAT_ALPHA: number;
  34756. /** LUMINANCE */
  34757. static readonly TEXTUREFORMAT_LUMINANCE: number;
  34758. /** LUMINANCE_ALPHA */
  34759. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  34760. /** RGB */
  34761. static readonly TEXTUREFORMAT_RGB: number;
  34762. /** RGBA */
  34763. static readonly TEXTUREFORMAT_RGBA: number;
  34764. /** RED */
  34765. static readonly TEXTUREFORMAT_RED: number;
  34766. /** RED (2nd reference) */
  34767. static readonly TEXTUREFORMAT_R: number;
  34768. /** RG */
  34769. static readonly TEXTUREFORMAT_RG: number;
  34770. /** RED_INTEGER */
  34771. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  34772. /** RED_INTEGER (2nd reference) */
  34773. static readonly TEXTUREFORMAT_R_INTEGER: number;
  34774. /** RG_INTEGER */
  34775. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  34776. /** RGB_INTEGER */
  34777. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  34778. /** RGBA_INTEGER */
  34779. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  34780. /** UNSIGNED_BYTE */
  34781. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  34782. /** UNSIGNED_BYTE (2nd reference) */
  34783. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  34784. /** FLOAT */
  34785. static readonly TEXTURETYPE_FLOAT: number;
  34786. /** HALF_FLOAT */
  34787. static readonly TEXTURETYPE_HALF_FLOAT: number;
  34788. /** BYTE */
  34789. static readonly TEXTURETYPE_BYTE: number;
  34790. /** SHORT */
  34791. static readonly TEXTURETYPE_SHORT: number;
  34792. /** UNSIGNED_SHORT */
  34793. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  34794. /** INT */
  34795. static readonly TEXTURETYPE_INT: number;
  34796. /** UNSIGNED_INT */
  34797. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  34798. /** UNSIGNED_SHORT_4_4_4_4 */
  34799. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  34800. /** UNSIGNED_SHORT_5_5_5_1 */
  34801. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  34802. /** UNSIGNED_SHORT_5_6_5 */
  34803. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  34804. /** UNSIGNED_INT_2_10_10_10_REV */
  34805. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  34806. /** UNSIGNED_INT_24_8 */
  34807. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  34808. /** UNSIGNED_INT_10F_11F_11F_REV */
  34809. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  34810. /** UNSIGNED_INT_5_9_9_9_REV */
  34811. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  34812. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  34813. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  34814. /** nearest is mag = nearest and min = nearest and mip = linear */
  34815. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  34816. /** Bilinear is mag = linear and min = linear and mip = nearest */
  34817. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  34818. /** Trilinear is mag = linear and min = linear and mip = linear */
  34819. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  34820. /** nearest is mag = nearest and min = nearest and mip = linear */
  34821. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  34822. /** Bilinear is mag = linear and min = linear and mip = nearest */
  34823. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  34824. /** Trilinear is mag = linear and min = linear and mip = linear */
  34825. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  34826. /** mag = nearest and min = nearest and mip = nearest */
  34827. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  34828. /** mag = nearest and min = linear and mip = nearest */
  34829. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  34830. /** mag = nearest and min = linear and mip = linear */
  34831. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  34832. /** mag = nearest and min = linear and mip = none */
  34833. static readonly TEXTURE_NEAREST_LINEAR: number;
  34834. /** mag = nearest and min = nearest and mip = none */
  34835. static readonly TEXTURE_NEAREST_NEAREST: number;
  34836. /** mag = linear and min = nearest and mip = nearest */
  34837. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  34838. /** mag = linear and min = nearest and mip = linear */
  34839. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  34840. /** mag = linear and min = linear and mip = none */
  34841. static readonly TEXTURE_LINEAR_LINEAR: number;
  34842. /** mag = linear and min = nearest and mip = none */
  34843. static readonly TEXTURE_LINEAR_NEAREST: number;
  34844. /** Explicit coordinates mode */
  34845. static readonly TEXTURE_EXPLICIT_MODE: number;
  34846. /** Spherical coordinates mode */
  34847. static readonly TEXTURE_SPHERICAL_MODE: number;
  34848. /** Planar coordinates mode */
  34849. static readonly TEXTURE_PLANAR_MODE: number;
  34850. /** Cubic coordinates mode */
  34851. static readonly TEXTURE_CUBIC_MODE: number;
  34852. /** Projection coordinates mode */
  34853. static readonly TEXTURE_PROJECTION_MODE: number;
  34854. /** Skybox coordinates mode */
  34855. static readonly TEXTURE_SKYBOX_MODE: number;
  34856. /** Inverse Cubic coordinates mode */
  34857. static readonly TEXTURE_INVCUBIC_MODE: number;
  34858. /** Equirectangular coordinates mode */
  34859. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  34860. /** Equirectangular Fixed coordinates mode */
  34861. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  34862. /** Equirectangular Fixed Mirrored coordinates mode */
  34863. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  34864. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  34865. static readonly SCALEMODE_FLOOR: number;
  34866. /** Defines that texture rescaling will look for the nearest power of 2 size */
  34867. static readonly SCALEMODE_NEAREST: number;
  34868. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  34869. static readonly SCALEMODE_CEILING: number;
  34870. /**
  34871. * Returns the current npm package of the sdk
  34872. */
  34873. static get NpmPackage(): string;
  34874. /**
  34875. * Returns the current version of the framework
  34876. */
  34877. static get Version(): string;
  34878. /** Gets the list of created engines */
  34879. static get Instances(): Engine[];
  34880. /**
  34881. * Gets the latest created engine
  34882. */
  34883. static get LastCreatedEngine(): Nullable<Engine>;
  34884. /**
  34885. * Gets the latest created scene
  34886. */
  34887. static get LastCreatedScene(): Nullable<Scene>;
  34888. /**
  34889. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  34890. * @param flag defines which part of the materials must be marked as dirty
  34891. * @param predicate defines a predicate used to filter which materials should be affected
  34892. */
  34893. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  34894. /**
  34895. * Method called to create the default loading screen.
  34896. * This can be overriden in your own app.
  34897. * @param canvas The rendering canvas element
  34898. * @returns The loading screen
  34899. */
  34900. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  34901. /**
  34902. * Method called to create the default rescale post process on each engine.
  34903. */
  34904. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  34905. /**
  34906. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  34907. **/
  34908. enableOfflineSupport: boolean;
  34909. /**
  34910. * 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)
  34911. **/
  34912. disableManifestCheck: boolean;
  34913. /**
  34914. * Gets the list of created scenes
  34915. */
  34916. scenes: Scene[];
  34917. /**
  34918. * Event raised when a new scene is created
  34919. */
  34920. onNewSceneAddedObservable: Observable<Scene>;
  34921. /**
  34922. * Gets the list of created postprocesses
  34923. */
  34924. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  34925. /**
  34926. * Gets a boolean indicating if the pointer is currently locked
  34927. */
  34928. isPointerLock: boolean;
  34929. /**
  34930. * Observable event triggered each time the rendering canvas is resized
  34931. */
  34932. onResizeObservable: Observable<Engine>;
  34933. /**
  34934. * Observable event triggered each time the canvas loses focus
  34935. */
  34936. onCanvasBlurObservable: Observable<Engine>;
  34937. /**
  34938. * Observable event triggered each time the canvas gains focus
  34939. */
  34940. onCanvasFocusObservable: Observable<Engine>;
  34941. /**
  34942. * Observable event triggered each time the canvas receives pointerout event
  34943. */
  34944. onCanvasPointerOutObservable: Observable<PointerEvent>;
  34945. /**
  34946. * Observable raised when the engine begins a new frame
  34947. */
  34948. onBeginFrameObservable: Observable<Engine>;
  34949. /**
  34950. * If set, will be used to request the next animation frame for the render loop
  34951. */
  34952. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  34953. /**
  34954. * Observable raised when the engine ends the current frame
  34955. */
  34956. onEndFrameObservable: Observable<Engine>;
  34957. /**
  34958. * Observable raised when the engine is about to compile a shader
  34959. */
  34960. onBeforeShaderCompilationObservable: Observable<Engine>;
  34961. /**
  34962. * Observable raised when the engine has jsut compiled a shader
  34963. */
  34964. onAfterShaderCompilationObservable: Observable<Engine>;
  34965. /**
  34966. * Gets the audio engine
  34967. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34968. * @ignorenaming
  34969. */
  34970. static audioEngine: IAudioEngine;
  34971. /**
  34972. * Default AudioEngine factory responsible of creating the Audio Engine.
  34973. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  34974. */
  34975. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  34976. /**
  34977. * Default offline support factory responsible of creating a tool used to store data locally.
  34978. * By default, this will create a Database object if the workload has been embedded.
  34979. */
  34980. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  34981. private _loadingScreen;
  34982. private _pointerLockRequested;
  34983. private _rescalePostProcess;
  34984. private _deterministicLockstep;
  34985. private _lockstepMaxSteps;
  34986. private _timeStep;
  34987. protected get _supportsHardwareTextureRescaling(): boolean;
  34988. private _fps;
  34989. private _deltaTime;
  34990. /** @hidden */
  34991. _drawCalls: PerfCounter;
  34992. /** 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 */
  34993. canvasTabIndex: number;
  34994. /**
  34995. * Turn this value on if you want to pause FPS computation when in background
  34996. */
  34997. disablePerformanceMonitorInBackground: boolean;
  34998. private _performanceMonitor;
  34999. /**
  35000. * Gets the performance monitor attached to this engine
  35001. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  35002. */
  35003. get performanceMonitor(): PerformanceMonitor;
  35004. private _onFocus;
  35005. private _onBlur;
  35006. private _onCanvasPointerOut;
  35007. private _onCanvasBlur;
  35008. private _onCanvasFocus;
  35009. private _onFullscreenChange;
  35010. private _onPointerLockChange;
  35011. /**
  35012. * Gets the HTML element used to attach event listeners
  35013. * @returns a HTML element
  35014. */
  35015. getInputElement(): Nullable<HTMLElement>;
  35016. /**
  35017. * Creates a new engine
  35018. * @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
  35019. * @param antialias defines enable antialiasing (default: false)
  35020. * @param options defines further options to be sent to the getContext() function
  35021. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  35022. */
  35023. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  35024. /**
  35025. * Gets current aspect ratio
  35026. * @param viewportOwner defines the camera to use to get the aspect ratio
  35027. * @param useScreen defines if screen size must be used (or the current render target if any)
  35028. * @returns a number defining the aspect ratio
  35029. */
  35030. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  35031. /**
  35032. * Gets current screen aspect ratio
  35033. * @returns a number defining the aspect ratio
  35034. */
  35035. getScreenAspectRatio(): number;
  35036. /**
  35037. * Gets the client rect of the HTML canvas attached with the current webGL context
  35038. * @returns a client rectanglee
  35039. */
  35040. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  35041. /**
  35042. * Gets the client rect of the HTML element used for events
  35043. * @returns a client rectanglee
  35044. */
  35045. getInputElementClientRect(): Nullable<ClientRect>;
  35046. /**
  35047. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  35048. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35049. * @returns true if engine is in deterministic lock step mode
  35050. */
  35051. isDeterministicLockStep(): boolean;
  35052. /**
  35053. * Gets the max steps when engine is running in deterministic lock step
  35054. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35055. * @returns the max steps
  35056. */
  35057. getLockstepMaxSteps(): number;
  35058. /**
  35059. * Returns the time in ms between steps when using deterministic lock step.
  35060. * @returns time step in (ms)
  35061. */
  35062. getTimeStep(): number;
  35063. /**
  35064. * Force the mipmap generation for the given render target texture
  35065. * @param texture defines the render target texture to use
  35066. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  35067. */
  35068. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  35069. /** States */
  35070. /**
  35071. * Set various states to the webGL context
  35072. * @param culling defines backface culling state
  35073. * @param zOffset defines the value to apply to zOffset (0 by default)
  35074. * @param force defines if states must be applied even if cache is up to date
  35075. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  35076. */
  35077. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  35078. /**
  35079. * Set the z offset to apply to current rendering
  35080. * @param value defines the offset to apply
  35081. */
  35082. setZOffset(value: number): void;
  35083. /**
  35084. * Gets the current value of the zOffset
  35085. * @returns the current zOffset state
  35086. */
  35087. getZOffset(): number;
  35088. /**
  35089. * Enable or disable depth buffering
  35090. * @param enable defines the state to set
  35091. */
  35092. setDepthBuffer(enable: boolean): void;
  35093. /**
  35094. * Gets a boolean indicating if depth writing is enabled
  35095. * @returns the current depth writing state
  35096. */
  35097. getDepthWrite(): boolean;
  35098. /**
  35099. * Enable or disable depth writing
  35100. * @param enable defines the state to set
  35101. */
  35102. setDepthWrite(enable: boolean): void;
  35103. /**
  35104. * Gets a boolean indicating if stencil buffer is enabled
  35105. * @returns the current stencil buffer state
  35106. */
  35107. getStencilBuffer(): boolean;
  35108. /**
  35109. * Enable or disable the stencil buffer
  35110. * @param enable defines if the stencil buffer must be enabled or disabled
  35111. */
  35112. setStencilBuffer(enable: boolean): void;
  35113. /**
  35114. * Gets the current stencil mask
  35115. * @returns a number defining the new stencil mask to use
  35116. */
  35117. getStencilMask(): number;
  35118. /**
  35119. * Sets the current stencil mask
  35120. * @param mask defines the new stencil mask to use
  35121. */
  35122. setStencilMask(mask: number): void;
  35123. /**
  35124. * Gets the current stencil function
  35125. * @returns a number defining the stencil function to use
  35126. */
  35127. getStencilFunction(): number;
  35128. /**
  35129. * Gets the current stencil reference value
  35130. * @returns a number defining the stencil reference value to use
  35131. */
  35132. getStencilFunctionReference(): number;
  35133. /**
  35134. * Gets the current stencil mask
  35135. * @returns a number defining the stencil mask to use
  35136. */
  35137. getStencilFunctionMask(): number;
  35138. /**
  35139. * Sets the current stencil function
  35140. * @param stencilFunc defines the new stencil function to use
  35141. */
  35142. setStencilFunction(stencilFunc: number): void;
  35143. /**
  35144. * Sets the current stencil reference
  35145. * @param reference defines the new stencil reference to use
  35146. */
  35147. setStencilFunctionReference(reference: number): void;
  35148. /**
  35149. * Sets the current stencil mask
  35150. * @param mask defines the new stencil mask to use
  35151. */
  35152. setStencilFunctionMask(mask: number): void;
  35153. /**
  35154. * Gets the current stencil operation when stencil fails
  35155. * @returns a number defining stencil operation to use when stencil fails
  35156. */
  35157. getStencilOperationFail(): number;
  35158. /**
  35159. * Gets the current stencil operation when depth fails
  35160. * @returns a number defining stencil operation to use when depth fails
  35161. */
  35162. getStencilOperationDepthFail(): number;
  35163. /**
  35164. * Gets the current stencil operation when stencil passes
  35165. * @returns a number defining stencil operation to use when stencil passes
  35166. */
  35167. getStencilOperationPass(): number;
  35168. /**
  35169. * Sets the stencil operation to use when stencil fails
  35170. * @param operation defines the stencil operation to use when stencil fails
  35171. */
  35172. setStencilOperationFail(operation: number): void;
  35173. /**
  35174. * Sets the stencil operation to use when depth fails
  35175. * @param operation defines the stencil operation to use when depth fails
  35176. */
  35177. setStencilOperationDepthFail(operation: number): void;
  35178. /**
  35179. * Sets the stencil operation to use when stencil passes
  35180. * @param operation defines the stencil operation to use when stencil passes
  35181. */
  35182. setStencilOperationPass(operation: number): void;
  35183. /**
  35184. * Sets a boolean indicating if the dithering state is enabled or disabled
  35185. * @param value defines the dithering state
  35186. */
  35187. setDitheringState(value: boolean): void;
  35188. /**
  35189. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  35190. * @param value defines the rasterizer state
  35191. */
  35192. setRasterizerState(value: boolean): void;
  35193. /**
  35194. * Gets the current depth function
  35195. * @returns a number defining the depth function
  35196. */
  35197. getDepthFunction(): Nullable<number>;
  35198. /**
  35199. * Sets the current depth function
  35200. * @param depthFunc defines the function to use
  35201. */
  35202. setDepthFunction(depthFunc: number): void;
  35203. /**
  35204. * Sets the current depth function to GREATER
  35205. */
  35206. setDepthFunctionToGreater(): void;
  35207. /**
  35208. * Sets the current depth function to GEQUAL
  35209. */
  35210. setDepthFunctionToGreaterOrEqual(): void;
  35211. /**
  35212. * Sets the current depth function to LESS
  35213. */
  35214. setDepthFunctionToLess(): void;
  35215. /**
  35216. * Sets the current depth function to LEQUAL
  35217. */
  35218. setDepthFunctionToLessOrEqual(): void;
  35219. private _cachedStencilBuffer;
  35220. private _cachedStencilFunction;
  35221. private _cachedStencilMask;
  35222. private _cachedStencilOperationPass;
  35223. private _cachedStencilOperationFail;
  35224. private _cachedStencilOperationDepthFail;
  35225. private _cachedStencilReference;
  35226. /**
  35227. * Caches the the state of the stencil buffer
  35228. */
  35229. cacheStencilState(): void;
  35230. /**
  35231. * Restores the state of the stencil buffer
  35232. */
  35233. restoreStencilState(): void;
  35234. /**
  35235. * Directly set the WebGL Viewport
  35236. * @param x defines the x coordinate of the viewport (in screen space)
  35237. * @param y defines the y coordinate of the viewport (in screen space)
  35238. * @param width defines the width of the viewport (in screen space)
  35239. * @param height defines the height of the viewport (in screen space)
  35240. * @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
  35241. */
  35242. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  35243. /**
  35244. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  35245. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  35246. * @param y defines the y-coordinate of the corner of the clear rectangle
  35247. * @param width defines the width of the clear rectangle
  35248. * @param height defines the height of the clear rectangle
  35249. * @param clearColor defines the clear color
  35250. */
  35251. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  35252. /**
  35253. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  35254. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  35255. * @param y defines the y-coordinate of the corner of the clear rectangle
  35256. * @param width defines the width of the clear rectangle
  35257. * @param height defines the height of the clear rectangle
  35258. */
  35259. enableScissor(x: number, y: number, width: number, height: number): void;
  35260. /**
  35261. * Disable previously set scissor test rectangle
  35262. */
  35263. disableScissor(): void;
  35264. protected _reportDrawCall(): void;
  35265. /**
  35266. * Initializes a webVR display and starts listening to display change events
  35267. * The onVRDisplayChangedObservable will be notified upon these changes
  35268. * @returns The onVRDisplayChangedObservable
  35269. */
  35270. initWebVR(): Observable<IDisplayChangedEventArgs>;
  35271. /** @hidden */
  35272. _prepareVRComponent(): void;
  35273. /** @hidden */
  35274. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  35275. /** @hidden */
  35276. _submitVRFrame(): void;
  35277. /**
  35278. * Call this function to leave webVR mode
  35279. * Will do nothing if webVR is not supported or if there is no webVR device
  35280. * @see http://doc.babylonjs.com/how_to/webvr_camera
  35281. */
  35282. disableVR(): void;
  35283. /**
  35284. * Gets a boolean indicating that the system is in VR mode and is presenting
  35285. * @returns true if VR mode is engaged
  35286. */
  35287. isVRPresenting(): boolean;
  35288. /** @hidden */
  35289. _requestVRFrame(): void;
  35290. /** @hidden */
  35291. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  35292. /**
  35293. * Gets the source code of the vertex shader associated with a specific webGL program
  35294. * @param program defines the program to use
  35295. * @returns a string containing the source code of the vertex shader associated with the program
  35296. */
  35297. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  35298. /**
  35299. * Gets the source code of the fragment shader associated with a specific webGL program
  35300. * @param program defines the program to use
  35301. * @returns a string containing the source code of the fragment shader associated with the program
  35302. */
  35303. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  35304. /**
  35305. * Sets a depth stencil texture from a render target to the according uniform.
  35306. * @param channel The texture channel
  35307. * @param uniform The uniform to set
  35308. * @param texture The render target texture containing the depth stencil texture to apply
  35309. */
  35310. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  35311. /**
  35312. * Sets a texture to the webGL context from a postprocess
  35313. * @param channel defines the channel to use
  35314. * @param postProcess defines the source postprocess
  35315. */
  35316. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  35317. /**
  35318. * Binds the output of the passed in post process to the texture channel specified
  35319. * @param channel The channel the texture should be bound to
  35320. * @param postProcess The post process which's output should be bound
  35321. */
  35322. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  35323. protected _rebuildBuffers(): void;
  35324. /** @hidden */
  35325. _renderFrame(): void;
  35326. _renderLoop(): void;
  35327. /** @hidden */
  35328. _renderViews(): boolean;
  35329. /**
  35330. * Toggle full screen mode
  35331. * @param requestPointerLock defines if a pointer lock should be requested from the user
  35332. */
  35333. switchFullscreen(requestPointerLock: boolean): void;
  35334. /**
  35335. * Enters full screen mode
  35336. * @param requestPointerLock defines if a pointer lock should be requested from the user
  35337. */
  35338. enterFullscreen(requestPointerLock: boolean): void;
  35339. /**
  35340. * Exits full screen mode
  35341. */
  35342. exitFullscreen(): void;
  35343. /**
  35344. * Enters Pointerlock mode
  35345. */
  35346. enterPointerlock(): void;
  35347. /**
  35348. * Exits Pointerlock mode
  35349. */
  35350. exitPointerlock(): void;
  35351. /**
  35352. * Begin a new frame
  35353. */
  35354. beginFrame(): void;
  35355. /**
  35356. * Enf the current frame
  35357. */
  35358. endFrame(): void;
  35359. resize(): void;
  35360. /**
  35361. * Force a specific size of the canvas
  35362. * @param width defines the new canvas' width
  35363. * @param height defines the new canvas' height
  35364. */
  35365. setSize(width: number, height: number): void;
  35366. /**
  35367. * Updates a dynamic vertex buffer.
  35368. * @param vertexBuffer the vertex buffer to update
  35369. * @param data the data used to update the vertex buffer
  35370. * @param byteOffset the byte offset of the data
  35371. * @param byteLength the byte length of the data
  35372. */
  35373. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  35374. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  35375. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  35376. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  35377. _releaseTexture(texture: InternalTexture): void;
  35378. /**
  35379. * @hidden
  35380. * Rescales a texture
  35381. * @param source input texutre
  35382. * @param destination destination texture
  35383. * @param scene scene to use to render the resize
  35384. * @param internalFormat format to use when resizing
  35385. * @param onComplete callback to be called when resize has completed
  35386. */
  35387. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  35388. /**
  35389. * Gets the current framerate
  35390. * @returns a number representing the framerate
  35391. */
  35392. getFps(): number;
  35393. /**
  35394. * Gets the time spent between current and previous frame
  35395. * @returns a number representing the delta time in ms
  35396. */
  35397. getDeltaTime(): number;
  35398. private _measureFps;
  35399. /** @hidden */
  35400. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  35401. /**
  35402. * Update a dynamic index buffer
  35403. * @param indexBuffer defines the target index buffer
  35404. * @param indices defines the data to update
  35405. * @param offset defines the offset in the target index buffer where update should start
  35406. */
  35407. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  35408. /**
  35409. * Updates the sample count of a render target texture
  35410. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  35411. * @param texture defines the texture to update
  35412. * @param samples defines the sample count to set
  35413. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  35414. */
  35415. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  35416. /**
  35417. * Updates a depth texture Comparison Mode and Function.
  35418. * If the comparison Function is equal to 0, the mode will be set to none.
  35419. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  35420. * @param texture The texture to set the comparison function for
  35421. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  35422. */
  35423. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  35424. /**
  35425. * Creates a webGL buffer to use with instanciation
  35426. * @param capacity defines the size of the buffer
  35427. * @returns the webGL buffer
  35428. */
  35429. createInstancesBuffer(capacity: number): DataBuffer;
  35430. /**
  35431. * Delete a webGL buffer used with instanciation
  35432. * @param buffer defines the webGL buffer to delete
  35433. */
  35434. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  35435. private _clientWaitAsync;
  35436. /** @hidden */
  35437. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  35438. dispose(): void;
  35439. private _disableTouchAction;
  35440. /**
  35441. * Display the loading screen
  35442. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  35443. */
  35444. displayLoadingUI(): void;
  35445. /**
  35446. * Hide the loading screen
  35447. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  35448. */
  35449. hideLoadingUI(): void;
  35450. /**
  35451. * Gets the current loading screen object
  35452. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  35453. */
  35454. get loadingScreen(): ILoadingScreen;
  35455. /**
  35456. * Sets the current loading screen object
  35457. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  35458. */
  35459. set loadingScreen(loadingScreen: ILoadingScreen);
  35460. /**
  35461. * Sets the current loading screen text
  35462. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  35463. */
  35464. set loadingUIText(text: string);
  35465. /**
  35466. * Sets the current loading screen background color
  35467. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  35468. */
  35469. set loadingUIBackgroundColor(color: string);
  35470. /** Pointerlock and fullscreen */
  35471. /**
  35472. * Ask the browser to promote the current element to pointerlock mode
  35473. * @param element defines the DOM element to promote
  35474. */
  35475. static _RequestPointerlock(element: HTMLElement): void;
  35476. /**
  35477. * Asks the browser to exit pointerlock mode
  35478. */
  35479. static _ExitPointerlock(): void;
  35480. /**
  35481. * Ask the browser to promote the current element to fullscreen rendering mode
  35482. * @param element defines the DOM element to promote
  35483. */
  35484. static _RequestFullscreen(element: HTMLElement): void;
  35485. /**
  35486. * Asks the browser to exit fullscreen mode
  35487. */
  35488. static _ExitFullscreen(): void;
  35489. }
  35490. }
  35491. declare module "babylonjs/Engines/engineStore" {
  35492. import { Nullable } from "babylonjs/types";
  35493. import { Engine } from "babylonjs/Engines/engine";
  35494. import { Scene } from "babylonjs/scene";
  35495. /**
  35496. * The engine store class is responsible to hold all the instances of Engine and Scene created
  35497. * during the life time of the application.
  35498. */
  35499. export class EngineStore {
  35500. /** Gets the list of created engines */
  35501. static Instances: import("babylonjs/Engines/engine").Engine[];
  35502. /** @hidden */
  35503. static _LastCreatedScene: Nullable<Scene>;
  35504. /**
  35505. * Gets the latest created engine
  35506. */
  35507. static get LastCreatedEngine(): Nullable<Engine>;
  35508. /**
  35509. * Gets the latest created scene
  35510. */
  35511. static get LastCreatedScene(): Nullable<Scene>;
  35512. /**
  35513. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  35514. * @ignorenaming
  35515. */
  35516. static UseFallbackTexture: boolean;
  35517. /**
  35518. * Texture content used if a texture cannot loaded
  35519. * @ignorenaming
  35520. */
  35521. static FallbackTexture: string;
  35522. }
  35523. }
  35524. declare module "babylonjs/Misc/promise" {
  35525. /**
  35526. * Helper class that provides a small promise polyfill
  35527. */
  35528. export class PromisePolyfill {
  35529. /**
  35530. * Static function used to check if the polyfill is required
  35531. * If this is the case then the function will inject the polyfill to window.Promise
  35532. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  35533. */
  35534. static Apply(force?: boolean): void;
  35535. }
  35536. }
  35537. declare module "babylonjs/Misc/interfaces/screenshotSize" {
  35538. /**
  35539. * Interface for screenshot methods with describe argument called `size` as object with options
  35540. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  35541. */
  35542. export interface IScreenshotSize {
  35543. /**
  35544. * number in pixels for canvas height
  35545. */
  35546. height?: number;
  35547. /**
  35548. * multiplier allowing render at a higher or lower resolution
  35549. * If value is defined then height and width will be ignored and taken from camera
  35550. */
  35551. precision?: number;
  35552. /**
  35553. * number in pixels for canvas width
  35554. */
  35555. width?: number;
  35556. }
  35557. }
  35558. declare module "babylonjs/Misc/tools" {
  35559. import { Nullable, float } from "babylonjs/types";
  35560. import { DomManagement } from "babylonjs/Misc/domManagement";
  35561. import { WebRequest } from "babylonjs/Misc/webRequest";
  35562. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  35563. import { ReadFileError } from "babylonjs/Misc/fileTools";
  35564. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  35565. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  35566. import { Camera } from "babylonjs/Cameras/camera";
  35567. import { Engine } from "babylonjs/Engines/engine";
  35568. interface IColor4Like {
  35569. r: float;
  35570. g: float;
  35571. b: float;
  35572. a: float;
  35573. }
  35574. /**
  35575. * Class containing a set of static utilities functions
  35576. */
  35577. export class Tools {
  35578. /**
  35579. * Gets or sets the base URL to use to load assets
  35580. */
  35581. static get BaseUrl(): string;
  35582. static set BaseUrl(value: string);
  35583. /**
  35584. * Enable/Disable Custom HTTP Request Headers globally.
  35585. * default = false
  35586. * @see CustomRequestHeaders
  35587. */
  35588. static UseCustomRequestHeaders: boolean;
  35589. /**
  35590. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  35591. * i.e. when loading files, where the server/service expects an Authorization header
  35592. */
  35593. static CustomRequestHeaders: {
  35594. [key: string]: string;
  35595. };
  35596. /**
  35597. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  35598. */
  35599. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  35600. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  35601. /**
  35602. * Default behaviour for cors in the application.
  35603. * It can be a string if the expected behavior is identical in the entire app.
  35604. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  35605. */
  35606. static get CorsBehavior(): string | ((url: string | string[]) => string);
  35607. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  35608. /**
  35609. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  35610. * @ignorenaming
  35611. */
  35612. static get UseFallbackTexture(): boolean;
  35613. static set UseFallbackTexture(value: boolean);
  35614. /**
  35615. * Use this object to register external classes like custom textures or material
  35616. * to allow the laoders to instantiate them
  35617. */
  35618. static get RegisteredExternalClasses(): {
  35619. [key: string]: Object;
  35620. };
  35621. static set RegisteredExternalClasses(classes: {
  35622. [key: string]: Object;
  35623. });
  35624. /**
  35625. * Texture content used if a texture cannot loaded
  35626. * @ignorenaming
  35627. */
  35628. static get fallbackTexture(): string;
  35629. static set fallbackTexture(value: string);
  35630. /**
  35631. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  35632. * @param u defines the coordinate on X axis
  35633. * @param v defines the coordinate on Y axis
  35634. * @param width defines the width of the source data
  35635. * @param height defines the height of the source data
  35636. * @param pixels defines the source byte array
  35637. * @param color defines the output color
  35638. */
  35639. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  35640. /**
  35641. * Interpolates between a and b via alpha
  35642. * @param a The lower value (returned when alpha = 0)
  35643. * @param b The upper value (returned when alpha = 1)
  35644. * @param alpha The interpolation-factor
  35645. * @return The mixed value
  35646. */
  35647. static Mix(a: number, b: number, alpha: number): number;
  35648. /**
  35649. * Tries to instantiate a new object from a given class name
  35650. * @param className defines the class name to instantiate
  35651. * @returns the new object or null if the system was not able to do the instantiation
  35652. */
  35653. static Instantiate(className: string): any;
  35654. /**
  35655. * Provides a slice function that will work even on IE
  35656. * @param data defines the array to slice
  35657. * @param start defines the start of the data (optional)
  35658. * @param end defines the end of the data (optional)
  35659. * @returns the new sliced array
  35660. */
  35661. static Slice<T>(data: T, start?: number, end?: number): T;
  35662. /**
  35663. * Polyfill for setImmediate
  35664. * @param action defines the action to execute after the current execution block
  35665. */
  35666. static SetImmediate(action: () => void): void;
  35667. /**
  35668. * Function indicating if a number is an exponent of 2
  35669. * @param value defines the value to test
  35670. * @returns true if the value is an exponent of 2
  35671. */
  35672. static IsExponentOfTwo(value: number): boolean;
  35673. private static _tmpFloatArray;
  35674. /**
  35675. * Returns the nearest 32-bit single precision float representation of a Number
  35676. * @param value A Number. If the parameter is of a different type, it will get converted
  35677. * to a number or to NaN if it cannot be converted
  35678. * @returns number
  35679. */
  35680. static FloatRound(value: number): number;
  35681. /**
  35682. * Extracts the filename from a path
  35683. * @param path defines the path to use
  35684. * @returns the filename
  35685. */
  35686. static GetFilename(path: string): string;
  35687. /**
  35688. * Extracts the "folder" part of a path (everything before the filename).
  35689. * @param uri The URI to extract the info from
  35690. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  35691. * @returns The "folder" part of the path
  35692. */
  35693. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  35694. /**
  35695. * Extracts text content from a DOM element hierarchy
  35696. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  35697. */
  35698. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  35699. /**
  35700. * Convert an angle in radians to degrees
  35701. * @param angle defines the angle to convert
  35702. * @returns the angle in degrees
  35703. */
  35704. static ToDegrees(angle: number): number;
  35705. /**
  35706. * Convert an angle in degrees to radians
  35707. * @param angle defines the angle to convert
  35708. * @returns the angle in radians
  35709. */
  35710. static ToRadians(angle: number): number;
  35711. /**
  35712. * Returns an array if obj is not an array
  35713. * @param obj defines the object to evaluate as an array
  35714. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  35715. * @returns either obj directly if obj is an array or a new array containing obj
  35716. */
  35717. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  35718. /**
  35719. * Gets the pointer prefix to use
  35720. * @returns "pointer" if touch is enabled. Else returns "mouse"
  35721. */
  35722. static GetPointerPrefix(): string;
  35723. /**
  35724. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  35725. * @param url define the url we are trying
  35726. * @param element define the dom element where to configure the cors policy
  35727. */
  35728. static SetCorsBehavior(url: string | string[], element: {
  35729. crossOrigin: string | null;
  35730. }): void;
  35731. /**
  35732. * Removes unwanted characters from an url
  35733. * @param url defines the url to clean
  35734. * @returns the cleaned url
  35735. */
  35736. static CleanUrl(url: string): string;
  35737. /**
  35738. * Gets or sets a function used to pre-process url before using them to load assets
  35739. */
  35740. static get PreprocessUrl(): (url: string) => string;
  35741. static set PreprocessUrl(processor: (url: string) => string);
  35742. /**
  35743. * Loads an image as an HTMLImageElement.
  35744. * @param input url string, ArrayBuffer, or Blob to load
  35745. * @param onLoad callback called when the image successfully loads
  35746. * @param onError callback called when the image fails to load
  35747. * @param offlineProvider offline provider for caching
  35748. * @param mimeType optional mime type
  35749. * @returns the HTMLImageElement of the loaded image
  35750. */
  35751. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  35752. /**
  35753. * Loads a file from a url
  35754. * @param url url string, ArrayBuffer, or Blob to load
  35755. * @param onSuccess callback called when the file successfully loads
  35756. * @param onProgress callback called while file is loading (if the server supports this mode)
  35757. * @param offlineProvider defines the offline provider for caching
  35758. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  35759. * @param onError callback called when the file fails to load
  35760. * @returns a file request object
  35761. */
  35762. 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;
  35763. /**
  35764. * Loads a file from a url
  35765. * @param url the file url to load
  35766. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  35767. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  35768. */
  35769. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  35770. /**
  35771. * Load a script (identified by an url). When the url returns, the
  35772. * content of this file is added into a new script element, attached to the DOM (body element)
  35773. * @param scriptUrl defines the url of the script to laod
  35774. * @param onSuccess defines the callback called when the script is loaded
  35775. * @param onError defines the callback to call if an error occurs
  35776. * @param scriptId defines the id of the script element
  35777. */
  35778. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  35779. /**
  35780. * Load an asynchronous script (identified by an url). When the url returns, the
  35781. * content of this file is added into a new script element, attached to the DOM (body element)
  35782. * @param scriptUrl defines the url of the script to laod
  35783. * @param scriptId defines the id of the script element
  35784. * @returns a promise request object
  35785. */
  35786. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  35787. /**
  35788. * Loads a file from a blob
  35789. * @param fileToLoad defines the blob to use
  35790. * @param callback defines the callback to call when data is loaded
  35791. * @param progressCallback defines the callback to call during loading process
  35792. * @returns a file request object
  35793. */
  35794. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  35795. /**
  35796. * Reads a file from a File object
  35797. * @param file defines the file to load
  35798. * @param onSuccess defines the callback to call when data is loaded
  35799. * @param onProgress defines the callback to call during loading process
  35800. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  35801. * @param onError defines the callback to call when an error occurs
  35802. * @returns a file request object
  35803. */
  35804. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  35805. /**
  35806. * Creates a data url from a given string content
  35807. * @param content defines the content to convert
  35808. * @returns the new data url link
  35809. */
  35810. static FileAsURL(content: string): string;
  35811. /**
  35812. * Format the given number to a specific decimal format
  35813. * @param value defines the number to format
  35814. * @param decimals defines the number of decimals to use
  35815. * @returns the formatted string
  35816. */
  35817. static Format(value: number, decimals?: number): string;
  35818. /**
  35819. * Tries to copy an object by duplicating every property
  35820. * @param source defines the source object
  35821. * @param destination defines the target object
  35822. * @param doNotCopyList defines a list of properties to avoid
  35823. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  35824. */
  35825. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  35826. /**
  35827. * Gets a boolean indicating if the given object has no own property
  35828. * @param obj defines the object to test
  35829. * @returns true if object has no own property
  35830. */
  35831. static IsEmpty(obj: any): boolean;
  35832. /**
  35833. * Function used to register events at window level
  35834. * @param windowElement defines the Window object to use
  35835. * @param events defines the events to register
  35836. */
  35837. static RegisterTopRootEvents(windowElement: Window, events: {
  35838. name: string;
  35839. handler: Nullable<(e: FocusEvent) => any>;
  35840. }[]): void;
  35841. /**
  35842. * Function used to unregister events from window level
  35843. * @param windowElement defines the Window object to use
  35844. * @param events defines the events to unregister
  35845. */
  35846. static UnregisterTopRootEvents(windowElement: Window, events: {
  35847. name: string;
  35848. handler: Nullable<(e: FocusEvent) => any>;
  35849. }[]): void;
  35850. /**
  35851. * @ignore
  35852. */
  35853. static _ScreenshotCanvas: HTMLCanvasElement;
  35854. /**
  35855. * Dumps the current bound framebuffer
  35856. * @param width defines the rendering width
  35857. * @param height defines the rendering height
  35858. * @param engine defines the hosting engine
  35859. * @param successCallback defines the callback triggered once the data are available
  35860. * @param mimeType defines the mime type of the result
  35861. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  35862. */
  35863. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  35864. /**
  35865. * Converts the canvas data to blob.
  35866. * This acts as a polyfill for browsers not supporting the to blob function.
  35867. * @param canvas Defines the canvas to extract the data from
  35868. * @param successCallback Defines the callback triggered once the data are available
  35869. * @param mimeType Defines the mime type of the result
  35870. */
  35871. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  35872. /**
  35873. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  35874. * @param successCallback defines the callback triggered once the data are available
  35875. * @param mimeType defines the mime type of the result
  35876. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  35877. */
  35878. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  35879. /**
  35880. * Downloads a blob in the browser
  35881. * @param blob defines the blob to download
  35882. * @param fileName defines the name of the downloaded file
  35883. */
  35884. static Download(blob: Blob, fileName: string): void;
  35885. /**
  35886. * Captures a screenshot of the current rendering
  35887. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  35888. * @param engine defines the rendering engine
  35889. * @param camera defines the source camera
  35890. * @param size This parameter can be set to a single number or to an object with the
  35891. * following (optional) properties: precision, width, height. If a single number is passed,
  35892. * it will be used for both width and height. If an object is passed, the screenshot size
  35893. * will be derived from the parameters. The precision property is a multiplier allowing
  35894. * rendering at a higher or lower resolution
  35895. * @param successCallback defines the callback receives a single parameter which contains the
  35896. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  35897. * src parameter of an <img> to display it
  35898. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  35899. * Check your browser for supported MIME types
  35900. */
  35901. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  35902. /**
  35903. * Captures a screenshot of the current rendering
  35904. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  35905. * @param engine defines the rendering engine
  35906. * @param camera defines the source camera
  35907. * @param size This parameter can be set to a single number or to an object with the
  35908. * following (optional) properties: precision, width, height. If a single number is passed,
  35909. * it will be used for both width and height. If an object is passed, the screenshot size
  35910. * will be derived from the parameters. The precision property is a multiplier allowing
  35911. * rendering at a higher or lower resolution
  35912. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  35913. * Check your browser for supported MIME types
  35914. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  35915. * to the src parameter of an <img> to display it
  35916. */
  35917. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  35918. /**
  35919. * Generates an image screenshot from the specified camera.
  35920. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  35921. * @param engine The engine to use for rendering
  35922. * @param camera The camera to use for rendering
  35923. * @param size This parameter can be set to a single number or to an object with the
  35924. * following (optional) properties: precision, width, height. If a single number is passed,
  35925. * it will be used for both width and height. If an object is passed, the screenshot size
  35926. * will be derived from the parameters. The precision property is a multiplier allowing
  35927. * rendering at a higher or lower resolution
  35928. * @param successCallback The callback receives a single parameter which contains the
  35929. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  35930. * src parameter of an <img> to display it
  35931. * @param mimeType The MIME type of the screenshot image (default: image/png).
  35932. * Check your browser for supported MIME types
  35933. * @param samples Texture samples (default: 1)
  35934. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  35935. * @param fileName A name for for the downloaded file.
  35936. */
  35937. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  35938. /**
  35939. * Generates an image screenshot from the specified camera.
  35940. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  35941. * @param engine The engine to use for rendering
  35942. * @param camera The camera to use for rendering
  35943. * @param size This parameter can be set to a single number or to an object with the
  35944. * following (optional) properties: precision, width, height. If a single number is passed,
  35945. * it will be used for both width and height. If an object is passed, the screenshot size
  35946. * will be derived from the parameters. The precision property is a multiplier allowing
  35947. * rendering at a higher or lower resolution
  35948. * @param mimeType The MIME type of the screenshot image (default: image/png).
  35949. * Check your browser for supported MIME types
  35950. * @param samples Texture samples (default: 1)
  35951. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  35952. * @param fileName A name for for the downloaded file.
  35953. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  35954. * to the src parameter of an <img> to display it
  35955. */
  35956. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  35957. /**
  35958. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  35959. * Be aware Math.random() could cause collisions, but:
  35960. * "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"
  35961. * @returns a pseudo random id
  35962. */
  35963. static RandomId(): string;
  35964. /**
  35965. * Test if the given uri is a base64 string
  35966. * @param uri The uri to test
  35967. * @return True if the uri is a base64 string or false otherwise
  35968. */
  35969. static IsBase64(uri: string): boolean;
  35970. /**
  35971. * Decode the given base64 uri.
  35972. * @param uri The uri to decode
  35973. * @return The decoded base64 data.
  35974. */
  35975. static DecodeBase64(uri: string): ArrayBuffer;
  35976. /**
  35977. * Gets the absolute url.
  35978. * @param url the input url
  35979. * @return the absolute url
  35980. */
  35981. static GetAbsoluteUrl(url: string): string;
  35982. /**
  35983. * No log
  35984. */
  35985. static readonly NoneLogLevel: number;
  35986. /**
  35987. * Only message logs
  35988. */
  35989. static readonly MessageLogLevel: number;
  35990. /**
  35991. * Only warning logs
  35992. */
  35993. static readonly WarningLogLevel: number;
  35994. /**
  35995. * Only error logs
  35996. */
  35997. static readonly ErrorLogLevel: number;
  35998. /**
  35999. * All logs
  36000. */
  36001. static readonly AllLogLevel: number;
  36002. /**
  36003. * Gets a value indicating the number of loading errors
  36004. * @ignorenaming
  36005. */
  36006. static get errorsCount(): number;
  36007. /**
  36008. * Callback called when a new log is added
  36009. */
  36010. static OnNewCacheEntry: (entry: string) => void;
  36011. /**
  36012. * Log a message to the console
  36013. * @param message defines the message to log
  36014. */
  36015. static Log(message: string): void;
  36016. /**
  36017. * Write a warning message to the console
  36018. * @param message defines the message to log
  36019. */
  36020. static Warn(message: string): void;
  36021. /**
  36022. * Write an error message to the console
  36023. * @param message defines the message to log
  36024. */
  36025. static Error(message: string): void;
  36026. /**
  36027. * Gets current log cache (list of logs)
  36028. */
  36029. static get LogCache(): string;
  36030. /**
  36031. * Clears the log cache
  36032. */
  36033. static ClearLogCache(): void;
  36034. /**
  36035. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  36036. */
  36037. static set LogLevels(level: number);
  36038. /**
  36039. * Checks if the window object exists
  36040. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  36041. */
  36042. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  36043. /**
  36044. * No performance log
  36045. */
  36046. static readonly PerformanceNoneLogLevel: number;
  36047. /**
  36048. * Use user marks to log performance
  36049. */
  36050. static readonly PerformanceUserMarkLogLevel: number;
  36051. /**
  36052. * Log performance to the console
  36053. */
  36054. static readonly PerformanceConsoleLogLevel: number;
  36055. private static _performance;
  36056. /**
  36057. * Sets the current performance log level
  36058. */
  36059. static set PerformanceLogLevel(level: number);
  36060. private static _StartPerformanceCounterDisabled;
  36061. private static _EndPerformanceCounterDisabled;
  36062. private static _StartUserMark;
  36063. private static _EndUserMark;
  36064. private static _StartPerformanceConsole;
  36065. private static _EndPerformanceConsole;
  36066. /**
  36067. * Starts a performance counter
  36068. */
  36069. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  36070. /**
  36071. * Ends a specific performance coutner
  36072. */
  36073. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  36074. /**
  36075. * Gets either window.performance.now() if supported or Date.now() else
  36076. */
  36077. static get Now(): number;
  36078. /**
  36079. * This method will return the name of the class used to create the instance of the given object.
  36080. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  36081. * @param object the object to get the class name from
  36082. * @param isType defines if the object is actually a type
  36083. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  36084. */
  36085. static GetClassName(object: any, isType?: boolean): string;
  36086. /**
  36087. * Gets the first element of an array satisfying a given predicate
  36088. * @param array defines the array to browse
  36089. * @param predicate defines the predicate to use
  36090. * @returns null if not found or the element
  36091. */
  36092. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  36093. /**
  36094. * This method will return the name of the full name of the class, including its owning module (if any).
  36095. * 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).
  36096. * @param object the object to get the class name from
  36097. * @param isType defines if the object is actually a type
  36098. * @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.
  36099. * @ignorenaming
  36100. */
  36101. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  36102. /**
  36103. * Returns a promise that resolves after the given amount of time.
  36104. * @param delay Number of milliseconds to delay
  36105. * @returns Promise that resolves after the given amount of time
  36106. */
  36107. static DelayAsync(delay: number): Promise<void>;
  36108. /**
  36109. * Utility function to detect if the current user agent is Safari
  36110. * @returns whether or not the current user agent is safari
  36111. */
  36112. static IsSafari(): boolean;
  36113. }
  36114. /**
  36115. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  36116. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  36117. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  36118. * @param name The name of the class, case should be preserved
  36119. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  36120. */
  36121. export function className(name: string, module?: string): (target: Object) => void;
  36122. /**
  36123. * An implementation of a loop for asynchronous functions.
  36124. */
  36125. export class AsyncLoop {
  36126. /**
  36127. * Defines the number of iterations for the loop
  36128. */
  36129. iterations: number;
  36130. /**
  36131. * Defines the current index of the loop.
  36132. */
  36133. index: number;
  36134. private _done;
  36135. private _fn;
  36136. private _successCallback;
  36137. /**
  36138. * Constructor.
  36139. * @param iterations the number of iterations.
  36140. * @param func the function to run each iteration
  36141. * @param successCallback the callback that will be called upon succesful execution
  36142. * @param offset starting offset.
  36143. */
  36144. constructor(
  36145. /**
  36146. * Defines the number of iterations for the loop
  36147. */
  36148. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  36149. /**
  36150. * Execute the next iteration. Must be called after the last iteration was finished.
  36151. */
  36152. executeNext(): void;
  36153. /**
  36154. * Break the loop and run the success callback.
  36155. */
  36156. breakLoop(): void;
  36157. /**
  36158. * Create and run an async loop.
  36159. * @param iterations the number of iterations.
  36160. * @param fn the function to run each iteration
  36161. * @param successCallback the callback that will be called upon succesful execution
  36162. * @param offset starting offset.
  36163. * @returns the created async loop object
  36164. */
  36165. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  36166. /**
  36167. * A for-loop that will run a given number of iterations synchronous and the rest async.
  36168. * @param iterations total number of iterations
  36169. * @param syncedIterations number of synchronous iterations in each async iteration.
  36170. * @param fn the function to call each iteration.
  36171. * @param callback a success call back that will be called when iterating stops.
  36172. * @param breakFunction a break condition (optional)
  36173. * @param timeout timeout settings for the setTimeout function. default - 0.
  36174. * @returns the created async loop object
  36175. */
  36176. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  36177. }
  36178. }
  36179. declare module "babylonjs/Misc/stringDictionary" {
  36180. import { Nullable } from "babylonjs/types";
  36181. /**
  36182. * This class implement a typical dictionary using a string as key and the generic type T as value.
  36183. * The underlying implementation relies on an associative array to ensure the best performances.
  36184. * The value can be anything including 'null' but except 'undefined'
  36185. */
  36186. export class StringDictionary<T> {
  36187. /**
  36188. * This will clear this dictionary and copy the content from the 'source' one.
  36189. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  36190. * @param source the dictionary to take the content from and copy to this dictionary
  36191. */
  36192. copyFrom(source: StringDictionary<T>): void;
  36193. /**
  36194. * Get a value based from its key
  36195. * @param key the given key to get the matching value from
  36196. * @return the value if found, otherwise undefined is returned
  36197. */
  36198. get(key: string): T | undefined;
  36199. /**
  36200. * Get a value from its key or add it if it doesn't exist.
  36201. * This method will ensure you that a given key/data will be present in the dictionary.
  36202. * @param key the given key to get the matching value from
  36203. * @param factory the factory that will create the value if the key is not present in the dictionary.
  36204. * The factory will only be invoked if there's no data for the given key.
  36205. * @return the value corresponding to the key.
  36206. */
  36207. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  36208. /**
  36209. * Get a value from its key if present in the dictionary otherwise add it
  36210. * @param key the key to get the value from
  36211. * @param val if there's no such key/value pair in the dictionary add it with this value
  36212. * @return the value corresponding to the key
  36213. */
  36214. getOrAdd(key: string, val: T): T;
  36215. /**
  36216. * Check if there's a given key in the dictionary
  36217. * @param key the key to check for
  36218. * @return true if the key is present, false otherwise
  36219. */
  36220. contains(key: string): boolean;
  36221. /**
  36222. * Add a new key and its corresponding value
  36223. * @param key the key to add
  36224. * @param value the value corresponding to the key
  36225. * @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
  36226. */
  36227. add(key: string, value: T): boolean;
  36228. /**
  36229. * Update a specific value associated to a key
  36230. * @param key defines the key to use
  36231. * @param value defines the value to store
  36232. * @returns true if the value was updated (or false if the key was not found)
  36233. */
  36234. set(key: string, value: T): boolean;
  36235. /**
  36236. * Get the element of the given key and remove it from the dictionary
  36237. * @param key defines the key to search
  36238. * @returns the value associated with the key or null if not found
  36239. */
  36240. getAndRemove(key: string): Nullable<T>;
  36241. /**
  36242. * Remove a key/value from the dictionary.
  36243. * @param key the key to remove
  36244. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  36245. */
  36246. remove(key: string): boolean;
  36247. /**
  36248. * Clear the whole content of the dictionary
  36249. */
  36250. clear(): void;
  36251. /**
  36252. * Gets the current count
  36253. */
  36254. get count(): number;
  36255. /**
  36256. * Execute a callback on each key/val of the dictionary.
  36257. * Note that you can remove any element in this dictionary in the callback implementation
  36258. * @param callback the callback to execute on a given key/value pair
  36259. */
  36260. forEach(callback: (key: string, val: T) => void): void;
  36261. /**
  36262. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  36263. * If the callback returns null or undefined the method will iterate to the next key/value pair
  36264. * Note that you can remove any element in this dictionary in the callback implementation
  36265. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  36266. * @returns the first item
  36267. */
  36268. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  36269. private _count;
  36270. private _data;
  36271. }
  36272. }
  36273. declare module "babylonjs/Collisions/collisionCoordinator" {
  36274. import { Nullable } from "babylonjs/types";
  36275. import { Scene } from "babylonjs/scene";
  36276. import { Vector3 } from "babylonjs/Maths/math.vector";
  36277. import { Collider } from "babylonjs/Collisions/collider";
  36278. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36279. /** @hidden */
  36280. export interface ICollisionCoordinator {
  36281. createCollider(): Collider;
  36282. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  36283. init(scene: Scene): void;
  36284. }
  36285. /** @hidden */
  36286. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  36287. private _scene;
  36288. private _scaledPosition;
  36289. private _scaledVelocity;
  36290. private _finalPosition;
  36291. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  36292. createCollider(): Collider;
  36293. init(scene: Scene): void;
  36294. private _collideWithWorld;
  36295. }
  36296. }
  36297. declare module "babylonjs/Inputs/scene.inputManager" {
  36298. import { Nullable } from "babylonjs/types";
  36299. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  36300. import { Vector2 } from "babylonjs/Maths/math.vector";
  36301. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36302. import { Scene } from "babylonjs/scene";
  36303. /**
  36304. * Class used to manage all inputs for the scene.
  36305. */
  36306. export class InputManager {
  36307. /** The distance in pixel that you have to move to prevent some events */
  36308. static DragMovementThreshold: number;
  36309. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  36310. static LongPressDelay: number;
  36311. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  36312. static DoubleClickDelay: number;
  36313. /** If you need to check double click without raising a single click at first click, enable this flag */
  36314. static ExclusiveDoubleClickMode: boolean;
  36315. private _wheelEventName;
  36316. private _onPointerMove;
  36317. private _onPointerDown;
  36318. private _onPointerUp;
  36319. private _initClickEvent;
  36320. private _initActionManager;
  36321. private _delayedSimpleClick;
  36322. private _delayedSimpleClickTimeout;
  36323. private _previousDelayedSimpleClickTimeout;
  36324. private _meshPickProceed;
  36325. private _previousButtonPressed;
  36326. private _currentPickResult;
  36327. private _previousPickResult;
  36328. private _totalPointersPressed;
  36329. private _doubleClickOccured;
  36330. private _pointerOverMesh;
  36331. private _pickedDownMesh;
  36332. private _pickedUpMesh;
  36333. private _pointerX;
  36334. private _pointerY;
  36335. private _unTranslatedPointerX;
  36336. private _unTranslatedPointerY;
  36337. private _startingPointerPosition;
  36338. private _previousStartingPointerPosition;
  36339. private _startingPointerTime;
  36340. private _previousStartingPointerTime;
  36341. private _pointerCaptures;
  36342. private _onKeyDown;
  36343. private _onKeyUp;
  36344. private _onCanvasFocusObserver;
  36345. private _onCanvasBlurObserver;
  36346. private _scene;
  36347. /**
  36348. * Creates a new InputManager
  36349. * @param scene defines the hosting scene
  36350. */
  36351. constructor(scene: Scene);
  36352. /**
  36353. * Gets the mesh that is currently under the pointer
  36354. */
  36355. get meshUnderPointer(): Nullable<AbstractMesh>;
  36356. /**
  36357. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  36358. */
  36359. get unTranslatedPointer(): Vector2;
  36360. /**
  36361. * Gets or sets the current on-screen X position of the pointer
  36362. */
  36363. get pointerX(): number;
  36364. set pointerX(value: number);
  36365. /**
  36366. * Gets or sets the current on-screen Y position of the pointer
  36367. */
  36368. get pointerY(): number;
  36369. set pointerY(value: number);
  36370. private _updatePointerPosition;
  36371. private _processPointerMove;
  36372. private _setRayOnPointerInfo;
  36373. private _checkPrePointerObservable;
  36374. /**
  36375. * Use this method to simulate a pointer move on a mesh
  36376. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  36377. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  36378. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  36379. */
  36380. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  36381. /**
  36382. * Use this method to simulate a pointer down on a mesh
  36383. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  36384. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  36385. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  36386. */
  36387. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  36388. private _processPointerDown;
  36389. /** @hidden */
  36390. _isPointerSwiping(): boolean;
  36391. /**
  36392. * Use this method to simulate a pointer up on a mesh
  36393. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  36394. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  36395. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  36396. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  36397. */
  36398. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  36399. private _processPointerUp;
  36400. /**
  36401. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  36402. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  36403. * @returns true if the pointer was captured
  36404. */
  36405. isPointerCaptured(pointerId?: number): boolean;
  36406. /**
  36407. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  36408. * @param attachUp defines if you want to attach events to pointerup
  36409. * @param attachDown defines if you want to attach events to pointerdown
  36410. * @param attachMove defines if you want to attach events to pointermove
  36411. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  36412. */
  36413. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  36414. /**
  36415. * Detaches all event handlers
  36416. */
  36417. detachControl(): void;
  36418. /**
  36419. * Force the value of meshUnderPointer
  36420. * @param mesh defines the mesh to use
  36421. */
  36422. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  36423. /**
  36424. * Gets the mesh under the pointer
  36425. * @returns a Mesh or null if no mesh is under the pointer
  36426. */
  36427. getPointerOverMesh(): Nullable<AbstractMesh>;
  36428. }
  36429. }
  36430. declare module "babylonjs/Misc/uniqueIdGenerator" {
  36431. /**
  36432. * Helper class used to generate session unique ID
  36433. */
  36434. export class UniqueIdGenerator {
  36435. private static _UniqueIdCounter;
  36436. /**
  36437. * Gets an unique (relatively to the current scene) Id
  36438. */
  36439. static get UniqueId(): number;
  36440. }
  36441. }
  36442. declare module "babylonjs/Animations/animationGroup" {
  36443. import { Animatable } from "babylonjs/Animations/animatable";
  36444. import { Animation } from "babylonjs/Animations/animation";
  36445. import { Scene, IDisposable } from "babylonjs/scene";
  36446. import { Observable } from "babylonjs/Misc/observable";
  36447. import { Nullable } from "babylonjs/types";
  36448. import "babylonjs/Animations/animatable";
  36449. /**
  36450. * This class defines the direct association between an animation and a target
  36451. */
  36452. export class TargetedAnimation {
  36453. /**
  36454. * Animation to perform
  36455. */
  36456. animation: Animation;
  36457. /**
  36458. * Target to animate
  36459. */
  36460. target: any;
  36461. /**
  36462. * Serialize the object
  36463. * @returns the JSON object representing the current entity
  36464. */
  36465. serialize(): any;
  36466. }
  36467. /**
  36468. * Use this class to create coordinated animations on multiple targets
  36469. */
  36470. export class AnimationGroup implements IDisposable {
  36471. /** The name of the animation group */
  36472. name: string;
  36473. private _scene;
  36474. private _targetedAnimations;
  36475. private _animatables;
  36476. private _from;
  36477. private _to;
  36478. private _isStarted;
  36479. private _isPaused;
  36480. private _speedRatio;
  36481. private _loopAnimation;
  36482. private _isAdditive;
  36483. /**
  36484. * Gets or sets the unique id of the node
  36485. */
  36486. uniqueId: number;
  36487. /**
  36488. * This observable will notify when one animation have ended
  36489. */
  36490. onAnimationEndObservable: Observable<TargetedAnimation>;
  36491. /**
  36492. * Observer raised when one animation loops
  36493. */
  36494. onAnimationLoopObservable: Observable<TargetedAnimation>;
  36495. /**
  36496. * Observer raised when all animations have looped
  36497. */
  36498. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  36499. /**
  36500. * This observable will notify when all animations have ended.
  36501. */
  36502. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  36503. /**
  36504. * This observable will notify when all animations have paused.
  36505. */
  36506. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  36507. /**
  36508. * This observable will notify when all animations are playing.
  36509. */
  36510. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  36511. /**
  36512. * Gets the first frame
  36513. */
  36514. get from(): number;
  36515. /**
  36516. * Gets the last frame
  36517. */
  36518. get to(): number;
  36519. /**
  36520. * Define if the animations are started
  36521. */
  36522. get isStarted(): boolean;
  36523. /**
  36524. * Gets a value indicating that the current group is playing
  36525. */
  36526. get isPlaying(): boolean;
  36527. /**
  36528. * Gets or sets the speed ratio to use for all animations
  36529. */
  36530. get speedRatio(): number;
  36531. /**
  36532. * Gets or sets the speed ratio to use for all animations
  36533. */
  36534. set speedRatio(value: number);
  36535. /**
  36536. * Gets or sets if all animations should loop or not
  36537. */
  36538. get loopAnimation(): boolean;
  36539. set loopAnimation(value: boolean);
  36540. /**
  36541. * Gets or sets if all animations should be evaluated additively
  36542. */
  36543. get isAdditive(): boolean;
  36544. set isAdditive(value: boolean);
  36545. /**
  36546. * Gets the targeted animations for this animation group
  36547. */
  36548. get targetedAnimations(): Array<TargetedAnimation>;
  36549. /**
  36550. * returning the list of animatables controlled by this animation group.
  36551. */
  36552. get animatables(): Array<Animatable>;
  36553. /**
  36554. * Instantiates a new Animation Group.
  36555. * This helps managing several animations at once.
  36556. * @see http://doc.babylonjs.com/how_to/group
  36557. * @param name Defines the name of the group
  36558. * @param scene Defines the scene the group belongs to
  36559. */
  36560. constructor(
  36561. /** The name of the animation group */
  36562. name: string, scene?: Nullable<Scene>);
  36563. /**
  36564. * Add an animation (with its target) in the group
  36565. * @param animation defines the animation we want to add
  36566. * @param target defines the target of the animation
  36567. * @returns the TargetedAnimation object
  36568. */
  36569. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  36570. /**
  36571. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  36572. * It can add constant keys at begin or end
  36573. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  36574. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  36575. * @returns the animation group
  36576. */
  36577. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  36578. private _animationLoopCount;
  36579. private _animationLoopFlags;
  36580. private _processLoop;
  36581. /**
  36582. * Start all animations on given targets
  36583. * @param loop defines if animations must loop
  36584. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  36585. * @param from defines the from key (optional)
  36586. * @param to defines the to key (optional)
  36587. * @param isAdditive defines the additive state for the resulting animatables (optional)
  36588. * @returns the current animation group
  36589. */
  36590. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  36591. /**
  36592. * Pause all animations
  36593. * @returns the animation group
  36594. */
  36595. pause(): AnimationGroup;
  36596. /**
  36597. * Play all animations to initial state
  36598. * This function will start() the animations if they were not started or will restart() them if they were paused
  36599. * @param loop defines if animations must loop
  36600. * @returns the animation group
  36601. */
  36602. play(loop?: boolean): AnimationGroup;
  36603. /**
  36604. * Reset all animations to initial state
  36605. * @returns the animation group
  36606. */
  36607. reset(): AnimationGroup;
  36608. /**
  36609. * Restart animations from key 0
  36610. * @returns the animation group
  36611. */
  36612. restart(): AnimationGroup;
  36613. /**
  36614. * Stop all animations
  36615. * @returns the animation group
  36616. */
  36617. stop(): AnimationGroup;
  36618. /**
  36619. * Set animation weight for all animatables
  36620. * @param weight defines the weight to use
  36621. * @return the animationGroup
  36622. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  36623. */
  36624. setWeightForAllAnimatables(weight: number): AnimationGroup;
  36625. /**
  36626. * Synchronize and normalize all animatables with a source animatable
  36627. * @param root defines the root animatable to synchronize with
  36628. * @return the animationGroup
  36629. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  36630. */
  36631. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  36632. /**
  36633. * Goes to a specific frame in this animation group
  36634. * @param frame the frame number to go to
  36635. * @return the animationGroup
  36636. */
  36637. goToFrame(frame: number): AnimationGroup;
  36638. /**
  36639. * Dispose all associated resources
  36640. */
  36641. dispose(): void;
  36642. private _checkAnimationGroupEnded;
  36643. /**
  36644. * Clone the current animation group and returns a copy
  36645. * @param newName defines the name of the new group
  36646. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  36647. * @returns the new aniamtion group
  36648. */
  36649. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  36650. /**
  36651. * Serializes the animationGroup to an object
  36652. * @returns Serialized object
  36653. */
  36654. serialize(): any;
  36655. /**
  36656. * Returns a new AnimationGroup object parsed from the source provided.
  36657. * @param parsedAnimationGroup defines the source
  36658. * @param scene defines the scene that will receive the animationGroup
  36659. * @returns a new AnimationGroup
  36660. */
  36661. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  36662. /**
  36663. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  36664. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  36665. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  36666. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  36667. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  36668. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  36669. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  36670. */
  36671. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  36672. /**
  36673. * Returns the string "AnimationGroup"
  36674. * @returns "AnimationGroup"
  36675. */
  36676. getClassName(): string;
  36677. /**
  36678. * Creates a detailled string about the object
  36679. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  36680. * @returns a string representing the object
  36681. */
  36682. toString(fullDetails?: boolean): string;
  36683. }
  36684. }
  36685. declare module "babylonjs/scene" {
  36686. import { Nullable } from "babylonjs/types";
  36687. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  36688. import { Observable } from "babylonjs/Misc/observable";
  36689. import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  36690. import { Vector2, Vector3, Matrix } from "babylonjs/Maths/math.vector";
  36691. import { Geometry } from "babylonjs/Meshes/geometry";
  36692. import { TransformNode } from "babylonjs/Meshes/transformNode";
  36693. import { SubMesh } from "babylonjs/Meshes/subMesh";
  36694. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36695. import { Mesh } from "babylonjs/Meshes/mesh";
  36696. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  36697. import { Bone } from "babylonjs/Bones/bone";
  36698. import { Skeleton } from "babylonjs/Bones/skeleton";
  36699. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  36700. import { Camera } from "babylonjs/Cameras/camera";
  36701. import { AbstractScene } from "babylonjs/abstractScene";
  36702. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  36703. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  36704. import { Material } from "babylonjs/Materials/material";
  36705. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  36706. import { Effect } from "babylonjs/Materials/effect";
  36707. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  36708. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  36709. import { Light } from "babylonjs/Lights/light";
  36710. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  36711. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  36712. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  36713. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  36714. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  36715. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  36716. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  36717. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  36718. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, ActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction, CameraStageFrameBufferAction } from "babylonjs/sceneComponent";
  36719. import { Engine } from "babylonjs/Engines/engine";
  36720. import { Node } from "babylonjs/node";
  36721. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  36722. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  36723. import { WebRequest } from "babylonjs/Misc/webRequest";
  36724. import { InputManager } from "babylonjs/Inputs/scene.inputManager";
  36725. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  36726. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  36727. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  36728. import { Plane } from "babylonjs/Maths/math.plane";
  36729. import { LoadFileError, RequestFileError, ReadFileError } from "babylonjs/Misc/fileTools";
  36730. import { Ray } from "babylonjs/Culling/ray";
  36731. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  36732. import { Animation } from "babylonjs/Animations/animation";
  36733. import { Animatable } from "babylonjs/Animations/animatable";
  36734. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  36735. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  36736. import { Collider } from "babylonjs/Collisions/collider";
  36737. /**
  36738. * Define an interface for all classes that will hold resources
  36739. */
  36740. export interface IDisposable {
  36741. /**
  36742. * Releases all held resources
  36743. */
  36744. dispose(): void;
  36745. }
  36746. /** Interface defining initialization parameters for Scene class */
  36747. export interface SceneOptions {
  36748. /**
  36749. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  36750. * It will improve performance when the number of geometries becomes important.
  36751. */
  36752. useGeometryUniqueIdsMap?: boolean;
  36753. /**
  36754. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  36755. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  36756. */
  36757. useMaterialMeshMap?: boolean;
  36758. /**
  36759. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  36760. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  36761. */
  36762. useClonedMeshMap?: boolean;
  36763. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  36764. virtual?: boolean;
  36765. }
  36766. /**
  36767. * Represents a scene to be rendered by the engine.
  36768. * @see http://doc.babylonjs.com/features/scene
  36769. */
  36770. export class Scene extends AbstractScene implements IAnimatable {
  36771. /** The fog is deactivated */
  36772. static readonly FOGMODE_NONE: number;
  36773. /** The fog density is following an exponential function */
  36774. static readonly FOGMODE_EXP: number;
  36775. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  36776. static readonly FOGMODE_EXP2: number;
  36777. /** The fog density is following a linear function. */
  36778. static readonly FOGMODE_LINEAR: number;
  36779. /**
  36780. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  36781. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36782. */
  36783. static MinDeltaTime: number;
  36784. /**
  36785. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  36786. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36787. */
  36788. static MaxDeltaTime: number;
  36789. /**
  36790. * Factory used to create the default material.
  36791. * @param name The name of the material to create
  36792. * @param scene The scene to create the material for
  36793. * @returns The default material
  36794. */
  36795. static DefaultMaterialFactory(scene: Scene): Material;
  36796. /**
  36797. * Factory used to create the a collision coordinator.
  36798. * @returns The collision coordinator
  36799. */
  36800. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  36801. /** @hidden */
  36802. _inputManager: InputManager;
  36803. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  36804. cameraToUseForPointers: Nullable<Camera>;
  36805. /** @hidden */
  36806. readonly _isScene: boolean;
  36807. /** @hidden */
  36808. _blockEntityCollection: boolean;
  36809. /**
  36810. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  36811. */
  36812. autoClear: boolean;
  36813. /**
  36814. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  36815. */
  36816. autoClearDepthAndStencil: boolean;
  36817. /**
  36818. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  36819. */
  36820. clearColor: Color4;
  36821. /**
  36822. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  36823. */
  36824. ambientColor: Color3;
  36825. /**
  36826. * This is use to store the default BRDF lookup for PBR materials in your scene.
  36827. * It should only be one of the following (if not the default embedded one):
  36828. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  36829. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  36830. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  36831. * The material properties need to be setup according to the type of texture in use.
  36832. */
  36833. environmentBRDFTexture: BaseTexture;
  36834. /** @hidden */
  36835. protected _environmentTexture: Nullable<BaseTexture>;
  36836. /**
  36837. * Texture used in all pbr material as the reflection texture.
  36838. * As in the majority of the scene they are the same (exception for multi room and so on),
  36839. * this is easier to reference from here than from all the materials.
  36840. */
  36841. get environmentTexture(): Nullable<BaseTexture>;
  36842. /**
  36843. * Texture used in all pbr material as the reflection texture.
  36844. * As in the majority of the scene they are the same (exception for multi room and so on),
  36845. * this is easier to set here than in all the materials.
  36846. */
  36847. set environmentTexture(value: Nullable<BaseTexture>);
  36848. /** @hidden */
  36849. protected _environmentIntensity: number;
  36850. /**
  36851. * Intensity of the environment in all pbr material.
  36852. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  36853. * As in the majority of the scene they are the same (exception for multi room and so on),
  36854. * this is easier to reference from here than from all the materials.
  36855. */
  36856. get environmentIntensity(): number;
  36857. /**
  36858. * Intensity of the environment in all pbr material.
  36859. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  36860. * As in the majority of the scene they are the same (exception for multi room and so on),
  36861. * this is easier to set here than in all the materials.
  36862. */
  36863. set environmentIntensity(value: number);
  36864. /** @hidden */
  36865. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  36866. /**
  36867. * Default image processing configuration used either in the rendering
  36868. * Forward main pass or through the imageProcessingPostProcess if present.
  36869. * As in the majority of the scene they are the same (exception for multi camera),
  36870. * this is easier to reference from here than from all the materials and post process.
  36871. *
  36872. * No setter as we it is a shared configuration, you can set the values instead.
  36873. */
  36874. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  36875. private _forceWireframe;
  36876. /**
  36877. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  36878. */
  36879. set forceWireframe(value: boolean);
  36880. get forceWireframe(): boolean;
  36881. private _skipFrustumClipping;
  36882. /**
  36883. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  36884. */
  36885. set skipFrustumClipping(value: boolean);
  36886. get skipFrustumClipping(): boolean;
  36887. private _forcePointsCloud;
  36888. /**
  36889. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  36890. */
  36891. set forcePointsCloud(value: boolean);
  36892. get forcePointsCloud(): boolean;
  36893. /**
  36894. * Gets or sets the active clipplane 1
  36895. */
  36896. clipPlane: Nullable<Plane>;
  36897. /**
  36898. * Gets or sets the active clipplane 2
  36899. */
  36900. clipPlane2: Nullable<Plane>;
  36901. /**
  36902. * Gets or sets the active clipplane 3
  36903. */
  36904. clipPlane3: Nullable<Plane>;
  36905. /**
  36906. * Gets or sets the active clipplane 4
  36907. */
  36908. clipPlane4: Nullable<Plane>;
  36909. /**
  36910. * Gets or sets the active clipplane 5
  36911. */
  36912. clipPlane5: Nullable<Plane>;
  36913. /**
  36914. * Gets or sets the active clipplane 6
  36915. */
  36916. clipPlane6: Nullable<Plane>;
  36917. /**
  36918. * Gets or sets a boolean indicating if animations are enabled
  36919. */
  36920. animationsEnabled: boolean;
  36921. private _animationPropertiesOverride;
  36922. /**
  36923. * Gets or sets the animation properties override
  36924. */
  36925. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  36926. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  36927. /**
  36928. * Gets or sets a boolean indicating if a constant deltatime has to be used
  36929. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  36930. */
  36931. useConstantAnimationDeltaTime: boolean;
  36932. /**
  36933. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  36934. * Please note that it requires to run a ray cast through the scene on every frame
  36935. */
  36936. constantlyUpdateMeshUnderPointer: boolean;
  36937. /**
  36938. * Defines the HTML cursor to use when hovering over interactive elements
  36939. */
  36940. hoverCursor: string;
  36941. /**
  36942. * Defines the HTML default cursor to use (empty by default)
  36943. */
  36944. defaultCursor: string;
  36945. /**
  36946. * Defines whether cursors are handled by the scene.
  36947. */
  36948. doNotHandleCursors: boolean;
  36949. /**
  36950. * This is used to call preventDefault() on pointer down
  36951. * in order to block unwanted artifacts like system double clicks
  36952. */
  36953. preventDefaultOnPointerDown: boolean;
  36954. /**
  36955. * This is used to call preventDefault() on pointer up
  36956. * in order to block unwanted artifacts like system double clicks
  36957. */
  36958. preventDefaultOnPointerUp: boolean;
  36959. /**
  36960. * Gets or sets user defined metadata
  36961. */
  36962. metadata: any;
  36963. /**
  36964. * For internal use only. Please do not use.
  36965. */
  36966. reservedDataStore: any;
  36967. /**
  36968. * Gets the name of the plugin used to load this scene (null by default)
  36969. */
  36970. loadingPluginName: string;
  36971. /**
  36972. * Use this array to add regular expressions used to disable offline support for specific urls
  36973. */
  36974. disableOfflineSupportExceptionRules: RegExp[];
  36975. /**
  36976. * An event triggered when the scene is disposed.
  36977. */
  36978. onDisposeObservable: Observable<Scene>;
  36979. private _onDisposeObserver;
  36980. /** Sets a function to be executed when this scene is disposed. */
  36981. set onDispose(callback: () => void);
  36982. /**
  36983. * An event triggered before rendering the scene (right after animations and physics)
  36984. */
  36985. onBeforeRenderObservable: Observable<Scene>;
  36986. private _onBeforeRenderObserver;
  36987. /** Sets a function to be executed before rendering this scene */
  36988. set beforeRender(callback: Nullable<() => void>);
  36989. /**
  36990. * An event triggered after rendering the scene
  36991. */
  36992. onAfterRenderObservable: Observable<Scene>;
  36993. /**
  36994. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  36995. */
  36996. onAfterRenderCameraObservable: Observable<Camera>;
  36997. private _onAfterRenderObserver;
  36998. /** Sets a function to be executed after rendering this scene */
  36999. set afterRender(callback: Nullable<() => void>);
  37000. /**
  37001. * An event triggered before animating the scene
  37002. */
  37003. onBeforeAnimationsObservable: Observable<Scene>;
  37004. /**
  37005. * An event triggered after animations processing
  37006. */
  37007. onAfterAnimationsObservable: Observable<Scene>;
  37008. /**
  37009. * An event triggered before draw calls are ready to be sent
  37010. */
  37011. onBeforeDrawPhaseObservable: Observable<Scene>;
  37012. /**
  37013. * An event triggered after draw calls have been sent
  37014. */
  37015. onAfterDrawPhaseObservable: Observable<Scene>;
  37016. /**
  37017. * An event triggered when the scene is ready
  37018. */
  37019. onReadyObservable: Observable<Scene>;
  37020. /**
  37021. * An event triggered before rendering a camera
  37022. */
  37023. onBeforeCameraRenderObservable: Observable<Camera>;
  37024. private _onBeforeCameraRenderObserver;
  37025. /** Sets a function to be executed before rendering a camera*/
  37026. set beforeCameraRender(callback: () => void);
  37027. /**
  37028. * An event triggered after rendering a camera
  37029. */
  37030. onAfterCameraRenderObservable: Observable<Camera>;
  37031. private _onAfterCameraRenderObserver;
  37032. /** Sets a function to be executed after rendering a camera*/
  37033. set afterCameraRender(callback: () => void);
  37034. /**
  37035. * An event triggered when active meshes evaluation is about to start
  37036. */
  37037. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  37038. /**
  37039. * An event triggered when active meshes evaluation is done
  37040. */
  37041. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  37042. /**
  37043. * An event triggered when particles rendering is about to start
  37044. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  37045. */
  37046. onBeforeParticlesRenderingObservable: Observable<Scene>;
  37047. /**
  37048. * An event triggered when particles rendering is done
  37049. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  37050. */
  37051. onAfterParticlesRenderingObservable: Observable<Scene>;
  37052. /**
  37053. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  37054. */
  37055. onDataLoadedObservable: Observable<Scene>;
  37056. /**
  37057. * An event triggered when a camera is created
  37058. */
  37059. onNewCameraAddedObservable: Observable<Camera>;
  37060. /**
  37061. * An event triggered when a camera is removed
  37062. */
  37063. onCameraRemovedObservable: Observable<Camera>;
  37064. /**
  37065. * An event triggered when a light is created
  37066. */
  37067. onNewLightAddedObservable: Observable<Light>;
  37068. /**
  37069. * An event triggered when a light is removed
  37070. */
  37071. onLightRemovedObservable: Observable<Light>;
  37072. /**
  37073. * An event triggered when a geometry is created
  37074. */
  37075. onNewGeometryAddedObservable: Observable<Geometry>;
  37076. /**
  37077. * An event triggered when a geometry is removed
  37078. */
  37079. onGeometryRemovedObservable: Observable<Geometry>;
  37080. /**
  37081. * An event triggered when a transform node is created
  37082. */
  37083. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  37084. /**
  37085. * An event triggered when a transform node is removed
  37086. */
  37087. onTransformNodeRemovedObservable: Observable<TransformNode>;
  37088. /**
  37089. * An event triggered when a mesh is created
  37090. */
  37091. onNewMeshAddedObservable: Observable<AbstractMesh>;
  37092. /**
  37093. * An event triggered when a mesh is removed
  37094. */
  37095. onMeshRemovedObservable: Observable<AbstractMesh>;
  37096. /**
  37097. * An event triggered when a skeleton is created
  37098. */
  37099. onNewSkeletonAddedObservable: Observable<Skeleton>;
  37100. /**
  37101. * An event triggered when a skeleton is removed
  37102. */
  37103. onSkeletonRemovedObservable: Observable<Skeleton>;
  37104. /**
  37105. * An event triggered when a material is created
  37106. */
  37107. onNewMaterialAddedObservable: Observable<Material>;
  37108. /**
  37109. * An event triggered when a material is removed
  37110. */
  37111. onMaterialRemovedObservable: Observable<Material>;
  37112. /**
  37113. * An event triggered when a texture is created
  37114. */
  37115. onNewTextureAddedObservable: Observable<BaseTexture>;
  37116. /**
  37117. * An event triggered when a texture is removed
  37118. */
  37119. onTextureRemovedObservable: Observable<BaseTexture>;
  37120. /**
  37121. * An event triggered when render targets are about to be rendered
  37122. * Can happen multiple times per frame.
  37123. */
  37124. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  37125. /**
  37126. * An event triggered when render targets were rendered.
  37127. * Can happen multiple times per frame.
  37128. */
  37129. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  37130. /**
  37131. * An event triggered before calculating deterministic simulation step
  37132. */
  37133. onBeforeStepObservable: Observable<Scene>;
  37134. /**
  37135. * An event triggered after calculating deterministic simulation step
  37136. */
  37137. onAfterStepObservable: Observable<Scene>;
  37138. /**
  37139. * An event triggered when the activeCamera property is updated
  37140. */
  37141. onActiveCameraChanged: Observable<Scene>;
  37142. /**
  37143. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  37144. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  37145. * 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)
  37146. */
  37147. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  37148. /**
  37149. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  37150. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  37151. * 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)
  37152. */
  37153. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  37154. /**
  37155. * This Observable will when a mesh has been imported into the scene.
  37156. */
  37157. onMeshImportedObservable: Observable<AbstractMesh>;
  37158. /**
  37159. * This Observable will when an animation file has been imported into the scene.
  37160. */
  37161. onAnimationFileImportedObservable: Observable<Scene>;
  37162. /**
  37163. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  37164. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  37165. */
  37166. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  37167. /** @hidden */
  37168. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  37169. /**
  37170. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  37171. */
  37172. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  37173. /**
  37174. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  37175. */
  37176. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  37177. /**
  37178. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  37179. */
  37180. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  37181. /** Callback called when a pointer move is detected */
  37182. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  37183. /** Callback called when a pointer down is detected */
  37184. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  37185. /** Callback called when a pointer up is detected */
  37186. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  37187. /** Callback called when a pointer pick is detected */
  37188. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  37189. /**
  37190. * 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).
  37191. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  37192. */
  37193. onPrePointerObservable: Observable<PointerInfoPre>;
  37194. /**
  37195. * Observable event triggered each time an input event is received from the rendering canvas
  37196. */
  37197. onPointerObservable: Observable<PointerInfo>;
  37198. /**
  37199. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  37200. */
  37201. get unTranslatedPointer(): Vector2;
  37202. /**
  37203. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  37204. */
  37205. static get DragMovementThreshold(): number;
  37206. static set DragMovementThreshold(value: number);
  37207. /**
  37208. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  37209. */
  37210. static get LongPressDelay(): number;
  37211. static set LongPressDelay(value: number);
  37212. /**
  37213. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  37214. */
  37215. static get DoubleClickDelay(): number;
  37216. static set DoubleClickDelay(value: number);
  37217. /** If you need to check double click without raising a single click at first click, enable this flag */
  37218. static get ExclusiveDoubleClickMode(): boolean;
  37219. static set ExclusiveDoubleClickMode(value: boolean);
  37220. /** @hidden */
  37221. _mirroredCameraPosition: Nullable<Vector3>;
  37222. /**
  37223. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  37224. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  37225. */
  37226. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  37227. /**
  37228. * Observable event triggered each time an keyboard event is received from the hosting window
  37229. */
  37230. onKeyboardObservable: Observable<KeyboardInfo>;
  37231. private _useRightHandedSystem;
  37232. /**
  37233. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  37234. */
  37235. set useRightHandedSystem(value: boolean);
  37236. get useRightHandedSystem(): boolean;
  37237. private _timeAccumulator;
  37238. private _currentStepId;
  37239. private _currentInternalStep;
  37240. /**
  37241. * Sets the step Id used by deterministic lock step
  37242. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  37243. * @param newStepId defines the step Id
  37244. */
  37245. setStepId(newStepId: number): void;
  37246. /**
  37247. * Gets the step Id used by deterministic lock step
  37248. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  37249. * @returns the step Id
  37250. */
  37251. getStepId(): number;
  37252. /**
  37253. * Gets the internal step used by deterministic lock step
  37254. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  37255. * @returns the internal step
  37256. */
  37257. getInternalStep(): number;
  37258. private _fogEnabled;
  37259. /**
  37260. * Gets or sets a boolean indicating if fog is enabled on this scene
  37261. * @see http://doc.babylonjs.com/babylon101/environment#fog
  37262. * (Default is true)
  37263. */
  37264. set fogEnabled(value: boolean);
  37265. get fogEnabled(): boolean;
  37266. private _fogMode;
  37267. /**
  37268. * Gets or sets the fog mode to use
  37269. * @see http://doc.babylonjs.com/babylon101/environment#fog
  37270. * | mode | value |
  37271. * | --- | --- |
  37272. * | FOGMODE_NONE | 0 |
  37273. * | FOGMODE_EXP | 1 |
  37274. * | FOGMODE_EXP2 | 2 |
  37275. * | FOGMODE_LINEAR | 3 |
  37276. */
  37277. set fogMode(value: number);
  37278. get fogMode(): number;
  37279. /**
  37280. * Gets or sets the fog color to use
  37281. * @see http://doc.babylonjs.com/babylon101/environment#fog
  37282. * (Default is Color3(0.2, 0.2, 0.3))
  37283. */
  37284. fogColor: Color3;
  37285. /**
  37286. * Gets or sets the fog density to use
  37287. * @see http://doc.babylonjs.com/babylon101/environment#fog
  37288. * (Default is 0.1)
  37289. */
  37290. fogDensity: number;
  37291. /**
  37292. * Gets or sets the fog start distance to use
  37293. * @see http://doc.babylonjs.com/babylon101/environment#fog
  37294. * (Default is 0)
  37295. */
  37296. fogStart: number;
  37297. /**
  37298. * Gets or sets the fog end distance to use
  37299. * @see http://doc.babylonjs.com/babylon101/environment#fog
  37300. * (Default is 1000)
  37301. */
  37302. fogEnd: number;
  37303. private _shadowsEnabled;
  37304. /**
  37305. * Gets or sets a boolean indicating if shadows are enabled on this scene
  37306. */
  37307. set shadowsEnabled(value: boolean);
  37308. get shadowsEnabled(): boolean;
  37309. private _lightsEnabled;
  37310. /**
  37311. * Gets or sets a boolean indicating if lights are enabled on this scene
  37312. */
  37313. set lightsEnabled(value: boolean);
  37314. get lightsEnabled(): boolean;
  37315. /** All of the active cameras added to this scene. */
  37316. activeCameras: Camera[];
  37317. /** @hidden */
  37318. _activeCamera: Nullable<Camera>;
  37319. /** Gets or sets the current active camera */
  37320. get activeCamera(): Nullable<Camera>;
  37321. set activeCamera(value: Nullable<Camera>);
  37322. private _defaultMaterial;
  37323. /** The default material used on meshes when no material is affected */
  37324. get defaultMaterial(): Material;
  37325. /** The default material used on meshes when no material is affected */
  37326. set defaultMaterial(value: Material);
  37327. private _texturesEnabled;
  37328. /**
  37329. * Gets or sets a boolean indicating if textures are enabled on this scene
  37330. */
  37331. set texturesEnabled(value: boolean);
  37332. get texturesEnabled(): boolean;
  37333. /**
  37334. * Gets or sets a boolean indicating if physic engines are enabled on this scene
  37335. */
  37336. physicsEnabled: boolean;
  37337. /**
  37338. * Gets or sets a boolean indicating if particles are enabled on this scene
  37339. */
  37340. particlesEnabled: boolean;
  37341. /**
  37342. * Gets or sets a boolean indicating if sprites are enabled on this scene
  37343. */
  37344. spritesEnabled: boolean;
  37345. private _skeletonsEnabled;
  37346. /**
  37347. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  37348. */
  37349. set skeletonsEnabled(value: boolean);
  37350. get skeletonsEnabled(): boolean;
  37351. /**
  37352. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  37353. */
  37354. lensFlaresEnabled: boolean;
  37355. /**
  37356. * Gets or sets a boolean indicating if collisions are enabled on this scene
  37357. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  37358. */
  37359. collisionsEnabled: boolean;
  37360. private _collisionCoordinator;
  37361. /** @hidden */
  37362. get collisionCoordinator(): ICollisionCoordinator;
  37363. /**
  37364. * Defines the gravity applied to this scene (used only for collisions)
  37365. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  37366. */
  37367. gravity: Vector3;
  37368. /**
  37369. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  37370. */
  37371. postProcessesEnabled: boolean;
  37372. /**
  37373. * The list of postprocesses added to the scene
  37374. */
  37375. postProcesses: PostProcess[];
  37376. /**
  37377. * Gets the current postprocess manager
  37378. */
  37379. postProcessManager: PostProcessManager;
  37380. /**
  37381. * Gets or sets a boolean indicating if render targets are enabled on this scene
  37382. */
  37383. renderTargetsEnabled: boolean;
  37384. /**
  37385. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  37386. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  37387. */
  37388. dumpNextRenderTargets: boolean;
  37389. /**
  37390. * The list of user defined render targets added to the scene
  37391. */
  37392. customRenderTargets: RenderTargetTexture[];
  37393. /**
  37394. * Defines if texture loading must be delayed
  37395. * If true, textures will only be loaded when they need to be rendered
  37396. */
  37397. useDelayedTextureLoading: boolean;
  37398. /**
  37399. * Gets the list of meshes imported to the scene through SceneLoader
  37400. */
  37401. importedMeshesFiles: String[];
  37402. /**
  37403. * Gets or sets a boolean indicating if probes are enabled on this scene
  37404. */
  37405. probesEnabled: boolean;
  37406. /**
  37407. * Gets or sets the current offline provider to use to store scene data
  37408. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  37409. */
  37410. offlineProvider: IOfflineProvider;
  37411. /**
  37412. * Gets or sets the action manager associated with the scene
  37413. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  37414. */
  37415. actionManager: AbstractActionManager;
  37416. private _meshesForIntersections;
  37417. /**
  37418. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  37419. */
  37420. proceduralTexturesEnabled: boolean;
  37421. private _engine;
  37422. private _totalVertices;
  37423. /** @hidden */
  37424. _activeIndices: PerfCounter;
  37425. /** @hidden */
  37426. _activeParticles: PerfCounter;
  37427. /** @hidden */
  37428. _activeBones: PerfCounter;
  37429. private _animationRatio;
  37430. /** @hidden */
  37431. _animationTimeLast: number;
  37432. /** @hidden */
  37433. _animationTime: number;
  37434. /**
  37435. * Gets or sets a general scale for animation speed
  37436. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  37437. */
  37438. animationTimeScale: number;
  37439. /** @hidden */
  37440. _cachedMaterial: Nullable<Material>;
  37441. /** @hidden */
  37442. _cachedEffect: Nullable<Effect>;
  37443. /** @hidden */
  37444. _cachedVisibility: Nullable<number>;
  37445. private _renderId;
  37446. private _frameId;
  37447. private _executeWhenReadyTimeoutId;
  37448. private _intermediateRendering;
  37449. private _viewUpdateFlag;
  37450. private _projectionUpdateFlag;
  37451. /** @hidden */
  37452. _toBeDisposed: Nullable<IDisposable>[];
  37453. private _activeRequests;
  37454. /** @hidden */
  37455. _pendingData: any[];
  37456. private _isDisposed;
  37457. /**
  37458. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  37459. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  37460. */
  37461. dispatchAllSubMeshesOfActiveMeshes: boolean;
  37462. private _activeMeshes;
  37463. private _processedMaterials;
  37464. private _renderTargets;
  37465. /** @hidden */
  37466. _activeParticleSystems: SmartArray<IParticleSystem>;
  37467. private _activeSkeletons;
  37468. private _softwareSkinnedMeshes;
  37469. private _renderingManager;
  37470. /** @hidden */
  37471. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  37472. private _transformMatrix;
  37473. private _sceneUbo;
  37474. /** @hidden */
  37475. _viewMatrix: Matrix;
  37476. private _projectionMatrix;
  37477. /** @hidden */
  37478. _forcedViewPosition: Nullable<Vector3>;
  37479. /** @hidden */
  37480. _frustumPlanes: Plane[];
  37481. /**
  37482. * Gets the list of frustum planes (built from the active camera)
  37483. */
  37484. get frustumPlanes(): Plane[];
  37485. /**
  37486. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  37487. * This is useful if there are more lights that the maximum simulteanous authorized
  37488. */
  37489. requireLightSorting: boolean;
  37490. /** @hidden */
  37491. readonly useMaterialMeshMap: boolean;
  37492. /** @hidden */
  37493. readonly useClonedMeshMap: boolean;
  37494. private _externalData;
  37495. private _uid;
  37496. /**
  37497. * @hidden
  37498. * Backing store of defined scene components.
  37499. */
  37500. _components: ISceneComponent[];
  37501. /**
  37502. * @hidden
  37503. * Backing store of defined scene components.
  37504. */
  37505. _serializableComponents: ISceneSerializableComponent[];
  37506. /**
  37507. * List of components to register on the next registration step.
  37508. */
  37509. private _transientComponents;
  37510. /**
  37511. * Registers the transient components if needed.
  37512. */
  37513. private _registerTransientComponents;
  37514. /**
  37515. * @hidden
  37516. * Add a component to the scene.
  37517. * Note that the ccomponent could be registered on th next frame if this is called after
  37518. * the register component stage.
  37519. * @param component Defines the component to add to the scene
  37520. */
  37521. _addComponent(component: ISceneComponent): void;
  37522. /**
  37523. * @hidden
  37524. * Gets a component from the scene.
  37525. * @param name defines the name of the component to retrieve
  37526. * @returns the component or null if not present
  37527. */
  37528. _getComponent(name: string): Nullable<ISceneComponent>;
  37529. /**
  37530. * @hidden
  37531. * Defines the actions happening before camera updates.
  37532. */
  37533. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  37534. /**
  37535. * @hidden
  37536. * Defines the actions happening before clear the canvas.
  37537. */
  37538. _beforeClearStage: Stage<SimpleStageAction>;
  37539. /**
  37540. * @hidden
  37541. * Defines the actions when collecting render targets for the frame.
  37542. */
  37543. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  37544. /**
  37545. * @hidden
  37546. * Defines the actions happening for one camera in the frame.
  37547. */
  37548. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  37549. /**
  37550. * @hidden
  37551. * Defines the actions happening during the per mesh ready checks.
  37552. */
  37553. _isReadyForMeshStage: Stage<MeshStageAction>;
  37554. /**
  37555. * @hidden
  37556. * Defines the actions happening before evaluate active mesh checks.
  37557. */
  37558. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  37559. /**
  37560. * @hidden
  37561. * Defines the actions happening during the evaluate sub mesh checks.
  37562. */
  37563. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  37564. /**
  37565. * @hidden
  37566. * Defines the actions happening during the active mesh stage.
  37567. */
  37568. _activeMeshStage: Stage<ActiveMeshStageAction>;
  37569. /**
  37570. * @hidden
  37571. * Defines the actions happening during the per camera render target step.
  37572. */
  37573. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  37574. /**
  37575. * @hidden
  37576. * Defines the actions happening just before the active camera is drawing.
  37577. */
  37578. _beforeCameraDrawStage: Stage<CameraStageAction>;
  37579. /**
  37580. * @hidden
  37581. * Defines the actions happening just before a render target is drawing.
  37582. */
  37583. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  37584. /**
  37585. * @hidden
  37586. * Defines the actions happening just before a rendering group is drawing.
  37587. */
  37588. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  37589. /**
  37590. * @hidden
  37591. * Defines the actions happening just before a mesh is drawing.
  37592. */
  37593. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  37594. /**
  37595. * @hidden
  37596. * Defines the actions happening just after a mesh has been drawn.
  37597. */
  37598. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  37599. /**
  37600. * @hidden
  37601. * Defines the actions happening just after a rendering group has been drawn.
  37602. */
  37603. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  37604. /**
  37605. * @hidden
  37606. * Defines the actions happening just after the active camera has been drawn.
  37607. */
  37608. _afterCameraDrawStage: Stage<CameraStageAction>;
  37609. /**
  37610. * @hidden
  37611. * Defines the actions happening just after a render target has been drawn.
  37612. */
  37613. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  37614. /**
  37615. * @hidden
  37616. * Defines the actions happening just after rendering all cameras and computing intersections.
  37617. */
  37618. _afterRenderStage: Stage<SimpleStageAction>;
  37619. /**
  37620. * @hidden
  37621. * Defines the actions happening when a pointer move event happens.
  37622. */
  37623. _pointerMoveStage: Stage<PointerMoveStageAction>;
  37624. /**
  37625. * @hidden
  37626. * Defines the actions happening when a pointer down event happens.
  37627. */
  37628. _pointerDownStage: Stage<PointerUpDownStageAction>;
  37629. /**
  37630. * @hidden
  37631. * Defines the actions happening when a pointer up event happens.
  37632. */
  37633. _pointerUpStage: Stage<PointerUpDownStageAction>;
  37634. /**
  37635. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  37636. */
  37637. private geometriesByUniqueId;
  37638. /**
  37639. * Creates a new Scene
  37640. * @param engine defines the engine to use to render this scene
  37641. * @param options defines the scene options
  37642. */
  37643. constructor(engine: Engine, options?: SceneOptions);
  37644. /**
  37645. * Gets a string idenfifying the name of the class
  37646. * @returns "Scene" string
  37647. */
  37648. getClassName(): string;
  37649. private _defaultMeshCandidates;
  37650. /**
  37651. * @hidden
  37652. */
  37653. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  37654. private _defaultSubMeshCandidates;
  37655. /**
  37656. * @hidden
  37657. */
  37658. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  37659. /**
  37660. * Sets the default candidate providers for the scene.
  37661. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  37662. * and getCollidingSubMeshCandidates to their default function
  37663. */
  37664. setDefaultCandidateProviders(): void;
  37665. /**
  37666. * Gets the mesh that is currently under the pointer
  37667. */
  37668. get meshUnderPointer(): Nullable<AbstractMesh>;
  37669. /**
  37670. * Gets or sets the current on-screen X position of the pointer
  37671. */
  37672. get pointerX(): number;
  37673. set pointerX(value: number);
  37674. /**
  37675. * Gets or sets the current on-screen Y position of the pointer
  37676. */
  37677. get pointerY(): number;
  37678. set pointerY(value: number);
  37679. /**
  37680. * Gets the cached material (ie. the latest rendered one)
  37681. * @returns the cached material
  37682. */
  37683. getCachedMaterial(): Nullable<Material>;
  37684. /**
  37685. * Gets the cached effect (ie. the latest rendered one)
  37686. * @returns the cached effect
  37687. */
  37688. getCachedEffect(): Nullable<Effect>;
  37689. /**
  37690. * Gets the cached visibility state (ie. the latest rendered one)
  37691. * @returns the cached visibility state
  37692. */
  37693. getCachedVisibility(): Nullable<number>;
  37694. /**
  37695. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  37696. * @param material defines the current material
  37697. * @param effect defines the current effect
  37698. * @param visibility defines the current visibility state
  37699. * @returns true if one parameter is not cached
  37700. */
  37701. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  37702. /**
  37703. * Gets the engine associated with the scene
  37704. * @returns an Engine
  37705. */
  37706. getEngine(): Engine;
  37707. /**
  37708. * Gets the total number of vertices rendered per frame
  37709. * @returns the total number of vertices rendered per frame
  37710. */
  37711. getTotalVertices(): number;
  37712. /**
  37713. * Gets the performance counter for total vertices
  37714. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  37715. */
  37716. get totalVerticesPerfCounter(): PerfCounter;
  37717. /**
  37718. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  37719. * @returns the total number of active indices rendered per frame
  37720. */
  37721. getActiveIndices(): number;
  37722. /**
  37723. * Gets the performance counter for active indices
  37724. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  37725. */
  37726. get totalActiveIndicesPerfCounter(): PerfCounter;
  37727. /**
  37728. * Gets the total number of active particles rendered per frame
  37729. * @returns the total number of active particles rendered per frame
  37730. */
  37731. getActiveParticles(): number;
  37732. /**
  37733. * Gets the performance counter for active particles
  37734. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  37735. */
  37736. get activeParticlesPerfCounter(): PerfCounter;
  37737. /**
  37738. * Gets the total number of active bones rendered per frame
  37739. * @returns the total number of active bones rendered per frame
  37740. */
  37741. getActiveBones(): number;
  37742. /**
  37743. * Gets the performance counter for active bones
  37744. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  37745. */
  37746. get activeBonesPerfCounter(): PerfCounter;
  37747. /**
  37748. * Gets the array of active meshes
  37749. * @returns an array of AbstractMesh
  37750. */
  37751. getActiveMeshes(): SmartArray<AbstractMesh>;
  37752. /**
  37753. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  37754. * @returns a number
  37755. */
  37756. getAnimationRatio(): number;
  37757. /**
  37758. * Gets an unique Id for the current render phase
  37759. * @returns a number
  37760. */
  37761. getRenderId(): number;
  37762. /**
  37763. * Gets an unique Id for the current frame
  37764. * @returns a number
  37765. */
  37766. getFrameId(): number;
  37767. /** Call this function if you want to manually increment the render Id*/
  37768. incrementRenderId(): void;
  37769. private _createUbo;
  37770. /**
  37771. * Use this method to simulate a pointer move on a mesh
  37772. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  37773. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  37774. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  37775. * @returns the current scene
  37776. */
  37777. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  37778. /**
  37779. * Use this method to simulate a pointer down on a mesh
  37780. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  37781. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  37782. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  37783. * @returns the current scene
  37784. */
  37785. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  37786. /**
  37787. * Use this method to simulate a pointer up on a mesh
  37788. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  37789. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  37790. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  37791. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  37792. * @returns the current scene
  37793. */
  37794. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  37795. /**
  37796. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  37797. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  37798. * @returns true if the pointer was captured
  37799. */
  37800. isPointerCaptured(pointerId?: number): boolean;
  37801. /**
  37802. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  37803. * @param attachUp defines if you want to attach events to pointerup
  37804. * @param attachDown defines if you want to attach events to pointerdown
  37805. * @param attachMove defines if you want to attach events to pointermove
  37806. */
  37807. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  37808. /** Detaches all event handlers*/
  37809. detachControl(): void;
  37810. /**
  37811. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  37812. * Delay loaded resources are not taking in account
  37813. * @return true if all required resources are ready
  37814. */
  37815. isReady(): boolean;
  37816. /** Resets all cached information relative to material (including effect and visibility) */
  37817. resetCachedMaterial(): void;
  37818. /**
  37819. * Registers a function to be called before every frame render
  37820. * @param func defines the function to register
  37821. */
  37822. registerBeforeRender(func: () => void): void;
  37823. /**
  37824. * Unregisters a function called before every frame render
  37825. * @param func defines the function to unregister
  37826. */
  37827. unregisterBeforeRender(func: () => void): void;
  37828. /**
  37829. * Registers a function to be called after every frame render
  37830. * @param func defines the function to register
  37831. */
  37832. registerAfterRender(func: () => void): void;
  37833. /**
  37834. * Unregisters a function called after every frame render
  37835. * @param func defines the function to unregister
  37836. */
  37837. unregisterAfterRender(func: () => void): void;
  37838. private _executeOnceBeforeRender;
  37839. /**
  37840. * The provided function will run before render once and will be disposed afterwards.
  37841. * A timeout delay can be provided so that the function will be executed in N ms.
  37842. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  37843. * @param func The function to be executed.
  37844. * @param timeout optional delay in ms
  37845. */
  37846. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  37847. /** @hidden */
  37848. _addPendingData(data: any): void;
  37849. /** @hidden */
  37850. _removePendingData(data: any): void;
  37851. /**
  37852. * Returns the number of items waiting to be loaded
  37853. * @returns the number of items waiting to be loaded
  37854. */
  37855. getWaitingItemsCount(): number;
  37856. /**
  37857. * Returns a boolean indicating if the scene is still loading data
  37858. */
  37859. get isLoading(): boolean;
  37860. /**
  37861. * Registers a function to be executed when the scene is ready
  37862. * @param {Function} func - the function to be executed
  37863. */
  37864. executeWhenReady(func: () => void): void;
  37865. /**
  37866. * Returns a promise that resolves when the scene is ready
  37867. * @returns A promise that resolves when the scene is ready
  37868. */
  37869. whenReadyAsync(): Promise<void>;
  37870. /** @hidden */
  37871. _checkIsReady(): void;
  37872. /**
  37873. * Gets all animatable attached to the scene
  37874. */
  37875. get animatables(): Animatable[];
  37876. /**
  37877. * Resets the last animation time frame.
  37878. * Useful to override when animations start running when loading a scene for the first time.
  37879. */
  37880. resetLastAnimationTimeFrame(): void;
  37881. /**
  37882. * Gets the current view matrix
  37883. * @returns a Matrix
  37884. */
  37885. getViewMatrix(): Matrix;
  37886. /**
  37887. * Gets the current projection matrix
  37888. * @returns a Matrix
  37889. */
  37890. getProjectionMatrix(): Matrix;
  37891. /**
  37892. * Gets the current transform matrix
  37893. * @returns a Matrix made of View * Projection
  37894. */
  37895. getTransformMatrix(): Matrix;
  37896. /**
  37897. * Sets the current transform matrix
  37898. * @param viewL defines the View matrix to use
  37899. * @param projectionL defines the Projection matrix to use
  37900. * @param viewR defines the right View matrix to use (if provided)
  37901. * @param projectionR defines the right Projection matrix to use (if provided)
  37902. */
  37903. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  37904. /**
  37905. * Gets the uniform buffer used to store scene data
  37906. * @returns a UniformBuffer
  37907. */
  37908. getSceneUniformBuffer(): UniformBuffer;
  37909. /**
  37910. * Gets an unique (relatively to the current scene) Id
  37911. * @returns an unique number for the scene
  37912. */
  37913. getUniqueId(): number;
  37914. /**
  37915. * Add a mesh to the list of scene's meshes
  37916. * @param newMesh defines the mesh to add
  37917. * @param recursive if all child meshes should also be added to the scene
  37918. */
  37919. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  37920. /**
  37921. * Remove a mesh for the list of scene's meshes
  37922. * @param toRemove defines the mesh to remove
  37923. * @param recursive if all child meshes should also be removed from the scene
  37924. * @returns the index where the mesh was in the mesh list
  37925. */
  37926. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  37927. /**
  37928. * Add a transform node to the list of scene's transform nodes
  37929. * @param newTransformNode defines the transform node to add
  37930. */
  37931. addTransformNode(newTransformNode: TransformNode): void;
  37932. /**
  37933. * Remove a transform node for the list of scene's transform nodes
  37934. * @param toRemove defines the transform node to remove
  37935. * @returns the index where the transform node was in the transform node list
  37936. */
  37937. removeTransformNode(toRemove: TransformNode): number;
  37938. /**
  37939. * Remove a skeleton for the list of scene's skeletons
  37940. * @param toRemove defines the skeleton to remove
  37941. * @returns the index where the skeleton was in the skeleton list
  37942. */
  37943. removeSkeleton(toRemove: Skeleton): number;
  37944. /**
  37945. * Remove a morph target for the list of scene's morph targets
  37946. * @param toRemove defines the morph target to remove
  37947. * @returns the index where the morph target was in the morph target list
  37948. */
  37949. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  37950. /**
  37951. * Remove a light for the list of scene's lights
  37952. * @param toRemove defines the light to remove
  37953. * @returns the index where the light was in the light list
  37954. */
  37955. removeLight(toRemove: Light): number;
  37956. /**
  37957. * Remove a camera for the list of scene's cameras
  37958. * @param toRemove defines the camera to remove
  37959. * @returns the index where the camera was in the camera list
  37960. */
  37961. removeCamera(toRemove: Camera): number;
  37962. /**
  37963. * Remove a particle system for the list of scene's particle systems
  37964. * @param toRemove defines the particle system to remove
  37965. * @returns the index where the particle system was in the particle system list
  37966. */
  37967. removeParticleSystem(toRemove: IParticleSystem): number;
  37968. /**
  37969. * Remove a animation for the list of scene's animations
  37970. * @param toRemove defines the animation to remove
  37971. * @returns the index where the animation was in the animation list
  37972. */
  37973. removeAnimation(toRemove: Animation): number;
  37974. /**
  37975. * Will stop the animation of the given target
  37976. * @param target - the target
  37977. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  37978. * @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)
  37979. */
  37980. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  37981. /**
  37982. * Removes the given animation group from this scene.
  37983. * @param toRemove The animation group to remove
  37984. * @returns The index of the removed animation group
  37985. */
  37986. removeAnimationGroup(toRemove: AnimationGroup): number;
  37987. /**
  37988. * Removes the given multi-material from this scene.
  37989. * @param toRemove The multi-material to remove
  37990. * @returns The index of the removed multi-material
  37991. */
  37992. removeMultiMaterial(toRemove: MultiMaterial): number;
  37993. /**
  37994. * Removes the given material from this scene.
  37995. * @param toRemove The material to remove
  37996. * @returns The index of the removed material
  37997. */
  37998. removeMaterial(toRemove: Material): number;
  37999. /**
  38000. * Removes the given action manager from this scene.
  38001. * @param toRemove The action manager to remove
  38002. * @returns The index of the removed action manager
  38003. */
  38004. removeActionManager(toRemove: AbstractActionManager): number;
  38005. /**
  38006. * Removes the given texture from this scene.
  38007. * @param toRemove The texture to remove
  38008. * @returns The index of the removed texture
  38009. */
  38010. removeTexture(toRemove: BaseTexture): number;
  38011. /**
  38012. * Adds the given light to this scene
  38013. * @param newLight The light to add
  38014. */
  38015. addLight(newLight: Light): void;
  38016. /**
  38017. * Sorts the list list based on light priorities
  38018. */
  38019. sortLightsByPriority(): void;
  38020. /**
  38021. * Adds the given camera to this scene
  38022. * @param newCamera The camera to add
  38023. */
  38024. addCamera(newCamera: Camera): void;
  38025. /**
  38026. * Adds the given skeleton to this scene
  38027. * @param newSkeleton The skeleton to add
  38028. */
  38029. addSkeleton(newSkeleton: Skeleton): void;
  38030. /**
  38031. * Adds the given particle system to this scene
  38032. * @param newParticleSystem The particle system to add
  38033. */
  38034. addParticleSystem(newParticleSystem: IParticleSystem): void;
  38035. /**
  38036. * Adds the given animation to this scene
  38037. * @param newAnimation The animation to add
  38038. */
  38039. addAnimation(newAnimation: Animation): void;
  38040. /**
  38041. * Adds the given animation group to this scene.
  38042. * @param newAnimationGroup The animation group to add
  38043. */
  38044. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  38045. /**
  38046. * Adds the given multi-material to this scene
  38047. * @param newMultiMaterial The multi-material to add
  38048. */
  38049. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  38050. /**
  38051. * Adds the given material to this scene
  38052. * @param newMaterial The material to add
  38053. */
  38054. addMaterial(newMaterial: Material): void;
  38055. /**
  38056. * Adds the given morph target to this scene
  38057. * @param newMorphTargetManager The morph target to add
  38058. */
  38059. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  38060. /**
  38061. * Adds the given geometry to this scene
  38062. * @param newGeometry The geometry to add
  38063. */
  38064. addGeometry(newGeometry: Geometry): void;
  38065. /**
  38066. * Adds the given action manager to this scene
  38067. * @param newActionManager The action manager to add
  38068. */
  38069. addActionManager(newActionManager: AbstractActionManager): void;
  38070. /**
  38071. * Adds the given texture to this scene.
  38072. * @param newTexture The texture to add
  38073. */
  38074. addTexture(newTexture: BaseTexture): void;
  38075. /**
  38076. * Switch active camera
  38077. * @param newCamera defines the new active camera
  38078. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  38079. */
  38080. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  38081. /**
  38082. * sets the active camera of the scene using its ID
  38083. * @param id defines the camera's ID
  38084. * @return the new active camera or null if none found.
  38085. */
  38086. setActiveCameraByID(id: string): Nullable<Camera>;
  38087. /**
  38088. * sets the active camera of the scene using its name
  38089. * @param name defines the camera's name
  38090. * @returns the new active camera or null if none found.
  38091. */
  38092. setActiveCameraByName(name: string): Nullable<Camera>;
  38093. /**
  38094. * get an animation group using its name
  38095. * @param name defines the material's name
  38096. * @return the animation group or null if none found.
  38097. */
  38098. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  38099. /**
  38100. * Get a material using its unique id
  38101. * @param uniqueId defines the material's unique id
  38102. * @return the material or null if none found.
  38103. */
  38104. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  38105. /**
  38106. * get a material using its id
  38107. * @param id defines the material's ID
  38108. * @return the material or null if none found.
  38109. */
  38110. getMaterialByID(id: string): Nullable<Material>;
  38111. /**
  38112. * Gets a the last added material using a given id
  38113. * @param id defines the material's ID
  38114. * @return the last material with the given id or null if none found.
  38115. */
  38116. getLastMaterialByID(id: string): Nullable<Material>;
  38117. /**
  38118. * Gets a material using its name
  38119. * @param name defines the material's name
  38120. * @return the material or null if none found.
  38121. */
  38122. getMaterialByName(name: string): Nullable<Material>;
  38123. /**
  38124. * Get a texture using its unique id
  38125. * @param uniqueId defines the texture's unique id
  38126. * @return the texture or null if none found.
  38127. */
  38128. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  38129. /**
  38130. * Gets a camera using its id
  38131. * @param id defines the id to look for
  38132. * @returns the camera or null if not found
  38133. */
  38134. getCameraByID(id: string): Nullable<Camera>;
  38135. /**
  38136. * Gets a camera using its unique id
  38137. * @param uniqueId defines the unique id to look for
  38138. * @returns the camera or null if not found
  38139. */
  38140. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  38141. /**
  38142. * Gets a camera using its name
  38143. * @param name defines the camera's name
  38144. * @return the camera or null if none found.
  38145. */
  38146. getCameraByName(name: string): Nullable<Camera>;
  38147. /**
  38148. * Gets a bone using its id
  38149. * @param id defines the bone's id
  38150. * @return the bone or null if not found
  38151. */
  38152. getBoneByID(id: string): Nullable<Bone>;
  38153. /**
  38154. * Gets a bone using its id
  38155. * @param name defines the bone's name
  38156. * @return the bone or null if not found
  38157. */
  38158. getBoneByName(name: string): Nullable<Bone>;
  38159. /**
  38160. * Gets a light node using its name
  38161. * @param name defines the the light's name
  38162. * @return the light or null if none found.
  38163. */
  38164. getLightByName(name: string): Nullable<Light>;
  38165. /**
  38166. * Gets a light node using its id
  38167. * @param id defines the light's id
  38168. * @return the light or null if none found.
  38169. */
  38170. getLightByID(id: string): Nullable<Light>;
  38171. /**
  38172. * Gets a light node using its scene-generated unique ID
  38173. * @param uniqueId defines the light's unique id
  38174. * @return the light or null if none found.
  38175. */
  38176. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  38177. /**
  38178. * Gets a particle system by id
  38179. * @param id defines the particle system id
  38180. * @return the corresponding system or null if none found
  38181. */
  38182. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  38183. /**
  38184. * Gets a geometry using its ID
  38185. * @param id defines the geometry's id
  38186. * @return the geometry or null if none found.
  38187. */
  38188. getGeometryByID(id: string): Nullable<Geometry>;
  38189. private _getGeometryByUniqueID;
  38190. /**
  38191. * Add a new geometry to this scene
  38192. * @param geometry defines the geometry to be added to the scene.
  38193. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  38194. * @return a boolean defining if the geometry was added or not
  38195. */
  38196. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  38197. /**
  38198. * Removes an existing geometry
  38199. * @param geometry defines the geometry to be removed from the scene
  38200. * @return a boolean defining if the geometry was removed or not
  38201. */
  38202. removeGeometry(geometry: Geometry): boolean;
  38203. /**
  38204. * Gets the list of geometries attached to the scene
  38205. * @returns an array of Geometry
  38206. */
  38207. getGeometries(): Geometry[];
  38208. /**
  38209. * Gets the first added mesh found of a given ID
  38210. * @param id defines the id to search for
  38211. * @return the mesh found or null if not found at all
  38212. */
  38213. getMeshByID(id: string): Nullable<AbstractMesh>;
  38214. /**
  38215. * Gets a list of meshes using their id
  38216. * @param id defines the id to search for
  38217. * @returns a list of meshes
  38218. */
  38219. getMeshesByID(id: string): Array<AbstractMesh>;
  38220. /**
  38221. * Gets the first added transform node found of a given ID
  38222. * @param id defines the id to search for
  38223. * @return the found transform node or null if not found at all.
  38224. */
  38225. getTransformNodeByID(id: string): Nullable<TransformNode>;
  38226. /**
  38227. * Gets a transform node with its auto-generated unique id
  38228. * @param uniqueId efines the unique id to search for
  38229. * @return the found transform node or null if not found at all.
  38230. */
  38231. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  38232. /**
  38233. * Gets a list of transform nodes using their id
  38234. * @param id defines the id to search for
  38235. * @returns a list of transform nodes
  38236. */
  38237. getTransformNodesByID(id: string): Array<TransformNode>;
  38238. /**
  38239. * Gets a mesh with its auto-generated unique id
  38240. * @param uniqueId defines the unique id to search for
  38241. * @return the found mesh or null if not found at all.
  38242. */
  38243. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  38244. /**
  38245. * Gets a the last added mesh using a given id
  38246. * @param id defines the id to search for
  38247. * @return the found mesh or null if not found at all.
  38248. */
  38249. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  38250. /**
  38251. * Gets a the last added node (Mesh, Camera, Light) using a given id
  38252. * @param id defines the id to search for
  38253. * @return the found node or null if not found at all
  38254. */
  38255. getLastEntryByID(id: string): Nullable<Node>;
  38256. /**
  38257. * Gets a node (Mesh, Camera, Light) using a given id
  38258. * @param id defines the id to search for
  38259. * @return the found node or null if not found at all
  38260. */
  38261. getNodeByID(id: string): Nullable<Node>;
  38262. /**
  38263. * Gets a node (Mesh, Camera, Light) using a given name
  38264. * @param name defines the name to search for
  38265. * @return the found node or null if not found at all.
  38266. */
  38267. getNodeByName(name: string): Nullable<Node>;
  38268. /**
  38269. * Gets a mesh using a given name
  38270. * @param name defines the name to search for
  38271. * @return the found mesh or null if not found at all.
  38272. */
  38273. getMeshByName(name: string): Nullable<AbstractMesh>;
  38274. /**
  38275. * Gets a transform node using a given name
  38276. * @param name defines the name to search for
  38277. * @return the found transform node or null if not found at all.
  38278. */
  38279. getTransformNodeByName(name: string): Nullable<TransformNode>;
  38280. /**
  38281. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  38282. * @param id defines the id to search for
  38283. * @return the found skeleton or null if not found at all.
  38284. */
  38285. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  38286. /**
  38287. * Gets a skeleton using a given auto generated unique id
  38288. * @param uniqueId defines the unique id to search for
  38289. * @return the found skeleton or null if not found at all.
  38290. */
  38291. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  38292. /**
  38293. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  38294. * @param id defines the id to search for
  38295. * @return the found skeleton or null if not found at all.
  38296. */
  38297. getSkeletonById(id: string): Nullable<Skeleton>;
  38298. /**
  38299. * Gets a skeleton using a given name
  38300. * @param name defines the name to search for
  38301. * @return the found skeleton or null if not found at all.
  38302. */
  38303. getSkeletonByName(name: string): Nullable<Skeleton>;
  38304. /**
  38305. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  38306. * @param id defines the id to search for
  38307. * @return the found morph target manager or null if not found at all.
  38308. */
  38309. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  38310. /**
  38311. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  38312. * @param id defines the id to search for
  38313. * @return the found morph target or null if not found at all.
  38314. */
  38315. getMorphTargetById(id: string): Nullable<MorphTarget>;
  38316. /**
  38317. * Gets a morph target using a given name (if many are found, this function will pick the first one)
  38318. * @param name defines the name to search for
  38319. * @return the found morph target or null if not found at all.
  38320. */
  38321. getMorphTargetByName(name: string): Nullable<MorphTarget>;
  38322. /**
  38323. * Gets a boolean indicating if the given mesh is active
  38324. * @param mesh defines the mesh to look for
  38325. * @returns true if the mesh is in the active list
  38326. */
  38327. isActiveMesh(mesh: AbstractMesh): boolean;
  38328. /**
  38329. * Return a unique id as a string which can serve as an identifier for the scene
  38330. */
  38331. get uid(): string;
  38332. /**
  38333. * Add an externaly attached data from its key.
  38334. * This method call will fail and return false, if such key already exists.
  38335. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  38336. * @param key the unique key that identifies the data
  38337. * @param data the data object to associate to the key for this Engine instance
  38338. * @return true if no such key were already present and the data was added successfully, false otherwise
  38339. */
  38340. addExternalData<T>(key: string, data: T): boolean;
  38341. /**
  38342. * Get an externaly attached data from its key
  38343. * @param key the unique key that identifies the data
  38344. * @return the associated data, if present (can be null), or undefined if not present
  38345. */
  38346. getExternalData<T>(key: string): Nullable<T>;
  38347. /**
  38348. * Get an externaly attached data from its key, create it using a factory if it's not already present
  38349. * @param key the unique key that identifies the data
  38350. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  38351. * @return the associated data, can be null if the factory returned null.
  38352. */
  38353. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  38354. /**
  38355. * Remove an externaly attached data from the Engine instance
  38356. * @param key the unique key that identifies the data
  38357. * @return true if the data was successfully removed, false if it doesn't exist
  38358. */
  38359. removeExternalData(key: string): boolean;
  38360. private _evaluateSubMesh;
  38361. /**
  38362. * Clear the processed materials smart array preventing retention point in material dispose.
  38363. */
  38364. freeProcessedMaterials(): void;
  38365. private _preventFreeActiveMeshesAndRenderingGroups;
  38366. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  38367. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  38368. * when disposing several meshes in a row or a hierarchy of meshes.
  38369. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  38370. */
  38371. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  38372. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  38373. /**
  38374. * Clear the active meshes smart array preventing retention point in mesh dispose.
  38375. */
  38376. freeActiveMeshes(): void;
  38377. /**
  38378. * Clear the info related to rendering groups preventing retention points during dispose.
  38379. */
  38380. freeRenderingGroups(): void;
  38381. /** @hidden */
  38382. _isInIntermediateRendering(): boolean;
  38383. /**
  38384. * Lambda returning the list of potentially active meshes.
  38385. */
  38386. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  38387. /**
  38388. * Lambda returning the list of potentially active sub meshes.
  38389. */
  38390. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  38391. /**
  38392. * Lambda returning the list of potentially intersecting sub meshes.
  38393. */
  38394. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  38395. /**
  38396. * Lambda returning the list of potentially colliding sub meshes.
  38397. */
  38398. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  38399. private _activeMeshesFrozen;
  38400. private _skipEvaluateActiveMeshesCompletely;
  38401. /**
  38402. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  38403. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  38404. * @returns the current scene
  38405. */
  38406. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  38407. /**
  38408. * Use this function to restart evaluating active meshes on every frame
  38409. * @returns the current scene
  38410. */
  38411. unfreezeActiveMeshes(): Scene;
  38412. private _evaluateActiveMeshes;
  38413. private _activeMesh;
  38414. /**
  38415. * Update the transform matrix to update from the current active camera
  38416. * @param force defines a boolean used to force the update even if cache is up to date
  38417. */
  38418. updateTransformMatrix(force?: boolean): void;
  38419. private _bindFrameBuffer;
  38420. /** @hidden */
  38421. _allowPostProcessClearColor: boolean;
  38422. /** @hidden */
  38423. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  38424. private _processSubCameras;
  38425. private _checkIntersections;
  38426. /** @hidden */
  38427. _advancePhysicsEngineStep(step: number): void;
  38428. /**
  38429. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  38430. */
  38431. getDeterministicFrameTime: () => number;
  38432. /** @hidden */
  38433. _animate(): void;
  38434. /** Execute all animations (for a frame) */
  38435. animate(): void;
  38436. /**
  38437. * Render the scene
  38438. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  38439. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  38440. */
  38441. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  38442. /**
  38443. * Freeze all materials
  38444. * A frozen material will not be updatable but should be faster to render
  38445. */
  38446. freezeMaterials(): void;
  38447. /**
  38448. * Unfreeze all materials
  38449. * A frozen material will not be updatable but should be faster to render
  38450. */
  38451. unfreezeMaterials(): void;
  38452. /**
  38453. * Releases all held ressources
  38454. */
  38455. dispose(): void;
  38456. /**
  38457. * Gets if the scene is already disposed
  38458. */
  38459. get isDisposed(): boolean;
  38460. /**
  38461. * Call this function to reduce memory footprint of the scene.
  38462. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  38463. */
  38464. clearCachedVertexData(): void;
  38465. /**
  38466. * This function will remove the local cached buffer data from texture.
  38467. * It will save memory but will prevent the texture from being rebuilt
  38468. */
  38469. cleanCachedTextureBuffer(): void;
  38470. /**
  38471. * Get the world extend vectors with an optional filter
  38472. *
  38473. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  38474. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  38475. */
  38476. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  38477. min: Vector3;
  38478. max: Vector3;
  38479. };
  38480. /**
  38481. * Creates a ray that can be used to pick in the scene
  38482. * @param x defines the x coordinate of the origin (on-screen)
  38483. * @param y defines the y coordinate of the origin (on-screen)
  38484. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  38485. * @param camera defines the camera to use for the picking
  38486. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  38487. * @returns a Ray
  38488. */
  38489. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  38490. /**
  38491. * Creates a ray that can be used to pick in the scene
  38492. * @param x defines the x coordinate of the origin (on-screen)
  38493. * @param y defines the y coordinate of the origin (on-screen)
  38494. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  38495. * @param result defines the ray where to store the picking ray
  38496. * @param camera defines the camera to use for the picking
  38497. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  38498. * @returns the current scene
  38499. */
  38500. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  38501. /**
  38502. * Creates a ray that can be used to pick in the scene
  38503. * @param x defines the x coordinate of the origin (on-screen)
  38504. * @param y defines the y coordinate of the origin (on-screen)
  38505. * @param camera defines the camera to use for the picking
  38506. * @returns a Ray
  38507. */
  38508. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  38509. /**
  38510. * Creates a ray that can be used to pick in the scene
  38511. * @param x defines the x coordinate of the origin (on-screen)
  38512. * @param y defines the y coordinate of the origin (on-screen)
  38513. * @param result defines the ray where to store the picking ray
  38514. * @param camera defines the camera to use for the picking
  38515. * @returns the current scene
  38516. */
  38517. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  38518. /** Launch a ray to try to pick a mesh in the scene
  38519. * @param x position on screen
  38520. * @param y position on screen
  38521. * @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
  38522. * @param fastCheck defines if the first intersection will be used (and not the closest)
  38523. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  38524. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  38525. * @returns a PickingInfo
  38526. */
  38527. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  38528. /** Launch a ray to try to pick a mesh in the scene using only bounding information of the main mesh (not using submeshes)
  38529. * @param x position on screen
  38530. * @param y position on screen
  38531. * @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
  38532. * @param fastCheck defines if the first intersection will be used (and not the closest)
  38533. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  38534. * @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)
  38535. */
  38536. pickWithBoundingInfo(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  38537. /** Use the given ray to pick a mesh in the scene
  38538. * @param ray The ray to use to pick meshes
  38539. * @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
  38540. * @param fastCheck defines if the first intersection will be used (and not the closest)
  38541. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  38542. * @returns a PickingInfo
  38543. */
  38544. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  38545. /**
  38546. * Launch a ray to try to pick a mesh in the scene
  38547. * @param x X position on screen
  38548. * @param y Y position on screen
  38549. * @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
  38550. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  38551. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  38552. * @returns an array of PickingInfo
  38553. */
  38554. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  38555. /**
  38556. * Launch a ray to try to pick a mesh in the scene
  38557. * @param ray Ray to use
  38558. * @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
  38559. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  38560. * @returns an array of PickingInfo
  38561. */
  38562. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  38563. /**
  38564. * Force the value of meshUnderPointer
  38565. * @param mesh defines the mesh to use
  38566. */
  38567. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  38568. /**
  38569. * Gets the mesh under the pointer
  38570. * @returns a Mesh or null if no mesh is under the pointer
  38571. */
  38572. getPointerOverMesh(): Nullable<AbstractMesh>;
  38573. /** @hidden */
  38574. _rebuildGeometries(): void;
  38575. /** @hidden */
  38576. _rebuildTextures(): void;
  38577. private _getByTags;
  38578. /**
  38579. * Get a list of meshes by tags
  38580. * @param tagsQuery defines the tags query to use
  38581. * @param forEach defines a predicate used to filter results
  38582. * @returns an array of Mesh
  38583. */
  38584. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  38585. /**
  38586. * Get a list of cameras by tags
  38587. * @param tagsQuery defines the tags query to use
  38588. * @param forEach defines a predicate used to filter results
  38589. * @returns an array of Camera
  38590. */
  38591. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  38592. /**
  38593. * Get a list of lights by tags
  38594. * @param tagsQuery defines the tags query to use
  38595. * @param forEach defines a predicate used to filter results
  38596. * @returns an array of Light
  38597. */
  38598. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  38599. /**
  38600. * Get a list of materials by tags
  38601. * @param tagsQuery defines the tags query to use
  38602. * @param forEach defines a predicate used to filter results
  38603. * @returns an array of Material
  38604. */
  38605. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  38606. /**
  38607. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  38608. * This allowed control for front to back rendering or reversly depending of the special needs.
  38609. *
  38610. * @param renderingGroupId The rendering group id corresponding to its index
  38611. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  38612. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  38613. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  38614. */
  38615. 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;
  38616. /**
  38617. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  38618. *
  38619. * @param renderingGroupId The rendering group id corresponding to its index
  38620. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  38621. * @param depth Automatically clears depth between groups if true and autoClear is true.
  38622. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  38623. */
  38624. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  38625. /**
  38626. * Gets the current auto clear configuration for one rendering group of the rendering
  38627. * manager.
  38628. * @param index the rendering group index to get the information for
  38629. * @returns The auto clear setup for the requested rendering group
  38630. */
  38631. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  38632. private _blockMaterialDirtyMechanism;
  38633. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  38634. get blockMaterialDirtyMechanism(): boolean;
  38635. set blockMaterialDirtyMechanism(value: boolean);
  38636. /**
  38637. * Will flag all materials as dirty to trigger new shader compilation
  38638. * @param flag defines the flag used to specify which material part must be marked as dirty
  38639. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  38640. */
  38641. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  38642. /** @hidden */
  38643. _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;
  38644. /** @hidden */
  38645. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  38646. /** @hidden */
  38647. _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;
  38648. /** @hidden */
  38649. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  38650. /** @hidden */
  38651. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  38652. /** @hidden */
  38653. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  38654. }
  38655. }
  38656. declare module "babylonjs/assetContainer" {
  38657. import { AbstractScene } from "babylonjs/abstractScene";
  38658. import { Scene } from "babylonjs/scene";
  38659. import { Mesh } from "babylonjs/Meshes/mesh";
  38660. import { TransformNode } from "babylonjs/Meshes/transformNode";
  38661. import { Skeleton } from "babylonjs/Bones/skeleton";
  38662. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  38663. import { Animatable } from "babylonjs/Animations/animatable";
  38664. import { Nullable } from "babylonjs/types";
  38665. import { Node } from "babylonjs/node";
  38666. /**
  38667. * Set of assets to keep when moving a scene into an asset container.
  38668. */
  38669. export class KeepAssets extends AbstractScene {
  38670. }
  38671. /**
  38672. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  38673. */
  38674. export class InstantiatedEntries {
  38675. /**
  38676. * List of new root nodes (eg. nodes with no parent)
  38677. */
  38678. rootNodes: TransformNode[];
  38679. /**
  38680. * List of new skeletons
  38681. */
  38682. skeletons: Skeleton[];
  38683. /**
  38684. * List of new animation groups
  38685. */
  38686. animationGroups: AnimationGroup[];
  38687. }
  38688. /**
  38689. * Container with a set of assets that can be added or removed from a scene.
  38690. */
  38691. export class AssetContainer extends AbstractScene {
  38692. private _wasAddedToScene;
  38693. /**
  38694. * The scene the AssetContainer belongs to.
  38695. */
  38696. scene: Scene;
  38697. /**
  38698. * Instantiates an AssetContainer.
  38699. * @param scene The scene the AssetContainer belongs to.
  38700. */
  38701. constructor(scene: Scene);
  38702. /**
  38703. * Instantiate or clone all meshes and add the new ones to the scene.
  38704. * Skeletons and animation groups will all be cloned
  38705. * @param nameFunction defines an optional function used to get new names for clones
  38706. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  38707. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  38708. */
  38709. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  38710. /**
  38711. * Adds all the assets from the container to the scene.
  38712. */
  38713. addAllToScene(): void;
  38714. /**
  38715. * Removes all the assets in the container from the scene
  38716. */
  38717. removeAllFromScene(): void;
  38718. /**
  38719. * Disposes all the assets in the container
  38720. */
  38721. dispose(): void;
  38722. private _moveAssets;
  38723. /**
  38724. * Removes all the assets contained in the scene and adds them to the container.
  38725. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  38726. */
  38727. moveAllFromScene(keepAssets?: KeepAssets): void;
  38728. /**
  38729. * 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.
  38730. * @returns the root mesh
  38731. */
  38732. createRootMesh(): Mesh;
  38733. /**
  38734. * Merge animations (direct and animation groups) from this asset container into a scene
  38735. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  38736. * @param animatables set of animatables to retarget to a node from the scene
  38737. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  38738. * @returns an array of the new AnimationGroup added to the scene (empty array if none)
  38739. */
  38740. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): AnimationGroup[];
  38741. }
  38742. }
  38743. declare module "babylonjs/abstractScene" {
  38744. import { Scene } from "babylonjs/scene";
  38745. import { Nullable } from "babylonjs/types";
  38746. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38747. import { TransformNode } from "babylonjs/Meshes/transformNode";
  38748. import { Geometry } from "babylonjs/Meshes/geometry";
  38749. import { Skeleton } from "babylonjs/Bones/skeleton";
  38750. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  38751. import { AssetContainer } from "babylonjs/assetContainer";
  38752. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  38753. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  38754. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  38755. import { Material } from "babylonjs/Materials/material";
  38756. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  38757. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  38758. import { Camera } from "babylonjs/Cameras/camera";
  38759. import { Light } from "babylonjs/Lights/light";
  38760. import { Node } from "babylonjs/node";
  38761. import { Animation } from "babylonjs/Animations/animation";
  38762. /**
  38763. * Defines how the parser contract is defined.
  38764. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  38765. */
  38766. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  38767. /**
  38768. * Defines how the individual parser contract is defined.
  38769. * These parser can parse an individual asset
  38770. */
  38771. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  38772. /**
  38773. * Base class of the scene acting as a container for the different elements composing a scene.
  38774. * This class is dynamically extended by the different components of the scene increasing
  38775. * flexibility and reducing coupling
  38776. */
  38777. export abstract class AbstractScene {
  38778. /**
  38779. * Stores the list of available parsers in the application.
  38780. */
  38781. private static _BabylonFileParsers;
  38782. /**
  38783. * Stores the list of available individual parsers in the application.
  38784. */
  38785. private static _IndividualBabylonFileParsers;
  38786. /**
  38787. * Adds a parser in the list of available ones
  38788. * @param name Defines the name of the parser
  38789. * @param parser Defines the parser to add
  38790. */
  38791. static AddParser(name: string, parser: BabylonFileParser): void;
  38792. /**
  38793. * Gets a general parser from the list of avaialble ones
  38794. * @param name Defines the name of the parser
  38795. * @returns the requested parser or null
  38796. */
  38797. static GetParser(name: string): Nullable<BabylonFileParser>;
  38798. /**
  38799. * Adds n individual parser in the list of available ones
  38800. * @param name Defines the name of the parser
  38801. * @param parser Defines the parser to add
  38802. */
  38803. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  38804. /**
  38805. * Gets an individual parser from the list of avaialble ones
  38806. * @param name Defines the name of the parser
  38807. * @returns the requested parser or null
  38808. */
  38809. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  38810. /**
  38811. * Parser json data and populate both a scene and its associated container object
  38812. * @param jsonData Defines the data to parse
  38813. * @param scene Defines the scene to parse the data for
  38814. * @param container Defines the container attached to the parsing sequence
  38815. * @param rootUrl Defines the root url of the data
  38816. */
  38817. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  38818. /**
  38819. * Gets the list of root nodes (ie. nodes with no parent)
  38820. */
  38821. rootNodes: Node[];
  38822. /** All of the cameras added to this scene
  38823. * @see http://doc.babylonjs.com/babylon101/cameras
  38824. */
  38825. cameras: Camera[];
  38826. /**
  38827. * All of the lights added to this scene
  38828. * @see http://doc.babylonjs.com/babylon101/lights
  38829. */
  38830. lights: Light[];
  38831. /**
  38832. * All of the (abstract) meshes added to this scene
  38833. */
  38834. meshes: AbstractMesh[];
  38835. /**
  38836. * The list of skeletons added to the scene
  38837. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  38838. */
  38839. skeletons: Skeleton[];
  38840. /**
  38841. * All of the particle systems added to this scene
  38842. * @see http://doc.babylonjs.com/babylon101/particles
  38843. */
  38844. particleSystems: IParticleSystem[];
  38845. /**
  38846. * Gets a list of Animations associated with the scene
  38847. */
  38848. animations: Animation[];
  38849. /**
  38850. * All of the animation groups added to this scene
  38851. * @see http://doc.babylonjs.com/how_to/group
  38852. */
  38853. animationGroups: AnimationGroup[];
  38854. /**
  38855. * All of the multi-materials added to this scene
  38856. * @see http://doc.babylonjs.com/how_to/multi_materials
  38857. */
  38858. multiMaterials: MultiMaterial[];
  38859. /**
  38860. * All of the materials added to this scene
  38861. * In the context of a Scene, it is not supposed to be modified manually.
  38862. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  38863. * Note also that the order of the Material within the array is not significant and might change.
  38864. * @see http://doc.babylonjs.com/babylon101/materials
  38865. */
  38866. materials: Material[];
  38867. /**
  38868. * The list of morph target managers added to the scene
  38869. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  38870. */
  38871. morphTargetManagers: MorphTargetManager[];
  38872. /**
  38873. * The list of geometries used in the scene.
  38874. */
  38875. geometries: Geometry[];
  38876. /**
  38877. * All of the tranform nodes added to this scene
  38878. * In the context of a Scene, it is not supposed to be modified manually.
  38879. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  38880. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  38881. * @see http://doc.babylonjs.com/how_to/transformnode
  38882. */
  38883. transformNodes: TransformNode[];
  38884. /**
  38885. * ActionManagers available on the scene.
  38886. */
  38887. actionManagers: AbstractActionManager[];
  38888. /**
  38889. * Textures to keep.
  38890. */
  38891. textures: BaseTexture[];
  38892. /**
  38893. * Environment texture for the scene
  38894. */
  38895. environmentTexture: Nullable<BaseTexture>;
  38896. /**
  38897. * @returns all meshes, lights, cameras, transformNodes and bones
  38898. */
  38899. getNodes(): Array<Node>;
  38900. }
  38901. }
  38902. declare module "babylonjs/Audio/sound" {
  38903. import { Observable } from "babylonjs/Misc/observable";
  38904. import { Vector3 } from "babylonjs/Maths/math.vector";
  38905. import { Nullable } from "babylonjs/types";
  38906. import { Scene } from "babylonjs/scene";
  38907. import { TransformNode } from "babylonjs/Meshes/transformNode";
  38908. /**
  38909. * Interface used to define options for Sound class
  38910. */
  38911. export interface ISoundOptions {
  38912. /**
  38913. * Does the sound autoplay once loaded.
  38914. */
  38915. autoplay?: boolean;
  38916. /**
  38917. * Does the sound loop after it finishes playing once.
  38918. */
  38919. loop?: boolean;
  38920. /**
  38921. * Sound's volume
  38922. */
  38923. volume?: number;
  38924. /**
  38925. * Is it a spatial sound?
  38926. */
  38927. spatialSound?: boolean;
  38928. /**
  38929. * Maximum distance to hear that sound
  38930. */
  38931. maxDistance?: number;
  38932. /**
  38933. * Uses user defined attenuation function
  38934. */
  38935. useCustomAttenuation?: boolean;
  38936. /**
  38937. * Define the roll off factor of spatial sounds.
  38938. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38939. */
  38940. rolloffFactor?: number;
  38941. /**
  38942. * Define the reference distance the sound should be heard perfectly.
  38943. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38944. */
  38945. refDistance?: number;
  38946. /**
  38947. * Define the distance attenuation model the sound will follow.
  38948. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38949. */
  38950. distanceModel?: string;
  38951. /**
  38952. * Defines the playback speed (1 by default)
  38953. */
  38954. playbackRate?: number;
  38955. /**
  38956. * Defines if the sound is from a streaming source
  38957. */
  38958. streaming?: boolean;
  38959. /**
  38960. * Defines an optional length (in seconds) inside the sound file
  38961. */
  38962. length?: number;
  38963. /**
  38964. * Defines an optional offset (in seconds) inside the sound file
  38965. */
  38966. offset?: number;
  38967. /**
  38968. * If true, URLs will not be required to state the audio file codec to use.
  38969. */
  38970. skipCodecCheck?: boolean;
  38971. }
  38972. /**
  38973. * Defines a sound that can be played in the application.
  38974. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  38975. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38976. */
  38977. export class Sound {
  38978. /**
  38979. * The name of the sound in the scene.
  38980. */
  38981. name: string;
  38982. /**
  38983. * Does the sound autoplay once loaded.
  38984. */
  38985. autoplay: boolean;
  38986. /**
  38987. * Does the sound loop after it finishes playing once.
  38988. */
  38989. loop: boolean;
  38990. /**
  38991. * Does the sound use a custom attenuation curve to simulate the falloff
  38992. * happening when the source gets further away from the camera.
  38993. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  38994. */
  38995. useCustomAttenuation: boolean;
  38996. /**
  38997. * The sound track id this sound belongs to.
  38998. */
  38999. soundTrackId: number;
  39000. /**
  39001. * Is this sound currently played.
  39002. */
  39003. isPlaying: boolean;
  39004. /**
  39005. * Is this sound currently paused.
  39006. */
  39007. isPaused: boolean;
  39008. /**
  39009. * Does this sound enables spatial sound.
  39010. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  39011. */
  39012. spatialSound: boolean;
  39013. /**
  39014. * Define the reference distance the sound should be heard perfectly.
  39015. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  39016. */
  39017. refDistance: number;
  39018. /**
  39019. * Define the roll off factor of spatial sounds.
  39020. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  39021. */
  39022. rolloffFactor: number;
  39023. /**
  39024. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  39025. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  39026. */
  39027. maxDistance: number;
  39028. /**
  39029. * Define the distance attenuation model the sound will follow.
  39030. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  39031. */
  39032. distanceModel: string;
  39033. /**
  39034. * @hidden
  39035. * Back Compat
  39036. **/
  39037. onended: () => any;
  39038. /**
  39039. * Observable event when the current playing sound finishes.
  39040. */
  39041. onEndedObservable: Observable<Sound>;
  39042. private _panningModel;
  39043. private _playbackRate;
  39044. private _streaming;
  39045. private _startTime;
  39046. private _startOffset;
  39047. private _position;
  39048. /** @hidden */
  39049. _positionInEmitterSpace: boolean;
  39050. private _localDirection;
  39051. private _volume;
  39052. private _isReadyToPlay;
  39053. private _isDirectional;
  39054. private _readyToPlayCallback;
  39055. private _audioBuffer;
  39056. private _soundSource;
  39057. private _streamingSource;
  39058. private _soundPanner;
  39059. private _soundGain;
  39060. private _inputAudioNode;
  39061. private _outputAudioNode;
  39062. private _coneInnerAngle;
  39063. private _coneOuterAngle;
  39064. private _coneOuterGain;
  39065. private _scene;
  39066. private _connectedTransformNode;
  39067. private _customAttenuationFunction;
  39068. private _registerFunc;
  39069. private _isOutputConnected;
  39070. private _htmlAudioElement;
  39071. private _urlType;
  39072. private _length?;
  39073. private _offset?;
  39074. /** @hidden */
  39075. static _SceneComponentInitialization: (scene: Scene) => void;
  39076. /**
  39077. * Create a sound and attach it to a scene
  39078. * @param name Name of your sound
  39079. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  39080. * @param scene defines the scene the sound belongs to
  39081. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  39082. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  39083. */
  39084. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  39085. /**
  39086. * Release the sound and its associated resources
  39087. */
  39088. dispose(): void;
  39089. /**
  39090. * Gets if the sounds is ready to be played or not.
  39091. * @returns true if ready, otherwise false
  39092. */
  39093. isReady(): boolean;
  39094. private _soundLoaded;
  39095. /**
  39096. * Sets the data of the sound from an audiobuffer
  39097. * @param audioBuffer The audioBuffer containing the data
  39098. */
  39099. setAudioBuffer(audioBuffer: AudioBuffer): void;
  39100. /**
  39101. * Updates the current sounds options such as maxdistance, loop...
  39102. * @param options A JSON object containing values named as the object properties
  39103. */
  39104. updateOptions(options: ISoundOptions): void;
  39105. private _createSpatialParameters;
  39106. private _updateSpatialParameters;
  39107. /**
  39108. * Switch the panning model to HRTF:
  39109. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  39110. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  39111. */
  39112. switchPanningModelToHRTF(): void;
  39113. /**
  39114. * Switch the panning model to Equal Power:
  39115. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  39116. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  39117. */
  39118. switchPanningModelToEqualPower(): void;
  39119. private _switchPanningModel;
  39120. /**
  39121. * Connect this sound to a sound track audio node like gain...
  39122. * @param soundTrackAudioNode the sound track audio node to connect to
  39123. */
  39124. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  39125. /**
  39126. * Transform this sound into a directional source
  39127. * @param coneInnerAngle Size of the inner cone in degree
  39128. * @param coneOuterAngle Size of the outer cone in degree
  39129. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  39130. */
  39131. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  39132. /**
  39133. * Gets or sets the inner angle for the directional cone.
  39134. */
  39135. get directionalConeInnerAngle(): number;
  39136. /**
  39137. * Gets or sets the inner angle for the directional cone.
  39138. */
  39139. set directionalConeInnerAngle(value: number);
  39140. /**
  39141. * Gets or sets the outer angle for the directional cone.
  39142. */
  39143. get directionalConeOuterAngle(): number;
  39144. /**
  39145. * Gets or sets the outer angle for the directional cone.
  39146. */
  39147. set directionalConeOuterAngle(value: number);
  39148. /**
  39149. * Sets the position of the emitter if spatial sound is enabled
  39150. * @param newPosition Defines the new posisiton
  39151. */
  39152. setPosition(newPosition: Vector3): void;
  39153. /**
  39154. * Sets the local direction of the emitter if spatial sound is enabled
  39155. * @param newLocalDirection Defines the new local direction
  39156. */
  39157. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  39158. private _updateDirection;
  39159. /** @hidden */
  39160. updateDistanceFromListener(): void;
  39161. /**
  39162. * Sets a new custom attenuation function for the sound.
  39163. * @param callback Defines the function used for the attenuation
  39164. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  39165. */
  39166. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  39167. /**
  39168. * Play the sound
  39169. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  39170. * @param offset (optional) Start the sound at a specific time in seconds
  39171. * @param length (optional) Sound duration (in seconds)
  39172. */
  39173. play(time?: number, offset?: number, length?: number): void;
  39174. private _onended;
  39175. /**
  39176. * Stop the sound
  39177. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  39178. */
  39179. stop(time?: number): void;
  39180. /**
  39181. * Put the sound in pause
  39182. */
  39183. pause(): void;
  39184. /**
  39185. * Sets a dedicated volume for this sounds
  39186. * @param newVolume Define the new volume of the sound
  39187. * @param time Define time for gradual change to new volume
  39188. */
  39189. setVolume(newVolume: number, time?: number): void;
  39190. /**
  39191. * Set the sound play back rate
  39192. * @param newPlaybackRate Define the playback rate the sound should be played at
  39193. */
  39194. setPlaybackRate(newPlaybackRate: number): void;
  39195. /**
  39196. * Gets the volume of the sound.
  39197. * @returns the volume of the sound
  39198. */
  39199. getVolume(): number;
  39200. /**
  39201. * Attach the sound to a dedicated mesh
  39202. * @param transformNode The transform node to connect the sound with
  39203. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  39204. */
  39205. attachToMesh(transformNode: TransformNode): void;
  39206. /**
  39207. * Detach the sound from the previously attached mesh
  39208. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  39209. */
  39210. detachFromMesh(): void;
  39211. private _onRegisterAfterWorldMatrixUpdate;
  39212. /**
  39213. * Clone the current sound in the scene.
  39214. * @returns the new sound clone
  39215. */
  39216. clone(): Nullable<Sound>;
  39217. /**
  39218. * Gets the current underlying audio buffer containing the data
  39219. * @returns the audio buffer
  39220. */
  39221. getAudioBuffer(): Nullable<AudioBuffer>;
  39222. /**
  39223. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  39224. * @returns the source node
  39225. */
  39226. getSoundSource(): Nullable<AudioBufferSourceNode>;
  39227. /**
  39228. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  39229. * @returns the gain node
  39230. */
  39231. getSoundGain(): Nullable<GainNode>;
  39232. /**
  39233. * Serializes the Sound in a JSON representation
  39234. * @returns the JSON representation of the sound
  39235. */
  39236. serialize(): any;
  39237. /**
  39238. * Parse a JSON representation of a sound to innstantiate in a given scene
  39239. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  39240. * @param scene Define the scene the new parsed sound should be created in
  39241. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  39242. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  39243. * @returns the newly parsed sound
  39244. */
  39245. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  39246. }
  39247. }
  39248. declare module "babylonjs/Actions/directAudioActions" {
  39249. import { Action } from "babylonjs/Actions/action";
  39250. import { Condition } from "babylonjs/Actions/condition";
  39251. import { Sound } from "babylonjs/Audio/sound";
  39252. /**
  39253. * This defines an action helpful to play a defined sound on a triggered action.
  39254. */
  39255. export class PlaySoundAction extends Action {
  39256. private _sound;
  39257. /**
  39258. * Instantiate the action
  39259. * @param triggerOptions defines the trigger options
  39260. * @param sound defines the sound to play
  39261. * @param condition defines the trigger related conditions
  39262. */
  39263. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  39264. /** @hidden */
  39265. _prepare(): void;
  39266. /**
  39267. * Execute the action and play the sound.
  39268. */
  39269. execute(): void;
  39270. /**
  39271. * Serializes the actions and its related information.
  39272. * @param parent defines the object to serialize in
  39273. * @returns the serialized object
  39274. */
  39275. serialize(parent: any): any;
  39276. }
  39277. /**
  39278. * This defines an action helpful to stop a defined sound on a triggered action.
  39279. */
  39280. export class StopSoundAction extends Action {
  39281. private _sound;
  39282. /**
  39283. * Instantiate the action
  39284. * @param triggerOptions defines the trigger options
  39285. * @param sound defines the sound to stop
  39286. * @param condition defines the trigger related conditions
  39287. */
  39288. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  39289. /** @hidden */
  39290. _prepare(): void;
  39291. /**
  39292. * Execute the action and stop the sound.
  39293. */
  39294. execute(): void;
  39295. /**
  39296. * Serializes the actions and its related information.
  39297. * @param parent defines the object to serialize in
  39298. * @returns the serialized object
  39299. */
  39300. serialize(parent: any): any;
  39301. }
  39302. }
  39303. declare module "babylonjs/Actions/interpolateValueAction" {
  39304. import { Action } from "babylonjs/Actions/action";
  39305. import { Condition } from "babylonjs/Actions/condition";
  39306. import { Observable } from "babylonjs/Misc/observable";
  39307. /**
  39308. * This defines an action responsible to change the value of a property
  39309. * by interpolating between its current value and the newly set one once triggered.
  39310. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  39311. */
  39312. export class InterpolateValueAction extends Action {
  39313. /**
  39314. * Defines the path of the property where the value should be interpolated
  39315. */
  39316. propertyPath: string;
  39317. /**
  39318. * Defines the target value at the end of the interpolation.
  39319. */
  39320. value: any;
  39321. /**
  39322. * Defines the time it will take for the property to interpolate to the value.
  39323. */
  39324. duration: number;
  39325. /**
  39326. * Defines if the other scene animations should be stopped when the action has been triggered
  39327. */
  39328. stopOtherAnimations?: boolean;
  39329. /**
  39330. * Defines a callback raised once the interpolation animation has been done.
  39331. */
  39332. onInterpolationDone?: () => void;
  39333. /**
  39334. * Observable triggered once the interpolation animation has been done.
  39335. */
  39336. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  39337. private _target;
  39338. private _effectiveTarget;
  39339. private _property;
  39340. /**
  39341. * Instantiate the action
  39342. * @param triggerOptions defines the trigger options
  39343. * @param target defines the object containing the value to interpolate
  39344. * @param propertyPath defines the path to the property in the target object
  39345. * @param value defines the target value at the end of the interpolation
  39346. * @param duration deines the time it will take for the property to interpolate to the value.
  39347. * @param condition defines the trigger related conditions
  39348. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  39349. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  39350. */
  39351. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  39352. /** @hidden */
  39353. _prepare(): void;
  39354. /**
  39355. * Execute the action starts the value interpolation.
  39356. */
  39357. execute(): void;
  39358. /**
  39359. * Serializes the actions and its related information.
  39360. * @param parent defines the object to serialize in
  39361. * @returns the serialized object
  39362. */
  39363. serialize(parent: any): any;
  39364. }
  39365. }
  39366. declare module "babylonjs/Actions/index" {
  39367. export * from "babylonjs/Actions/abstractActionManager";
  39368. export * from "babylonjs/Actions/action";
  39369. export * from "babylonjs/Actions/actionEvent";
  39370. export * from "babylonjs/Actions/actionManager";
  39371. export * from "babylonjs/Actions/condition";
  39372. export * from "babylonjs/Actions/directActions";
  39373. export * from "babylonjs/Actions/directAudioActions";
  39374. export * from "babylonjs/Actions/interpolateValueAction";
  39375. }
  39376. declare module "babylonjs/Animations/index" {
  39377. export * from "babylonjs/Animations/animatable";
  39378. export * from "babylonjs/Animations/animation";
  39379. export * from "babylonjs/Animations/animationGroup";
  39380. export * from "babylonjs/Animations/animationPropertiesOverride";
  39381. export * from "babylonjs/Animations/easing";
  39382. export * from "babylonjs/Animations/runtimeAnimation";
  39383. export * from "babylonjs/Animations/animationEvent";
  39384. export * from "babylonjs/Animations/animationGroup";
  39385. export * from "babylonjs/Animations/animationKey";
  39386. export * from "babylonjs/Animations/animationRange";
  39387. export * from "babylonjs/Animations/animatable.interface";
  39388. }
  39389. declare module "babylonjs/Audio/soundTrack" {
  39390. import { Sound } from "babylonjs/Audio/sound";
  39391. import { Analyser } from "babylonjs/Audio/analyser";
  39392. import { Scene } from "babylonjs/scene";
  39393. /**
  39394. * Options allowed during the creation of a sound track.
  39395. */
  39396. export interface ISoundTrackOptions {
  39397. /**
  39398. * The volume the sound track should take during creation
  39399. */
  39400. volume?: number;
  39401. /**
  39402. * Define if the sound track is the main sound track of the scene
  39403. */
  39404. mainTrack?: boolean;
  39405. }
  39406. /**
  39407. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  39408. * It will be also used in a future release to apply effects on a specific track.
  39409. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  39410. */
  39411. export class SoundTrack {
  39412. /**
  39413. * The unique identifier of the sound track in the scene.
  39414. */
  39415. id: number;
  39416. /**
  39417. * The list of sounds included in the sound track.
  39418. */
  39419. soundCollection: Array<Sound>;
  39420. private _outputAudioNode;
  39421. private _scene;
  39422. private _connectedAnalyser;
  39423. private _options;
  39424. private _isInitialized;
  39425. /**
  39426. * Creates a new sound track.
  39427. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  39428. * @param scene Define the scene the sound track belongs to
  39429. * @param options
  39430. */
  39431. constructor(scene: Scene, options?: ISoundTrackOptions);
  39432. private _initializeSoundTrackAudioGraph;
  39433. /**
  39434. * Release the sound track and its associated resources
  39435. */
  39436. dispose(): void;
  39437. /**
  39438. * Adds a sound to this sound track
  39439. * @param sound define the cound to add
  39440. * @ignoreNaming
  39441. */
  39442. AddSound(sound: Sound): void;
  39443. /**
  39444. * Removes a sound to this sound track
  39445. * @param sound define the cound to remove
  39446. * @ignoreNaming
  39447. */
  39448. RemoveSound(sound: Sound): void;
  39449. /**
  39450. * Set a global volume for the full sound track.
  39451. * @param newVolume Define the new volume of the sound track
  39452. */
  39453. setVolume(newVolume: number): void;
  39454. /**
  39455. * Switch the panning model to HRTF:
  39456. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  39457. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  39458. */
  39459. switchPanningModelToHRTF(): void;
  39460. /**
  39461. * Switch the panning model to Equal Power:
  39462. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  39463. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  39464. */
  39465. switchPanningModelToEqualPower(): void;
  39466. /**
  39467. * Connect the sound track to an audio analyser allowing some amazing
  39468. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  39469. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  39470. * @param analyser The analyser to connect to the engine
  39471. */
  39472. connectToAnalyser(analyser: Analyser): void;
  39473. }
  39474. }
  39475. declare module "babylonjs/Audio/audioSceneComponent" {
  39476. import { Sound } from "babylonjs/Audio/sound";
  39477. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  39478. import { Nullable } from "babylonjs/types";
  39479. import { Vector3 } from "babylonjs/Maths/math.vector";
  39480. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  39481. import { Scene } from "babylonjs/scene";
  39482. import { AbstractScene } from "babylonjs/abstractScene";
  39483. import "babylonjs/Audio/audioEngine";
  39484. module "babylonjs/abstractScene" {
  39485. interface AbstractScene {
  39486. /**
  39487. * The list of sounds used in the scene.
  39488. */
  39489. sounds: Nullable<Array<Sound>>;
  39490. }
  39491. }
  39492. module "babylonjs/scene" {
  39493. interface Scene {
  39494. /**
  39495. * @hidden
  39496. * Backing field
  39497. */
  39498. _mainSoundTrack: SoundTrack;
  39499. /**
  39500. * The main sound track played by the scene.
  39501. * It cotains your primary collection of sounds.
  39502. */
  39503. mainSoundTrack: SoundTrack;
  39504. /**
  39505. * The list of sound tracks added to the scene
  39506. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  39507. */
  39508. soundTracks: Nullable<Array<SoundTrack>>;
  39509. /**
  39510. * Gets a sound using a given name
  39511. * @param name defines the name to search for
  39512. * @return the found sound or null if not found at all.
  39513. */
  39514. getSoundByName(name: string): Nullable<Sound>;
  39515. /**
  39516. * Gets or sets if audio support is enabled
  39517. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  39518. */
  39519. audioEnabled: boolean;
  39520. /**
  39521. * Gets or sets if audio will be output to headphones
  39522. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  39523. */
  39524. headphone: boolean;
  39525. /**
  39526. * Gets or sets custom audio listener position provider
  39527. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  39528. */
  39529. audioListenerPositionProvider: Nullable<() => Vector3>;
  39530. /**
  39531. * Gets or sets a refresh rate when using 3D audio positioning
  39532. */
  39533. audioPositioningRefreshRate: number;
  39534. }
  39535. }
  39536. /**
  39537. * Defines the sound scene component responsible to manage any sounds
  39538. * in a given scene.
  39539. */
  39540. export class AudioSceneComponent implements ISceneSerializableComponent {
  39541. /**
  39542. * The component name helpfull to identify the component in the list of scene components.
  39543. */
  39544. readonly name: string;
  39545. /**
  39546. * The scene the component belongs to.
  39547. */
  39548. scene: Scene;
  39549. private _audioEnabled;
  39550. /**
  39551. * Gets whether audio is enabled or not.
  39552. * Please use related enable/disable method to switch state.
  39553. */
  39554. get audioEnabled(): boolean;
  39555. private _headphone;
  39556. /**
  39557. * Gets whether audio is outputing to headphone or not.
  39558. * Please use the according Switch methods to change output.
  39559. */
  39560. get headphone(): boolean;
  39561. /**
  39562. * Gets or sets a refresh rate when using 3D audio positioning
  39563. */
  39564. audioPositioningRefreshRate: number;
  39565. private _audioListenerPositionProvider;
  39566. /**
  39567. * Gets the current audio listener position provider
  39568. */
  39569. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  39570. /**
  39571. * Sets a custom listener position for all sounds in the scene
  39572. * By default, this is the position of the first active camera
  39573. */
  39574. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  39575. /**
  39576. * Creates a new instance of the component for the given scene
  39577. * @param scene Defines the scene to register the component in
  39578. */
  39579. constructor(scene: Scene);
  39580. /**
  39581. * Registers the component in a given scene
  39582. */
  39583. register(): void;
  39584. /**
  39585. * Rebuilds the elements related to this component in case of
  39586. * context lost for instance.
  39587. */
  39588. rebuild(): void;
  39589. /**
  39590. * Serializes the component data to the specified json object
  39591. * @param serializationObject The object to serialize to
  39592. */
  39593. serialize(serializationObject: any): void;
  39594. /**
  39595. * Adds all the elements from the container to the scene
  39596. * @param container the container holding the elements
  39597. */
  39598. addFromContainer(container: AbstractScene): void;
  39599. /**
  39600. * Removes all the elements in the container from the scene
  39601. * @param container contains the elements to remove
  39602. * @param dispose if the removed element should be disposed (default: false)
  39603. */
  39604. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  39605. /**
  39606. * Disposes the component and the associated ressources.
  39607. */
  39608. dispose(): void;
  39609. /**
  39610. * Disables audio in the associated scene.
  39611. */
  39612. disableAudio(): void;
  39613. /**
  39614. * Enables audio in the associated scene.
  39615. */
  39616. enableAudio(): void;
  39617. /**
  39618. * Switch audio to headphone output.
  39619. */
  39620. switchAudioModeForHeadphones(): void;
  39621. /**
  39622. * Switch audio to normal speakers.
  39623. */
  39624. switchAudioModeForNormalSpeakers(): void;
  39625. private _cachedCameraDirection;
  39626. private _cachedCameraPosition;
  39627. private _lastCheck;
  39628. private _afterRender;
  39629. }
  39630. }
  39631. declare module "babylonjs/Audio/weightedsound" {
  39632. import { Sound } from "babylonjs/Audio/sound";
  39633. /**
  39634. * Wraps one or more Sound objects and selects one with random weight for playback.
  39635. */
  39636. export class WeightedSound {
  39637. /** When true a Sound will be selected and played when the current playing Sound completes. */
  39638. loop: boolean;
  39639. private _coneInnerAngle;
  39640. private _coneOuterAngle;
  39641. private _volume;
  39642. /** A Sound is currently playing. */
  39643. isPlaying: boolean;
  39644. /** A Sound is currently paused. */
  39645. isPaused: boolean;
  39646. private _sounds;
  39647. private _weights;
  39648. private _currentIndex?;
  39649. /**
  39650. * Creates a new WeightedSound from the list of sounds given.
  39651. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  39652. * @param sounds Array of Sounds that will be selected from.
  39653. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  39654. */
  39655. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  39656. /**
  39657. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  39658. */
  39659. get directionalConeInnerAngle(): number;
  39660. /**
  39661. * The size of cone in degress for a directional sound in which there will be no attenuation.
  39662. */
  39663. set directionalConeInnerAngle(value: number);
  39664. /**
  39665. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  39666. * Listener angles between innerAngle and outerAngle will falloff linearly.
  39667. */
  39668. get directionalConeOuterAngle(): number;
  39669. /**
  39670. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  39671. * Listener angles between innerAngle and outerAngle will falloff linearly.
  39672. */
  39673. set directionalConeOuterAngle(value: number);
  39674. /**
  39675. * Playback volume.
  39676. */
  39677. get volume(): number;
  39678. /**
  39679. * Playback volume.
  39680. */
  39681. set volume(value: number);
  39682. private _onended;
  39683. /**
  39684. * Suspend playback
  39685. */
  39686. pause(): void;
  39687. /**
  39688. * Stop playback
  39689. */
  39690. stop(): void;
  39691. /**
  39692. * Start playback.
  39693. * @param startOffset Position the clip head at a specific time in seconds.
  39694. */
  39695. play(startOffset?: number): void;
  39696. }
  39697. }
  39698. declare module "babylonjs/Audio/index" {
  39699. export * from "babylonjs/Audio/analyser";
  39700. export * from "babylonjs/Audio/audioEngine";
  39701. export * from "babylonjs/Audio/audioSceneComponent";
  39702. export * from "babylonjs/Audio/sound";
  39703. export * from "babylonjs/Audio/soundTrack";
  39704. export * from "babylonjs/Audio/weightedsound";
  39705. }
  39706. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  39707. import { Behavior } from "babylonjs/Behaviors/behavior";
  39708. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39709. import { BackEase } from "babylonjs/Animations/easing";
  39710. /**
  39711. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  39712. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  39713. */
  39714. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  39715. /**
  39716. * Gets the name of the behavior.
  39717. */
  39718. get name(): string;
  39719. /**
  39720. * The easing function used by animations
  39721. */
  39722. static EasingFunction: BackEase;
  39723. /**
  39724. * The easing mode used by animations
  39725. */
  39726. static EasingMode: number;
  39727. /**
  39728. * The duration of the animation, in milliseconds
  39729. */
  39730. transitionDuration: number;
  39731. /**
  39732. * Length of the distance animated by the transition when lower radius is reached
  39733. */
  39734. lowerRadiusTransitionRange: number;
  39735. /**
  39736. * Length of the distance animated by the transition when upper radius is reached
  39737. */
  39738. upperRadiusTransitionRange: number;
  39739. private _autoTransitionRange;
  39740. /**
  39741. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  39742. */
  39743. get autoTransitionRange(): boolean;
  39744. /**
  39745. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  39746. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  39747. */
  39748. set autoTransitionRange(value: boolean);
  39749. private _attachedCamera;
  39750. private _onAfterCheckInputsObserver;
  39751. private _onMeshTargetChangedObserver;
  39752. /**
  39753. * Initializes the behavior.
  39754. */
  39755. init(): void;
  39756. /**
  39757. * Attaches the behavior to its arc rotate camera.
  39758. * @param camera Defines the camera to attach the behavior to
  39759. */
  39760. attach(camera: ArcRotateCamera): void;
  39761. /**
  39762. * Detaches the behavior from its current arc rotate camera.
  39763. */
  39764. detach(): void;
  39765. private _radiusIsAnimating;
  39766. private _radiusBounceTransition;
  39767. private _animatables;
  39768. private _cachedWheelPrecision;
  39769. /**
  39770. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  39771. * @param radiusLimit The limit to check against.
  39772. * @return Bool to indicate if at limit.
  39773. */
  39774. private _isRadiusAtLimit;
  39775. /**
  39776. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  39777. * @param radiusDelta The delta by which to animate to. Can be negative.
  39778. */
  39779. private _applyBoundRadiusAnimation;
  39780. /**
  39781. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  39782. */
  39783. protected _clearAnimationLocks(): void;
  39784. /**
  39785. * Stops and removes all animations that have been applied to the camera
  39786. */
  39787. stopAllAnimations(): void;
  39788. }
  39789. }
  39790. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  39791. import { Behavior } from "babylonjs/Behaviors/behavior";
  39792. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39793. import { ExponentialEase } from "babylonjs/Animations/easing";
  39794. import { Nullable } from "babylonjs/types";
  39795. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39796. import { Vector3 } from "babylonjs/Maths/math.vector";
  39797. /**
  39798. * 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.
  39799. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  39800. */
  39801. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  39802. /**
  39803. * Gets the name of the behavior.
  39804. */
  39805. get name(): string;
  39806. private _mode;
  39807. private _radiusScale;
  39808. private _positionScale;
  39809. private _defaultElevation;
  39810. private _elevationReturnTime;
  39811. private _elevationReturnWaitTime;
  39812. private _zoomStopsAnimation;
  39813. private _framingTime;
  39814. /**
  39815. * The easing function used by animations
  39816. */
  39817. static EasingFunction: ExponentialEase;
  39818. /**
  39819. * The easing mode used by animations
  39820. */
  39821. static EasingMode: number;
  39822. /**
  39823. * Sets the current mode used by the behavior
  39824. */
  39825. set mode(mode: number);
  39826. /**
  39827. * Gets current mode used by the behavior.
  39828. */
  39829. get mode(): number;
  39830. /**
  39831. * Sets the scale applied to the radius (1 by default)
  39832. */
  39833. set radiusScale(radius: number);
  39834. /**
  39835. * Gets the scale applied to the radius
  39836. */
  39837. get radiusScale(): number;
  39838. /**
  39839. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  39840. */
  39841. set positionScale(scale: number);
  39842. /**
  39843. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  39844. */
  39845. get positionScale(): number;
  39846. /**
  39847. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  39848. * behaviour is triggered, in radians.
  39849. */
  39850. set defaultElevation(elevation: number);
  39851. /**
  39852. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  39853. * behaviour is triggered, in radians.
  39854. */
  39855. get defaultElevation(): number;
  39856. /**
  39857. * Sets the time (in milliseconds) taken to return to the default beta position.
  39858. * Negative value indicates camera should not return to default.
  39859. */
  39860. set elevationReturnTime(speed: number);
  39861. /**
  39862. * Gets the time (in milliseconds) taken to return to the default beta position.
  39863. * Negative value indicates camera should not return to default.
  39864. */
  39865. get elevationReturnTime(): number;
  39866. /**
  39867. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  39868. */
  39869. set elevationReturnWaitTime(time: number);
  39870. /**
  39871. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  39872. */
  39873. get elevationReturnWaitTime(): number;
  39874. /**
  39875. * Sets the flag that indicates if user zooming should stop animation.
  39876. */
  39877. set zoomStopsAnimation(flag: boolean);
  39878. /**
  39879. * Gets the flag that indicates if user zooming should stop animation.
  39880. */
  39881. get zoomStopsAnimation(): boolean;
  39882. /**
  39883. * Sets the transition time when framing the mesh, in milliseconds
  39884. */
  39885. set framingTime(time: number);
  39886. /**
  39887. * Gets the transition time when framing the mesh, in milliseconds
  39888. */
  39889. get framingTime(): number;
  39890. /**
  39891. * Define if the behavior should automatically change the configured
  39892. * camera limits and sensibilities.
  39893. */
  39894. autoCorrectCameraLimitsAndSensibility: boolean;
  39895. private _onPrePointerObservableObserver;
  39896. private _onAfterCheckInputsObserver;
  39897. private _onMeshTargetChangedObserver;
  39898. private _attachedCamera;
  39899. private _isPointerDown;
  39900. private _lastInteractionTime;
  39901. /**
  39902. * Initializes the behavior.
  39903. */
  39904. init(): void;
  39905. /**
  39906. * Attaches the behavior to its arc rotate camera.
  39907. * @param camera Defines the camera to attach the behavior to
  39908. */
  39909. attach(camera: ArcRotateCamera): void;
  39910. /**
  39911. * Detaches the behavior from its current arc rotate camera.
  39912. */
  39913. detach(): void;
  39914. private _animatables;
  39915. private _betaIsAnimating;
  39916. private _betaTransition;
  39917. private _radiusTransition;
  39918. private _vectorTransition;
  39919. /**
  39920. * Targets the given mesh and updates zoom level accordingly.
  39921. * @param mesh The mesh to target.
  39922. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  39923. * @param onAnimationEnd Callback triggered at the end of the framing animation
  39924. */
  39925. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  39926. /**
  39927. * Targets the given mesh with its children and updates zoom level accordingly.
  39928. * @param mesh The mesh to target.
  39929. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  39930. * @param onAnimationEnd Callback triggered at the end of the framing animation
  39931. */
  39932. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  39933. /**
  39934. * Targets the given meshes with their children and updates zoom level accordingly.
  39935. * @param meshes The mesh to target.
  39936. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  39937. * @param onAnimationEnd Callback triggered at the end of the framing animation
  39938. */
  39939. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  39940. /**
  39941. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  39942. * @param minimumWorld Determines the smaller position of the bounding box extend
  39943. * @param maximumWorld Determines the bigger position of the bounding box extend
  39944. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  39945. * @param onAnimationEnd Callback triggered at the end of the framing animation
  39946. */
  39947. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  39948. /**
  39949. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  39950. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  39951. * frustum width.
  39952. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  39953. * to fully enclose the mesh in the viewing frustum.
  39954. */
  39955. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  39956. /**
  39957. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  39958. * is automatically returned to its default position (expected to be above ground plane).
  39959. */
  39960. private _maintainCameraAboveGround;
  39961. /**
  39962. * Returns the frustum slope based on the canvas ratio and camera FOV
  39963. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  39964. */
  39965. private _getFrustumSlope;
  39966. /**
  39967. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  39968. */
  39969. private _clearAnimationLocks;
  39970. /**
  39971. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  39972. */
  39973. private _applyUserInteraction;
  39974. /**
  39975. * Stops and removes all animations that have been applied to the camera
  39976. */
  39977. stopAllAnimations(): void;
  39978. /**
  39979. * Gets a value indicating if the user is moving the camera
  39980. */
  39981. get isUserIsMoving(): boolean;
  39982. /**
  39983. * The camera can move all the way towards the mesh.
  39984. */
  39985. static IgnoreBoundsSizeMode: number;
  39986. /**
  39987. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  39988. */
  39989. static FitFrustumSidesMode: number;
  39990. }
  39991. }
  39992. declare module "babylonjs/Cameras/Inputs/BaseCameraPointersInput" {
  39993. import { Nullable } from "babylonjs/types";
  39994. import { Camera } from "babylonjs/Cameras/camera";
  39995. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39996. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  39997. /**
  39998. * Base class for Camera Pointer Inputs.
  39999. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  40000. * for example usage.
  40001. */
  40002. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  40003. /**
  40004. * Defines the camera the input is attached to.
  40005. */
  40006. abstract camera: Camera;
  40007. /**
  40008. * Whether keyboard modifier keys are pressed at time of last mouse event.
  40009. */
  40010. protected _altKey: boolean;
  40011. protected _ctrlKey: boolean;
  40012. protected _metaKey: boolean;
  40013. protected _shiftKey: boolean;
  40014. /**
  40015. * Which mouse buttons were pressed at time of last mouse event.
  40016. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  40017. */
  40018. protected _buttonsPressed: number;
  40019. /**
  40020. * Defines the buttons associated with the input to handle camera move.
  40021. */
  40022. buttons: number[];
  40023. /**
  40024. * Attach the input controls to a specific dom element to get the input from.
  40025. * @param element Defines the element the controls should be listened from
  40026. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40027. */
  40028. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40029. /**
  40030. * Detach the current controls from the specified dom element.
  40031. * @param element Defines the element to stop listening the inputs from
  40032. */
  40033. detachControl(element: Nullable<HTMLElement>): void;
  40034. /**
  40035. * Gets the class name of the current input.
  40036. * @returns the class name
  40037. */
  40038. getClassName(): string;
  40039. /**
  40040. * Get the friendly name associated with the input class.
  40041. * @returns the input friendly name
  40042. */
  40043. getSimpleName(): string;
  40044. /**
  40045. * Called on pointer POINTERDOUBLETAP event.
  40046. * Override this method to provide functionality on POINTERDOUBLETAP event.
  40047. */
  40048. protected onDoubleTap(type: string): void;
  40049. /**
  40050. * Called on pointer POINTERMOVE event if only a single touch is active.
  40051. * Override this method to provide functionality.
  40052. */
  40053. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  40054. /**
  40055. * Called on pointer POINTERMOVE event if multiple touches are active.
  40056. * Override this method to provide functionality.
  40057. */
  40058. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  40059. /**
  40060. * Called on JS contextmenu event.
  40061. * Override this method to provide functionality.
  40062. */
  40063. protected onContextMenu(evt: PointerEvent): void;
  40064. /**
  40065. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  40066. * press.
  40067. * Override this method to provide functionality.
  40068. */
  40069. protected onButtonDown(evt: PointerEvent): void;
  40070. /**
  40071. * Called each time a new POINTERUP event occurs. Ie, for each button
  40072. * release.
  40073. * Override this method to provide functionality.
  40074. */
  40075. protected onButtonUp(evt: PointerEvent): void;
  40076. /**
  40077. * Called when window becomes inactive.
  40078. * Override this method to provide functionality.
  40079. */
  40080. protected onLostFocus(): void;
  40081. private _pointerInput;
  40082. private _observer;
  40083. private _onLostFocus;
  40084. private pointA;
  40085. private pointB;
  40086. }
  40087. }
  40088. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  40089. import { Nullable } from "babylonjs/types";
  40090. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40091. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  40092. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  40093. /**
  40094. * Manage the pointers inputs to control an arc rotate camera.
  40095. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40096. */
  40097. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  40098. /**
  40099. * Defines the camera the input is attached to.
  40100. */
  40101. camera: ArcRotateCamera;
  40102. /**
  40103. * Gets the class name of the current input.
  40104. * @returns the class name
  40105. */
  40106. getClassName(): string;
  40107. /**
  40108. * Defines the buttons associated with the input to handle camera move.
  40109. */
  40110. buttons: number[];
  40111. /**
  40112. * Defines the pointer angular sensibility along the X axis or how fast is
  40113. * the camera rotating.
  40114. */
  40115. angularSensibilityX: number;
  40116. /**
  40117. * Defines the pointer angular sensibility along the Y axis or how fast is
  40118. * the camera rotating.
  40119. */
  40120. angularSensibilityY: number;
  40121. /**
  40122. * Defines the pointer pinch precision or how fast is the camera zooming.
  40123. */
  40124. pinchPrecision: number;
  40125. /**
  40126. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  40127. * from 0.
  40128. * It defines the percentage of current camera.radius to use as delta when
  40129. * pinch zoom is used.
  40130. */
  40131. pinchDeltaPercentage: number;
  40132. /**
  40133. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  40134. * that any object in the plane at the camera's target point will scale
  40135. * perfectly with finger motion.
  40136. * Overrides pinchDeltaPercentage and pinchPrecision.
  40137. */
  40138. useNaturalPinchZoom: boolean;
  40139. /**
  40140. * Defines the pointer panning sensibility or how fast is the camera moving.
  40141. */
  40142. panningSensibility: number;
  40143. /**
  40144. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  40145. */
  40146. multiTouchPanning: boolean;
  40147. /**
  40148. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  40149. * zoom (pinch) through multitouch.
  40150. */
  40151. multiTouchPanAndZoom: boolean;
  40152. /**
  40153. * Revers pinch action direction.
  40154. */
  40155. pinchInwards: boolean;
  40156. private _isPanClick;
  40157. private _twoFingerActivityCount;
  40158. private _isPinching;
  40159. /**
  40160. * Called on pointer POINTERMOVE event if only a single touch is active.
  40161. */
  40162. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  40163. /**
  40164. * Called on pointer POINTERDOUBLETAP event.
  40165. */
  40166. protected onDoubleTap(type: string): void;
  40167. /**
  40168. * Called on pointer POINTERMOVE event if multiple touches are active.
  40169. */
  40170. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  40171. /**
  40172. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  40173. * press.
  40174. */
  40175. protected onButtonDown(evt: PointerEvent): void;
  40176. /**
  40177. * Called each time a new POINTERUP event occurs. Ie, for each button
  40178. * release.
  40179. */
  40180. protected onButtonUp(evt: PointerEvent): void;
  40181. /**
  40182. * Called when window becomes inactive.
  40183. */
  40184. protected onLostFocus(): void;
  40185. }
  40186. }
  40187. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  40188. import { Nullable } from "babylonjs/types";
  40189. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40190. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  40191. /**
  40192. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  40193. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40194. */
  40195. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  40196. /**
  40197. * Defines the camera the input is attached to.
  40198. */
  40199. camera: ArcRotateCamera;
  40200. /**
  40201. * Defines the list of key codes associated with the up action (increase alpha)
  40202. */
  40203. keysUp: number[];
  40204. /**
  40205. * Defines the list of key codes associated with the down action (decrease alpha)
  40206. */
  40207. keysDown: number[];
  40208. /**
  40209. * Defines the list of key codes associated with the left action (increase beta)
  40210. */
  40211. keysLeft: number[];
  40212. /**
  40213. * Defines the list of key codes associated with the right action (decrease beta)
  40214. */
  40215. keysRight: number[];
  40216. /**
  40217. * Defines the list of key codes associated with the reset action.
  40218. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  40219. */
  40220. keysReset: number[];
  40221. /**
  40222. * Defines the panning sensibility of the inputs.
  40223. * (How fast is the camera panning)
  40224. */
  40225. panningSensibility: number;
  40226. /**
  40227. * Defines the zooming sensibility of the inputs.
  40228. * (How fast is the camera zooming)
  40229. */
  40230. zoomingSensibility: number;
  40231. /**
  40232. * Defines whether maintaining the alt key down switch the movement mode from
  40233. * orientation to zoom.
  40234. */
  40235. useAltToZoom: boolean;
  40236. /**
  40237. * Rotation speed of the camera
  40238. */
  40239. angularSpeed: number;
  40240. private _keys;
  40241. private _ctrlPressed;
  40242. private _altPressed;
  40243. private _onCanvasBlurObserver;
  40244. private _onKeyboardObserver;
  40245. private _engine;
  40246. private _scene;
  40247. /**
  40248. * Attach the input controls to a specific dom element to get the input from.
  40249. * @param element Defines the element the controls should be listened from
  40250. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40251. */
  40252. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40253. /**
  40254. * Detach the current controls from the specified dom element.
  40255. * @param element Defines the element to stop listening the inputs from
  40256. */
  40257. detachControl(element: Nullable<HTMLElement>): void;
  40258. /**
  40259. * Update the current camera state depending on the inputs that have been used this frame.
  40260. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40261. */
  40262. checkInputs(): void;
  40263. /**
  40264. * Gets the class name of the current intput.
  40265. * @returns the class name
  40266. */
  40267. getClassName(): string;
  40268. /**
  40269. * Get the friendly name associated with the input class.
  40270. * @returns the input friendly name
  40271. */
  40272. getSimpleName(): string;
  40273. }
  40274. }
  40275. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  40276. import { Nullable } from "babylonjs/types";
  40277. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40278. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  40279. /**
  40280. * Manage the mouse wheel inputs to control an arc rotate camera.
  40281. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40282. */
  40283. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  40284. /**
  40285. * Defines the camera the input is attached to.
  40286. */
  40287. camera: ArcRotateCamera;
  40288. /**
  40289. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  40290. */
  40291. wheelPrecision: number;
  40292. /**
  40293. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  40294. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  40295. */
  40296. wheelDeltaPercentage: number;
  40297. private _wheel;
  40298. private _observer;
  40299. private computeDeltaFromMouseWheelLegacyEvent;
  40300. /**
  40301. * Attach the input controls to a specific dom element to get the input from.
  40302. * @param element Defines the element the controls should be listened from
  40303. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40304. */
  40305. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40306. /**
  40307. * Detach the current controls from the specified dom element.
  40308. * @param element Defines the element to stop listening the inputs from
  40309. */
  40310. detachControl(element: Nullable<HTMLElement>): void;
  40311. /**
  40312. * Gets the class name of the current intput.
  40313. * @returns the class name
  40314. */
  40315. getClassName(): string;
  40316. /**
  40317. * Get the friendly name associated with the input class.
  40318. * @returns the input friendly name
  40319. */
  40320. getSimpleName(): string;
  40321. }
  40322. }
  40323. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  40324. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40325. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  40326. /**
  40327. * Default Inputs manager for the ArcRotateCamera.
  40328. * It groups all the default supported inputs for ease of use.
  40329. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40330. */
  40331. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  40332. /**
  40333. * Instantiates a new ArcRotateCameraInputsManager.
  40334. * @param camera Defines the camera the inputs belong to
  40335. */
  40336. constructor(camera: ArcRotateCamera);
  40337. /**
  40338. * Add mouse wheel input support to the input manager.
  40339. * @returns the current input manager
  40340. */
  40341. addMouseWheel(): ArcRotateCameraInputsManager;
  40342. /**
  40343. * Add pointers input support to the input manager.
  40344. * @returns the current input manager
  40345. */
  40346. addPointers(): ArcRotateCameraInputsManager;
  40347. /**
  40348. * Add keyboard input support to the input manager.
  40349. * @returns the current input manager
  40350. */
  40351. addKeyboard(): ArcRotateCameraInputsManager;
  40352. }
  40353. }
  40354. declare module "babylonjs/Cameras/arcRotateCamera" {
  40355. import { Observable } from "babylonjs/Misc/observable";
  40356. import { Nullable } from "babylonjs/types";
  40357. import { Scene } from "babylonjs/scene";
  40358. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  40359. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40360. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  40361. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  40362. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  40363. import { Camera } from "babylonjs/Cameras/camera";
  40364. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  40365. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  40366. import { Collider } from "babylonjs/Collisions/collider";
  40367. /**
  40368. * This represents an orbital type of camera.
  40369. *
  40370. * 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.
  40371. * 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.
  40372. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  40373. */
  40374. export class ArcRotateCamera extends TargetCamera {
  40375. /**
  40376. * Defines the rotation angle of the camera along the longitudinal axis.
  40377. */
  40378. alpha: number;
  40379. /**
  40380. * Defines the rotation angle of the camera along the latitudinal axis.
  40381. */
  40382. beta: number;
  40383. /**
  40384. * Defines the radius of the camera from it s target point.
  40385. */
  40386. radius: number;
  40387. protected _target: Vector3;
  40388. protected _targetHost: Nullable<AbstractMesh>;
  40389. /**
  40390. * Defines the target point of the camera.
  40391. * The camera looks towards it form the radius distance.
  40392. */
  40393. get target(): Vector3;
  40394. set target(value: Vector3);
  40395. /**
  40396. * Define the current local position of the camera in the scene
  40397. */
  40398. get position(): Vector3;
  40399. set position(newPosition: Vector3);
  40400. protected _upVector: Vector3;
  40401. protected _upToYMatrix: Matrix;
  40402. protected _YToUpMatrix: Matrix;
  40403. /**
  40404. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  40405. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  40406. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  40407. */
  40408. set upVector(vec: Vector3);
  40409. get upVector(): Vector3;
  40410. /**
  40411. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  40412. */
  40413. setMatUp(): void;
  40414. /**
  40415. * Current inertia value on the longitudinal axis.
  40416. * The bigger this number the longer it will take for the camera to stop.
  40417. */
  40418. inertialAlphaOffset: number;
  40419. /**
  40420. * Current inertia value on the latitudinal axis.
  40421. * The bigger this number the longer it will take for the camera to stop.
  40422. */
  40423. inertialBetaOffset: number;
  40424. /**
  40425. * Current inertia value on the radius axis.
  40426. * The bigger this number the longer it will take for the camera to stop.
  40427. */
  40428. inertialRadiusOffset: number;
  40429. /**
  40430. * Minimum allowed angle on the longitudinal axis.
  40431. * This can help limiting how the Camera is able to move in the scene.
  40432. */
  40433. lowerAlphaLimit: Nullable<number>;
  40434. /**
  40435. * Maximum allowed angle on the longitudinal axis.
  40436. * This can help limiting how the Camera is able to move in the scene.
  40437. */
  40438. upperAlphaLimit: Nullable<number>;
  40439. /**
  40440. * Minimum allowed angle on the latitudinal axis.
  40441. * This can help limiting how the Camera is able to move in the scene.
  40442. */
  40443. lowerBetaLimit: number;
  40444. /**
  40445. * Maximum allowed angle on the latitudinal axis.
  40446. * This can help limiting how the Camera is able to move in the scene.
  40447. */
  40448. upperBetaLimit: number;
  40449. /**
  40450. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  40451. * This can help limiting how the Camera is able to move in the scene.
  40452. */
  40453. lowerRadiusLimit: Nullable<number>;
  40454. /**
  40455. * Maximum allowed distance of the camera to the target (The camera can not get further).
  40456. * This can help limiting how the Camera is able to move in the scene.
  40457. */
  40458. upperRadiusLimit: Nullable<number>;
  40459. /**
  40460. * Defines the current inertia value used during panning of the camera along the X axis.
  40461. */
  40462. inertialPanningX: number;
  40463. /**
  40464. * Defines the current inertia value used during panning of the camera along the Y axis.
  40465. */
  40466. inertialPanningY: number;
  40467. /**
  40468. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  40469. * Basically if your fingers moves away from more than this distance you will be considered
  40470. * in pinch mode.
  40471. */
  40472. pinchToPanMaxDistance: number;
  40473. /**
  40474. * Defines the maximum distance the camera can pan.
  40475. * This could help keeping the cammera always in your scene.
  40476. */
  40477. panningDistanceLimit: Nullable<number>;
  40478. /**
  40479. * Defines the target of the camera before paning.
  40480. */
  40481. panningOriginTarget: Vector3;
  40482. /**
  40483. * Defines the value of the inertia used during panning.
  40484. * 0 would mean stop inertia and one would mean no decelleration at all.
  40485. */
  40486. panningInertia: number;
  40487. /**
  40488. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  40489. */
  40490. get angularSensibilityX(): number;
  40491. set angularSensibilityX(value: number);
  40492. /**
  40493. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  40494. */
  40495. get angularSensibilityY(): number;
  40496. set angularSensibilityY(value: number);
  40497. /**
  40498. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  40499. */
  40500. get pinchPrecision(): number;
  40501. set pinchPrecision(value: number);
  40502. /**
  40503. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  40504. * It will be used instead of pinchDeltaPrecision if different from 0.
  40505. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  40506. */
  40507. get pinchDeltaPercentage(): number;
  40508. set pinchDeltaPercentage(value: number);
  40509. /**
  40510. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  40511. * and pinch delta percentage.
  40512. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  40513. * that any object in the plane at the camera's target point will scale
  40514. * perfectly with finger motion.
  40515. */
  40516. get useNaturalPinchZoom(): boolean;
  40517. set useNaturalPinchZoom(value: boolean);
  40518. /**
  40519. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  40520. */
  40521. get panningSensibility(): number;
  40522. set panningSensibility(value: number);
  40523. /**
  40524. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  40525. */
  40526. get keysUp(): number[];
  40527. set keysUp(value: number[]);
  40528. /**
  40529. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  40530. */
  40531. get keysDown(): number[];
  40532. set keysDown(value: number[]);
  40533. /**
  40534. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  40535. */
  40536. get keysLeft(): number[];
  40537. set keysLeft(value: number[]);
  40538. /**
  40539. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  40540. */
  40541. get keysRight(): number[];
  40542. set keysRight(value: number[]);
  40543. /**
  40544. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  40545. */
  40546. get wheelPrecision(): number;
  40547. set wheelPrecision(value: number);
  40548. /**
  40549. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  40550. * It will be used instead of pinchDeltaPrecision if different from 0.
  40551. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  40552. */
  40553. get wheelDeltaPercentage(): number;
  40554. set wheelDeltaPercentage(value: number);
  40555. /**
  40556. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  40557. */
  40558. zoomOnFactor: number;
  40559. /**
  40560. * Defines a screen offset for the camera position.
  40561. */
  40562. targetScreenOffset: Vector2;
  40563. /**
  40564. * Allows the camera to be completely reversed.
  40565. * If false the camera can not arrive upside down.
  40566. */
  40567. allowUpsideDown: boolean;
  40568. /**
  40569. * Define if double tap/click is used to restore the previously saved state of the camera.
  40570. */
  40571. useInputToRestoreState: boolean;
  40572. /** @hidden */
  40573. _viewMatrix: Matrix;
  40574. /** @hidden */
  40575. _useCtrlForPanning: boolean;
  40576. /** @hidden */
  40577. _panningMouseButton: number;
  40578. /**
  40579. * Defines the input associated to the camera.
  40580. */
  40581. inputs: ArcRotateCameraInputsManager;
  40582. /** @hidden */
  40583. _reset: () => void;
  40584. /**
  40585. * Defines the allowed panning axis.
  40586. */
  40587. panningAxis: Vector3;
  40588. protected _localDirection: Vector3;
  40589. protected _transformedDirection: Vector3;
  40590. private _bouncingBehavior;
  40591. /**
  40592. * Gets the bouncing behavior of the camera if it has been enabled.
  40593. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  40594. */
  40595. get bouncingBehavior(): Nullable<BouncingBehavior>;
  40596. /**
  40597. * Defines if the bouncing behavior of the camera is enabled on the camera.
  40598. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  40599. */
  40600. get useBouncingBehavior(): boolean;
  40601. set useBouncingBehavior(value: boolean);
  40602. private _framingBehavior;
  40603. /**
  40604. * Gets the framing behavior of the camera if it has been enabled.
  40605. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  40606. */
  40607. get framingBehavior(): Nullable<FramingBehavior>;
  40608. /**
  40609. * Defines if the framing behavior of the camera is enabled on the camera.
  40610. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  40611. */
  40612. get useFramingBehavior(): boolean;
  40613. set useFramingBehavior(value: boolean);
  40614. private _autoRotationBehavior;
  40615. /**
  40616. * Gets the auto rotation behavior of the camera if it has been enabled.
  40617. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  40618. */
  40619. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  40620. /**
  40621. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  40622. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  40623. */
  40624. get useAutoRotationBehavior(): boolean;
  40625. set useAutoRotationBehavior(value: boolean);
  40626. /**
  40627. * Observable triggered when the mesh target has been changed on the camera.
  40628. */
  40629. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  40630. /**
  40631. * Event raised when the camera is colliding with a mesh.
  40632. */
  40633. onCollide: (collidedMesh: AbstractMesh) => void;
  40634. /**
  40635. * Defines whether the camera should check collision with the objects oh the scene.
  40636. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  40637. */
  40638. checkCollisions: boolean;
  40639. /**
  40640. * Defines the collision radius of the camera.
  40641. * This simulates a sphere around the camera.
  40642. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  40643. */
  40644. collisionRadius: Vector3;
  40645. protected _collider: Collider;
  40646. protected _previousPosition: Vector3;
  40647. protected _collisionVelocity: Vector3;
  40648. protected _newPosition: Vector3;
  40649. protected _previousAlpha: number;
  40650. protected _previousBeta: number;
  40651. protected _previousRadius: number;
  40652. protected _collisionTriggered: boolean;
  40653. protected _targetBoundingCenter: Nullable<Vector3>;
  40654. private _computationVector;
  40655. /**
  40656. * Instantiates a new ArcRotateCamera in a given scene
  40657. * @param name Defines the name of the camera
  40658. * @param alpha Defines the camera rotation along the logitudinal axis
  40659. * @param beta Defines the camera rotation along the latitudinal axis
  40660. * @param radius Defines the camera distance from its target
  40661. * @param target Defines the camera target
  40662. * @param scene Defines the scene the camera belongs to
  40663. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  40664. */
  40665. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  40666. /** @hidden */
  40667. _initCache(): void;
  40668. /** @hidden */
  40669. _updateCache(ignoreParentClass?: boolean): void;
  40670. protected _getTargetPosition(): Vector3;
  40671. private _storedAlpha;
  40672. private _storedBeta;
  40673. private _storedRadius;
  40674. private _storedTarget;
  40675. private _storedTargetScreenOffset;
  40676. /**
  40677. * Stores the current state of the camera (alpha, beta, radius and target)
  40678. * @returns the camera itself
  40679. */
  40680. storeState(): Camera;
  40681. /**
  40682. * @hidden
  40683. * Restored camera state. You must call storeState() first
  40684. */
  40685. _restoreStateValues(): boolean;
  40686. /** @hidden */
  40687. _isSynchronizedViewMatrix(): boolean;
  40688. /**
  40689. * Attached controls to the current camera.
  40690. * @param element Defines the element the controls should be listened from
  40691. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40692. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  40693. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  40694. */
  40695. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  40696. /**
  40697. * Detach the current controls from the camera.
  40698. * The camera will stop reacting to inputs.
  40699. * @param element Defines the element to stop listening the inputs from
  40700. */
  40701. detachControl(element: HTMLElement): void;
  40702. /** @hidden */
  40703. _checkInputs(): void;
  40704. protected _checkLimits(): void;
  40705. /**
  40706. * Rebuilds angles (alpha, beta) and radius from the give position and target
  40707. */
  40708. rebuildAnglesAndRadius(): void;
  40709. /**
  40710. * Use a position to define the current camera related information like alpha, beta and radius
  40711. * @param position Defines the position to set the camera at
  40712. */
  40713. setPosition(position: Vector3): void;
  40714. /**
  40715. * Defines the target the camera should look at.
  40716. * This will automatically adapt alpha beta and radius to fit within the new target.
  40717. * @param target Defines the new target as a Vector or a mesh
  40718. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  40719. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  40720. */
  40721. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  40722. /** @hidden */
  40723. _getViewMatrix(): Matrix;
  40724. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  40725. /**
  40726. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  40727. * @param meshes Defines the mesh to zoom on
  40728. * @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)
  40729. */
  40730. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  40731. /**
  40732. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  40733. * The target will be changed but the radius
  40734. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  40735. * @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)
  40736. */
  40737. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  40738. min: Vector3;
  40739. max: Vector3;
  40740. distance: number;
  40741. }, doNotUpdateMaxZ?: boolean): void;
  40742. /**
  40743. * @override
  40744. * Override Camera.createRigCamera
  40745. */
  40746. createRigCamera(name: string, cameraIndex: number): Camera;
  40747. /**
  40748. * @hidden
  40749. * @override
  40750. * Override Camera._updateRigCameras
  40751. */
  40752. _updateRigCameras(): void;
  40753. /**
  40754. * Destroy the camera and release the current resources hold by it.
  40755. */
  40756. dispose(): void;
  40757. /**
  40758. * Gets the current object class name.
  40759. * @return the class name
  40760. */
  40761. getClassName(): string;
  40762. }
  40763. }
  40764. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  40765. import { Behavior } from "babylonjs/Behaviors/behavior";
  40766. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40767. /**
  40768. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  40769. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  40770. */
  40771. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  40772. /**
  40773. * Gets the name of the behavior.
  40774. */
  40775. get name(): string;
  40776. private _zoomStopsAnimation;
  40777. private _idleRotationSpeed;
  40778. private _idleRotationWaitTime;
  40779. private _idleRotationSpinupTime;
  40780. /**
  40781. * Sets the flag that indicates if user zooming should stop animation.
  40782. */
  40783. set zoomStopsAnimation(flag: boolean);
  40784. /**
  40785. * Gets the flag that indicates if user zooming should stop animation.
  40786. */
  40787. get zoomStopsAnimation(): boolean;
  40788. /**
  40789. * Sets the default speed at which the camera rotates around the model.
  40790. */
  40791. set idleRotationSpeed(speed: number);
  40792. /**
  40793. * Gets the default speed at which the camera rotates around the model.
  40794. */
  40795. get idleRotationSpeed(): number;
  40796. /**
  40797. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  40798. */
  40799. set idleRotationWaitTime(time: number);
  40800. /**
  40801. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  40802. */
  40803. get idleRotationWaitTime(): number;
  40804. /**
  40805. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  40806. */
  40807. set idleRotationSpinupTime(time: number);
  40808. /**
  40809. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  40810. */
  40811. get idleRotationSpinupTime(): number;
  40812. /**
  40813. * Gets a value indicating if the camera is currently rotating because of this behavior
  40814. */
  40815. get rotationInProgress(): boolean;
  40816. private _onPrePointerObservableObserver;
  40817. private _onAfterCheckInputsObserver;
  40818. private _attachedCamera;
  40819. private _isPointerDown;
  40820. private _lastFrameTime;
  40821. private _lastInteractionTime;
  40822. private _cameraRotationSpeed;
  40823. /**
  40824. * Initializes the behavior.
  40825. */
  40826. init(): void;
  40827. /**
  40828. * Attaches the behavior to its arc rotate camera.
  40829. * @param camera Defines the camera to attach the behavior to
  40830. */
  40831. attach(camera: ArcRotateCamera): void;
  40832. /**
  40833. * Detaches the behavior from its current arc rotate camera.
  40834. */
  40835. detach(): void;
  40836. /**
  40837. * Returns true if user is scrolling.
  40838. * @return true if user is scrolling.
  40839. */
  40840. private _userIsZooming;
  40841. private _lastFrameRadius;
  40842. private _shouldAnimationStopForInteraction;
  40843. /**
  40844. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  40845. */
  40846. private _applyUserInteraction;
  40847. private _userIsMoving;
  40848. }
  40849. }
  40850. declare module "babylonjs/Behaviors/Cameras/index" {
  40851. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  40852. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  40853. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  40854. }
  40855. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  40856. import { Mesh } from "babylonjs/Meshes/mesh";
  40857. import { TransformNode } from "babylonjs/Meshes/transformNode";
  40858. import { Behavior } from "babylonjs/Behaviors/behavior";
  40859. /**
  40860. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  40861. */
  40862. export class AttachToBoxBehavior implements Behavior<Mesh> {
  40863. private ui;
  40864. /**
  40865. * The name of the behavior
  40866. */
  40867. name: string;
  40868. /**
  40869. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  40870. */
  40871. distanceAwayFromFace: number;
  40872. /**
  40873. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  40874. */
  40875. distanceAwayFromBottomOfFace: number;
  40876. private _faceVectors;
  40877. private _target;
  40878. private _scene;
  40879. private _onRenderObserver;
  40880. private _tmpMatrix;
  40881. private _tmpVector;
  40882. /**
  40883. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  40884. * @param ui The transform node that should be attched to the mesh
  40885. */
  40886. constructor(ui: TransformNode);
  40887. /**
  40888. * Initializes the behavior
  40889. */
  40890. init(): void;
  40891. private _closestFace;
  40892. private _zeroVector;
  40893. private _lookAtTmpMatrix;
  40894. private _lookAtToRef;
  40895. /**
  40896. * Attaches the AttachToBoxBehavior to the passed in mesh
  40897. * @param target The mesh that the specified node will be attached to
  40898. */
  40899. attach(target: Mesh): void;
  40900. /**
  40901. * Detaches the behavior from the mesh
  40902. */
  40903. detach(): void;
  40904. }
  40905. }
  40906. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  40907. import { Behavior } from "babylonjs/Behaviors/behavior";
  40908. import { Mesh } from "babylonjs/Meshes/mesh";
  40909. /**
  40910. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  40911. */
  40912. export class FadeInOutBehavior implements Behavior<Mesh> {
  40913. /**
  40914. * Time in milliseconds to delay before fading in (Default: 0)
  40915. */
  40916. delay: number;
  40917. /**
  40918. * Time in milliseconds for the mesh to fade in (Default: 300)
  40919. */
  40920. fadeInTime: number;
  40921. private _millisecondsPerFrame;
  40922. private _hovered;
  40923. private _hoverValue;
  40924. private _ownerNode;
  40925. /**
  40926. * Instatiates the FadeInOutBehavior
  40927. */
  40928. constructor();
  40929. /**
  40930. * The name of the behavior
  40931. */
  40932. get name(): string;
  40933. /**
  40934. * Initializes the behavior
  40935. */
  40936. init(): void;
  40937. /**
  40938. * Attaches the fade behavior on the passed in mesh
  40939. * @param ownerNode The mesh that will be faded in/out once attached
  40940. */
  40941. attach(ownerNode: Mesh): void;
  40942. /**
  40943. * Detaches the behavior from the mesh
  40944. */
  40945. detach(): void;
  40946. /**
  40947. * Triggers the mesh to begin fading in or out
  40948. * @param value if the object should fade in or out (true to fade in)
  40949. */
  40950. fadeIn(value: boolean): void;
  40951. private _update;
  40952. private _setAllVisibility;
  40953. }
  40954. }
  40955. declare module "babylonjs/Misc/pivotTools" {
  40956. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40957. /**
  40958. * Class containing a set of static utilities functions for managing Pivots
  40959. * @hidden
  40960. */
  40961. export class PivotTools {
  40962. private static _PivotCached;
  40963. private static _OldPivotPoint;
  40964. private static _PivotTranslation;
  40965. private static _PivotTmpVector;
  40966. /** @hidden */
  40967. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  40968. /** @hidden */
  40969. static _RestorePivotPoint(mesh: AbstractMesh): void;
  40970. }
  40971. }
  40972. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  40973. import { Scene } from "babylonjs/scene";
  40974. import { Vector4 } from "babylonjs/Maths/math.vector";
  40975. import { Mesh } from "babylonjs/Meshes/mesh";
  40976. import { Nullable } from "babylonjs/types";
  40977. import { Plane } from "babylonjs/Maths/math.plane";
  40978. /**
  40979. * Class containing static functions to help procedurally build meshes
  40980. */
  40981. export class PlaneBuilder {
  40982. /**
  40983. * Creates a plane mesh
  40984. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  40985. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  40986. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  40987. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  40988. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  40989. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40990. * @param name defines the name of the mesh
  40991. * @param options defines the options used to create the mesh
  40992. * @param scene defines the hosting scene
  40993. * @returns the plane mesh
  40994. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  40995. */
  40996. static CreatePlane(name: string, options: {
  40997. size?: number;
  40998. width?: number;
  40999. height?: number;
  41000. sideOrientation?: number;
  41001. frontUVs?: Vector4;
  41002. backUVs?: Vector4;
  41003. updatable?: boolean;
  41004. sourcePlane?: Plane;
  41005. }, scene?: Nullable<Scene>): Mesh;
  41006. }
  41007. }
  41008. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  41009. import { Behavior } from "babylonjs/Behaviors/behavior";
  41010. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41011. import { Observable } from "babylonjs/Misc/observable";
  41012. import { Vector3 } from "babylonjs/Maths/math.vector";
  41013. import { Ray } from "babylonjs/Culling/ray";
  41014. import "babylonjs/Meshes/Builders/planeBuilder";
  41015. /**
  41016. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  41017. */
  41018. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  41019. private static _AnyMouseID;
  41020. /**
  41021. * Abstract mesh the behavior is set on
  41022. */
  41023. attachedNode: AbstractMesh;
  41024. private _dragPlane;
  41025. private _scene;
  41026. private _pointerObserver;
  41027. private _beforeRenderObserver;
  41028. private static _planeScene;
  41029. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  41030. /**
  41031. * 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)
  41032. */
  41033. maxDragAngle: number;
  41034. /**
  41035. * @hidden
  41036. */
  41037. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  41038. /**
  41039. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  41040. */
  41041. currentDraggingPointerID: number;
  41042. /**
  41043. * The last position where the pointer hit the drag plane in world space
  41044. */
  41045. lastDragPosition: Vector3;
  41046. /**
  41047. * If the behavior is currently in a dragging state
  41048. */
  41049. dragging: boolean;
  41050. /**
  41051. * 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)
  41052. */
  41053. dragDeltaRatio: number;
  41054. /**
  41055. * If the drag plane orientation should be updated during the dragging (Default: true)
  41056. */
  41057. updateDragPlane: boolean;
  41058. private _debugMode;
  41059. private _moving;
  41060. /**
  41061. * Fires each time the attached mesh is dragged with the pointer
  41062. * * delta between last drag position and current drag position in world space
  41063. * * dragDistance along the drag axis
  41064. * * dragPlaneNormal normal of the current drag plane used during the drag
  41065. * * dragPlanePoint in world space where the drag intersects the drag plane
  41066. */
  41067. onDragObservable: Observable<{
  41068. delta: Vector3;
  41069. dragPlanePoint: Vector3;
  41070. dragPlaneNormal: Vector3;
  41071. dragDistance: number;
  41072. pointerId: number;
  41073. }>;
  41074. /**
  41075. * Fires each time a drag begins (eg. mouse down on mesh)
  41076. */
  41077. onDragStartObservable: Observable<{
  41078. dragPlanePoint: Vector3;
  41079. pointerId: number;
  41080. }>;
  41081. /**
  41082. * Fires each time a drag ends (eg. mouse release after drag)
  41083. */
  41084. onDragEndObservable: Observable<{
  41085. dragPlanePoint: Vector3;
  41086. pointerId: number;
  41087. }>;
  41088. /**
  41089. * If the attached mesh should be moved when dragged
  41090. */
  41091. moveAttached: boolean;
  41092. /**
  41093. * If the drag behavior will react to drag events (Default: true)
  41094. */
  41095. enabled: boolean;
  41096. /**
  41097. * If pointer events should start and release the drag (Default: true)
  41098. */
  41099. startAndReleaseDragOnPointerEvents: boolean;
  41100. /**
  41101. * If camera controls should be detached during the drag
  41102. */
  41103. detachCameraControls: boolean;
  41104. /**
  41105. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  41106. */
  41107. useObjectOrientationForDragging: boolean;
  41108. private _options;
  41109. /**
  41110. * Gets the options used by the behavior
  41111. */
  41112. get options(): {
  41113. dragAxis?: Vector3;
  41114. dragPlaneNormal?: Vector3;
  41115. };
  41116. /**
  41117. * Sets the options used by the behavior
  41118. */
  41119. set options(options: {
  41120. dragAxis?: Vector3;
  41121. dragPlaneNormal?: Vector3;
  41122. });
  41123. /**
  41124. * Creates a pointer drag behavior that can be attached to a mesh
  41125. * @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)
  41126. */
  41127. constructor(options?: {
  41128. dragAxis?: Vector3;
  41129. dragPlaneNormal?: Vector3;
  41130. });
  41131. /**
  41132. * Predicate to determine if it is valid to move the object to a new position when it is moved
  41133. */
  41134. validateDrag: (targetPosition: Vector3) => boolean;
  41135. /**
  41136. * The name of the behavior
  41137. */
  41138. get name(): string;
  41139. /**
  41140. * Initializes the behavior
  41141. */
  41142. init(): void;
  41143. private _tmpVector;
  41144. private _alternatePickedPoint;
  41145. private _worldDragAxis;
  41146. private _targetPosition;
  41147. private _attachedElement;
  41148. /**
  41149. * Attaches the drag behavior the passed in mesh
  41150. * @param ownerNode The mesh that will be dragged around once attached
  41151. * @param predicate Predicate to use for pick filtering
  41152. */
  41153. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  41154. /**
  41155. * Force relase the drag action by code.
  41156. */
  41157. releaseDrag(): void;
  41158. private _startDragRay;
  41159. private _lastPointerRay;
  41160. /**
  41161. * Simulates the start of a pointer drag event on the behavior
  41162. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  41163. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  41164. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  41165. */
  41166. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  41167. private _startDrag;
  41168. private _dragDelta;
  41169. private _moveDrag;
  41170. private _pickWithRayOnDragPlane;
  41171. private _pointA;
  41172. private _pointB;
  41173. private _pointC;
  41174. private _lineA;
  41175. private _lineB;
  41176. private _localAxis;
  41177. private _lookAt;
  41178. private _updateDragPlanePosition;
  41179. /**
  41180. * Detaches the behavior from the mesh
  41181. */
  41182. detach(): void;
  41183. }
  41184. }
  41185. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  41186. import { Mesh } from "babylonjs/Meshes/mesh";
  41187. import { Behavior } from "babylonjs/Behaviors/behavior";
  41188. /**
  41189. * A behavior that when attached to a mesh will allow the mesh to be scaled
  41190. */
  41191. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  41192. private _dragBehaviorA;
  41193. private _dragBehaviorB;
  41194. private _startDistance;
  41195. private _initialScale;
  41196. private _targetScale;
  41197. private _ownerNode;
  41198. private _sceneRenderObserver;
  41199. /**
  41200. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  41201. */
  41202. constructor();
  41203. /**
  41204. * The name of the behavior
  41205. */
  41206. get name(): string;
  41207. /**
  41208. * Initializes the behavior
  41209. */
  41210. init(): void;
  41211. private _getCurrentDistance;
  41212. /**
  41213. * Attaches the scale behavior the passed in mesh
  41214. * @param ownerNode The mesh that will be scaled around once attached
  41215. */
  41216. attach(ownerNode: Mesh): void;
  41217. /**
  41218. * Detaches the behavior from the mesh
  41219. */
  41220. detach(): void;
  41221. }
  41222. }
  41223. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  41224. import { Behavior } from "babylonjs/Behaviors/behavior";
  41225. import { Mesh } from "babylonjs/Meshes/mesh";
  41226. import { Observable } from "babylonjs/Misc/observable";
  41227. /**
  41228. * 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
  41229. */
  41230. export class SixDofDragBehavior implements Behavior<Mesh> {
  41231. private static _virtualScene;
  41232. private _ownerNode;
  41233. private _sceneRenderObserver;
  41234. private _scene;
  41235. private _targetPosition;
  41236. private _virtualOriginMesh;
  41237. private _virtualDragMesh;
  41238. private _pointerObserver;
  41239. private _moving;
  41240. private _startingOrientation;
  41241. private _attachedElement;
  41242. /**
  41243. * 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)
  41244. */
  41245. private zDragFactor;
  41246. /**
  41247. * If the object should rotate to face the drag origin
  41248. */
  41249. rotateDraggedObject: boolean;
  41250. /**
  41251. * If the behavior is currently in a dragging state
  41252. */
  41253. dragging: boolean;
  41254. /**
  41255. * 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)
  41256. */
  41257. dragDeltaRatio: number;
  41258. /**
  41259. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  41260. */
  41261. currentDraggingPointerID: number;
  41262. /**
  41263. * If camera controls should be detached during the drag
  41264. */
  41265. detachCameraControls: boolean;
  41266. /**
  41267. * Fires each time a drag starts
  41268. */
  41269. onDragStartObservable: Observable<{}>;
  41270. /**
  41271. * Fires each time a drag ends (eg. mouse release after drag)
  41272. */
  41273. onDragEndObservable: Observable<{}>;
  41274. /**
  41275. * 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
  41276. */
  41277. constructor();
  41278. /**
  41279. * The name of the behavior
  41280. */
  41281. get name(): string;
  41282. /**
  41283. * Initializes the behavior
  41284. */
  41285. init(): void;
  41286. /**
  41287. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  41288. */
  41289. private get _pointerCamera();
  41290. /**
  41291. * Attaches the scale behavior the passed in mesh
  41292. * @param ownerNode The mesh that will be scaled around once attached
  41293. */
  41294. attach(ownerNode: Mesh): void;
  41295. /**
  41296. * Detaches the behavior from the mesh
  41297. */
  41298. detach(): void;
  41299. }
  41300. }
  41301. declare module "babylonjs/Behaviors/Meshes/index" {
  41302. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  41303. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  41304. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  41305. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  41306. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  41307. }
  41308. declare module "babylonjs/Behaviors/index" {
  41309. export * from "babylonjs/Behaviors/behavior";
  41310. export * from "babylonjs/Behaviors/Cameras/index";
  41311. export * from "babylonjs/Behaviors/Meshes/index";
  41312. }
  41313. declare module "babylonjs/Bones/boneIKController" {
  41314. import { Bone } from "babylonjs/Bones/bone";
  41315. import { Vector3 } from "babylonjs/Maths/math.vector";
  41316. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41317. import { Nullable } from "babylonjs/types";
  41318. /**
  41319. * Class used to apply inverse kinematics to bones
  41320. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  41321. */
  41322. export class BoneIKController {
  41323. private static _tmpVecs;
  41324. private static _tmpQuat;
  41325. private static _tmpMats;
  41326. /**
  41327. * Gets or sets the target mesh
  41328. */
  41329. targetMesh: AbstractMesh;
  41330. /** Gets or sets the mesh used as pole */
  41331. poleTargetMesh: AbstractMesh;
  41332. /**
  41333. * Gets or sets the bone used as pole
  41334. */
  41335. poleTargetBone: Nullable<Bone>;
  41336. /**
  41337. * Gets or sets the target position
  41338. */
  41339. targetPosition: Vector3;
  41340. /**
  41341. * Gets or sets the pole target position
  41342. */
  41343. poleTargetPosition: Vector3;
  41344. /**
  41345. * Gets or sets the pole target local offset
  41346. */
  41347. poleTargetLocalOffset: Vector3;
  41348. /**
  41349. * Gets or sets the pole angle
  41350. */
  41351. poleAngle: number;
  41352. /**
  41353. * Gets or sets the mesh associated with the controller
  41354. */
  41355. mesh: AbstractMesh;
  41356. /**
  41357. * 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)
  41358. */
  41359. slerpAmount: number;
  41360. private _bone1Quat;
  41361. private _bone1Mat;
  41362. private _bone2Ang;
  41363. private _bone1;
  41364. private _bone2;
  41365. private _bone1Length;
  41366. private _bone2Length;
  41367. private _maxAngle;
  41368. private _maxReach;
  41369. private _rightHandedSystem;
  41370. private _bendAxis;
  41371. private _slerping;
  41372. private _adjustRoll;
  41373. /**
  41374. * Gets or sets maximum allowed angle
  41375. */
  41376. get maxAngle(): number;
  41377. set maxAngle(value: number);
  41378. /**
  41379. * Creates a new BoneIKController
  41380. * @param mesh defines the mesh to control
  41381. * @param bone defines the bone to control
  41382. * @param options defines options to set up the controller
  41383. */
  41384. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  41385. targetMesh?: AbstractMesh;
  41386. poleTargetMesh?: AbstractMesh;
  41387. poleTargetBone?: Bone;
  41388. poleTargetLocalOffset?: Vector3;
  41389. poleAngle?: number;
  41390. bendAxis?: Vector3;
  41391. maxAngle?: number;
  41392. slerpAmount?: number;
  41393. });
  41394. private _setMaxAngle;
  41395. /**
  41396. * Force the controller to update the bones
  41397. */
  41398. update(): void;
  41399. }
  41400. }
  41401. declare module "babylonjs/Bones/boneLookController" {
  41402. import { Vector3 } from "babylonjs/Maths/math.vector";
  41403. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41404. import { Bone } from "babylonjs/Bones/bone";
  41405. import { Space } from "babylonjs/Maths/math.axis";
  41406. /**
  41407. * Class used to make a bone look toward a point in space
  41408. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  41409. */
  41410. export class BoneLookController {
  41411. private static _tmpVecs;
  41412. private static _tmpQuat;
  41413. private static _tmpMats;
  41414. /**
  41415. * The target Vector3 that the bone will look at
  41416. */
  41417. target: Vector3;
  41418. /**
  41419. * The mesh that the bone is attached to
  41420. */
  41421. mesh: AbstractMesh;
  41422. /**
  41423. * The bone that will be looking to the target
  41424. */
  41425. bone: Bone;
  41426. /**
  41427. * The up axis of the coordinate system that is used when the bone is rotated
  41428. */
  41429. upAxis: Vector3;
  41430. /**
  41431. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  41432. */
  41433. upAxisSpace: Space;
  41434. /**
  41435. * Used to make an adjustment to the yaw of the bone
  41436. */
  41437. adjustYaw: number;
  41438. /**
  41439. * Used to make an adjustment to the pitch of the bone
  41440. */
  41441. adjustPitch: number;
  41442. /**
  41443. * Used to make an adjustment to the roll of the bone
  41444. */
  41445. adjustRoll: number;
  41446. /**
  41447. * 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)
  41448. */
  41449. slerpAmount: number;
  41450. private _minYaw;
  41451. private _maxYaw;
  41452. private _minPitch;
  41453. private _maxPitch;
  41454. private _minYawSin;
  41455. private _minYawCos;
  41456. private _maxYawSin;
  41457. private _maxYawCos;
  41458. private _midYawConstraint;
  41459. private _minPitchTan;
  41460. private _maxPitchTan;
  41461. private _boneQuat;
  41462. private _slerping;
  41463. private _transformYawPitch;
  41464. private _transformYawPitchInv;
  41465. private _firstFrameSkipped;
  41466. private _yawRange;
  41467. private _fowardAxis;
  41468. /**
  41469. * Gets or sets the minimum yaw angle that the bone can look to
  41470. */
  41471. get minYaw(): number;
  41472. set minYaw(value: number);
  41473. /**
  41474. * Gets or sets the maximum yaw angle that the bone can look to
  41475. */
  41476. get maxYaw(): number;
  41477. set maxYaw(value: number);
  41478. /**
  41479. * Gets or sets the minimum pitch angle that the bone can look to
  41480. */
  41481. get minPitch(): number;
  41482. set minPitch(value: number);
  41483. /**
  41484. * Gets or sets the maximum pitch angle that the bone can look to
  41485. */
  41486. get maxPitch(): number;
  41487. set maxPitch(value: number);
  41488. /**
  41489. * Create a BoneLookController
  41490. * @param mesh the mesh that the bone belongs to
  41491. * @param bone the bone that will be looking to the target
  41492. * @param target the target Vector3 to look at
  41493. * @param options optional settings:
  41494. * * maxYaw: the maximum angle the bone will yaw to
  41495. * * minYaw: the minimum angle the bone will yaw to
  41496. * * maxPitch: the maximum angle the bone will pitch to
  41497. * * minPitch: the minimum angle the bone will yaw to
  41498. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  41499. * * upAxis: the up axis of the coordinate system
  41500. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  41501. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  41502. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  41503. * * adjustYaw: used to make an adjustment to the yaw of the bone
  41504. * * adjustPitch: used to make an adjustment to the pitch of the bone
  41505. * * adjustRoll: used to make an adjustment to the roll of the bone
  41506. **/
  41507. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  41508. maxYaw?: number;
  41509. minYaw?: number;
  41510. maxPitch?: number;
  41511. minPitch?: number;
  41512. slerpAmount?: number;
  41513. upAxis?: Vector3;
  41514. upAxisSpace?: Space;
  41515. yawAxis?: Vector3;
  41516. pitchAxis?: Vector3;
  41517. adjustYaw?: number;
  41518. adjustPitch?: number;
  41519. adjustRoll?: number;
  41520. });
  41521. /**
  41522. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  41523. */
  41524. update(): void;
  41525. private _getAngleDiff;
  41526. private _getAngleBetween;
  41527. private _isAngleBetween;
  41528. }
  41529. }
  41530. declare module "babylonjs/Bones/index" {
  41531. export * from "babylonjs/Bones/bone";
  41532. export * from "babylonjs/Bones/boneIKController";
  41533. export * from "babylonjs/Bones/boneLookController";
  41534. export * from "babylonjs/Bones/skeleton";
  41535. }
  41536. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  41537. import { Nullable } from "babylonjs/types";
  41538. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  41539. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41540. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  41541. /**
  41542. * Manage the gamepad inputs to control an arc rotate camera.
  41543. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41544. */
  41545. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  41546. /**
  41547. * Defines the camera the input is attached to.
  41548. */
  41549. camera: ArcRotateCamera;
  41550. /**
  41551. * Defines the gamepad the input is gathering event from.
  41552. */
  41553. gamepad: Nullable<Gamepad>;
  41554. /**
  41555. * Defines the gamepad rotation sensiblity.
  41556. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  41557. */
  41558. gamepadRotationSensibility: number;
  41559. /**
  41560. * Defines the gamepad move sensiblity.
  41561. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  41562. */
  41563. gamepadMoveSensibility: number;
  41564. private _yAxisScale;
  41565. /**
  41566. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  41567. */
  41568. get invertYAxis(): boolean;
  41569. set invertYAxis(value: boolean);
  41570. private _onGamepadConnectedObserver;
  41571. private _onGamepadDisconnectedObserver;
  41572. /**
  41573. * Attach the input controls to a specific dom element to get the input from.
  41574. * @param element Defines the element the controls should be listened from
  41575. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41576. */
  41577. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41578. /**
  41579. * Detach the current controls from the specified dom element.
  41580. * @param element Defines the element to stop listening the inputs from
  41581. */
  41582. detachControl(element: Nullable<HTMLElement>): void;
  41583. /**
  41584. * Update the current camera state depending on the inputs that have been used this frame.
  41585. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41586. */
  41587. checkInputs(): void;
  41588. /**
  41589. * Gets the class name of the current intput.
  41590. * @returns the class name
  41591. */
  41592. getClassName(): string;
  41593. /**
  41594. * Get the friendly name associated with the input class.
  41595. * @returns the input friendly name
  41596. */
  41597. getSimpleName(): string;
  41598. }
  41599. }
  41600. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  41601. import { Nullable } from "babylonjs/types";
  41602. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  41603. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41604. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  41605. interface ArcRotateCameraInputsManager {
  41606. /**
  41607. * Add orientation input support to the input manager.
  41608. * @returns the current input manager
  41609. */
  41610. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  41611. }
  41612. }
  41613. /**
  41614. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  41615. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41616. */
  41617. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  41618. /**
  41619. * Defines the camera the input is attached to.
  41620. */
  41621. camera: ArcRotateCamera;
  41622. /**
  41623. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  41624. */
  41625. alphaCorrection: number;
  41626. /**
  41627. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  41628. */
  41629. gammaCorrection: number;
  41630. private _alpha;
  41631. private _gamma;
  41632. private _dirty;
  41633. private _deviceOrientationHandler;
  41634. /**
  41635. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  41636. */
  41637. constructor();
  41638. /**
  41639. * Attach the input controls to a specific dom element to get the input from.
  41640. * @param element Defines the element the controls should be listened from
  41641. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41642. */
  41643. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41644. /** @hidden */
  41645. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  41646. /**
  41647. * Update the current camera state depending on the inputs that have been used this frame.
  41648. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41649. */
  41650. checkInputs(): void;
  41651. /**
  41652. * Detach the current controls from the specified dom element.
  41653. * @param element Defines the element to stop listening the inputs from
  41654. */
  41655. detachControl(element: Nullable<HTMLElement>): void;
  41656. /**
  41657. * Gets the class name of the current intput.
  41658. * @returns the class name
  41659. */
  41660. getClassName(): string;
  41661. /**
  41662. * Get the friendly name associated with the input class.
  41663. * @returns the input friendly name
  41664. */
  41665. getSimpleName(): string;
  41666. }
  41667. }
  41668. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  41669. import { Nullable } from "babylonjs/types";
  41670. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41671. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  41672. /**
  41673. * Listen to mouse events to control the camera.
  41674. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41675. */
  41676. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  41677. /**
  41678. * Defines the camera the input is attached to.
  41679. */
  41680. camera: FlyCamera;
  41681. /**
  41682. * Defines if touch is enabled. (Default is true.)
  41683. */
  41684. touchEnabled: boolean;
  41685. /**
  41686. * Defines the buttons associated with the input to handle camera rotation.
  41687. */
  41688. buttons: number[];
  41689. /**
  41690. * Assign buttons for Yaw control.
  41691. */
  41692. buttonsYaw: number[];
  41693. /**
  41694. * Assign buttons for Pitch control.
  41695. */
  41696. buttonsPitch: number[];
  41697. /**
  41698. * Assign buttons for Roll control.
  41699. */
  41700. buttonsRoll: number[];
  41701. /**
  41702. * Detect if any button is being pressed while mouse is moved.
  41703. * -1 = Mouse locked.
  41704. * 0 = Left button.
  41705. * 1 = Middle Button.
  41706. * 2 = Right Button.
  41707. */
  41708. activeButton: number;
  41709. /**
  41710. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  41711. * Higher values reduce its sensitivity.
  41712. */
  41713. angularSensibility: number;
  41714. private _mousemoveCallback;
  41715. private _observer;
  41716. private _rollObserver;
  41717. private previousPosition;
  41718. private noPreventDefault;
  41719. private element;
  41720. /**
  41721. * Listen to mouse events to control the camera.
  41722. * @param touchEnabled Define if touch is enabled. (Default is true.)
  41723. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41724. */
  41725. constructor(touchEnabled?: boolean);
  41726. /**
  41727. * Attach the mouse control to the HTML DOM element.
  41728. * @param element Defines the element that listens to the input events.
  41729. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  41730. */
  41731. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41732. /**
  41733. * Detach the current controls from the specified dom element.
  41734. * @param element Defines the element to stop listening the inputs from
  41735. */
  41736. detachControl(element: Nullable<HTMLElement>): void;
  41737. /**
  41738. * Gets the class name of the current input.
  41739. * @returns the class name.
  41740. */
  41741. getClassName(): string;
  41742. /**
  41743. * Get the friendly name associated with the input class.
  41744. * @returns the input's friendly name.
  41745. */
  41746. getSimpleName(): string;
  41747. private _pointerInput;
  41748. private _onMouseMove;
  41749. /**
  41750. * Rotate camera by mouse offset.
  41751. */
  41752. private rotateCamera;
  41753. }
  41754. }
  41755. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  41756. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  41757. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  41758. /**
  41759. * Default Inputs manager for the FlyCamera.
  41760. * It groups all the default supported inputs for ease of use.
  41761. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41762. */
  41763. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  41764. /**
  41765. * Instantiates a new FlyCameraInputsManager.
  41766. * @param camera Defines the camera the inputs belong to.
  41767. */
  41768. constructor(camera: FlyCamera);
  41769. /**
  41770. * Add keyboard input support to the input manager.
  41771. * @returns the new FlyCameraKeyboardMoveInput().
  41772. */
  41773. addKeyboard(): FlyCameraInputsManager;
  41774. /**
  41775. * Add mouse input support to the input manager.
  41776. * @param touchEnabled Enable touch screen support.
  41777. * @returns the new FlyCameraMouseInput().
  41778. */
  41779. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  41780. }
  41781. }
  41782. declare module "babylonjs/Cameras/flyCamera" {
  41783. import { Scene } from "babylonjs/scene";
  41784. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  41785. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41786. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  41787. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  41788. /**
  41789. * This is a flying camera, designed for 3D movement and rotation in all directions,
  41790. * such as in a 3D Space Shooter or a Flight Simulator.
  41791. */
  41792. export class FlyCamera extends TargetCamera {
  41793. /**
  41794. * Define the collision ellipsoid of the camera.
  41795. * This is helpful for simulating a camera body, like a player's body.
  41796. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  41797. */
  41798. ellipsoid: Vector3;
  41799. /**
  41800. * Define an offset for the position of the ellipsoid around the camera.
  41801. * This can be helpful if the camera is attached away from the player's body center,
  41802. * such as at its head.
  41803. */
  41804. ellipsoidOffset: Vector3;
  41805. /**
  41806. * Enable or disable collisions of the camera with the rest of the scene objects.
  41807. */
  41808. checkCollisions: boolean;
  41809. /**
  41810. * Enable or disable gravity on the camera.
  41811. */
  41812. applyGravity: boolean;
  41813. /**
  41814. * Define the current direction the camera is moving to.
  41815. */
  41816. cameraDirection: Vector3;
  41817. /**
  41818. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  41819. * This overrides and empties cameraRotation.
  41820. */
  41821. rotationQuaternion: Quaternion;
  41822. /**
  41823. * Track Roll to maintain the wanted Rolling when looking around.
  41824. */
  41825. _trackRoll: number;
  41826. /**
  41827. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  41828. */
  41829. rollCorrect: number;
  41830. /**
  41831. * Mimic a banked turn, Rolling the camera when Yawing.
  41832. * It's recommended to use rollCorrect = 10 for faster banking correction.
  41833. */
  41834. bankedTurn: boolean;
  41835. /**
  41836. * Limit in radians for how much Roll banking will add. (Default: 90°)
  41837. */
  41838. bankedTurnLimit: number;
  41839. /**
  41840. * Value of 0 disables the banked Roll.
  41841. * Value of 1 is equal to the Yaw angle in radians.
  41842. */
  41843. bankedTurnMultiplier: number;
  41844. /**
  41845. * The inputs manager loads all the input sources, such as keyboard and mouse.
  41846. */
  41847. inputs: FlyCameraInputsManager;
  41848. /**
  41849. * Gets the input sensibility for mouse input.
  41850. * Higher values reduce sensitivity.
  41851. */
  41852. get angularSensibility(): number;
  41853. /**
  41854. * Sets the input sensibility for a mouse input.
  41855. * Higher values reduce sensitivity.
  41856. */
  41857. set angularSensibility(value: number);
  41858. /**
  41859. * Get the keys for camera movement forward.
  41860. */
  41861. get keysForward(): number[];
  41862. /**
  41863. * Set the keys for camera movement forward.
  41864. */
  41865. set keysForward(value: number[]);
  41866. /**
  41867. * Get the keys for camera movement backward.
  41868. */
  41869. get keysBackward(): number[];
  41870. set keysBackward(value: number[]);
  41871. /**
  41872. * Get the keys for camera movement up.
  41873. */
  41874. get keysUp(): number[];
  41875. /**
  41876. * Set the keys for camera movement up.
  41877. */
  41878. set keysUp(value: number[]);
  41879. /**
  41880. * Get the keys for camera movement down.
  41881. */
  41882. get keysDown(): number[];
  41883. /**
  41884. * Set the keys for camera movement down.
  41885. */
  41886. set keysDown(value: number[]);
  41887. /**
  41888. * Get the keys for camera movement left.
  41889. */
  41890. get keysLeft(): number[];
  41891. /**
  41892. * Set the keys for camera movement left.
  41893. */
  41894. set keysLeft(value: number[]);
  41895. /**
  41896. * Set the keys for camera movement right.
  41897. */
  41898. get keysRight(): number[];
  41899. /**
  41900. * Set the keys for camera movement right.
  41901. */
  41902. set keysRight(value: number[]);
  41903. /**
  41904. * Event raised when the camera collides with a mesh in the scene.
  41905. */
  41906. onCollide: (collidedMesh: AbstractMesh) => void;
  41907. private _collider;
  41908. private _needMoveForGravity;
  41909. private _oldPosition;
  41910. private _diffPosition;
  41911. private _newPosition;
  41912. /** @hidden */
  41913. _localDirection: Vector3;
  41914. /** @hidden */
  41915. _transformedDirection: Vector3;
  41916. /**
  41917. * Instantiates a FlyCamera.
  41918. * This is a flying camera, designed for 3D movement and rotation in all directions,
  41919. * such as in a 3D Space Shooter or a Flight Simulator.
  41920. * @param name Define the name of the camera in the scene.
  41921. * @param position Define the starting position of the camera in the scene.
  41922. * @param scene Define the scene the camera belongs to.
  41923. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  41924. */
  41925. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  41926. /**
  41927. * Attach a control to the HTML DOM element.
  41928. * @param element Defines the element that listens to the input events.
  41929. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  41930. */
  41931. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41932. /**
  41933. * Detach a control from the HTML DOM element.
  41934. * The camera will stop reacting to that input.
  41935. * @param element Defines the element that listens to the input events.
  41936. */
  41937. detachControl(element: HTMLElement): void;
  41938. private _collisionMask;
  41939. /**
  41940. * Get the mask that the camera ignores in collision events.
  41941. */
  41942. get collisionMask(): number;
  41943. /**
  41944. * Set the mask that the camera ignores in collision events.
  41945. */
  41946. set collisionMask(mask: number);
  41947. /** @hidden */
  41948. _collideWithWorld(displacement: Vector3): void;
  41949. /** @hidden */
  41950. private _onCollisionPositionChange;
  41951. /** @hidden */
  41952. _checkInputs(): void;
  41953. /** @hidden */
  41954. _decideIfNeedsToMove(): boolean;
  41955. /** @hidden */
  41956. _updatePosition(): void;
  41957. /**
  41958. * Restore the Roll to its target value at the rate specified.
  41959. * @param rate - Higher means slower restoring.
  41960. * @hidden
  41961. */
  41962. restoreRoll(rate: number): void;
  41963. /**
  41964. * Destroy the camera and release the current resources held by it.
  41965. */
  41966. dispose(): void;
  41967. /**
  41968. * Get the current object class name.
  41969. * @returns the class name.
  41970. */
  41971. getClassName(): string;
  41972. }
  41973. }
  41974. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  41975. import { Nullable } from "babylonjs/types";
  41976. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41977. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  41978. /**
  41979. * Listen to keyboard events to control the camera.
  41980. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41981. */
  41982. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  41983. /**
  41984. * Defines the camera the input is attached to.
  41985. */
  41986. camera: FlyCamera;
  41987. /**
  41988. * The list of keyboard keys used to control the forward move of the camera.
  41989. */
  41990. keysForward: number[];
  41991. /**
  41992. * The list of keyboard keys used to control the backward move of the camera.
  41993. */
  41994. keysBackward: number[];
  41995. /**
  41996. * The list of keyboard keys used to control the forward move of the camera.
  41997. */
  41998. keysUp: number[];
  41999. /**
  42000. * The list of keyboard keys used to control the backward move of the camera.
  42001. */
  42002. keysDown: number[];
  42003. /**
  42004. * The list of keyboard keys used to control the right strafe move of the camera.
  42005. */
  42006. keysRight: number[];
  42007. /**
  42008. * The list of keyboard keys used to control the left strafe move of the camera.
  42009. */
  42010. keysLeft: number[];
  42011. private _keys;
  42012. private _onCanvasBlurObserver;
  42013. private _onKeyboardObserver;
  42014. private _engine;
  42015. private _scene;
  42016. /**
  42017. * Attach the input controls to a specific dom element to get the input from.
  42018. * @param element Defines the element the controls should be listened from
  42019. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42020. */
  42021. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42022. /**
  42023. * Detach the current controls from the specified dom element.
  42024. * @param element Defines the element to stop listening the inputs from
  42025. */
  42026. detachControl(element: Nullable<HTMLElement>): void;
  42027. /**
  42028. * Gets the class name of the current intput.
  42029. * @returns the class name
  42030. */
  42031. getClassName(): string;
  42032. /** @hidden */
  42033. _onLostFocus(e: FocusEvent): void;
  42034. /**
  42035. * Get the friendly name associated with the input class.
  42036. * @returns the input friendly name
  42037. */
  42038. getSimpleName(): string;
  42039. /**
  42040. * Update the current camera state depending on the inputs that have been used this frame.
  42041. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  42042. */
  42043. checkInputs(): void;
  42044. }
  42045. }
  42046. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  42047. import { Nullable } from "babylonjs/types";
  42048. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  42049. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  42050. /**
  42051. * Manage the mouse wheel inputs to control a follow camera.
  42052. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42053. */
  42054. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  42055. /**
  42056. * Defines the camera the input is attached to.
  42057. */
  42058. camera: FollowCamera;
  42059. /**
  42060. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  42061. */
  42062. axisControlRadius: boolean;
  42063. /**
  42064. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  42065. */
  42066. axisControlHeight: boolean;
  42067. /**
  42068. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  42069. */
  42070. axisControlRotation: boolean;
  42071. /**
  42072. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  42073. * relation to mouseWheel events.
  42074. */
  42075. wheelPrecision: number;
  42076. /**
  42077. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  42078. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  42079. */
  42080. wheelDeltaPercentage: number;
  42081. private _wheel;
  42082. private _observer;
  42083. /**
  42084. * Attach the input controls to a specific dom element to get the input from.
  42085. * @param element Defines the element the controls should be listened from
  42086. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42087. */
  42088. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42089. /**
  42090. * Detach the current controls from the specified dom element.
  42091. * @param element Defines the element to stop listening the inputs from
  42092. */
  42093. detachControl(element: Nullable<HTMLElement>): void;
  42094. /**
  42095. * Gets the class name of the current intput.
  42096. * @returns the class name
  42097. */
  42098. getClassName(): string;
  42099. /**
  42100. * Get the friendly name associated with the input class.
  42101. * @returns the input friendly name
  42102. */
  42103. getSimpleName(): string;
  42104. }
  42105. }
  42106. declare module "babylonjs/Cameras/Inputs/followCameraPointersInput" {
  42107. import { Nullable } from "babylonjs/types";
  42108. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  42109. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  42110. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  42111. /**
  42112. * Manage the pointers inputs to control an follow camera.
  42113. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42114. */
  42115. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  42116. /**
  42117. * Defines the camera the input is attached to.
  42118. */
  42119. camera: FollowCamera;
  42120. /**
  42121. * Gets the class name of the current input.
  42122. * @returns the class name
  42123. */
  42124. getClassName(): string;
  42125. /**
  42126. * Defines the pointer angular sensibility along the X axis or how fast is
  42127. * the camera rotating.
  42128. * A negative number will reverse the axis direction.
  42129. */
  42130. angularSensibilityX: number;
  42131. /**
  42132. * Defines the pointer angular sensibility along the Y axis or how fast is
  42133. * the camera rotating.
  42134. * A negative number will reverse the axis direction.
  42135. */
  42136. angularSensibilityY: number;
  42137. /**
  42138. * Defines the pointer pinch precision or how fast is the camera zooming.
  42139. * A negative number will reverse the axis direction.
  42140. */
  42141. pinchPrecision: number;
  42142. /**
  42143. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  42144. * from 0.
  42145. * It defines the percentage of current camera.radius to use as delta when
  42146. * pinch zoom is used.
  42147. */
  42148. pinchDeltaPercentage: number;
  42149. /**
  42150. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  42151. */
  42152. axisXControlRadius: boolean;
  42153. /**
  42154. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  42155. */
  42156. axisXControlHeight: boolean;
  42157. /**
  42158. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  42159. */
  42160. axisXControlRotation: boolean;
  42161. /**
  42162. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  42163. */
  42164. axisYControlRadius: boolean;
  42165. /**
  42166. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  42167. */
  42168. axisYControlHeight: boolean;
  42169. /**
  42170. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  42171. */
  42172. axisYControlRotation: boolean;
  42173. /**
  42174. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  42175. */
  42176. axisPinchControlRadius: boolean;
  42177. /**
  42178. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  42179. */
  42180. axisPinchControlHeight: boolean;
  42181. /**
  42182. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  42183. */
  42184. axisPinchControlRotation: boolean;
  42185. /**
  42186. * Log error messages if basic misconfiguration has occurred.
  42187. */
  42188. warningEnable: boolean;
  42189. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  42190. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  42191. private _warningCounter;
  42192. private _warning;
  42193. }
  42194. }
  42195. declare module "babylonjs/Cameras/followCameraInputsManager" {
  42196. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  42197. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  42198. /**
  42199. * Default Inputs manager for the FollowCamera.
  42200. * It groups all the default supported inputs for ease of use.
  42201. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42202. */
  42203. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  42204. /**
  42205. * Instantiates a new FollowCameraInputsManager.
  42206. * @param camera Defines the camera the inputs belong to
  42207. */
  42208. constructor(camera: FollowCamera);
  42209. /**
  42210. * Add keyboard input support to the input manager.
  42211. * @returns the current input manager
  42212. */
  42213. addKeyboard(): FollowCameraInputsManager;
  42214. /**
  42215. * Add mouse wheel input support to the input manager.
  42216. * @returns the current input manager
  42217. */
  42218. addMouseWheel(): FollowCameraInputsManager;
  42219. /**
  42220. * Add pointers input support to the input manager.
  42221. * @returns the current input manager
  42222. */
  42223. addPointers(): FollowCameraInputsManager;
  42224. /**
  42225. * Add orientation input support to the input manager.
  42226. * @returns the current input manager
  42227. */
  42228. addVRDeviceOrientation(): FollowCameraInputsManager;
  42229. }
  42230. }
  42231. declare module "babylonjs/Cameras/followCamera" {
  42232. import { Nullable } from "babylonjs/types";
  42233. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  42234. import { Scene } from "babylonjs/scene";
  42235. import { Vector3 } from "babylonjs/Maths/math.vector";
  42236. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42237. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  42238. /**
  42239. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  42240. * an arc rotate version arcFollowCamera are available.
  42241. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  42242. */
  42243. export class FollowCamera extends TargetCamera {
  42244. /**
  42245. * Distance the follow camera should follow an object at
  42246. */
  42247. radius: number;
  42248. /**
  42249. * Minimum allowed distance of the camera to the axis of rotation
  42250. * (The camera can not get closer).
  42251. * This can help limiting how the Camera is able to move in the scene.
  42252. */
  42253. lowerRadiusLimit: Nullable<number>;
  42254. /**
  42255. * Maximum allowed distance of the camera to the axis of rotation
  42256. * (The camera can not get further).
  42257. * This can help limiting how the Camera is able to move in the scene.
  42258. */
  42259. upperRadiusLimit: Nullable<number>;
  42260. /**
  42261. * Define a rotation offset between the camera and the object it follows
  42262. */
  42263. rotationOffset: number;
  42264. /**
  42265. * Minimum allowed angle to camera position relative to target object.
  42266. * This can help limiting how the Camera is able to move in the scene.
  42267. */
  42268. lowerRotationOffsetLimit: Nullable<number>;
  42269. /**
  42270. * Maximum allowed angle to camera position relative to target object.
  42271. * This can help limiting how the Camera is able to move in the scene.
  42272. */
  42273. upperRotationOffsetLimit: Nullable<number>;
  42274. /**
  42275. * Define a height offset between the camera and the object it follows.
  42276. * It can help following an object from the top (like a car chaing a plane)
  42277. */
  42278. heightOffset: number;
  42279. /**
  42280. * Minimum allowed height of camera position relative to target object.
  42281. * This can help limiting how the Camera is able to move in the scene.
  42282. */
  42283. lowerHeightOffsetLimit: Nullable<number>;
  42284. /**
  42285. * Maximum allowed height of camera position relative to target object.
  42286. * This can help limiting how the Camera is able to move in the scene.
  42287. */
  42288. upperHeightOffsetLimit: Nullable<number>;
  42289. /**
  42290. * Define how fast the camera can accelerate to follow it s target.
  42291. */
  42292. cameraAcceleration: number;
  42293. /**
  42294. * Define the speed limit of the camera following an object.
  42295. */
  42296. maxCameraSpeed: number;
  42297. /**
  42298. * Define the target of the camera.
  42299. */
  42300. lockedTarget: Nullable<AbstractMesh>;
  42301. /**
  42302. * Defines the input associated with the camera.
  42303. */
  42304. inputs: FollowCameraInputsManager;
  42305. /**
  42306. * Instantiates the follow camera.
  42307. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  42308. * @param name Define the name of the camera in the scene
  42309. * @param position Define the position of the camera
  42310. * @param scene Define the scene the camera belong to
  42311. * @param lockedTarget Define the target of the camera
  42312. */
  42313. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  42314. private _follow;
  42315. /**
  42316. * Attached controls to the current camera.
  42317. * @param element Defines the element the controls should be listened from
  42318. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42319. */
  42320. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42321. /**
  42322. * Detach the current controls from the camera.
  42323. * The camera will stop reacting to inputs.
  42324. * @param element Defines the element to stop listening the inputs from
  42325. */
  42326. detachControl(element: HTMLElement): void;
  42327. /** @hidden */
  42328. _checkInputs(): void;
  42329. private _checkLimits;
  42330. /**
  42331. * Gets the camera class name.
  42332. * @returns the class name
  42333. */
  42334. getClassName(): string;
  42335. }
  42336. /**
  42337. * Arc Rotate version of the follow camera.
  42338. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  42339. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  42340. */
  42341. export class ArcFollowCamera extends TargetCamera {
  42342. /** The longitudinal angle of the camera */
  42343. alpha: number;
  42344. /** The latitudinal angle of the camera */
  42345. beta: number;
  42346. /** The radius of the camera from its target */
  42347. radius: number;
  42348. /** Define the camera target (the messh it should follow) */
  42349. target: Nullable<AbstractMesh>;
  42350. private _cartesianCoordinates;
  42351. /**
  42352. * Instantiates a new ArcFollowCamera
  42353. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  42354. * @param name Define the name of the camera
  42355. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  42356. * @param beta Define the rotation angle of the camera around the elevation axis
  42357. * @param radius Define the radius of the camera from its target point
  42358. * @param target Define the target of the camera
  42359. * @param scene Define the scene the camera belongs to
  42360. */
  42361. constructor(name: string,
  42362. /** The longitudinal angle of the camera */
  42363. alpha: number,
  42364. /** The latitudinal angle of the camera */
  42365. beta: number,
  42366. /** The radius of the camera from its target */
  42367. radius: number,
  42368. /** Define the camera target (the messh it should follow) */
  42369. target: Nullable<AbstractMesh>, scene: Scene);
  42370. private _follow;
  42371. /** @hidden */
  42372. _checkInputs(): void;
  42373. /**
  42374. * Returns the class name of the object.
  42375. * It is mostly used internally for serialization purposes.
  42376. */
  42377. getClassName(): string;
  42378. }
  42379. }
  42380. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  42381. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  42382. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  42383. import { Nullable } from "babylonjs/types";
  42384. /**
  42385. * Manage the keyboard inputs to control the movement of a follow camera.
  42386. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42387. */
  42388. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  42389. /**
  42390. * Defines the camera the input is attached to.
  42391. */
  42392. camera: FollowCamera;
  42393. /**
  42394. * Defines the list of key codes associated with the up action (increase heightOffset)
  42395. */
  42396. keysHeightOffsetIncr: number[];
  42397. /**
  42398. * Defines the list of key codes associated with the down action (decrease heightOffset)
  42399. */
  42400. keysHeightOffsetDecr: number[];
  42401. /**
  42402. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  42403. */
  42404. keysHeightOffsetModifierAlt: boolean;
  42405. /**
  42406. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  42407. */
  42408. keysHeightOffsetModifierCtrl: boolean;
  42409. /**
  42410. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  42411. */
  42412. keysHeightOffsetModifierShift: boolean;
  42413. /**
  42414. * Defines the list of key codes associated with the left action (increase rotationOffset)
  42415. */
  42416. keysRotationOffsetIncr: number[];
  42417. /**
  42418. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  42419. */
  42420. keysRotationOffsetDecr: number[];
  42421. /**
  42422. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  42423. */
  42424. keysRotationOffsetModifierAlt: boolean;
  42425. /**
  42426. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  42427. */
  42428. keysRotationOffsetModifierCtrl: boolean;
  42429. /**
  42430. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  42431. */
  42432. keysRotationOffsetModifierShift: boolean;
  42433. /**
  42434. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  42435. */
  42436. keysRadiusIncr: number[];
  42437. /**
  42438. * Defines the list of key codes associated with the zoom-out action (increase radius)
  42439. */
  42440. keysRadiusDecr: number[];
  42441. /**
  42442. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  42443. */
  42444. keysRadiusModifierAlt: boolean;
  42445. /**
  42446. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  42447. */
  42448. keysRadiusModifierCtrl: boolean;
  42449. /**
  42450. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  42451. */
  42452. keysRadiusModifierShift: boolean;
  42453. /**
  42454. * Defines the rate of change of heightOffset.
  42455. */
  42456. heightSensibility: number;
  42457. /**
  42458. * Defines the rate of change of rotationOffset.
  42459. */
  42460. rotationSensibility: number;
  42461. /**
  42462. * Defines the rate of change of radius.
  42463. */
  42464. radiusSensibility: number;
  42465. private _keys;
  42466. private _ctrlPressed;
  42467. private _altPressed;
  42468. private _shiftPressed;
  42469. private _onCanvasBlurObserver;
  42470. private _onKeyboardObserver;
  42471. private _engine;
  42472. private _scene;
  42473. /**
  42474. * Attach the input controls to a specific dom element to get the input from.
  42475. * @param element Defines the element the controls should be listened from
  42476. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42477. */
  42478. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42479. /**
  42480. * Detach the current controls from the specified dom element.
  42481. * @param element Defines the element to stop listening the inputs from
  42482. */
  42483. detachControl(element: Nullable<HTMLElement>): void;
  42484. /**
  42485. * Update the current camera state depending on the inputs that have been used this frame.
  42486. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  42487. */
  42488. checkInputs(): void;
  42489. /**
  42490. * Gets the class name of the current input.
  42491. * @returns the class name
  42492. */
  42493. getClassName(): string;
  42494. /**
  42495. * Get the friendly name associated with the input class.
  42496. * @returns the input friendly name
  42497. */
  42498. getSimpleName(): string;
  42499. /**
  42500. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  42501. * allow modification of the heightOffset value.
  42502. */
  42503. private _modifierHeightOffset;
  42504. /**
  42505. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  42506. * allow modification of the rotationOffset value.
  42507. */
  42508. private _modifierRotationOffset;
  42509. /**
  42510. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  42511. * allow modification of the radius value.
  42512. */
  42513. private _modifierRadius;
  42514. }
  42515. }
  42516. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  42517. import { Nullable } from "babylonjs/types";
  42518. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  42519. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  42520. import { Observable } from "babylonjs/Misc/observable";
  42521. module "babylonjs/Cameras/freeCameraInputsManager" {
  42522. interface FreeCameraInputsManager {
  42523. /**
  42524. * @hidden
  42525. */
  42526. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  42527. /**
  42528. * Add orientation input support to the input manager.
  42529. * @returns the current input manager
  42530. */
  42531. addDeviceOrientation(): FreeCameraInputsManager;
  42532. }
  42533. }
  42534. /**
  42535. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  42536. * Screen rotation is taken into account.
  42537. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42538. */
  42539. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  42540. private _camera;
  42541. private _screenOrientationAngle;
  42542. private _constantTranform;
  42543. private _screenQuaternion;
  42544. private _alpha;
  42545. private _beta;
  42546. private _gamma;
  42547. /**
  42548. * Can be used to detect if a device orientation sensor is available on a device
  42549. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  42550. * @returns a promise that will resolve on orientation change
  42551. */
  42552. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  42553. /**
  42554. * @hidden
  42555. */
  42556. _onDeviceOrientationChangedObservable: Observable<void>;
  42557. /**
  42558. * Instantiates a new input
  42559. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42560. */
  42561. constructor();
  42562. /**
  42563. * Define the camera controlled by the input.
  42564. */
  42565. get camera(): FreeCamera;
  42566. set camera(camera: FreeCamera);
  42567. /**
  42568. * Attach the input controls to a specific dom element to get the input from.
  42569. * @param element Defines the element the controls should be listened from
  42570. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42571. */
  42572. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42573. private _orientationChanged;
  42574. private _deviceOrientation;
  42575. /**
  42576. * Detach the current controls from the specified dom element.
  42577. * @param element Defines the element to stop listening the inputs from
  42578. */
  42579. detachControl(element: Nullable<HTMLElement>): void;
  42580. /**
  42581. * Update the current camera state depending on the inputs that have been used this frame.
  42582. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  42583. */
  42584. checkInputs(): void;
  42585. /**
  42586. * Gets the class name of the current intput.
  42587. * @returns the class name
  42588. */
  42589. getClassName(): string;
  42590. /**
  42591. * Get the friendly name associated with the input class.
  42592. * @returns the input friendly name
  42593. */
  42594. getSimpleName(): string;
  42595. }
  42596. }
  42597. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  42598. import { Nullable } from "babylonjs/types";
  42599. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  42600. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  42601. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  42602. /**
  42603. * Manage the gamepad inputs to control a free camera.
  42604. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42605. */
  42606. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  42607. /**
  42608. * Define the camera the input is attached to.
  42609. */
  42610. camera: FreeCamera;
  42611. /**
  42612. * Define the Gamepad controlling the input
  42613. */
  42614. gamepad: Nullable<Gamepad>;
  42615. /**
  42616. * Defines the gamepad rotation sensiblity.
  42617. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  42618. */
  42619. gamepadAngularSensibility: number;
  42620. /**
  42621. * Defines the gamepad move sensiblity.
  42622. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  42623. */
  42624. gamepadMoveSensibility: number;
  42625. private _yAxisScale;
  42626. /**
  42627. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  42628. */
  42629. get invertYAxis(): boolean;
  42630. set invertYAxis(value: boolean);
  42631. private _onGamepadConnectedObserver;
  42632. private _onGamepadDisconnectedObserver;
  42633. private _cameraTransform;
  42634. private _deltaTransform;
  42635. private _vector3;
  42636. private _vector2;
  42637. /**
  42638. * Attach the input controls to a specific dom element to get the input from.
  42639. * @param element Defines the element the controls should be listened from
  42640. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42641. */
  42642. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42643. /**
  42644. * Detach the current controls from the specified dom element.
  42645. * @param element Defines the element to stop listening the inputs from
  42646. */
  42647. detachControl(element: Nullable<HTMLElement>): void;
  42648. /**
  42649. * Update the current camera state depending on the inputs that have been used this frame.
  42650. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  42651. */
  42652. checkInputs(): void;
  42653. /**
  42654. * Gets the class name of the current intput.
  42655. * @returns the class name
  42656. */
  42657. getClassName(): string;
  42658. /**
  42659. * Get the friendly name associated with the input class.
  42660. * @returns the input friendly name
  42661. */
  42662. getSimpleName(): string;
  42663. }
  42664. }
  42665. declare module "babylonjs/Misc/virtualJoystick" {
  42666. import { Nullable } from "babylonjs/types";
  42667. import { Vector3 } from "babylonjs/Maths/math.vector";
  42668. /**
  42669. * Defines the potential axis of a Joystick
  42670. */
  42671. export enum JoystickAxis {
  42672. /** X axis */
  42673. X = 0,
  42674. /** Y axis */
  42675. Y = 1,
  42676. /** Z axis */
  42677. Z = 2
  42678. }
  42679. /**
  42680. * Class used to define virtual joystick (used in touch mode)
  42681. */
  42682. export class VirtualJoystick {
  42683. /**
  42684. * Gets or sets a boolean indicating that left and right values must be inverted
  42685. */
  42686. reverseLeftRight: boolean;
  42687. /**
  42688. * Gets or sets a boolean indicating that up and down values must be inverted
  42689. */
  42690. reverseUpDown: boolean;
  42691. /**
  42692. * Gets the offset value for the position (ie. the change of the position value)
  42693. */
  42694. deltaPosition: Vector3;
  42695. /**
  42696. * Gets a boolean indicating if the virtual joystick was pressed
  42697. */
  42698. pressed: boolean;
  42699. /**
  42700. * Canvas the virtual joystick will render onto, default z-index of this is 5
  42701. */
  42702. static Canvas: Nullable<HTMLCanvasElement>;
  42703. private static _globalJoystickIndex;
  42704. private static vjCanvasContext;
  42705. private static vjCanvasWidth;
  42706. private static vjCanvasHeight;
  42707. private static halfWidth;
  42708. private _action;
  42709. private _axisTargetedByLeftAndRight;
  42710. private _axisTargetedByUpAndDown;
  42711. private _joystickSensibility;
  42712. private _inversedSensibility;
  42713. private _joystickPointerID;
  42714. private _joystickColor;
  42715. private _joystickPointerPos;
  42716. private _joystickPreviousPointerPos;
  42717. private _joystickPointerStartPos;
  42718. private _deltaJoystickVector;
  42719. private _leftJoystick;
  42720. private _touches;
  42721. private _onPointerDownHandlerRef;
  42722. private _onPointerMoveHandlerRef;
  42723. private _onPointerUpHandlerRef;
  42724. private _onResize;
  42725. /**
  42726. * Creates a new virtual joystick
  42727. * @param leftJoystick defines that the joystick is for left hand (false by default)
  42728. */
  42729. constructor(leftJoystick?: boolean);
  42730. /**
  42731. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  42732. * @param newJoystickSensibility defines the new sensibility
  42733. */
  42734. setJoystickSensibility(newJoystickSensibility: number): void;
  42735. private _onPointerDown;
  42736. private _onPointerMove;
  42737. private _onPointerUp;
  42738. /**
  42739. * Change the color of the virtual joystick
  42740. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  42741. */
  42742. setJoystickColor(newColor: string): void;
  42743. /**
  42744. * Defines a callback to call when the joystick is touched
  42745. * @param action defines the callback
  42746. */
  42747. setActionOnTouch(action: () => any): void;
  42748. /**
  42749. * Defines which axis you'd like to control for left & right
  42750. * @param axis defines the axis to use
  42751. */
  42752. setAxisForLeftRight(axis: JoystickAxis): void;
  42753. /**
  42754. * Defines which axis you'd like to control for up & down
  42755. * @param axis defines the axis to use
  42756. */
  42757. setAxisForUpDown(axis: JoystickAxis): void;
  42758. private _drawVirtualJoystick;
  42759. /**
  42760. * Release internal HTML canvas
  42761. */
  42762. releaseCanvas(): void;
  42763. }
  42764. }
  42765. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  42766. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  42767. import { Nullable } from "babylonjs/types";
  42768. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  42769. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  42770. module "babylonjs/Cameras/freeCameraInputsManager" {
  42771. interface FreeCameraInputsManager {
  42772. /**
  42773. * Add virtual joystick input support to the input manager.
  42774. * @returns the current input manager
  42775. */
  42776. addVirtualJoystick(): FreeCameraInputsManager;
  42777. }
  42778. }
  42779. /**
  42780. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  42781. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42782. */
  42783. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  42784. /**
  42785. * Defines the camera the input is attached to.
  42786. */
  42787. camera: FreeCamera;
  42788. private _leftjoystick;
  42789. private _rightjoystick;
  42790. /**
  42791. * Gets the left stick of the virtual joystick.
  42792. * @returns The virtual Joystick
  42793. */
  42794. getLeftJoystick(): VirtualJoystick;
  42795. /**
  42796. * Gets the right stick of the virtual joystick.
  42797. * @returns The virtual Joystick
  42798. */
  42799. getRightJoystick(): VirtualJoystick;
  42800. /**
  42801. * Update the current camera state depending on the inputs that have been used this frame.
  42802. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  42803. */
  42804. checkInputs(): void;
  42805. /**
  42806. * Attach the input controls to a specific dom element to get the input from.
  42807. * @param element Defines the element the controls should be listened from
  42808. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42809. */
  42810. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42811. /**
  42812. * Detach the current controls from the specified dom element.
  42813. * @param element Defines the element to stop listening the inputs from
  42814. */
  42815. detachControl(element: Nullable<HTMLElement>): void;
  42816. /**
  42817. * Gets the class name of the current intput.
  42818. * @returns the class name
  42819. */
  42820. getClassName(): string;
  42821. /**
  42822. * Get the friendly name associated with the input class.
  42823. * @returns the input friendly name
  42824. */
  42825. getSimpleName(): string;
  42826. }
  42827. }
  42828. declare module "babylonjs/Cameras/Inputs/index" {
  42829. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  42830. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  42831. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  42832. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  42833. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  42834. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  42835. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  42836. export * from "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput";
  42837. export * from "babylonjs/Cameras/Inputs/followCameraMouseWheelInput";
  42838. export * from "babylonjs/Cameras/Inputs/followCameraPointersInput";
  42839. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  42840. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  42841. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  42842. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  42843. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  42844. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  42845. }
  42846. declare module "babylonjs/Cameras/touchCamera" {
  42847. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  42848. import { Scene } from "babylonjs/scene";
  42849. import { Vector3 } from "babylonjs/Maths/math.vector";
  42850. /**
  42851. * This represents a FPS type of camera controlled by touch.
  42852. * This is like a universal camera minus the Gamepad controls.
  42853. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42854. */
  42855. export class TouchCamera extends FreeCamera {
  42856. /**
  42857. * Defines the touch sensibility for rotation.
  42858. * The higher the faster.
  42859. */
  42860. get touchAngularSensibility(): number;
  42861. set touchAngularSensibility(value: number);
  42862. /**
  42863. * Defines the touch sensibility for move.
  42864. * The higher the faster.
  42865. */
  42866. get touchMoveSensibility(): number;
  42867. set touchMoveSensibility(value: number);
  42868. /**
  42869. * Instantiates a new touch camera.
  42870. * This represents a FPS type of camera controlled by touch.
  42871. * This is like a universal camera minus the Gamepad controls.
  42872. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42873. * @param name Define the name of the camera in the scene
  42874. * @param position Define the start position of the camera in the scene
  42875. * @param scene Define the scene the camera belongs to
  42876. */
  42877. constructor(name: string, position: Vector3, scene: Scene);
  42878. /**
  42879. * Gets the current object class name.
  42880. * @return the class name
  42881. */
  42882. getClassName(): string;
  42883. /** @hidden */
  42884. _setupInputs(): void;
  42885. }
  42886. }
  42887. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  42888. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  42889. import { Scene } from "babylonjs/scene";
  42890. import { Vector3 } from "babylonjs/Maths/math.vector";
  42891. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  42892. import { Axis } from "babylonjs/Maths/math.axis";
  42893. /**
  42894. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  42895. * being tilted forward or back and left or right.
  42896. */
  42897. export class DeviceOrientationCamera extends FreeCamera {
  42898. private _initialQuaternion;
  42899. private _quaternionCache;
  42900. private _tmpDragQuaternion;
  42901. private _disablePointerInputWhenUsingDeviceOrientation;
  42902. /**
  42903. * Creates a new device orientation camera
  42904. * @param name The name of the camera
  42905. * @param position The start position camera
  42906. * @param scene The scene the camera belongs to
  42907. */
  42908. constructor(name: string, position: Vector3, scene: Scene);
  42909. /**
  42910. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  42911. */
  42912. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  42913. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  42914. private _dragFactor;
  42915. /**
  42916. * Enabled turning on the y axis when the orientation sensor is active
  42917. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  42918. */
  42919. enableHorizontalDragging(dragFactor?: number): void;
  42920. /**
  42921. * Gets the current instance class name ("DeviceOrientationCamera").
  42922. * This helps avoiding instanceof at run time.
  42923. * @returns the class name
  42924. */
  42925. getClassName(): string;
  42926. /**
  42927. * @hidden
  42928. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  42929. */
  42930. _checkInputs(): void;
  42931. /**
  42932. * Reset the camera to its default orientation on the specified axis only.
  42933. * @param axis The axis to reset
  42934. */
  42935. resetToCurrentRotation(axis?: Axis): void;
  42936. }
  42937. }
  42938. declare module "babylonjs/Gamepads/xboxGamepad" {
  42939. import { Observable } from "babylonjs/Misc/observable";
  42940. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  42941. /**
  42942. * Defines supported buttons for XBox360 compatible gamepads
  42943. */
  42944. export enum Xbox360Button {
  42945. /** A */
  42946. A = 0,
  42947. /** B */
  42948. B = 1,
  42949. /** X */
  42950. X = 2,
  42951. /** Y */
  42952. Y = 3,
  42953. /** Left button */
  42954. LB = 4,
  42955. /** Right button */
  42956. RB = 5,
  42957. /** Back */
  42958. Back = 8,
  42959. /** Start */
  42960. Start = 9,
  42961. /** Left stick */
  42962. LeftStick = 10,
  42963. /** Right stick */
  42964. RightStick = 11
  42965. }
  42966. /** Defines values for XBox360 DPad */
  42967. export enum Xbox360Dpad {
  42968. /** Up */
  42969. Up = 12,
  42970. /** Down */
  42971. Down = 13,
  42972. /** Left */
  42973. Left = 14,
  42974. /** Right */
  42975. Right = 15
  42976. }
  42977. /**
  42978. * Defines a XBox360 gamepad
  42979. */
  42980. export class Xbox360Pad extends Gamepad {
  42981. private _leftTrigger;
  42982. private _rightTrigger;
  42983. private _onlefttriggerchanged;
  42984. private _onrighttriggerchanged;
  42985. private _onbuttondown;
  42986. private _onbuttonup;
  42987. private _ondpaddown;
  42988. private _ondpadup;
  42989. /** Observable raised when a button is pressed */
  42990. onButtonDownObservable: Observable<Xbox360Button>;
  42991. /** Observable raised when a button is released */
  42992. onButtonUpObservable: Observable<Xbox360Button>;
  42993. /** Observable raised when a pad is pressed */
  42994. onPadDownObservable: Observable<Xbox360Dpad>;
  42995. /** Observable raised when a pad is released */
  42996. onPadUpObservable: Observable<Xbox360Dpad>;
  42997. private _buttonA;
  42998. private _buttonB;
  42999. private _buttonX;
  43000. private _buttonY;
  43001. private _buttonBack;
  43002. private _buttonStart;
  43003. private _buttonLB;
  43004. private _buttonRB;
  43005. private _buttonLeftStick;
  43006. private _buttonRightStick;
  43007. private _dPadUp;
  43008. private _dPadDown;
  43009. private _dPadLeft;
  43010. private _dPadRight;
  43011. private _isXboxOnePad;
  43012. /**
  43013. * Creates a new XBox360 gamepad object
  43014. * @param id defines the id of this gamepad
  43015. * @param index defines its index
  43016. * @param gamepad defines the internal HTML gamepad object
  43017. * @param xboxOne defines if it is a XBox One gamepad
  43018. */
  43019. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  43020. /**
  43021. * Defines the callback to call when left trigger is pressed
  43022. * @param callback defines the callback to use
  43023. */
  43024. onlefttriggerchanged(callback: (value: number) => void): void;
  43025. /**
  43026. * Defines the callback to call when right trigger is pressed
  43027. * @param callback defines the callback to use
  43028. */
  43029. onrighttriggerchanged(callback: (value: number) => void): void;
  43030. /**
  43031. * Gets the left trigger value
  43032. */
  43033. get leftTrigger(): number;
  43034. /**
  43035. * Sets the left trigger value
  43036. */
  43037. set leftTrigger(newValue: number);
  43038. /**
  43039. * Gets the right trigger value
  43040. */
  43041. get rightTrigger(): number;
  43042. /**
  43043. * Sets the right trigger value
  43044. */
  43045. set rightTrigger(newValue: number);
  43046. /**
  43047. * Defines the callback to call when a button is pressed
  43048. * @param callback defines the callback to use
  43049. */
  43050. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  43051. /**
  43052. * Defines the callback to call when a button is released
  43053. * @param callback defines the callback to use
  43054. */
  43055. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  43056. /**
  43057. * Defines the callback to call when a pad is pressed
  43058. * @param callback defines the callback to use
  43059. */
  43060. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  43061. /**
  43062. * Defines the callback to call when a pad is released
  43063. * @param callback defines the callback to use
  43064. */
  43065. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  43066. private _setButtonValue;
  43067. private _setDPadValue;
  43068. /**
  43069. * Gets the value of the `A` button
  43070. */
  43071. get buttonA(): number;
  43072. /**
  43073. * Sets the value of the `A` button
  43074. */
  43075. set buttonA(value: number);
  43076. /**
  43077. * Gets the value of the `B` button
  43078. */
  43079. get buttonB(): number;
  43080. /**
  43081. * Sets the value of the `B` button
  43082. */
  43083. set buttonB(value: number);
  43084. /**
  43085. * Gets the value of the `X` button
  43086. */
  43087. get buttonX(): number;
  43088. /**
  43089. * Sets the value of the `X` button
  43090. */
  43091. set buttonX(value: number);
  43092. /**
  43093. * Gets the value of the `Y` button
  43094. */
  43095. get buttonY(): number;
  43096. /**
  43097. * Sets the value of the `Y` button
  43098. */
  43099. set buttonY(value: number);
  43100. /**
  43101. * Gets the value of the `Start` button
  43102. */
  43103. get buttonStart(): number;
  43104. /**
  43105. * Sets the value of the `Start` button
  43106. */
  43107. set buttonStart(value: number);
  43108. /**
  43109. * Gets the value of the `Back` button
  43110. */
  43111. get buttonBack(): number;
  43112. /**
  43113. * Sets the value of the `Back` button
  43114. */
  43115. set buttonBack(value: number);
  43116. /**
  43117. * Gets the value of the `Left` button
  43118. */
  43119. get buttonLB(): number;
  43120. /**
  43121. * Sets the value of the `Left` button
  43122. */
  43123. set buttonLB(value: number);
  43124. /**
  43125. * Gets the value of the `Right` button
  43126. */
  43127. get buttonRB(): number;
  43128. /**
  43129. * Sets the value of the `Right` button
  43130. */
  43131. set buttonRB(value: number);
  43132. /**
  43133. * Gets the value of the Left joystick
  43134. */
  43135. get buttonLeftStick(): number;
  43136. /**
  43137. * Sets the value of the Left joystick
  43138. */
  43139. set buttonLeftStick(value: number);
  43140. /**
  43141. * Gets the value of the Right joystick
  43142. */
  43143. get buttonRightStick(): number;
  43144. /**
  43145. * Sets the value of the Right joystick
  43146. */
  43147. set buttonRightStick(value: number);
  43148. /**
  43149. * Gets the value of D-pad up
  43150. */
  43151. get dPadUp(): number;
  43152. /**
  43153. * Sets the value of D-pad up
  43154. */
  43155. set dPadUp(value: number);
  43156. /**
  43157. * Gets the value of D-pad down
  43158. */
  43159. get dPadDown(): number;
  43160. /**
  43161. * Sets the value of D-pad down
  43162. */
  43163. set dPadDown(value: number);
  43164. /**
  43165. * Gets the value of D-pad left
  43166. */
  43167. get dPadLeft(): number;
  43168. /**
  43169. * Sets the value of D-pad left
  43170. */
  43171. set dPadLeft(value: number);
  43172. /**
  43173. * Gets the value of D-pad right
  43174. */
  43175. get dPadRight(): number;
  43176. /**
  43177. * Sets the value of D-pad right
  43178. */
  43179. set dPadRight(value: number);
  43180. /**
  43181. * Force the gamepad to synchronize with device values
  43182. */
  43183. update(): void;
  43184. /**
  43185. * Disposes the gamepad
  43186. */
  43187. dispose(): void;
  43188. }
  43189. }
  43190. declare module "babylonjs/Gamepads/dualShockGamepad" {
  43191. import { Observable } from "babylonjs/Misc/observable";
  43192. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  43193. /**
  43194. * Defines supported buttons for DualShock compatible gamepads
  43195. */
  43196. export enum DualShockButton {
  43197. /** Cross */
  43198. Cross = 0,
  43199. /** Circle */
  43200. Circle = 1,
  43201. /** Square */
  43202. Square = 2,
  43203. /** Triangle */
  43204. Triangle = 3,
  43205. /** L1 */
  43206. L1 = 4,
  43207. /** R1 */
  43208. R1 = 5,
  43209. /** Share */
  43210. Share = 8,
  43211. /** Options */
  43212. Options = 9,
  43213. /** Left stick */
  43214. LeftStick = 10,
  43215. /** Right stick */
  43216. RightStick = 11
  43217. }
  43218. /** Defines values for DualShock DPad */
  43219. export enum DualShockDpad {
  43220. /** Up */
  43221. Up = 12,
  43222. /** Down */
  43223. Down = 13,
  43224. /** Left */
  43225. Left = 14,
  43226. /** Right */
  43227. Right = 15
  43228. }
  43229. /**
  43230. * Defines a DualShock gamepad
  43231. */
  43232. export class DualShockPad extends Gamepad {
  43233. private _leftTrigger;
  43234. private _rightTrigger;
  43235. private _onlefttriggerchanged;
  43236. private _onrighttriggerchanged;
  43237. private _onbuttondown;
  43238. private _onbuttonup;
  43239. private _ondpaddown;
  43240. private _ondpadup;
  43241. /** Observable raised when a button is pressed */
  43242. onButtonDownObservable: Observable<DualShockButton>;
  43243. /** Observable raised when a button is released */
  43244. onButtonUpObservable: Observable<DualShockButton>;
  43245. /** Observable raised when a pad is pressed */
  43246. onPadDownObservable: Observable<DualShockDpad>;
  43247. /** Observable raised when a pad is released */
  43248. onPadUpObservable: Observable<DualShockDpad>;
  43249. private _buttonCross;
  43250. private _buttonCircle;
  43251. private _buttonSquare;
  43252. private _buttonTriangle;
  43253. private _buttonShare;
  43254. private _buttonOptions;
  43255. private _buttonL1;
  43256. private _buttonR1;
  43257. private _buttonLeftStick;
  43258. private _buttonRightStick;
  43259. private _dPadUp;
  43260. private _dPadDown;
  43261. private _dPadLeft;
  43262. private _dPadRight;
  43263. /**
  43264. * Creates a new DualShock gamepad object
  43265. * @param id defines the id of this gamepad
  43266. * @param index defines its index
  43267. * @param gamepad defines the internal HTML gamepad object
  43268. */
  43269. constructor(id: string, index: number, gamepad: any);
  43270. /**
  43271. * Defines the callback to call when left trigger is pressed
  43272. * @param callback defines the callback to use
  43273. */
  43274. onlefttriggerchanged(callback: (value: number) => void): void;
  43275. /**
  43276. * Defines the callback to call when right trigger is pressed
  43277. * @param callback defines the callback to use
  43278. */
  43279. onrighttriggerchanged(callback: (value: number) => void): void;
  43280. /**
  43281. * Gets the left trigger value
  43282. */
  43283. get leftTrigger(): number;
  43284. /**
  43285. * Sets the left trigger value
  43286. */
  43287. set leftTrigger(newValue: number);
  43288. /**
  43289. * Gets the right trigger value
  43290. */
  43291. get rightTrigger(): number;
  43292. /**
  43293. * Sets the right trigger value
  43294. */
  43295. set rightTrigger(newValue: number);
  43296. /**
  43297. * Defines the callback to call when a button is pressed
  43298. * @param callback defines the callback to use
  43299. */
  43300. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  43301. /**
  43302. * Defines the callback to call when a button is released
  43303. * @param callback defines the callback to use
  43304. */
  43305. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  43306. /**
  43307. * Defines the callback to call when a pad is pressed
  43308. * @param callback defines the callback to use
  43309. */
  43310. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  43311. /**
  43312. * Defines the callback to call when a pad is released
  43313. * @param callback defines the callback to use
  43314. */
  43315. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  43316. private _setButtonValue;
  43317. private _setDPadValue;
  43318. /**
  43319. * Gets the value of the `Cross` button
  43320. */
  43321. get buttonCross(): number;
  43322. /**
  43323. * Sets the value of the `Cross` button
  43324. */
  43325. set buttonCross(value: number);
  43326. /**
  43327. * Gets the value of the `Circle` button
  43328. */
  43329. get buttonCircle(): number;
  43330. /**
  43331. * Sets the value of the `Circle` button
  43332. */
  43333. set buttonCircle(value: number);
  43334. /**
  43335. * Gets the value of the `Square` button
  43336. */
  43337. get buttonSquare(): number;
  43338. /**
  43339. * Sets the value of the `Square` button
  43340. */
  43341. set buttonSquare(value: number);
  43342. /**
  43343. * Gets the value of the `Triangle` button
  43344. */
  43345. get buttonTriangle(): number;
  43346. /**
  43347. * Sets the value of the `Triangle` button
  43348. */
  43349. set buttonTriangle(value: number);
  43350. /**
  43351. * Gets the value of the `Options` button
  43352. */
  43353. get buttonOptions(): number;
  43354. /**
  43355. * Sets the value of the `Options` button
  43356. */
  43357. set buttonOptions(value: number);
  43358. /**
  43359. * Gets the value of the `Share` button
  43360. */
  43361. get buttonShare(): number;
  43362. /**
  43363. * Sets the value of the `Share` button
  43364. */
  43365. set buttonShare(value: number);
  43366. /**
  43367. * Gets the value of the `L1` button
  43368. */
  43369. get buttonL1(): number;
  43370. /**
  43371. * Sets the value of the `L1` button
  43372. */
  43373. set buttonL1(value: number);
  43374. /**
  43375. * Gets the value of the `R1` button
  43376. */
  43377. get buttonR1(): number;
  43378. /**
  43379. * Sets the value of the `R1` button
  43380. */
  43381. set buttonR1(value: number);
  43382. /**
  43383. * Gets the value of the Left joystick
  43384. */
  43385. get buttonLeftStick(): number;
  43386. /**
  43387. * Sets the value of the Left joystick
  43388. */
  43389. set buttonLeftStick(value: number);
  43390. /**
  43391. * Gets the value of the Right joystick
  43392. */
  43393. get buttonRightStick(): number;
  43394. /**
  43395. * Sets the value of the Right joystick
  43396. */
  43397. set buttonRightStick(value: number);
  43398. /**
  43399. * Gets the value of D-pad up
  43400. */
  43401. get dPadUp(): number;
  43402. /**
  43403. * Sets the value of D-pad up
  43404. */
  43405. set dPadUp(value: number);
  43406. /**
  43407. * Gets the value of D-pad down
  43408. */
  43409. get dPadDown(): number;
  43410. /**
  43411. * Sets the value of D-pad down
  43412. */
  43413. set dPadDown(value: number);
  43414. /**
  43415. * Gets the value of D-pad left
  43416. */
  43417. get dPadLeft(): number;
  43418. /**
  43419. * Sets the value of D-pad left
  43420. */
  43421. set dPadLeft(value: number);
  43422. /**
  43423. * Gets the value of D-pad right
  43424. */
  43425. get dPadRight(): number;
  43426. /**
  43427. * Sets the value of D-pad right
  43428. */
  43429. set dPadRight(value: number);
  43430. /**
  43431. * Force the gamepad to synchronize with device values
  43432. */
  43433. update(): void;
  43434. /**
  43435. * Disposes the gamepad
  43436. */
  43437. dispose(): void;
  43438. }
  43439. }
  43440. declare module "babylonjs/Gamepads/gamepadManager" {
  43441. import { Observable } from "babylonjs/Misc/observable";
  43442. import { Nullable } from "babylonjs/types";
  43443. import { Scene } from "babylonjs/scene";
  43444. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  43445. /**
  43446. * Manager for handling gamepads
  43447. */
  43448. export class GamepadManager {
  43449. private _scene?;
  43450. private _babylonGamepads;
  43451. private _oneGamepadConnected;
  43452. /** @hidden */
  43453. _isMonitoring: boolean;
  43454. private _gamepadEventSupported;
  43455. private _gamepadSupport?;
  43456. /**
  43457. * observable to be triggered when the gamepad controller has been connected
  43458. */
  43459. onGamepadConnectedObservable: Observable<Gamepad>;
  43460. /**
  43461. * observable to be triggered when the gamepad controller has been disconnected
  43462. */
  43463. onGamepadDisconnectedObservable: Observable<Gamepad>;
  43464. private _onGamepadConnectedEvent;
  43465. private _onGamepadDisconnectedEvent;
  43466. /**
  43467. * Initializes the gamepad manager
  43468. * @param _scene BabylonJS scene
  43469. */
  43470. constructor(_scene?: Scene | undefined);
  43471. /**
  43472. * The gamepads in the game pad manager
  43473. */
  43474. get gamepads(): Gamepad[];
  43475. /**
  43476. * Get the gamepad controllers based on type
  43477. * @param type The type of gamepad controller
  43478. * @returns Nullable gamepad
  43479. */
  43480. getGamepadByType(type?: number): Nullable<Gamepad>;
  43481. /**
  43482. * Disposes the gamepad manager
  43483. */
  43484. dispose(): void;
  43485. private _addNewGamepad;
  43486. private _startMonitoringGamepads;
  43487. private _stopMonitoringGamepads;
  43488. /** @hidden */
  43489. _checkGamepadsStatus(): void;
  43490. private _updateGamepadObjects;
  43491. }
  43492. }
  43493. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  43494. import { Nullable } from "babylonjs/types";
  43495. import { Scene } from "babylonjs/scene";
  43496. import { ISceneComponent } from "babylonjs/sceneComponent";
  43497. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  43498. module "babylonjs/scene" {
  43499. interface Scene {
  43500. /** @hidden */
  43501. _gamepadManager: Nullable<GamepadManager>;
  43502. /**
  43503. * Gets the gamepad manager associated with the scene
  43504. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  43505. */
  43506. gamepadManager: GamepadManager;
  43507. }
  43508. }
  43509. module "babylonjs/Cameras/freeCameraInputsManager" {
  43510. /**
  43511. * Interface representing a free camera inputs manager
  43512. */
  43513. interface FreeCameraInputsManager {
  43514. /**
  43515. * Adds gamepad input support to the FreeCameraInputsManager.
  43516. * @returns the FreeCameraInputsManager
  43517. */
  43518. addGamepad(): FreeCameraInputsManager;
  43519. }
  43520. }
  43521. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  43522. /**
  43523. * Interface representing an arc rotate camera inputs manager
  43524. */
  43525. interface ArcRotateCameraInputsManager {
  43526. /**
  43527. * Adds gamepad input support to the ArcRotateCamera InputManager.
  43528. * @returns the camera inputs manager
  43529. */
  43530. addGamepad(): ArcRotateCameraInputsManager;
  43531. }
  43532. }
  43533. /**
  43534. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  43535. */
  43536. export class GamepadSystemSceneComponent implements ISceneComponent {
  43537. /**
  43538. * The component name helpfull to identify the component in the list of scene components.
  43539. */
  43540. readonly name: string;
  43541. /**
  43542. * The scene the component belongs to.
  43543. */
  43544. scene: Scene;
  43545. /**
  43546. * Creates a new instance of the component for the given scene
  43547. * @param scene Defines the scene to register the component in
  43548. */
  43549. constructor(scene: Scene);
  43550. /**
  43551. * Registers the component in a given scene
  43552. */
  43553. register(): void;
  43554. /**
  43555. * Rebuilds the elements related to this component in case of
  43556. * context lost for instance.
  43557. */
  43558. rebuild(): void;
  43559. /**
  43560. * Disposes the component and the associated ressources
  43561. */
  43562. dispose(): void;
  43563. private _beforeCameraUpdate;
  43564. }
  43565. }
  43566. declare module "babylonjs/Cameras/universalCamera" {
  43567. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  43568. import { Scene } from "babylonjs/scene";
  43569. import { Vector3 } from "babylonjs/Maths/math.vector";
  43570. import "babylonjs/Gamepads/gamepadSceneComponent";
  43571. /**
  43572. * 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,
  43573. * which still works and will still be found in many Playgrounds.
  43574. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  43575. */
  43576. export class UniversalCamera extends TouchCamera {
  43577. /**
  43578. * Defines the gamepad rotation sensiblity.
  43579. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  43580. */
  43581. get gamepadAngularSensibility(): number;
  43582. set gamepadAngularSensibility(value: number);
  43583. /**
  43584. * Defines the gamepad move sensiblity.
  43585. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  43586. */
  43587. get gamepadMoveSensibility(): number;
  43588. set gamepadMoveSensibility(value: number);
  43589. /**
  43590. * 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,
  43591. * which still works and will still be found in many Playgrounds.
  43592. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  43593. * @param name Define the name of the camera in the scene
  43594. * @param position Define the start position of the camera in the scene
  43595. * @param scene Define the scene the camera belongs to
  43596. */
  43597. constructor(name: string, position: Vector3, scene: Scene);
  43598. /**
  43599. * Gets the current object class name.
  43600. * @return the class name
  43601. */
  43602. getClassName(): string;
  43603. }
  43604. }
  43605. declare module "babylonjs/Cameras/gamepadCamera" {
  43606. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  43607. import { Scene } from "babylonjs/scene";
  43608. import { Vector3 } from "babylonjs/Maths/math.vector";
  43609. /**
  43610. * This represents a FPS type of camera. This is only here for back compat purpose.
  43611. * Please use the UniversalCamera instead as both are identical.
  43612. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  43613. */
  43614. export class GamepadCamera extends UniversalCamera {
  43615. /**
  43616. * Instantiates a new Gamepad Camera
  43617. * This represents a FPS type of camera. This is only here for back compat purpose.
  43618. * Please use the UniversalCamera instead as both are identical.
  43619. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  43620. * @param name Define the name of the camera in the scene
  43621. * @param position Define the start position of the camera in the scene
  43622. * @param scene Define the scene the camera belongs to
  43623. */
  43624. constructor(name: string, position: Vector3, scene: Scene);
  43625. /**
  43626. * Gets the current object class name.
  43627. * @return the class name
  43628. */
  43629. getClassName(): string;
  43630. }
  43631. }
  43632. declare module "babylonjs/Shaders/pass.fragment" {
  43633. /** @hidden */
  43634. export var passPixelShader: {
  43635. name: string;
  43636. shader: string;
  43637. };
  43638. }
  43639. declare module "babylonjs/Shaders/passCube.fragment" {
  43640. /** @hidden */
  43641. export var passCubePixelShader: {
  43642. name: string;
  43643. shader: string;
  43644. };
  43645. }
  43646. declare module "babylonjs/PostProcesses/passPostProcess" {
  43647. import { Nullable } from "babylonjs/types";
  43648. import { Camera } from "babylonjs/Cameras/camera";
  43649. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  43650. import { Engine } from "babylonjs/Engines/engine";
  43651. import "babylonjs/Shaders/pass.fragment";
  43652. import "babylonjs/Shaders/passCube.fragment";
  43653. /**
  43654. * PassPostProcess which produces an output the same as it's input
  43655. */
  43656. export class PassPostProcess extends PostProcess {
  43657. /**
  43658. * Creates the PassPostProcess
  43659. * @param name The name of the effect.
  43660. * @param options The required width/height ratio to downsize to before computing the render pass.
  43661. * @param camera The camera to apply the render pass to.
  43662. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  43663. * @param engine The engine which the post process will be applied. (default: current engine)
  43664. * @param reusable If the post process can be reused on the same frame. (default: false)
  43665. * @param textureType The type of texture to be used when performing the post processing.
  43666. * @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)
  43667. */
  43668. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  43669. }
  43670. /**
  43671. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  43672. */
  43673. export class PassCubePostProcess extends PostProcess {
  43674. private _face;
  43675. /**
  43676. * Gets or sets the cube face to display.
  43677. * * 0 is +X
  43678. * * 1 is -X
  43679. * * 2 is +Y
  43680. * * 3 is -Y
  43681. * * 4 is +Z
  43682. * * 5 is -Z
  43683. */
  43684. get face(): number;
  43685. set face(value: number);
  43686. /**
  43687. * Creates the PassCubePostProcess
  43688. * @param name The name of the effect.
  43689. * @param options The required width/height ratio to downsize to before computing the render pass.
  43690. * @param camera The camera to apply the render pass to.
  43691. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  43692. * @param engine The engine which the post process will be applied. (default: current engine)
  43693. * @param reusable If the post process can be reused on the same frame. (default: false)
  43694. * @param textureType The type of texture to be used when performing the post processing.
  43695. * @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)
  43696. */
  43697. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  43698. }
  43699. }
  43700. declare module "babylonjs/Shaders/anaglyph.fragment" {
  43701. /** @hidden */
  43702. export var anaglyphPixelShader: {
  43703. name: string;
  43704. shader: string;
  43705. };
  43706. }
  43707. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  43708. import { Engine } from "babylonjs/Engines/engine";
  43709. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  43710. import { Camera } from "babylonjs/Cameras/camera";
  43711. import "babylonjs/Shaders/anaglyph.fragment";
  43712. /**
  43713. * Postprocess used to generate anaglyphic rendering
  43714. */
  43715. export class AnaglyphPostProcess extends PostProcess {
  43716. private _passedProcess;
  43717. /**
  43718. * Creates a new AnaglyphPostProcess
  43719. * @param name defines postprocess name
  43720. * @param options defines creation options or target ratio scale
  43721. * @param rigCameras defines cameras using this postprocess
  43722. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  43723. * @param engine defines hosting engine
  43724. * @param reusable defines if the postprocess will be reused multiple times per frame
  43725. */
  43726. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  43727. }
  43728. }
  43729. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  43730. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  43731. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  43732. import { Scene } from "babylonjs/scene";
  43733. import { Vector3 } from "babylonjs/Maths/math.vector";
  43734. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  43735. /**
  43736. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  43737. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  43738. */
  43739. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  43740. /**
  43741. * Creates a new AnaglyphArcRotateCamera
  43742. * @param name defines camera name
  43743. * @param alpha defines alpha angle (in radians)
  43744. * @param beta defines beta angle (in radians)
  43745. * @param radius defines radius
  43746. * @param target defines camera target
  43747. * @param interaxialDistance defines distance between each color axis
  43748. * @param scene defines the hosting scene
  43749. */
  43750. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  43751. /**
  43752. * Gets camera class name
  43753. * @returns AnaglyphArcRotateCamera
  43754. */
  43755. getClassName(): string;
  43756. }
  43757. }
  43758. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  43759. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  43760. import { Scene } from "babylonjs/scene";
  43761. import { Vector3 } from "babylonjs/Maths/math.vector";
  43762. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  43763. /**
  43764. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  43765. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  43766. */
  43767. export class AnaglyphFreeCamera extends FreeCamera {
  43768. /**
  43769. * Creates a new AnaglyphFreeCamera
  43770. * @param name defines camera name
  43771. * @param position defines initial position
  43772. * @param interaxialDistance defines distance between each color axis
  43773. * @param scene defines the hosting scene
  43774. */
  43775. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  43776. /**
  43777. * Gets camera class name
  43778. * @returns AnaglyphFreeCamera
  43779. */
  43780. getClassName(): string;
  43781. }
  43782. }
  43783. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  43784. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  43785. import { Scene } from "babylonjs/scene";
  43786. import { Vector3 } from "babylonjs/Maths/math.vector";
  43787. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  43788. /**
  43789. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  43790. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  43791. */
  43792. export class AnaglyphGamepadCamera extends GamepadCamera {
  43793. /**
  43794. * Creates a new AnaglyphGamepadCamera
  43795. * @param name defines camera name
  43796. * @param position defines initial position
  43797. * @param interaxialDistance defines distance between each color axis
  43798. * @param scene defines the hosting scene
  43799. */
  43800. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  43801. /**
  43802. * Gets camera class name
  43803. * @returns AnaglyphGamepadCamera
  43804. */
  43805. getClassName(): string;
  43806. }
  43807. }
  43808. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  43809. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  43810. import { Scene } from "babylonjs/scene";
  43811. import { Vector3 } from "babylonjs/Maths/math.vector";
  43812. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  43813. /**
  43814. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  43815. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  43816. */
  43817. export class AnaglyphUniversalCamera extends UniversalCamera {
  43818. /**
  43819. * Creates a new AnaglyphUniversalCamera
  43820. * @param name defines camera name
  43821. * @param position defines initial position
  43822. * @param interaxialDistance defines distance between each color axis
  43823. * @param scene defines the hosting scene
  43824. */
  43825. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  43826. /**
  43827. * Gets camera class name
  43828. * @returns AnaglyphUniversalCamera
  43829. */
  43830. getClassName(): string;
  43831. }
  43832. }
  43833. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  43834. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  43835. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  43836. import { Scene } from "babylonjs/scene";
  43837. import { Vector3 } from "babylonjs/Maths/math.vector";
  43838. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  43839. /**
  43840. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  43841. * @see http://doc.babylonjs.com/features/cameras
  43842. */
  43843. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  43844. /**
  43845. * Creates a new StereoscopicArcRotateCamera
  43846. * @param name defines camera name
  43847. * @param alpha defines alpha angle (in radians)
  43848. * @param beta defines beta angle (in radians)
  43849. * @param radius defines radius
  43850. * @param target defines camera target
  43851. * @param interaxialDistance defines distance between each color axis
  43852. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  43853. * @param scene defines the hosting scene
  43854. */
  43855. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  43856. /**
  43857. * Gets camera class name
  43858. * @returns StereoscopicArcRotateCamera
  43859. */
  43860. getClassName(): string;
  43861. }
  43862. }
  43863. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  43864. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  43865. import { Scene } from "babylonjs/scene";
  43866. import { Vector3 } from "babylonjs/Maths/math.vector";
  43867. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  43868. /**
  43869. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  43870. * @see http://doc.babylonjs.com/features/cameras
  43871. */
  43872. export class StereoscopicFreeCamera extends FreeCamera {
  43873. /**
  43874. * Creates a new StereoscopicFreeCamera
  43875. * @param name defines camera name
  43876. * @param position defines initial position
  43877. * @param interaxialDistance defines distance between each color axis
  43878. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  43879. * @param scene defines the hosting scene
  43880. */
  43881. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  43882. /**
  43883. * Gets camera class name
  43884. * @returns StereoscopicFreeCamera
  43885. */
  43886. getClassName(): string;
  43887. }
  43888. }
  43889. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  43890. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  43891. import { Scene } from "babylonjs/scene";
  43892. import { Vector3 } from "babylonjs/Maths/math.vector";
  43893. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  43894. /**
  43895. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  43896. * @see http://doc.babylonjs.com/features/cameras
  43897. */
  43898. export class StereoscopicGamepadCamera extends GamepadCamera {
  43899. /**
  43900. * Creates a new StereoscopicGamepadCamera
  43901. * @param name defines camera name
  43902. * @param position defines initial position
  43903. * @param interaxialDistance defines distance between each color axis
  43904. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  43905. * @param scene defines the hosting scene
  43906. */
  43907. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  43908. /**
  43909. * Gets camera class name
  43910. * @returns StereoscopicGamepadCamera
  43911. */
  43912. getClassName(): string;
  43913. }
  43914. }
  43915. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  43916. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  43917. import { Scene } from "babylonjs/scene";
  43918. import { Vector3 } from "babylonjs/Maths/math.vector";
  43919. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  43920. /**
  43921. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  43922. * @see http://doc.babylonjs.com/features/cameras
  43923. */
  43924. export class StereoscopicUniversalCamera extends UniversalCamera {
  43925. /**
  43926. * Creates a new StereoscopicUniversalCamera
  43927. * @param name defines camera name
  43928. * @param position defines initial position
  43929. * @param interaxialDistance defines distance between each color axis
  43930. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  43931. * @param scene defines the hosting scene
  43932. */
  43933. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  43934. /**
  43935. * Gets camera class name
  43936. * @returns StereoscopicUniversalCamera
  43937. */
  43938. getClassName(): string;
  43939. }
  43940. }
  43941. declare module "babylonjs/Cameras/Stereoscopic/index" {
  43942. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  43943. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  43944. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  43945. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  43946. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  43947. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  43948. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  43949. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  43950. }
  43951. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  43952. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  43953. import { Scene } from "babylonjs/scene";
  43954. import { Vector3 } from "babylonjs/Maths/math.vector";
  43955. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  43956. /**
  43957. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  43958. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  43959. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  43960. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  43961. */
  43962. export class VirtualJoysticksCamera extends FreeCamera {
  43963. /**
  43964. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  43965. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  43966. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  43967. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  43968. * @param name Define the name of the camera in the scene
  43969. * @param position Define the start position of the camera in the scene
  43970. * @param scene Define the scene the camera belongs to
  43971. */
  43972. constructor(name: string, position: Vector3, scene: Scene);
  43973. /**
  43974. * Gets the current object class name.
  43975. * @return the class name
  43976. */
  43977. getClassName(): string;
  43978. }
  43979. }
  43980. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  43981. import { Matrix } from "babylonjs/Maths/math.vector";
  43982. /**
  43983. * This represents all the required metrics to create a VR camera.
  43984. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  43985. */
  43986. export class VRCameraMetrics {
  43987. /**
  43988. * Define the horizontal resolution off the screen.
  43989. */
  43990. hResolution: number;
  43991. /**
  43992. * Define the vertical resolution off the screen.
  43993. */
  43994. vResolution: number;
  43995. /**
  43996. * Define the horizontal screen size.
  43997. */
  43998. hScreenSize: number;
  43999. /**
  44000. * Define the vertical screen size.
  44001. */
  44002. vScreenSize: number;
  44003. /**
  44004. * Define the vertical screen center position.
  44005. */
  44006. vScreenCenter: number;
  44007. /**
  44008. * Define the distance of the eyes to the screen.
  44009. */
  44010. eyeToScreenDistance: number;
  44011. /**
  44012. * Define the distance between both lenses
  44013. */
  44014. lensSeparationDistance: number;
  44015. /**
  44016. * Define the distance between both viewer's eyes.
  44017. */
  44018. interpupillaryDistance: number;
  44019. /**
  44020. * Define the distortion factor of the VR postprocess.
  44021. * Please, touch with care.
  44022. */
  44023. distortionK: number[];
  44024. /**
  44025. * Define the chromatic aberration correction factors for the VR post process.
  44026. */
  44027. chromaAbCorrection: number[];
  44028. /**
  44029. * Define the scale factor of the post process.
  44030. * The smaller the better but the slower.
  44031. */
  44032. postProcessScaleFactor: number;
  44033. /**
  44034. * Define an offset for the lens center.
  44035. */
  44036. lensCenterOffset: number;
  44037. /**
  44038. * Define if the current vr camera should compensate the distortion of the lense or not.
  44039. */
  44040. compensateDistortion: boolean;
  44041. /**
  44042. * Defines if multiview should be enabled when rendering (Default: false)
  44043. */
  44044. multiviewEnabled: boolean;
  44045. /**
  44046. * Gets the rendering aspect ratio based on the provided resolutions.
  44047. */
  44048. get aspectRatio(): number;
  44049. /**
  44050. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  44051. */
  44052. get aspectRatioFov(): number;
  44053. /**
  44054. * @hidden
  44055. */
  44056. get leftHMatrix(): Matrix;
  44057. /**
  44058. * @hidden
  44059. */
  44060. get rightHMatrix(): Matrix;
  44061. /**
  44062. * @hidden
  44063. */
  44064. get leftPreViewMatrix(): Matrix;
  44065. /**
  44066. * @hidden
  44067. */
  44068. get rightPreViewMatrix(): Matrix;
  44069. /**
  44070. * Get the default VRMetrics based on the most generic setup.
  44071. * @returns the default vr metrics
  44072. */
  44073. static GetDefault(): VRCameraMetrics;
  44074. }
  44075. }
  44076. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  44077. /** @hidden */
  44078. export var vrDistortionCorrectionPixelShader: {
  44079. name: string;
  44080. shader: string;
  44081. };
  44082. }
  44083. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  44084. import { Camera } from "babylonjs/Cameras/camera";
  44085. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  44086. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  44087. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  44088. /**
  44089. * VRDistortionCorrectionPostProcess used for mobile VR
  44090. */
  44091. export class VRDistortionCorrectionPostProcess extends PostProcess {
  44092. private _isRightEye;
  44093. private _distortionFactors;
  44094. private _postProcessScaleFactor;
  44095. private _lensCenterOffset;
  44096. private _scaleIn;
  44097. private _scaleFactor;
  44098. private _lensCenter;
  44099. /**
  44100. * Initializes the VRDistortionCorrectionPostProcess
  44101. * @param name The name of the effect.
  44102. * @param camera The camera to apply the render pass to.
  44103. * @param isRightEye If this is for the right eye distortion
  44104. * @param vrMetrics All the required metrics for the VR camera
  44105. */
  44106. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  44107. }
  44108. }
  44109. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  44110. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  44111. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  44112. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  44113. import { Scene } from "babylonjs/scene";
  44114. import { Vector3 } from "babylonjs/Maths/math.vector";
  44115. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  44116. import "babylonjs/Cameras/RigModes/vrRigMode";
  44117. /**
  44118. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  44119. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  44120. */
  44121. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  44122. /**
  44123. * Creates a new VRDeviceOrientationArcRotateCamera
  44124. * @param name defines camera name
  44125. * @param alpha defines the camera rotation along the logitudinal axis
  44126. * @param beta defines the camera rotation along the latitudinal axis
  44127. * @param radius defines the camera distance from its target
  44128. * @param target defines the camera target
  44129. * @param scene defines the scene the camera belongs to
  44130. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  44131. * @param vrCameraMetrics defines the vr metrics associated to the camera
  44132. */
  44133. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  44134. /**
  44135. * Gets camera class name
  44136. * @returns VRDeviceOrientationArcRotateCamera
  44137. */
  44138. getClassName(): string;
  44139. }
  44140. }
  44141. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  44142. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  44143. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  44144. import { Scene } from "babylonjs/scene";
  44145. import { Vector3 } from "babylonjs/Maths/math.vector";
  44146. import "babylonjs/Cameras/RigModes/vrRigMode";
  44147. /**
  44148. * Camera used to simulate VR rendering (based on FreeCamera)
  44149. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  44150. */
  44151. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  44152. /**
  44153. * Creates a new VRDeviceOrientationFreeCamera
  44154. * @param name defines camera name
  44155. * @param position defines the start position of the camera
  44156. * @param scene defines the scene the camera belongs to
  44157. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  44158. * @param vrCameraMetrics defines the vr metrics associated to the camera
  44159. */
  44160. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  44161. /**
  44162. * Gets camera class name
  44163. * @returns VRDeviceOrientationFreeCamera
  44164. */
  44165. getClassName(): string;
  44166. }
  44167. }
  44168. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  44169. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  44170. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  44171. import { Scene } from "babylonjs/scene";
  44172. import { Vector3 } from "babylonjs/Maths/math.vector";
  44173. import "babylonjs/Gamepads/gamepadSceneComponent";
  44174. /**
  44175. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  44176. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  44177. */
  44178. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  44179. /**
  44180. * Creates a new VRDeviceOrientationGamepadCamera
  44181. * @param name defines camera name
  44182. * @param position defines the start position of the camera
  44183. * @param scene defines the scene the camera belongs to
  44184. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  44185. * @param vrCameraMetrics defines the vr metrics associated to the camera
  44186. */
  44187. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  44188. /**
  44189. * Gets camera class name
  44190. * @returns VRDeviceOrientationGamepadCamera
  44191. */
  44192. getClassName(): string;
  44193. }
  44194. }
  44195. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  44196. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  44197. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  44198. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  44199. /** @hidden */
  44200. export var imageProcessingPixelShader: {
  44201. name: string;
  44202. shader: string;
  44203. };
  44204. }
  44205. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  44206. import { Nullable } from "babylonjs/types";
  44207. import { Color4 } from "babylonjs/Maths/math.color";
  44208. import { Camera } from "babylonjs/Cameras/camera";
  44209. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  44210. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  44211. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  44212. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  44213. import { Engine } from "babylonjs/Engines/engine";
  44214. import "babylonjs/Shaders/imageProcessing.fragment";
  44215. import "babylonjs/Shaders/postprocess.vertex";
  44216. /**
  44217. * ImageProcessingPostProcess
  44218. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  44219. */
  44220. export class ImageProcessingPostProcess extends PostProcess {
  44221. /**
  44222. * Default configuration related to image processing available in the PBR Material.
  44223. */
  44224. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  44225. /**
  44226. * Gets the image processing configuration used either in this material.
  44227. */
  44228. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  44229. /**
  44230. * Sets the Default image processing configuration used either in the this material.
  44231. *
  44232. * If sets to null, the scene one is in use.
  44233. */
  44234. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  44235. /**
  44236. * Keep track of the image processing observer to allow dispose and replace.
  44237. */
  44238. private _imageProcessingObserver;
  44239. /**
  44240. * Attaches a new image processing configuration to the PBR Material.
  44241. * @param configuration
  44242. */
  44243. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  44244. /**
  44245. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  44246. */
  44247. get colorCurves(): Nullable<ColorCurves>;
  44248. /**
  44249. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  44250. */
  44251. set colorCurves(value: Nullable<ColorCurves>);
  44252. /**
  44253. * Gets wether the color curves effect is enabled.
  44254. */
  44255. get colorCurvesEnabled(): boolean;
  44256. /**
  44257. * Sets wether the color curves effect is enabled.
  44258. */
  44259. set colorCurvesEnabled(value: boolean);
  44260. /**
  44261. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  44262. */
  44263. get colorGradingTexture(): Nullable<BaseTexture>;
  44264. /**
  44265. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  44266. */
  44267. set colorGradingTexture(value: Nullable<BaseTexture>);
  44268. /**
  44269. * Gets wether the color grading effect is enabled.
  44270. */
  44271. get colorGradingEnabled(): boolean;
  44272. /**
  44273. * Gets wether the color grading effect is enabled.
  44274. */
  44275. set colorGradingEnabled(value: boolean);
  44276. /**
  44277. * Gets exposure used in the effect.
  44278. */
  44279. get exposure(): number;
  44280. /**
  44281. * Sets exposure used in the effect.
  44282. */
  44283. set exposure(value: number);
  44284. /**
  44285. * Gets wether tonemapping is enabled or not.
  44286. */
  44287. get toneMappingEnabled(): boolean;
  44288. /**
  44289. * Sets wether tonemapping is enabled or not
  44290. */
  44291. set toneMappingEnabled(value: boolean);
  44292. /**
  44293. * Gets the type of tone mapping effect.
  44294. */
  44295. get toneMappingType(): number;
  44296. /**
  44297. * Sets the type of tone mapping effect.
  44298. */
  44299. set toneMappingType(value: number);
  44300. /**
  44301. * Gets contrast used in the effect.
  44302. */
  44303. get contrast(): number;
  44304. /**
  44305. * Sets contrast used in the effect.
  44306. */
  44307. set contrast(value: number);
  44308. /**
  44309. * Gets Vignette stretch size.
  44310. */
  44311. get vignetteStretch(): number;
  44312. /**
  44313. * Sets Vignette stretch size.
  44314. */
  44315. set vignetteStretch(value: number);
  44316. /**
  44317. * Gets Vignette centre X Offset.
  44318. */
  44319. get vignetteCentreX(): number;
  44320. /**
  44321. * Sets Vignette centre X Offset.
  44322. */
  44323. set vignetteCentreX(value: number);
  44324. /**
  44325. * Gets Vignette centre Y Offset.
  44326. */
  44327. get vignetteCentreY(): number;
  44328. /**
  44329. * Sets Vignette centre Y Offset.
  44330. */
  44331. set vignetteCentreY(value: number);
  44332. /**
  44333. * Gets Vignette weight or intensity of the vignette effect.
  44334. */
  44335. get vignetteWeight(): number;
  44336. /**
  44337. * Sets Vignette weight or intensity of the vignette effect.
  44338. */
  44339. set vignetteWeight(value: number);
  44340. /**
  44341. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  44342. * if vignetteEnabled is set to true.
  44343. */
  44344. get vignetteColor(): Color4;
  44345. /**
  44346. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  44347. * if vignetteEnabled is set to true.
  44348. */
  44349. set vignetteColor(value: Color4);
  44350. /**
  44351. * Gets Camera field of view used by the Vignette effect.
  44352. */
  44353. get vignetteCameraFov(): number;
  44354. /**
  44355. * Sets Camera field of view used by the Vignette effect.
  44356. */
  44357. set vignetteCameraFov(value: number);
  44358. /**
  44359. * Gets the vignette blend mode allowing different kind of effect.
  44360. */
  44361. get vignetteBlendMode(): number;
  44362. /**
  44363. * Sets the vignette blend mode allowing different kind of effect.
  44364. */
  44365. set vignetteBlendMode(value: number);
  44366. /**
  44367. * Gets wether the vignette effect is enabled.
  44368. */
  44369. get vignetteEnabled(): boolean;
  44370. /**
  44371. * Sets wether the vignette effect is enabled.
  44372. */
  44373. set vignetteEnabled(value: boolean);
  44374. private _fromLinearSpace;
  44375. /**
  44376. * Gets wether the input of the processing is in Gamma or Linear Space.
  44377. */
  44378. get fromLinearSpace(): boolean;
  44379. /**
  44380. * Sets wether the input of the processing is in Gamma or Linear Space.
  44381. */
  44382. set fromLinearSpace(value: boolean);
  44383. /**
  44384. * Defines cache preventing GC.
  44385. */
  44386. private _defines;
  44387. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  44388. /**
  44389. * "ImageProcessingPostProcess"
  44390. * @returns "ImageProcessingPostProcess"
  44391. */
  44392. getClassName(): string;
  44393. protected _updateParameters(): void;
  44394. dispose(camera?: Camera): void;
  44395. }
  44396. }
  44397. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  44398. import { Scene } from "babylonjs/scene";
  44399. import { Color3 } from "babylonjs/Maths/math.color";
  44400. import { Mesh } from "babylonjs/Meshes/mesh";
  44401. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  44402. import { Nullable } from "babylonjs/types";
  44403. /**
  44404. * Class containing static functions to help procedurally build meshes
  44405. */
  44406. export class GroundBuilder {
  44407. /**
  44408. * Creates a ground mesh
  44409. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  44410. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  44411. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44412. * @param name defines the name of the mesh
  44413. * @param options defines the options used to create the mesh
  44414. * @param scene defines the hosting scene
  44415. * @returns the ground mesh
  44416. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  44417. */
  44418. static CreateGround(name: string, options: {
  44419. width?: number;
  44420. height?: number;
  44421. subdivisions?: number;
  44422. subdivisionsX?: number;
  44423. subdivisionsY?: number;
  44424. updatable?: boolean;
  44425. }, scene: any): Mesh;
  44426. /**
  44427. * Creates a tiled ground mesh
  44428. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  44429. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  44430. * * 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
  44431. * * 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
  44432. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  44433. * @param name defines the name of the mesh
  44434. * @param options defines the options used to create the mesh
  44435. * @param scene defines the hosting scene
  44436. * @returns the tiled ground mesh
  44437. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  44438. */
  44439. static CreateTiledGround(name: string, options: {
  44440. xmin: number;
  44441. zmin: number;
  44442. xmax: number;
  44443. zmax: number;
  44444. subdivisions?: {
  44445. w: number;
  44446. h: number;
  44447. };
  44448. precision?: {
  44449. w: number;
  44450. h: number;
  44451. };
  44452. updatable?: boolean;
  44453. }, scene?: Nullable<Scene>): Mesh;
  44454. /**
  44455. * Creates a ground mesh from a height map
  44456. * * The parameter `url` sets the URL of the height map image resource.
  44457. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  44458. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  44459. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  44460. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  44461. * * 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.
  44462. * * 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).
  44463. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  44464. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  44465. * @param name defines the name of the mesh
  44466. * @param url defines the url to the height map
  44467. * @param options defines the options used to create the mesh
  44468. * @param scene defines the hosting scene
  44469. * @returns the ground mesh
  44470. * @see https://doc.babylonjs.com/babylon101/height_map
  44471. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  44472. */
  44473. static CreateGroundFromHeightMap(name: string, url: string, options: {
  44474. width?: number;
  44475. height?: number;
  44476. subdivisions?: number;
  44477. minHeight?: number;
  44478. maxHeight?: number;
  44479. colorFilter?: Color3;
  44480. alphaFilter?: number;
  44481. updatable?: boolean;
  44482. onReady?: (mesh: GroundMesh) => void;
  44483. }, scene?: Nullable<Scene>): GroundMesh;
  44484. }
  44485. }
  44486. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  44487. import { Vector4 } from "babylonjs/Maths/math.vector";
  44488. import { Mesh } from "babylonjs/Meshes/mesh";
  44489. /**
  44490. * Class containing static functions to help procedurally build meshes
  44491. */
  44492. export class TorusBuilder {
  44493. /**
  44494. * Creates a torus mesh
  44495. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  44496. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  44497. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  44498. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  44499. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  44500. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  44501. * @param name defines the name of the mesh
  44502. * @param options defines the options used to create the mesh
  44503. * @param scene defines the hosting scene
  44504. * @returns the torus mesh
  44505. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  44506. */
  44507. static CreateTorus(name: string, options: {
  44508. diameter?: number;
  44509. thickness?: number;
  44510. tessellation?: number;
  44511. updatable?: boolean;
  44512. sideOrientation?: number;
  44513. frontUVs?: Vector4;
  44514. backUVs?: Vector4;
  44515. }, scene: any): Mesh;
  44516. }
  44517. }
  44518. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  44519. import { Vector4 } from "babylonjs/Maths/math.vector";
  44520. import { Color4 } from "babylonjs/Maths/math.color";
  44521. import { Mesh } from "babylonjs/Meshes/mesh";
  44522. /**
  44523. * Class containing static functions to help procedurally build meshes
  44524. */
  44525. export class CylinderBuilder {
  44526. /**
  44527. * Creates a cylinder or a cone mesh
  44528. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  44529. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  44530. * * 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.
  44531. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  44532. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  44533. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  44534. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  44535. * * 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).
  44536. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  44537. * * 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).
  44538. * * 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
  44539. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  44540. * * 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
  44541. * * 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.
  44542. * * If `enclose` is false, a ring surface is one element.
  44543. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  44544. * * 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
  44545. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  44546. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  44547. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  44548. * @param name defines the name of the mesh
  44549. * @param options defines the options used to create the mesh
  44550. * @param scene defines the hosting scene
  44551. * @returns the cylinder mesh
  44552. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  44553. */
  44554. static CreateCylinder(name: string, options: {
  44555. height?: number;
  44556. diameterTop?: number;
  44557. diameterBottom?: number;
  44558. diameter?: number;
  44559. tessellation?: number;
  44560. subdivisions?: number;
  44561. arc?: number;
  44562. faceColors?: Color4[];
  44563. faceUV?: Vector4[];
  44564. updatable?: boolean;
  44565. hasRings?: boolean;
  44566. enclose?: boolean;
  44567. cap?: number;
  44568. sideOrientation?: number;
  44569. frontUVs?: Vector4;
  44570. backUVs?: Vector4;
  44571. }, scene: any): Mesh;
  44572. }
  44573. }
  44574. declare module "babylonjs/XR/webXRTypes" {
  44575. import { Nullable } from "babylonjs/types";
  44576. import { IDisposable } from "babylonjs/scene";
  44577. /**
  44578. * States of the webXR experience
  44579. */
  44580. export enum WebXRState {
  44581. /**
  44582. * Transitioning to being in XR mode
  44583. */
  44584. ENTERING_XR = 0,
  44585. /**
  44586. * Transitioning to non XR mode
  44587. */
  44588. EXITING_XR = 1,
  44589. /**
  44590. * In XR mode and presenting
  44591. */
  44592. IN_XR = 2,
  44593. /**
  44594. * Not entered XR mode
  44595. */
  44596. NOT_IN_XR = 3
  44597. }
  44598. /**
  44599. * Abstraction of the XR render target
  44600. */
  44601. export interface WebXRRenderTarget extends IDisposable {
  44602. /**
  44603. * xrpresent context of the canvas which can be used to display/mirror xr content
  44604. */
  44605. canvasContext: WebGLRenderingContext;
  44606. /**
  44607. * xr layer for the canvas
  44608. */
  44609. xrLayer: Nullable<XRWebGLLayer>;
  44610. /**
  44611. * Initializes the xr layer for the session
  44612. * @param xrSession xr session
  44613. * @returns a promise that will resolve once the XR Layer has been created
  44614. */
  44615. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  44616. }
  44617. }
  44618. declare module "babylonjs/XR/webXRManagedOutputCanvas" {
  44619. import { Nullable } from "babylonjs/types";
  44620. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  44621. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  44622. /**
  44623. * COnfiguration object for WebXR output canvas
  44624. */
  44625. export class WebXRManagedOutputCanvasOptions {
  44626. /**
  44627. * An optional canvas in case you wish to create it yourself and provide it here.
  44628. * If not provided, a new canvas will be created
  44629. */
  44630. canvasElement?: HTMLCanvasElement;
  44631. /**
  44632. * Options for this XR Layer output
  44633. */
  44634. canvasOptions?: XRWebGLLayerOptions;
  44635. /**
  44636. * CSS styling for a newly created canvas (if not provided)
  44637. */
  44638. newCanvasCssStyle?: string;
  44639. /**
  44640. * Get the default values of the configuration object
  44641. * @returns default values of this configuration object
  44642. */
  44643. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  44644. }
  44645. /**
  44646. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  44647. */
  44648. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  44649. private _options;
  44650. private _canvas;
  44651. private _engine;
  44652. /**
  44653. * Rendering context of the canvas which can be used to display/mirror xr content
  44654. */
  44655. canvasContext: WebGLRenderingContext;
  44656. /**
  44657. * xr layer for the canvas
  44658. */
  44659. xrLayer: Nullable<XRWebGLLayer>;
  44660. /**
  44661. * Initializes the canvas to be added/removed upon entering/exiting xr
  44662. * @param _xrSessionManager The XR Session manager
  44663. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  44664. */
  44665. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  44666. /**
  44667. * Disposes of the object
  44668. */
  44669. dispose(): void;
  44670. /**
  44671. * Initializes the xr layer for the session
  44672. * @param xrSession xr session
  44673. * @returns a promise that will resolve once the XR Layer has been created
  44674. */
  44675. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  44676. private _addCanvas;
  44677. private _removeCanvas;
  44678. private _setManagedOutputCanvas;
  44679. }
  44680. }
  44681. declare module "babylonjs/XR/webXRSessionManager" {
  44682. import { Observable } from "babylonjs/Misc/observable";
  44683. import { Nullable } from "babylonjs/types";
  44684. import { IDisposable, Scene } from "babylonjs/scene";
  44685. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  44686. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  44687. import { WebXRManagedOutputCanvasOptions } from "babylonjs/XR/webXRManagedOutputCanvas";
  44688. /**
  44689. * Manages an XRSession to work with Babylon's engine
  44690. * @see https://doc.babylonjs.com/how_to/webxr
  44691. */
  44692. export class WebXRSessionManager implements IDisposable {
  44693. /** The scene which the session should be created for */
  44694. scene: Scene;
  44695. private _referenceSpace;
  44696. private _rttProvider;
  44697. private _sessionEnded;
  44698. private _xrNavigator;
  44699. private baseLayer;
  44700. /**
  44701. * The base reference space from which the session started. good if you want to reset your
  44702. * reference space
  44703. */
  44704. baseReferenceSpace: XRReferenceSpace;
  44705. /**
  44706. * Current XR frame
  44707. */
  44708. currentFrame: Nullable<XRFrame>;
  44709. /** WebXR timestamp updated every frame */
  44710. currentTimestamp: number;
  44711. /**
  44712. * Used just in case of a failure to initialize an immersive session.
  44713. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  44714. */
  44715. defaultHeightCompensation: number;
  44716. /**
  44717. * Fires every time a new xrFrame arrives which can be used to update the camera
  44718. */
  44719. onXRFrameObservable: Observable<XRFrame>;
  44720. /**
  44721. * Fires when the reference space changed
  44722. */
  44723. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  44724. /**
  44725. * Fires when the xr session is ended either by the device or manually done
  44726. */
  44727. onXRSessionEnded: Observable<any>;
  44728. /**
  44729. * Fires when the xr session is ended either by the device or manually done
  44730. */
  44731. onXRSessionInit: Observable<XRSession>;
  44732. /**
  44733. * Underlying xr session
  44734. */
  44735. session: XRSession;
  44736. /**
  44737. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  44738. * or get the offset the player is currently at.
  44739. */
  44740. viewerReferenceSpace: XRReferenceSpace;
  44741. /**
  44742. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  44743. * @param scene The scene which the session should be created for
  44744. */
  44745. constructor(
  44746. /** The scene which the session should be created for */
  44747. scene: Scene);
  44748. /**
  44749. * The current reference space used in this session. This reference space can constantly change!
  44750. * It is mainly used to offset the camera's position.
  44751. */
  44752. get referenceSpace(): XRReferenceSpace;
  44753. /**
  44754. * Set a new reference space and triggers the observable
  44755. */
  44756. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  44757. /**
  44758. * Disposes of the session manager
  44759. */
  44760. dispose(): void;
  44761. /**
  44762. * Stops the xrSession and restores the render loop
  44763. * @returns Promise which resolves after it exits XR
  44764. */
  44765. exitXRAsync(): Promise<void>;
  44766. /**
  44767. * Gets the correct render target texture to be rendered this frame for this eye
  44768. * @param eye the eye for which to get the render target
  44769. * @returns the render target for the specified eye
  44770. */
  44771. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  44772. /**
  44773. * Creates a WebXRRenderTarget object for the XR session
  44774. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  44775. * @param options optional options to provide when creating a new render target
  44776. * @returns a WebXR render target to which the session can render
  44777. */
  44778. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  44779. /**
  44780. * Initializes the manager
  44781. * After initialization enterXR can be called to start an XR session
  44782. * @returns Promise which resolves after it is initialized
  44783. */
  44784. initializeAsync(): Promise<void>;
  44785. /**
  44786. * Initializes an xr session
  44787. * @param xrSessionMode mode to initialize
  44788. * @param xrSessionInit defines optional and required values to pass to the session builder
  44789. * @returns a promise which will resolve once the session has been initialized
  44790. */
  44791. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  44792. /**
  44793. * Checks if a session would be supported for the creation options specified
  44794. * @param sessionMode session mode to check if supported eg. immersive-vr
  44795. * @returns A Promise that resolves to true if supported and false if not
  44796. */
  44797. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  44798. /**
  44799. * Resets the reference space to the one started the session
  44800. */
  44801. resetReferenceSpace(): void;
  44802. /**
  44803. * Starts rendering to the xr layer
  44804. */
  44805. runXRRenderLoop(): void;
  44806. /**
  44807. * Sets the reference space on the xr session
  44808. * @param referenceSpaceType space to set
  44809. * @returns a promise that will resolve once the reference space has been set
  44810. */
  44811. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  44812. /**
  44813. * Updates the render state of the session
  44814. * @param state state to set
  44815. * @returns a promise that resolves once the render state has been updated
  44816. */
  44817. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  44818. /**
  44819. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  44820. * @param sessionMode defines the session to test
  44821. * @returns a promise with boolean as final value
  44822. */
  44823. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  44824. private _createRenderTargetTexture;
  44825. }
  44826. }
  44827. declare module "babylonjs/XR/webXRCamera" {
  44828. import { Scene } from "babylonjs/scene";
  44829. import { Camera } from "babylonjs/Cameras/camera";
  44830. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  44831. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  44832. /**
  44833. * WebXR Camera which holds the views for the xrSession
  44834. * @see https://doc.babylonjs.com/how_to/webxr_camera
  44835. */
  44836. export class WebXRCamera extends FreeCamera {
  44837. private _xrSessionManager;
  44838. private _firstFrame;
  44839. private _referenceQuaternion;
  44840. private _referencedPosition;
  44841. private _xrInvPositionCache;
  44842. private _xrInvQuaternionCache;
  44843. /**
  44844. * Should position compensation execute on first frame.
  44845. * This is used when copying the position from a native (non XR) camera
  44846. */
  44847. compensateOnFirstFrame: boolean;
  44848. /**
  44849. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  44850. * @param name the name of the camera
  44851. * @param scene the scene to add the camera to
  44852. * @param _xrSessionManager a constructed xr session manager
  44853. */
  44854. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  44855. /**
  44856. * Return the user's height, unrelated to the current ground.
  44857. * This will be the y position of this camera, when ground level is 0.
  44858. */
  44859. get realWorldHeight(): number;
  44860. /** @hidden */
  44861. _updateForDualEyeDebugging(): void;
  44862. /**
  44863. * Sets this camera's transformation based on a non-vr camera
  44864. * @param otherCamera the non-vr camera to copy the transformation from
  44865. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  44866. */
  44867. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  44868. /**
  44869. * Gets the current instance class name ("WebXRCamera").
  44870. * @returns the class name
  44871. */
  44872. getClassName(): string;
  44873. private _updateFromXRSession;
  44874. private _updateNumberOfRigCameras;
  44875. private _updateReferenceSpace;
  44876. private _updateReferenceSpaceOffset;
  44877. }
  44878. }
  44879. declare module "babylonjs/XR/webXRFeaturesManager" {
  44880. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  44881. import { IDisposable } from "babylonjs/scene";
  44882. /**
  44883. * Defining the interface required for a (webxr) feature
  44884. */
  44885. export interface IWebXRFeature extends IDisposable {
  44886. /**
  44887. * Is this feature attached
  44888. */
  44889. attached: boolean;
  44890. /**
  44891. * Should auto-attach be disabled?
  44892. */
  44893. disableAutoAttach: boolean;
  44894. /**
  44895. * Attach the feature to the session
  44896. * Will usually be called by the features manager
  44897. *
  44898. * @param force should attachment be forced (even when already attached)
  44899. * @returns true if successful.
  44900. */
  44901. attach(force?: boolean): boolean;
  44902. /**
  44903. * Detach the feature from the session
  44904. * Will usually be called by the features manager
  44905. *
  44906. * @returns true if successful.
  44907. */
  44908. detach(): boolean;
  44909. }
  44910. /**
  44911. * A list of the currently available features without referencing them
  44912. */
  44913. export class WebXRFeatureName {
  44914. /**
  44915. * The name of the anchor system feature
  44916. */
  44917. static ANCHOR_SYSTEM: string;
  44918. /**
  44919. * The name of the background remover feature
  44920. */
  44921. static BACKGROUND_REMOVER: string;
  44922. /**
  44923. * The name of the hit test feature
  44924. */
  44925. static HIT_TEST: string;
  44926. /**
  44927. * physics impostors for xr controllers feature
  44928. */
  44929. static PHYSICS_CONTROLLERS: string;
  44930. /**
  44931. * The name of the plane detection feature
  44932. */
  44933. static PLANE_DETECTION: string;
  44934. /**
  44935. * The name of the pointer selection feature
  44936. */
  44937. static POINTER_SELECTION: string;
  44938. /**
  44939. * The name of the teleportation feature
  44940. */
  44941. static TELEPORTATION: string;
  44942. }
  44943. /**
  44944. * Defining the constructor of a feature. Used to register the modules.
  44945. */
  44946. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => (() => IWebXRFeature);
  44947. /**
  44948. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  44949. * It is mainly used in AR sessions.
  44950. *
  44951. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  44952. */
  44953. export class WebXRFeaturesManager implements IDisposable {
  44954. private _xrSessionManager;
  44955. private static readonly _AvailableFeatures;
  44956. private _features;
  44957. /**
  44958. * constructs a new features manages.
  44959. *
  44960. * @param _xrSessionManager an instance of WebXRSessionManager
  44961. */
  44962. constructor(_xrSessionManager: WebXRSessionManager);
  44963. /**
  44964. * Used to register a module. After calling this function a developer can use this feature in the scene.
  44965. * Mainly used internally.
  44966. *
  44967. * @param featureName the name of the feature to register
  44968. * @param constructorFunction the function used to construct the module
  44969. * @param version the (babylon) version of the module
  44970. * @param stable is that a stable version of this module
  44971. */
  44972. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  44973. /**
  44974. * Returns a constructor of a specific feature.
  44975. *
  44976. * @param featureName the name of the feature to construct
  44977. * @param version the version of the feature to load
  44978. * @param xrSessionManager the xrSessionManager. Used to construct the module
  44979. * @param options optional options provided to the module.
  44980. * @returns a function that, when called, will return a new instance of this feature
  44981. */
  44982. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): (() => IWebXRFeature);
  44983. /**
  44984. * Can be used to return the list of features currently registered
  44985. *
  44986. * @returns an Array of available features
  44987. */
  44988. static GetAvailableFeatures(): string[];
  44989. /**
  44990. * Gets the versions available for a specific feature
  44991. * @param featureName the name of the feature
  44992. * @returns an array with the available versions
  44993. */
  44994. static GetAvailableVersions(featureName: string): string[];
  44995. /**
  44996. * Return the latest unstable version of this feature
  44997. * @param featureName the name of the feature to search
  44998. * @returns the version number. if not found will return -1
  44999. */
  45000. static GetLatestVersionOfFeature(featureName: string): number;
  45001. /**
  45002. * Return the latest stable version of this feature
  45003. * @param featureName the name of the feature to search
  45004. * @returns the version number. if not found will return -1
  45005. */
  45006. static GetStableVersionOfFeature(featureName: string): number;
  45007. /**
  45008. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  45009. * Can be used during a session to start a feature
  45010. * @param featureName the name of feature to attach
  45011. */
  45012. attachFeature(featureName: string): void;
  45013. /**
  45014. * Can be used inside a session or when the session ends to detach a specific feature
  45015. * @param featureName the name of the feature to detach
  45016. */
  45017. detachFeature(featureName: string): void;
  45018. /**
  45019. * Used to disable an already-enabled feature
  45020. * The feature will be disposed and will be recreated once enabled.
  45021. * @param featureName the feature to disable
  45022. * @returns true if disable was successful
  45023. */
  45024. disableFeature(featureName: string | {
  45025. Name: string;
  45026. }): boolean;
  45027. /**
  45028. * dispose this features manager
  45029. */
  45030. dispose(): void;
  45031. /**
  45032. * 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.
  45033. * 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.
  45034. *
  45035. * @param featureName the name of the feature to load or the class of the feature
  45036. * @param version optional version to load. if not provided the latest version will be enabled
  45037. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  45038. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  45039. * @returns a new constructed feature or throws an error if feature not found.
  45040. */
  45041. enableFeature(featureName: string | {
  45042. Name: string;
  45043. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean): IWebXRFeature;
  45044. /**
  45045. * get the implementation of an enabled feature.
  45046. * @param featureName the name of the feature to load
  45047. * @returns the feature class, if found
  45048. */
  45049. getEnabledFeature(featureName: string): IWebXRFeature;
  45050. /**
  45051. * Get the list of enabled features
  45052. * @returns an array of enabled features
  45053. */
  45054. getEnabledFeatures(): string[];
  45055. }
  45056. }
  45057. declare module "babylonjs/XR/webXRExperienceHelper" {
  45058. import { Observable } from "babylonjs/Misc/observable";
  45059. import { IDisposable, Scene } from "babylonjs/scene";
  45060. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  45061. import { WebXRCamera } from "babylonjs/XR/webXRCamera";
  45062. import { WebXRState, WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  45063. import { WebXRFeaturesManager } from "babylonjs/XR/webXRFeaturesManager";
  45064. /**
  45065. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  45066. * @see https://doc.babylonjs.com/how_to/webxr
  45067. */
  45068. export class WebXRExperienceHelper implements IDisposable {
  45069. private scene;
  45070. private _nonVRCamera;
  45071. private _originalSceneAutoClear;
  45072. private _supported;
  45073. /**
  45074. * Camera used to render xr content
  45075. */
  45076. camera: WebXRCamera;
  45077. /** A features manager for this xr session */
  45078. featuresManager: WebXRFeaturesManager;
  45079. /**
  45080. * Observers registered here will be triggered after the camera's initial transformation is set
  45081. * This can be used to set a different ground level or an extra rotation.
  45082. *
  45083. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  45084. * to the position set after this observable is done executing.
  45085. */
  45086. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  45087. /**
  45088. * Fires when the state of the experience helper has changed
  45089. */
  45090. onStateChangedObservable: Observable<WebXRState>;
  45091. /** Session manager used to keep track of xr session */
  45092. sessionManager: WebXRSessionManager;
  45093. /**
  45094. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  45095. */
  45096. state: WebXRState;
  45097. /**
  45098. * Creates a WebXRExperienceHelper
  45099. * @param scene The scene the helper should be created in
  45100. */
  45101. private constructor();
  45102. /**
  45103. * Creates the experience helper
  45104. * @param scene the scene to attach the experience helper to
  45105. * @returns a promise for the experience helper
  45106. */
  45107. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  45108. /**
  45109. * Disposes of the experience helper
  45110. */
  45111. dispose(): void;
  45112. /**
  45113. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  45114. * @param sessionMode options for the XR session
  45115. * @param referenceSpaceType frame of reference of the XR session
  45116. * @param renderTarget the output canvas that will be used to enter XR mode
  45117. * @param sessionCreationOptions optional XRSessionInit object to init the session with
  45118. * @returns promise that resolves after xr mode has entered
  45119. */
  45120. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget, sessionCreationOptions?: XRSessionInit): Promise<WebXRSessionManager>;
  45121. /**
  45122. * Exits XR mode and returns the scene to its original state
  45123. * @returns promise that resolves after xr mode has exited
  45124. */
  45125. exitXRAsync(): Promise<void>;
  45126. private _nonXRToXRCamera;
  45127. private _setState;
  45128. }
  45129. }
  45130. declare module "babylonjs/XR/motionController/webXRControllerComponent" {
  45131. import { IMinimalMotionControllerObject, MotionControllerComponentType } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  45132. import { Observable } from "babylonjs/Misc/observable";
  45133. import { IDisposable } from "babylonjs/scene";
  45134. /**
  45135. * X-Y values for axes in WebXR
  45136. */
  45137. export interface IWebXRMotionControllerAxesValue {
  45138. /**
  45139. * The value of the x axis
  45140. */
  45141. x: number;
  45142. /**
  45143. * The value of the y-axis
  45144. */
  45145. y: number;
  45146. }
  45147. /**
  45148. * changed / previous values for the values of this component
  45149. */
  45150. export interface IWebXRMotionControllerComponentChangesValues<T> {
  45151. /**
  45152. * current (this frame) value
  45153. */
  45154. current: T;
  45155. /**
  45156. * previous (last change) value
  45157. */
  45158. previous: T;
  45159. }
  45160. /**
  45161. * Represents changes in the component between current frame and last values recorded
  45162. */
  45163. export interface IWebXRMotionControllerComponentChanges {
  45164. /**
  45165. * will be populated with previous and current values if axes changed
  45166. */
  45167. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  45168. /**
  45169. * will be populated with previous and current values if pressed changed
  45170. */
  45171. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  45172. /**
  45173. * will be populated with previous and current values if touched changed
  45174. */
  45175. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  45176. /**
  45177. * will be populated with previous and current values if value changed
  45178. */
  45179. value?: IWebXRMotionControllerComponentChangesValues<number>;
  45180. }
  45181. /**
  45182. * This class represents a single component (for example button or thumbstick) of a motion controller
  45183. */
  45184. export class WebXRControllerComponent implements IDisposable {
  45185. /**
  45186. * the id of this component
  45187. */
  45188. id: string;
  45189. /**
  45190. * the type of the component
  45191. */
  45192. type: MotionControllerComponentType;
  45193. private _buttonIndex;
  45194. private _axesIndices;
  45195. private _axes;
  45196. private _changes;
  45197. private _currentValue;
  45198. private _hasChanges;
  45199. private _pressed;
  45200. private _touched;
  45201. /**
  45202. * button component type
  45203. */
  45204. static BUTTON_TYPE: MotionControllerComponentType;
  45205. /**
  45206. * squeeze component type
  45207. */
  45208. static SQUEEZE_TYPE: MotionControllerComponentType;
  45209. /**
  45210. * Thumbstick component type
  45211. */
  45212. static THUMBSTICK_TYPE: MotionControllerComponentType;
  45213. /**
  45214. * Touchpad component type
  45215. */
  45216. static TOUCHPAD_TYPE: MotionControllerComponentType;
  45217. /**
  45218. * trigger component type
  45219. */
  45220. static TRIGGER_TYPE: MotionControllerComponentType;
  45221. /**
  45222. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  45223. * the axes data changes
  45224. */
  45225. onAxisValueChangedObservable: Observable<{
  45226. x: number;
  45227. y: number;
  45228. }>;
  45229. /**
  45230. * Observers registered here will be triggered when the state of a button changes
  45231. * State change is either pressed / touched / value
  45232. */
  45233. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  45234. /**
  45235. * Creates a new component for a motion controller.
  45236. * It is created by the motion controller itself
  45237. *
  45238. * @param id the id of this component
  45239. * @param type the type of the component
  45240. * @param _buttonIndex index in the buttons array of the gamepad
  45241. * @param _axesIndices indices of the values in the axes array of the gamepad
  45242. */
  45243. constructor(
  45244. /**
  45245. * the id of this component
  45246. */
  45247. id: string,
  45248. /**
  45249. * the type of the component
  45250. */
  45251. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  45252. /**
  45253. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  45254. */
  45255. get axes(): IWebXRMotionControllerAxesValue;
  45256. /**
  45257. * Get the changes. Elements will be populated only if they changed with their previous and current value
  45258. */
  45259. get changes(): IWebXRMotionControllerComponentChanges;
  45260. /**
  45261. * Return whether or not the component changed the last frame
  45262. */
  45263. get hasChanges(): boolean;
  45264. /**
  45265. * is the button currently pressed
  45266. */
  45267. get pressed(): boolean;
  45268. /**
  45269. * is the button currently touched
  45270. */
  45271. get touched(): boolean;
  45272. /**
  45273. * Get the current value of this component
  45274. */
  45275. get value(): number;
  45276. /**
  45277. * Dispose this component
  45278. */
  45279. dispose(): void;
  45280. /**
  45281. * Are there axes correlating to this component
  45282. * @return true is axes data is available
  45283. */
  45284. isAxes(): boolean;
  45285. /**
  45286. * Is this component a button (hence - pressable)
  45287. * @returns true if can be pressed
  45288. */
  45289. isButton(): boolean;
  45290. /**
  45291. * update this component using the gamepad object it is in. Called on every frame
  45292. * @param nativeController the native gamepad controller object
  45293. */
  45294. update(nativeController: IMinimalMotionControllerObject): void;
  45295. }
  45296. }
  45297. declare module "babylonjs/Loading/sceneLoader" {
  45298. import { Observable } from "babylonjs/Misc/observable";
  45299. import { Nullable } from "babylonjs/types";
  45300. import { Scene } from "babylonjs/scene";
  45301. import { Engine } from "babylonjs/Engines/engine";
  45302. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45303. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  45304. import { AssetContainer } from "babylonjs/assetContainer";
  45305. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  45306. import { Skeleton } from "babylonjs/Bones/skeleton";
  45307. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  45308. import { WebRequest } from "babylonjs/Misc/webRequest";
  45309. /**
  45310. * Class used to represent data loading progression
  45311. */
  45312. export class SceneLoaderProgressEvent {
  45313. /** defines if data length to load can be evaluated */
  45314. readonly lengthComputable: boolean;
  45315. /** defines the loaded data length */
  45316. readonly loaded: number;
  45317. /** defines the data length to load */
  45318. readonly total: number;
  45319. /**
  45320. * Create a new progress event
  45321. * @param lengthComputable defines if data length to load can be evaluated
  45322. * @param loaded defines the loaded data length
  45323. * @param total defines the data length to load
  45324. */
  45325. constructor(
  45326. /** defines if data length to load can be evaluated */
  45327. lengthComputable: boolean,
  45328. /** defines the loaded data length */
  45329. loaded: number,
  45330. /** defines the data length to load */
  45331. total: number);
  45332. /**
  45333. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  45334. * @param event defines the source event
  45335. * @returns a new SceneLoaderProgressEvent
  45336. */
  45337. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  45338. }
  45339. /**
  45340. * Interface used by SceneLoader plugins to define supported file extensions
  45341. */
  45342. export interface ISceneLoaderPluginExtensions {
  45343. /**
  45344. * Defines the list of supported extensions
  45345. */
  45346. [extension: string]: {
  45347. isBinary: boolean;
  45348. };
  45349. }
  45350. /**
  45351. * Interface used by SceneLoader plugin factory
  45352. */
  45353. export interface ISceneLoaderPluginFactory {
  45354. /**
  45355. * Defines the name of the factory
  45356. */
  45357. name: string;
  45358. /**
  45359. * Function called to create a new plugin
  45360. * @return the new plugin
  45361. */
  45362. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  45363. /**
  45364. * The callback that returns true if the data can be directly loaded.
  45365. * @param data string containing the file data
  45366. * @returns if the data can be loaded directly
  45367. */
  45368. canDirectLoad?(data: string): boolean;
  45369. }
  45370. /**
  45371. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  45372. */
  45373. export interface ISceneLoaderPluginBase {
  45374. /**
  45375. * The friendly name of this plugin.
  45376. */
  45377. name: string;
  45378. /**
  45379. * The file extensions supported by this plugin.
  45380. */
  45381. extensions: string | ISceneLoaderPluginExtensions;
  45382. /**
  45383. * The callback called when loading from a url.
  45384. * @param scene scene loading this url
  45385. * @param url url to load
  45386. * @param onSuccess callback called when the file successfully loads
  45387. * @param onProgress callback called while file is loading (if the server supports this mode)
  45388. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  45389. * @param onError callback called when the file fails to load
  45390. * @returns a file request object
  45391. */
  45392. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  45393. /**
  45394. * The callback called when loading from a file object.
  45395. * @param scene scene loading this file
  45396. * @param file defines the file to load
  45397. * @param onSuccess defines the callback to call when data is loaded
  45398. * @param onProgress defines the callback to call during loading process
  45399. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  45400. * @param onError defines the callback to call when an error occurs
  45401. * @returns a file request object
  45402. */
  45403. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  45404. /**
  45405. * The callback that returns true if the data can be directly loaded.
  45406. * @param data string containing the file data
  45407. * @returns if the data can be loaded directly
  45408. */
  45409. canDirectLoad?(data: string): boolean;
  45410. /**
  45411. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  45412. * @param scene scene loading this data
  45413. * @param data string containing the data
  45414. * @returns data to pass to the plugin
  45415. */
  45416. directLoad?(scene: Scene, data: string): any;
  45417. /**
  45418. * The callback that allows custom handling of the root url based on the response url.
  45419. * @param rootUrl the original root url
  45420. * @param responseURL the response url if available
  45421. * @returns the new root url
  45422. */
  45423. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  45424. }
  45425. /**
  45426. * Interface used to define a SceneLoader plugin
  45427. */
  45428. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  45429. /**
  45430. * Import meshes into a scene.
  45431. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  45432. * @param scene The scene to import into
  45433. * @param data The data to import
  45434. * @param rootUrl The root url for scene and resources
  45435. * @param meshes The meshes array to import into
  45436. * @param particleSystems The particle systems array to import into
  45437. * @param skeletons The skeletons array to import into
  45438. * @param onError The callback when import fails
  45439. * @returns True if successful or false otherwise
  45440. */
  45441. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  45442. /**
  45443. * Load into a scene.
  45444. * @param scene The scene to load into
  45445. * @param data The data to import
  45446. * @param rootUrl The root url for scene and resources
  45447. * @param onError The callback when import fails
  45448. * @returns True if successful or false otherwise
  45449. */
  45450. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  45451. /**
  45452. * Load into an asset container.
  45453. * @param scene The scene to load into
  45454. * @param data The data to import
  45455. * @param rootUrl The root url for scene and resources
  45456. * @param onError The callback when import fails
  45457. * @returns The loaded asset container
  45458. */
  45459. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  45460. }
  45461. /**
  45462. * Interface used to define an async SceneLoader plugin
  45463. */
  45464. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  45465. /**
  45466. * Import meshes into a scene.
  45467. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  45468. * @param scene The scene to import into
  45469. * @param data The data to import
  45470. * @param rootUrl The root url for scene and resources
  45471. * @param onProgress The callback when the load progresses
  45472. * @param fileName Defines the name of the file to load
  45473. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  45474. */
  45475. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  45476. meshes: AbstractMesh[];
  45477. particleSystems: IParticleSystem[];
  45478. skeletons: Skeleton[];
  45479. animationGroups: AnimationGroup[];
  45480. }>;
  45481. /**
  45482. * Load into a scene.
  45483. * @param scene The scene to load into
  45484. * @param data The data to import
  45485. * @param rootUrl The root url for scene and resources
  45486. * @param onProgress The callback when the load progresses
  45487. * @param fileName Defines the name of the file to load
  45488. * @returns Nothing
  45489. */
  45490. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  45491. /**
  45492. * Load into an asset container.
  45493. * @param scene The scene to load into
  45494. * @param data The data to import
  45495. * @param rootUrl The root url for scene and resources
  45496. * @param onProgress The callback when the load progresses
  45497. * @param fileName Defines the name of the file to load
  45498. * @returns The loaded asset container
  45499. */
  45500. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  45501. }
  45502. /**
  45503. * Mode that determines how to handle old animation groups before loading new ones.
  45504. */
  45505. export enum SceneLoaderAnimationGroupLoadingMode {
  45506. /**
  45507. * Reset all old animations to initial state then dispose them.
  45508. */
  45509. Clean = 0,
  45510. /**
  45511. * Stop all old animations.
  45512. */
  45513. Stop = 1,
  45514. /**
  45515. * Restart old animations from first frame.
  45516. */
  45517. Sync = 2,
  45518. /**
  45519. * Old animations remains untouched.
  45520. */
  45521. NoSync = 3
  45522. }
  45523. /**
  45524. * Class used to load scene from various file formats using registered plugins
  45525. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  45526. */
  45527. export class SceneLoader {
  45528. /**
  45529. * No logging while loading
  45530. */
  45531. static readonly NO_LOGGING: number;
  45532. /**
  45533. * Minimal logging while loading
  45534. */
  45535. static readonly MINIMAL_LOGGING: number;
  45536. /**
  45537. * Summary logging while loading
  45538. */
  45539. static readonly SUMMARY_LOGGING: number;
  45540. /**
  45541. * Detailled logging while loading
  45542. */
  45543. static readonly DETAILED_LOGGING: number;
  45544. /**
  45545. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  45546. */
  45547. static get ForceFullSceneLoadingForIncremental(): boolean;
  45548. static set ForceFullSceneLoadingForIncremental(value: boolean);
  45549. /**
  45550. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  45551. */
  45552. static get ShowLoadingScreen(): boolean;
  45553. static set ShowLoadingScreen(value: boolean);
  45554. /**
  45555. * Defines the current logging level (while loading the scene)
  45556. * @ignorenaming
  45557. */
  45558. static get loggingLevel(): number;
  45559. static set loggingLevel(value: number);
  45560. /**
  45561. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  45562. */
  45563. static get CleanBoneMatrixWeights(): boolean;
  45564. static set CleanBoneMatrixWeights(value: boolean);
  45565. /**
  45566. * Event raised when a plugin is used to load a scene
  45567. */
  45568. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  45569. private static _registeredPlugins;
  45570. private static _getDefaultPlugin;
  45571. private static _getPluginForExtension;
  45572. private static _getPluginForDirectLoad;
  45573. private static _getPluginForFilename;
  45574. private static _getDirectLoad;
  45575. private static _loadData;
  45576. private static _getFileInfo;
  45577. /**
  45578. * Gets a plugin that can load the given extension
  45579. * @param extension defines the extension to load
  45580. * @returns a plugin or null if none works
  45581. */
  45582. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  45583. /**
  45584. * Gets a boolean indicating that the given extension can be loaded
  45585. * @param extension defines the extension to load
  45586. * @returns true if the extension is supported
  45587. */
  45588. static IsPluginForExtensionAvailable(extension: string): boolean;
  45589. /**
  45590. * Adds a new plugin to the list of registered plugins
  45591. * @param plugin defines the plugin to add
  45592. */
  45593. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  45594. /**
  45595. * Import meshes into a scene
  45596. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  45597. * @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)
  45598. * @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)
  45599. * @param scene the instance of BABYLON.Scene to append to
  45600. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  45601. * @param onProgress a callback with a progress event for each file being loaded
  45602. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  45603. * @param pluginExtension the extension used to determine the plugin
  45604. * @returns The loaded plugin
  45605. */
  45606. 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>;
  45607. /**
  45608. * Import meshes into a scene
  45609. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  45610. * @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)
  45611. * @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)
  45612. * @param scene the instance of BABYLON.Scene to append to
  45613. * @param onProgress a callback with a progress event for each file being loaded
  45614. * @param pluginExtension the extension used to determine the plugin
  45615. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  45616. */
  45617. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  45618. meshes: AbstractMesh[];
  45619. particleSystems: IParticleSystem[];
  45620. skeletons: Skeleton[];
  45621. animationGroups: AnimationGroup[];
  45622. }>;
  45623. /**
  45624. * Load a scene
  45625. * @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)
  45626. * @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)
  45627. * @param engine is the instance of BABYLON.Engine to use to create the scene
  45628. * @param onSuccess a callback with the scene when import succeeds
  45629. * @param onProgress a callback with a progress event for each file being loaded
  45630. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  45631. * @param pluginExtension the extension used to determine the plugin
  45632. * @returns The loaded plugin
  45633. */
  45634. 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>;
  45635. /**
  45636. * Load a scene
  45637. * @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)
  45638. * @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)
  45639. * @param engine is the instance of BABYLON.Engine to use to create the scene
  45640. * @param onProgress a callback with a progress event for each file being loaded
  45641. * @param pluginExtension the extension used to determine the plugin
  45642. * @returns The loaded scene
  45643. */
  45644. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  45645. /**
  45646. * Append a scene
  45647. * @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)
  45648. * @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)
  45649. * @param scene is the instance of BABYLON.Scene to append to
  45650. * @param onSuccess a callback with the scene when import succeeds
  45651. * @param onProgress a callback with a progress event for each file being loaded
  45652. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  45653. * @param pluginExtension the extension used to determine the plugin
  45654. * @returns The loaded plugin
  45655. */
  45656. 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>;
  45657. /**
  45658. * Append a scene
  45659. * @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)
  45660. * @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)
  45661. * @param scene is the instance of BABYLON.Scene to append to
  45662. * @param onProgress a callback with a progress event for each file being loaded
  45663. * @param pluginExtension the extension used to determine the plugin
  45664. * @returns The given scene
  45665. */
  45666. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  45667. /**
  45668. * Load a scene into an asset container
  45669. * @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)
  45670. * @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)
  45671. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  45672. * @param onSuccess a callback with the scene when import succeeds
  45673. * @param onProgress a callback with a progress event for each file being loaded
  45674. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  45675. * @param pluginExtension the extension used to determine the plugin
  45676. * @returns The loaded plugin
  45677. */
  45678. 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>;
  45679. /**
  45680. * Load a scene into an asset container
  45681. * @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)
  45682. * @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)
  45683. * @param scene is the instance of Scene to append to
  45684. * @param onProgress a callback with a progress event for each file being loaded
  45685. * @param pluginExtension the extension used to determine the plugin
  45686. * @returns The loaded asset container
  45687. */
  45688. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  45689. /**
  45690. * Import animations from a file into a scene
  45691. * @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)
  45692. * @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)
  45693. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  45694. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  45695. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  45696. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  45697. * @param onSuccess a callback with the scene when import succeeds
  45698. * @param onProgress a callback with a progress event for each file being loaded
  45699. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  45700. */
  45701. 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;
  45702. /**
  45703. * Import animations from a file into a scene
  45704. * @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)
  45705. * @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)
  45706. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  45707. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  45708. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  45709. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  45710. * @param onSuccess a callback with the scene when import succeeds
  45711. * @param onProgress a callback with a progress event for each file being loaded
  45712. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  45713. * @returns the updated scene with imported animations
  45714. */
  45715. 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>;
  45716. }
  45717. }
  45718. declare module "babylonjs/XR/motionController/webXRAbstractMotionController" {
  45719. import { IDisposable, Scene } from "babylonjs/scene";
  45720. import { WebXRControllerComponent } from "babylonjs/XR/motionController/webXRControllerComponent";
  45721. import { Observable } from "babylonjs/Misc/observable";
  45722. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45723. import { Nullable } from "babylonjs/types";
  45724. /**
  45725. * Handedness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  45726. */
  45727. export type MotionControllerHandedness = "none" | "left" | "right";
  45728. /**
  45729. * The type of components available in motion controllers.
  45730. * This is not the name of the component.
  45731. */
  45732. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  45733. /**
  45734. * The state of a controller component
  45735. */
  45736. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  45737. /**
  45738. * The schema of motion controller layout.
  45739. * No object will be initialized using this interface
  45740. * This is used just to define the profile.
  45741. */
  45742. export interface IMotionControllerLayout {
  45743. /**
  45744. * Path to load the assets. Usually relative to the base path
  45745. */
  45746. assetPath: string;
  45747. /**
  45748. * Available components (unsorted)
  45749. */
  45750. components: {
  45751. /**
  45752. * A map of component Ids
  45753. */
  45754. [componentId: string]: {
  45755. /**
  45756. * The type of input the component outputs
  45757. */
  45758. type: MotionControllerComponentType;
  45759. /**
  45760. * The indices of this component in the gamepad object
  45761. */
  45762. gamepadIndices: {
  45763. /**
  45764. * Index of button
  45765. */
  45766. button?: number;
  45767. /**
  45768. * If available, index of x-axis
  45769. */
  45770. xAxis?: number;
  45771. /**
  45772. * If available, index of y-axis
  45773. */
  45774. yAxis?: number;
  45775. };
  45776. /**
  45777. * The mesh's root node name
  45778. */
  45779. rootNodeName: string;
  45780. /**
  45781. * Animation definitions for this model
  45782. */
  45783. visualResponses: {
  45784. [stateKey: string]: {
  45785. /**
  45786. * What property will be animated
  45787. */
  45788. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  45789. /**
  45790. * What states influence this visual response
  45791. */
  45792. states: MotionControllerComponentStateType[];
  45793. /**
  45794. * Type of animation - movement or visibility
  45795. */
  45796. valueNodeProperty: "transform" | "visibility";
  45797. /**
  45798. * Base node name to move. Its position will be calculated according to the min and max nodes
  45799. */
  45800. valueNodeName?: string;
  45801. /**
  45802. * Minimum movement node
  45803. */
  45804. minNodeName?: string;
  45805. /**
  45806. * Max movement node
  45807. */
  45808. maxNodeName?: string;
  45809. };
  45810. };
  45811. /**
  45812. * If touch enabled, what is the name of node to display user feedback
  45813. */
  45814. touchPointNodeName?: string;
  45815. };
  45816. };
  45817. /**
  45818. * Is it xr standard mapping or not
  45819. */
  45820. gamepadMapping: "" | "xr-standard";
  45821. /**
  45822. * Base root node of this entire model
  45823. */
  45824. rootNodeName: string;
  45825. /**
  45826. * Defines the main button component id
  45827. */
  45828. selectComponentId: string;
  45829. }
  45830. /**
  45831. * A definition for the layout map in the input profile
  45832. */
  45833. export interface IMotionControllerLayoutMap {
  45834. /**
  45835. * Layouts with handedness type as a key
  45836. */
  45837. [handedness: string]: IMotionControllerLayout;
  45838. }
  45839. /**
  45840. * The XR Input profile schema
  45841. * Profiles can be found here:
  45842. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  45843. */
  45844. export interface IMotionControllerProfile {
  45845. /**
  45846. * fallback profiles for this profileId
  45847. */
  45848. fallbackProfileIds: string[];
  45849. /**
  45850. * The layout map, with handedness as key
  45851. */
  45852. layouts: IMotionControllerLayoutMap;
  45853. /**
  45854. * The id of this profile
  45855. * correlates to the profile(s) in the xrInput.profiles array
  45856. */
  45857. profileId: string;
  45858. }
  45859. /**
  45860. * A helper-interface for the 3 meshes needed for controller button animation
  45861. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  45862. */
  45863. export interface IMotionControllerButtonMeshMap {
  45864. /**
  45865. * the mesh that defines the pressed value mesh position.
  45866. * This is used to find the max-position of this button
  45867. */
  45868. pressedMesh: AbstractMesh;
  45869. /**
  45870. * the mesh that defines the unpressed value mesh position.
  45871. * This is used to find the min (or initial) position of this button
  45872. */
  45873. unpressedMesh: AbstractMesh;
  45874. /**
  45875. * The mesh that will be changed when value changes
  45876. */
  45877. valueMesh: AbstractMesh;
  45878. }
  45879. /**
  45880. * A helper-interface for the 3 meshes needed for controller axis animation.
  45881. * This will be expanded when touchpad animations are fully supported
  45882. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  45883. */
  45884. export interface IMotionControllerMeshMap {
  45885. /**
  45886. * the mesh that defines the maximum value mesh position.
  45887. */
  45888. maxMesh?: AbstractMesh;
  45889. /**
  45890. * the mesh that defines the minimum value mesh position.
  45891. */
  45892. minMesh?: AbstractMesh;
  45893. /**
  45894. * The mesh that will be changed when axis value changes
  45895. */
  45896. valueMesh: AbstractMesh;
  45897. }
  45898. /**
  45899. * The elements needed for change-detection of the gamepad objects in motion controllers
  45900. */
  45901. export interface IMinimalMotionControllerObject {
  45902. /**
  45903. * Available axes of this controller
  45904. */
  45905. axes: number[];
  45906. /**
  45907. * An array of available buttons
  45908. */
  45909. buttons: Array<{
  45910. /**
  45911. * Value of the button/trigger
  45912. */
  45913. value: number;
  45914. /**
  45915. * If the button/trigger is currently touched
  45916. */
  45917. touched: boolean;
  45918. /**
  45919. * If the button/trigger is currently pressed
  45920. */
  45921. pressed: boolean;
  45922. }>;
  45923. /**
  45924. * EXPERIMENTAL haptic support.
  45925. */
  45926. hapticActuators?: Array<{
  45927. pulse: (value: number, duration: number) => Promise<boolean>;
  45928. }>;
  45929. }
  45930. /**
  45931. * An Abstract Motion controller
  45932. * This class receives an xrInput and a profile layout and uses those to initialize the components
  45933. * Each component has an observable to check for changes in value and state
  45934. */
  45935. export abstract class WebXRAbstractMotionController implements IDisposable {
  45936. protected scene: Scene;
  45937. protected layout: IMotionControllerLayout;
  45938. /**
  45939. * The gamepad object correlating to this controller
  45940. */
  45941. gamepadObject: IMinimalMotionControllerObject;
  45942. /**
  45943. * handedness (left/right/none) of this controller
  45944. */
  45945. handedness: MotionControllerHandedness;
  45946. private _initComponent;
  45947. private _modelReady;
  45948. /**
  45949. * A map of components (WebXRControllerComponent) in this motion controller
  45950. * Components have a ComponentType and can also have both button and axis definitions
  45951. */
  45952. readonly components: {
  45953. [id: string]: WebXRControllerComponent;
  45954. };
  45955. /**
  45956. * Disable the model's animation. Can be set at any time.
  45957. */
  45958. disableAnimation: boolean;
  45959. /**
  45960. * Observers registered here will be triggered when the model of this controller is done loading
  45961. */
  45962. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  45963. /**
  45964. * The profile id of this motion controller
  45965. */
  45966. abstract profileId: string;
  45967. /**
  45968. * The root mesh of the model. It is null if the model was not yet initialized
  45969. */
  45970. rootMesh: Nullable<AbstractMesh>;
  45971. /**
  45972. * constructs a new abstract motion controller
  45973. * @param scene the scene to which the model of the controller will be added
  45974. * @param layout The profile layout to load
  45975. * @param gamepadObject The gamepad object correlating to this controller
  45976. * @param handedness handedness (left/right/none) of this controller
  45977. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  45978. */
  45979. constructor(scene: Scene, layout: IMotionControllerLayout,
  45980. /**
  45981. * The gamepad object correlating to this controller
  45982. */
  45983. gamepadObject: IMinimalMotionControllerObject,
  45984. /**
  45985. * handedness (left/right/none) of this controller
  45986. */
  45987. handedness: MotionControllerHandedness, _doNotLoadControllerMesh?: boolean);
  45988. /**
  45989. * Dispose this controller, the model mesh and all its components
  45990. */
  45991. dispose(): void;
  45992. /**
  45993. * Returns all components of specific type
  45994. * @param type the type to search for
  45995. * @return an array of components with this type
  45996. */
  45997. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  45998. /**
  45999. * get a component based an its component id as defined in layout.components
  46000. * @param id the id of the component
  46001. * @returns the component correlates to the id or undefined if not found
  46002. */
  46003. getComponent(id: string): WebXRControllerComponent;
  46004. /**
  46005. * Get the list of components available in this motion controller
  46006. * @returns an array of strings correlating to available components
  46007. */
  46008. getComponentIds(): string[];
  46009. /**
  46010. * Get the first component of specific type
  46011. * @param type type of component to find
  46012. * @return a controller component or null if not found
  46013. */
  46014. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  46015. /**
  46016. * Get the main (Select) component of this controller as defined in the layout
  46017. * @returns the main component of this controller
  46018. */
  46019. getMainComponent(): WebXRControllerComponent;
  46020. /**
  46021. * Loads the model correlating to this controller
  46022. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  46023. * @returns A promise fulfilled with the result of the model loading
  46024. */
  46025. loadModel(): Promise<boolean>;
  46026. /**
  46027. * Update this model using the current XRFrame
  46028. * @param xrFrame the current xr frame to use and update the model
  46029. */
  46030. updateFromXRFrame(xrFrame: XRFrame): void;
  46031. /**
  46032. * Backwards compatibility due to a deeply-integrated typo
  46033. */
  46034. get handness(): XREye;
  46035. /**
  46036. * Pulse (vibrate) this controller
  46037. * If the controller does not support pulses, this function will fail silently and return Promise<false> directly after called
  46038. * Consecutive calls to this function will cancel the last pulse call
  46039. *
  46040. * @param value the strength of the pulse in 0.0...1.0 range
  46041. * @param duration Duration of the pulse in milliseconds
  46042. * @param hapticActuatorIndex optional index of actuator (will usually be 0)
  46043. * @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
  46044. */
  46045. pulse(value: number, duration: number, hapticActuatorIndex?: number): Promise<boolean>;
  46046. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh;
  46047. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh;
  46048. /**
  46049. * Moves the axis on the controller mesh based on its current state
  46050. * @param axis the index of the axis
  46051. * @param axisValue the value of the axis which determines the meshes new position
  46052. * @hidden
  46053. */
  46054. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  46055. /**
  46056. * Update the model itself with the current frame data
  46057. * @param xrFrame the frame to use for updating the model mesh
  46058. */
  46059. protected updateModel(xrFrame: XRFrame): void;
  46060. /**
  46061. * Get the filename and path for this controller's model
  46062. * @returns a map of filename and path
  46063. */
  46064. protected abstract _getFilenameAndPath(): {
  46065. filename: string;
  46066. path: string;
  46067. };
  46068. /**
  46069. * This function is called before the mesh is loaded. It checks for loading constraints.
  46070. * For example, this function can check if the GLB loader is available
  46071. * If this function returns false, the generic controller will be loaded instead
  46072. * @returns Is the client ready to load the mesh
  46073. */
  46074. protected abstract _getModelLoadingConstraints(): boolean;
  46075. /**
  46076. * This function will be called after the model was successfully loaded and can be used
  46077. * for mesh transformations before it is available for the user
  46078. * @param meshes the loaded meshes
  46079. */
  46080. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  46081. /**
  46082. * Set the root mesh for this controller. Important for the WebXR controller class
  46083. * @param meshes the loaded meshes
  46084. */
  46085. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  46086. /**
  46087. * A function executed each frame that updates the mesh (if needed)
  46088. * @param xrFrame the current xrFrame
  46089. */
  46090. protected abstract _updateModel(xrFrame: XRFrame): void;
  46091. private _getGenericFilenameAndPath;
  46092. private _getGenericParentMesh;
  46093. }
  46094. }
  46095. declare module "babylonjs/XR/motionController/webXRGenericMotionController" {
  46096. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandedness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  46097. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46098. import { Scene } from "babylonjs/scene";
  46099. /**
  46100. * A generic trigger-only motion controller for WebXR
  46101. */
  46102. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  46103. /**
  46104. * Static version of the profile id of this controller
  46105. */
  46106. static ProfileId: string;
  46107. profileId: string;
  46108. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  46109. protected _getFilenameAndPath(): {
  46110. filename: string;
  46111. path: string;
  46112. };
  46113. protected _getModelLoadingConstraints(): boolean;
  46114. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  46115. protected _setRootMesh(meshes: AbstractMesh[]): void;
  46116. protected _updateModel(): void;
  46117. }
  46118. }
  46119. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  46120. import { Vector4 } from "babylonjs/Maths/math.vector";
  46121. import { Mesh } from "babylonjs/Meshes/mesh";
  46122. import { Scene } from "babylonjs/scene";
  46123. import { Nullable } from "babylonjs/types";
  46124. /**
  46125. * Class containing static functions to help procedurally build meshes
  46126. */
  46127. export class SphereBuilder {
  46128. /**
  46129. * Creates a sphere mesh
  46130. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  46131. * * 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`)
  46132. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  46133. * * 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
  46134. * * 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)
  46135. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  46136. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  46137. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46138. * @param name defines the name of the mesh
  46139. * @param options defines the options used to create the mesh
  46140. * @param scene defines the hosting scene
  46141. * @returns the sphere mesh
  46142. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  46143. */
  46144. static CreateSphere(name: string, options: {
  46145. segments?: number;
  46146. diameter?: number;
  46147. diameterX?: number;
  46148. diameterY?: number;
  46149. diameterZ?: number;
  46150. arc?: number;
  46151. slice?: number;
  46152. sideOrientation?: number;
  46153. frontUVs?: Vector4;
  46154. backUVs?: Vector4;
  46155. updatable?: boolean;
  46156. }, scene?: Nullable<Scene>): Mesh;
  46157. }
  46158. }
  46159. declare module "babylonjs/XR/motionController/webXRProfiledMotionController" {
  46160. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46161. import { WebXRAbstractMotionController, IMotionControllerProfile } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  46162. import { Scene } from "babylonjs/scene";
  46163. /**
  46164. * A profiled motion controller has its profile loaded from an online repository.
  46165. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  46166. */
  46167. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  46168. private _repositoryUrl;
  46169. private _buttonMeshMapping;
  46170. private _touchDots;
  46171. /**
  46172. * The profile ID of this controller. Will be populated when the controller initializes.
  46173. */
  46174. profileId: string;
  46175. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  46176. dispose(): void;
  46177. protected _getFilenameAndPath(): {
  46178. filename: string;
  46179. path: string;
  46180. };
  46181. protected _getModelLoadingConstraints(): boolean;
  46182. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  46183. protected _setRootMesh(meshes: AbstractMesh[]): void;
  46184. protected _updateModel(_xrFrame: XRFrame): void;
  46185. }
  46186. }
  46187. declare module "babylonjs/XR/motionController/webXRMotionControllerManager" {
  46188. import { WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  46189. import { Scene } from "babylonjs/scene";
  46190. /**
  46191. * A construction function type to create a new controller based on an xrInput object
  46192. */
  46193. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  46194. /**
  46195. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  46196. *
  46197. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  46198. * it should be replaced with auto-loaded controllers.
  46199. *
  46200. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  46201. */
  46202. export class WebXRMotionControllerManager {
  46203. private static _AvailableControllers;
  46204. private static _Fallbacks;
  46205. private static _ProfileLoadingPromises;
  46206. private static _ProfilesList;
  46207. /**
  46208. * The base URL of the online controller repository. Can be changed at any time.
  46209. */
  46210. static BaseRepositoryUrl: string;
  46211. /**
  46212. * Which repository gets priority - local or online
  46213. */
  46214. static PrioritizeOnlineRepository: boolean;
  46215. /**
  46216. * Use the online repository, or use only locally-defined controllers
  46217. */
  46218. static UseOnlineRepository: boolean;
  46219. /**
  46220. * Clear the cache used for profile loading and reload when requested again
  46221. */
  46222. static ClearProfilesCache(): void;
  46223. /**
  46224. * Register the default fallbacks.
  46225. * This function is called automatically when this file is imported.
  46226. */
  46227. static DefaultFallbacks(): void;
  46228. /**
  46229. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  46230. * @param profileId the profile to which a fallback needs to be found
  46231. * @return an array with corresponding fallback profiles
  46232. */
  46233. static FindFallbackWithProfileId(profileId: string): string[];
  46234. /**
  46235. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  46236. * The order of search:
  46237. *
  46238. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  46239. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  46240. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  46241. * 4) return the generic trigger controller if none were found
  46242. *
  46243. * @param xrInput the xrInput to which a new controller is initialized
  46244. * @param scene the scene to which the model will be added
  46245. * @param forceProfile force a certain profile for this controller
  46246. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  46247. */
  46248. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  46249. /**
  46250. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  46251. *
  46252. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  46253. *
  46254. * @param type the profile type to register
  46255. * @param constructFunction the function to be called when loading this profile
  46256. */
  46257. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  46258. /**
  46259. * Register a fallback to a specific profile.
  46260. * @param profileId the profileId that will receive the fallbacks
  46261. * @param fallbacks A list of fallback profiles
  46262. */
  46263. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  46264. /**
  46265. * Will update the list of profiles available in the repository
  46266. * @return a promise that resolves to a map of profiles available online
  46267. */
  46268. static UpdateProfilesList(): Promise<{
  46269. [profile: string]: string;
  46270. }>;
  46271. private static _LoadProfileFromRepository;
  46272. private static _LoadProfilesFromAvailableControllers;
  46273. }
  46274. }
  46275. declare module "babylonjs/XR/webXRInputSource" {
  46276. import { Observable } from "babylonjs/Misc/observable";
  46277. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46278. import { Ray } from "babylonjs/Culling/ray";
  46279. import { Scene } from "babylonjs/scene";
  46280. import { WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  46281. /**
  46282. * Configuration options for the WebXR controller creation
  46283. */
  46284. export interface IWebXRControllerOptions {
  46285. /**
  46286. * Should the controller mesh be animated when a user interacts with it
  46287. * The pressed buttons / thumbstick and touchpad animations will be disabled
  46288. */
  46289. disableMotionControllerAnimation?: boolean;
  46290. /**
  46291. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  46292. */
  46293. doNotLoadControllerMesh?: boolean;
  46294. /**
  46295. * Force a specific controller type for this controller.
  46296. * This can be used when creating your own profile or when testing different controllers
  46297. */
  46298. forceControllerProfile?: string;
  46299. /**
  46300. * Defines a rendering group ID for meshes that will be loaded.
  46301. * This is for the default controllers only.
  46302. */
  46303. renderingGroupId?: number;
  46304. }
  46305. /**
  46306. * Represents an XR controller
  46307. */
  46308. export class WebXRInputSource {
  46309. private _scene;
  46310. /** The underlying input source for the controller */
  46311. inputSource: XRInputSource;
  46312. private _options;
  46313. private _tmpQuaternion;
  46314. private _tmpVector;
  46315. private _uniqueId;
  46316. /**
  46317. * 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
  46318. */
  46319. grip?: AbstractMesh;
  46320. /**
  46321. * If available, this is the gamepad object related to this controller.
  46322. * Using this object it is possible to get click events and trackpad changes of the
  46323. * webxr controller that is currently being used.
  46324. */
  46325. motionController?: WebXRAbstractMotionController;
  46326. /**
  46327. * Event that fires when the controller is removed/disposed.
  46328. * The object provided as event data is this controller, after associated assets were disposed.
  46329. * uniqueId is still available.
  46330. */
  46331. onDisposeObservable: Observable<WebXRInputSource>;
  46332. /**
  46333. * Will be triggered when the mesh associated with the motion controller is done loading.
  46334. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  46335. * A shortened version of controller -> motion controller -> on mesh loaded.
  46336. */
  46337. onMeshLoadedObservable: Observable<AbstractMesh>;
  46338. /**
  46339. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  46340. */
  46341. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  46342. /**
  46343. * Pointer which can be used to select objects or attach a visible laser to
  46344. */
  46345. pointer: AbstractMesh;
  46346. /**
  46347. * Creates the controller
  46348. * @see https://doc.babylonjs.com/how_to/webxr
  46349. * @param _scene the scene which the controller should be associated to
  46350. * @param inputSource the underlying input source for the controller
  46351. * @param _options options for this controller creation
  46352. */
  46353. constructor(_scene: Scene,
  46354. /** The underlying input source for the controller */
  46355. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  46356. /**
  46357. * Get this controllers unique id
  46358. */
  46359. get uniqueId(): string;
  46360. /**
  46361. * Disposes of the object
  46362. */
  46363. dispose(): void;
  46364. /**
  46365. * Gets a world space ray coming from the pointer or grip
  46366. * @param result the resulting ray
  46367. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  46368. */
  46369. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  46370. /**
  46371. * Updates the controller pose based on the given XRFrame
  46372. * @param xrFrame xr frame to update the pose with
  46373. * @param referenceSpace reference space to use
  46374. */
  46375. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  46376. }
  46377. }
  46378. declare module "babylonjs/XR/webXRInput" {
  46379. import { Observable } from "babylonjs/Misc/observable";
  46380. import { IDisposable } from "babylonjs/scene";
  46381. import { WebXRInputSource, IWebXRControllerOptions } from "babylonjs/XR/webXRInputSource";
  46382. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  46383. import { WebXRCamera } from "babylonjs/XR/webXRCamera";
  46384. /**
  46385. * The schema for initialization options of the XR Input class
  46386. */
  46387. export interface IWebXRInputOptions {
  46388. /**
  46389. * If set to true no model will be automatically loaded
  46390. */
  46391. doNotLoadControllerMeshes?: boolean;
  46392. /**
  46393. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  46394. * If not found, the xr input profile data will be used.
  46395. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  46396. */
  46397. forceInputProfile?: string;
  46398. /**
  46399. * Do not send a request to the controller repository to load the profile.
  46400. *
  46401. * Instead, use the controllers available in babylon itself.
  46402. */
  46403. disableOnlineControllerRepository?: boolean;
  46404. /**
  46405. * A custom URL for the controllers repository
  46406. */
  46407. customControllersRepositoryURL?: string;
  46408. /**
  46409. * Should the controller model's components not move according to the user input
  46410. */
  46411. disableControllerAnimation?: boolean;
  46412. /**
  46413. * Optional options to pass to the controller. Will be overridden by the Input options where applicable
  46414. */
  46415. controllerOptions?: IWebXRControllerOptions;
  46416. }
  46417. /**
  46418. * XR input used to track XR inputs such as controllers/rays
  46419. */
  46420. export class WebXRInput implements IDisposable {
  46421. /**
  46422. * the xr session manager for this session
  46423. */
  46424. xrSessionManager: WebXRSessionManager;
  46425. /**
  46426. * the WebXR camera for this session. Mainly used for teleportation
  46427. */
  46428. xrCamera: WebXRCamera;
  46429. private readonly options;
  46430. /**
  46431. * XR controllers being tracked
  46432. */
  46433. controllers: Array<WebXRInputSource>;
  46434. private _frameObserver;
  46435. private _sessionEndedObserver;
  46436. private _sessionInitObserver;
  46437. /**
  46438. * Event when a controller has been connected/added
  46439. */
  46440. onControllerAddedObservable: Observable<WebXRInputSource>;
  46441. /**
  46442. * Event when a controller has been removed/disconnected
  46443. */
  46444. onControllerRemovedObservable: Observable<WebXRInputSource>;
  46445. /**
  46446. * Initializes the WebXRInput
  46447. * @param xrSessionManager the xr session manager for this session
  46448. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  46449. * @param options = initialization options for this xr input
  46450. */
  46451. constructor(
  46452. /**
  46453. * the xr session manager for this session
  46454. */
  46455. xrSessionManager: WebXRSessionManager,
  46456. /**
  46457. * the WebXR camera for this session. Mainly used for teleportation
  46458. */
  46459. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  46460. private _onInputSourcesChange;
  46461. private _addAndRemoveControllers;
  46462. /**
  46463. * Disposes of the object
  46464. */
  46465. dispose(): void;
  46466. }
  46467. }
  46468. declare module "babylonjs/XR/features/WebXRAbstractFeature" {
  46469. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  46470. import { Observable, EventState } from "babylonjs/Misc/observable";
  46471. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  46472. /**
  46473. * This is the base class for all WebXR features.
  46474. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  46475. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  46476. */
  46477. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  46478. protected _xrSessionManager: WebXRSessionManager;
  46479. private _attached;
  46480. private _removeOnDetach;
  46481. /**
  46482. * Should auto-attach be disabled?
  46483. */
  46484. disableAutoAttach: boolean;
  46485. /**
  46486. * Construct a new (abstract) WebXR feature
  46487. * @param _xrSessionManager the xr session manager for this feature
  46488. */
  46489. constructor(_xrSessionManager: WebXRSessionManager);
  46490. /**
  46491. * Is this feature attached
  46492. */
  46493. get attached(): boolean;
  46494. /**
  46495. * attach this feature
  46496. *
  46497. * @param force should attachment be forced (even when already attached)
  46498. * @returns true if successful, false is failed or already attached
  46499. */
  46500. attach(force?: boolean): boolean;
  46501. /**
  46502. * detach this feature.
  46503. *
  46504. * @returns true if successful, false if failed or already detached
  46505. */
  46506. detach(): boolean;
  46507. /**
  46508. * Dispose this feature and all of the resources attached
  46509. */
  46510. dispose(): void;
  46511. /**
  46512. * This is used to register callbacks that will automatically be removed when detach is called.
  46513. * @param observable the observable to which the observer will be attached
  46514. * @param callback the callback to register
  46515. */
  46516. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  46517. /**
  46518. * Code in this function will be executed on each xrFrame received from the browser.
  46519. * This function will not execute after the feature is detached.
  46520. * @param _xrFrame the current frame
  46521. */
  46522. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  46523. }
  46524. }
  46525. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  46526. import { IDisposable, Scene } from "babylonjs/scene";
  46527. import { Nullable } from "babylonjs/types";
  46528. import { Observable } from "babylonjs/Misc/observable";
  46529. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46530. import { HemisphericLight } from "babylonjs/Lights/hemisphericLight";
  46531. import { Camera } from "babylonjs/Cameras/camera";
  46532. /**
  46533. * Renders a layer on top of an existing scene
  46534. */
  46535. export class UtilityLayerRenderer implements IDisposable {
  46536. /** the original scene that will be rendered on top of */
  46537. originalScene: Scene;
  46538. private _pointerCaptures;
  46539. private _lastPointerEvents;
  46540. private static _DefaultUtilityLayer;
  46541. private static _DefaultKeepDepthUtilityLayer;
  46542. private _sharedGizmoLight;
  46543. private _renderCamera;
  46544. /**
  46545. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  46546. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  46547. * @returns the camera that is used when rendering the utility layer
  46548. */
  46549. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  46550. /**
  46551. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  46552. * @param cam the camera that should be used when rendering the utility layer
  46553. */
  46554. setRenderCamera(cam: Nullable<Camera>): void;
  46555. /**
  46556. * @hidden
  46557. * Light which used by gizmos to get light shading
  46558. */
  46559. _getSharedGizmoLight(): HemisphericLight;
  46560. /**
  46561. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  46562. */
  46563. pickUtilitySceneFirst: boolean;
  46564. /**
  46565. * 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)
  46566. */
  46567. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  46568. /**
  46569. * 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)
  46570. */
  46571. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  46572. /**
  46573. * The scene that is rendered on top of the original scene
  46574. */
  46575. utilityLayerScene: Scene;
  46576. /**
  46577. * If the utility layer should automatically be rendered on top of existing scene
  46578. */
  46579. shouldRender: boolean;
  46580. /**
  46581. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  46582. */
  46583. onlyCheckPointerDownEvents: boolean;
  46584. /**
  46585. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  46586. */
  46587. processAllEvents: boolean;
  46588. /**
  46589. * Observable raised when the pointer move from the utility layer scene to the main scene
  46590. */
  46591. onPointerOutObservable: Observable<number>;
  46592. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  46593. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  46594. private _afterRenderObserver;
  46595. private _sceneDisposeObserver;
  46596. private _originalPointerObserver;
  46597. /**
  46598. * Instantiates a UtilityLayerRenderer
  46599. * @param originalScene the original scene that will be rendered on top of
  46600. * @param handleEvents boolean indicating if the utility layer should handle events
  46601. */
  46602. constructor(
  46603. /** the original scene that will be rendered on top of */
  46604. originalScene: Scene, handleEvents?: boolean);
  46605. private _notifyObservers;
  46606. /**
  46607. * Renders the utility layers scene on top of the original scene
  46608. */
  46609. render(): void;
  46610. /**
  46611. * Disposes of the renderer
  46612. */
  46613. dispose(): void;
  46614. private _updateCamera;
  46615. }
  46616. }
  46617. declare module "babylonjs/XR/features/WebXRControllerPointerSelection" {
  46618. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  46619. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46620. import { WebXRInput } from "babylonjs/XR/webXRInput";
  46621. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  46622. import { Scene } from "babylonjs/scene";
  46623. import { Nullable } from "babylonjs/types";
  46624. import { Color3 } from "babylonjs/Maths/math.color";
  46625. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  46626. /**
  46627. * Options interface for the pointer selection module
  46628. */
  46629. export interface IWebXRControllerPointerSelectionOptions {
  46630. /**
  46631. * if provided, this scene will be used to render meshes.
  46632. */
  46633. customUtilityLayerScene?: Scene;
  46634. /**
  46635. * 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)
  46636. * If not disabled, the last picked point will be used to execute a pointer up event
  46637. * If disabled, pointer up event will be triggered right after the pointer down event.
  46638. * Used in screen and gaze target ray mode only
  46639. */
  46640. disablePointerUpOnTouchOut: boolean;
  46641. /**
  46642. * For gaze mode (time to select instead of press)
  46643. */
  46644. forceGazeMode: boolean;
  46645. /**
  46646. * 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
  46647. * to start a new countdown to the pointer down event.
  46648. * Defaults to 1.
  46649. */
  46650. gazeModePointerMovedFactor?: number;
  46651. /**
  46652. * Different button type to use instead of the main component
  46653. */
  46654. overrideButtonId?: string;
  46655. /**
  46656. * use this rendering group id for the meshes (optional)
  46657. */
  46658. renderingGroupId?: number;
  46659. /**
  46660. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  46661. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  46662. * 3000 means 3 seconds between pointing at something and selecting it
  46663. */
  46664. timeToSelect?: number;
  46665. /**
  46666. * Should meshes created here be added to a utility layer or the main scene
  46667. */
  46668. useUtilityLayer?: boolean;
  46669. /**
  46670. * the xr input to use with this pointer selection
  46671. */
  46672. xrInput: WebXRInput;
  46673. }
  46674. /**
  46675. * A module that will enable pointer selection for motion controllers of XR Input Sources
  46676. */
  46677. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  46678. private readonly _options;
  46679. private static _idCounter;
  46680. private _attachController;
  46681. private _controllers;
  46682. private _scene;
  46683. private _tmpVectorForPickCompare;
  46684. /**
  46685. * The module's name
  46686. */
  46687. static readonly Name: string;
  46688. /**
  46689. * The (Babylon) version of this module.
  46690. * This is an integer representing the implementation version.
  46691. * This number does not correspond to the WebXR specs version
  46692. */
  46693. static readonly Version: number;
  46694. /**
  46695. * Disable lighting on the laser pointer (so it will always be visible)
  46696. */
  46697. disablePointerLighting: boolean;
  46698. /**
  46699. * Disable lighting on the selection mesh (so it will always be visible)
  46700. */
  46701. disableSelectionMeshLighting: boolean;
  46702. /**
  46703. * Should the laser pointer be displayed
  46704. */
  46705. displayLaserPointer: boolean;
  46706. /**
  46707. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  46708. */
  46709. displaySelectionMesh: boolean;
  46710. /**
  46711. * This color will be set to the laser pointer when selection is triggered
  46712. */
  46713. laserPointerPickedColor: Color3;
  46714. /**
  46715. * Default color of the laser pointer
  46716. */
  46717. lasterPointerDefaultColor: Color3;
  46718. /**
  46719. * default color of the selection ring
  46720. */
  46721. selectionMeshDefaultColor: Color3;
  46722. /**
  46723. * This color will be applied to the selection ring when selection is triggered
  46724. */
  46725. selectionMeshPickedColor: Color3;
  46726. /**
  46727. * Optional filter to be used for ray selection. This predicate shares behavior with
  46728. * scene.pointerMovePredicate which takes priority if it is also assigned.
  46729. */
  46730. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  46731. /**
  46732. * constructs a new background remover module
  46733. * @param _xrSessionManager the session manager for this module
  46734. * @param _options read-only options to be used in this module
  46735. */
  46736. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  46737. /**
  46738. * attach this feature
  46739. * Will usually be called by the features manager
  46740. *
  46741. * @returns true if successful.
  46742. */
  46743. attach(): boolean;
  46744. /**
  46745. * detach this feature.
  46746. * Will usually be called by the features manager
  46747. *
  46748. * @returns true if successful.
  46749. */
  46750. detach(): boolean;
  46751. /**
  46752. * Will get the mesh under a specific pointer.
  46753. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  46754. * @param controllerId the controllerId to check
  46755. * @returns The mesh under pointer or null if no mesh is under the pointer
  46756. */
  46757. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  46758. /**
  46759. * Get the xr controller that correlates to the pointer id in the pointer event
  46760. *
  46761. * @param id the pointer id to search for
  46762. * @returns the controller that correlates to this id or null if not found
  46763. */
  46764. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  46765. protected _onXRFrame(_xrFrame: XRFrame): void;
  46766. private _attachGazeMode;
  46767. private _attachScreenRayMode;
  46768. private _attachTrackedPointerRayMode;
  46769. private _convertNormalToDirectionOfRay;
  46770. private _detachController;
  46771. private _generateNewMeshPair;
  46772. private _pickingMoved;
  46773. private _updatePointerDistance;
  46774. }
  46775. }
  46776. declare module "babylonjs/XR/webXREnterExitUI" {
  46777. import { Nullable } from "babylonjs/types";
  46778. import { Observable } from "babylonjs/Misc/observable";
  46779. import { IDisposable, Scene } from "babylonjs/scene";
  46780. import { WebXRExperienceHelper } from "babylonjs/XR/webXRExperienceHelper";
  46781. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  46782. /**
  46783. * Button which can be used to enter a different mode of XR
  46784. */
  46785. export class WebXREnterExitUIButton {
  46786. /** button element */
  46787. element: HTMLElement;
  46788. /** XR initialization options for the button */
  46789. sessionMode: XRSessionMode;
  46790. /** Reference space type */
  46791. referenceSpaceType: XRReferenceSpaceType;
  46792. /**
  46793. * Creates a WebXREnterExitUIButton
  46794. * @param element button element
  46795. * @param sessionMode XR initialization session mode
  46796. * @param referenceSpaceType the type of reference space to be used
  46797. */
  46798. constructor(
  46799. /** button element */
  46800. element: HTMLElement,
  46801. /** XR initialization options for the button */
  46802. sessionMode: XRSessionMode,
  46803. /** Reference space type */
  46804. referenceSpaceType: XRReferenceSpaceType);
  46805. /**
  46806. * Extendable function which can be used to update the button's visuals when the state changes
  46807. * @param activeButton the current active button in the UI
  46808. */
  46809. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  46810. }
  46811. /**
  46812. * Options to create the webXR UI
  46813. */
  46814. export class WebXREnterExitUIOptions {
  46815. /**
  46816. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  46817. */
  46818. customButtons?: Array<WebXREnterExitUIButton>;
  46819. /**
  46820. * A reference space type to use when creating the default button.
  46821. * Default is local-floor
  46822. */
  46823. referenceSpaceType?: XRReferenceSpaceType;
  46824. /**
  46825. * Context to enter xr with
  46826. */
  46827. renderTarget?: Nullable<WebXRRenderTarget>;
  46828. /**
  46829. * A session mode to use when creating the default button.
  46830. * Default is immersive-vr
  46831. */
  46832. sessionMode?: XRSessionMode;
  46833. /**
  46834. * A list of optional features to init the session with
  46835. */
  46836. optionalFeatures?: string[];
  46837. }
  46838. /**
  46839. * UI to allow the user to enter/exit XR mode
  46840. */
  46841. export class WebXREnterExitUI implements IDisposable {
  46842. private scene;
  46843. /** version of the options passed to this UI */
  46844. options: WebXREnterExitUIOptions;
  46845. private _activeButton;
  46846. private _buttons;
  46847. private _overlay;
  46848. /**
  46849. * Fired every time the active button is changed.
  46850. *
  46851. * When xr is entered via a button that launches xr that button will be the callback parameter
  46852. *
  46853. * When exiting xr the callback parameter will be null)
  46854. */
  46855. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  46856. /**
  46857. *
  46858. * @param scene babylon scene object to use
  46859. * @param options (read-only) version of the options passed to this UI
  46860. */
  46861. private constructor();
  46862. /**
  46863. * Creates UI to allow the user to enter/exit XR mode
  46864. * @param scene the scene to add the ui to
  46865. * @param helper the xr experience helper to enter/exit xr with
  46866. * @param options options to configure the UI
  46867. * @returns the created ui
  46868. */
  46869. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  46870. /**
  46871. * Disposes of the XR UI component
  46872. */
  46873. dispose(): void;
  46874. private _updateButtons;
  46875. }
  46876. }
  46877. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  46878. import { Vector3 } from "babylonjs/Maths/math.vector";
  46879. import { Color4 } from "babylonjs/Maths/math.color";
  46880. import { Nullable } from "babylonjs/types";
  46881. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  46882. import { Scene } from "babylonjs/scene";
  46883. /**
  46884. * Class containing static functions to help procedurally build meshes
  46885. */
  46886. export class LinesBuilder {
  46887. /**
  46888. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  46889. * * 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
  46890. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  46891. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  46892. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  46893. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  46894. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  46895. * * 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
  46896. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  46897. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46898. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  46899. * @param name defines the name of the new line system
  46900. * @param options defines the options used to create the line system
  46901. * @param scene defines the hosting scene
  46902. * @returns a new line system mesh
  46903. */
  46904. static CreateLineSystem(name: string, options: {
  46905. lines: Vector3[][];
  46906. updatable?: boolean;
  46907. instance?: Nullable<LinesMesh>;
  46908. colors?: Nullable<Color4[][]>;
  46909. useVertexAlpha?: boolean;
  46910. }, scene: Nullable<Scene>): LinesMesh;
  46911. /**
  46912. * Creates a line mesh
  46913. * 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
  46914. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  46915. * * The parameter `points` is an array successive Vector3
  46916. * * 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
  46917. * * The optional parameter `colors` is an array of successive Color4, one per line point
  46918. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  46919. * * When updating an instance, remember that only point positions can change, not the number of points
  46920. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46921. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  46922. * @param name defines the name of the new line system
  46923. * @param options defines the options used to create the line system
  46924. * @param scene defines the hosting scene
  46925. * @returns a new line mesh
  46926. */
  46927. static CreateLines(name: string, options: {
  46928. points: Vector3[];
  46929. updatable?: boolean;
  46930. instance?: Nullable<LinesMesh>;
  46931. colors?: Color4[];
  46932. useVertexAlpha?: boolean;
  46933. }, scene?: Nullable<Scene>): LinesMesh;
  46934. /**
  46935. * Creates a dashed line mesh
  46936. * * 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
  46937. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  46938. * * The parameter `points` is an array successive Vector3
  46939. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  46940. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  46941. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  46942. * * 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
  46943. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  46944. * * When updating an instance, remember that only point positions can change, not the number of points
  46945. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46946. * @param name defines the name of the mesh
  46947. * @param options defines the options used to create the mesh
  46948. * @param scene defines the hosting scene
  46949. * @returns the dashed line mesh
  46950. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  46951. */
  46952. static CreateDashedLines(name: string, options: {
  46953. points: Vector3[];
  46954. dashSize?: number;
  46955. gapSize?: number;
  46956. dashNb?: number;
  46957. updatable?: boolean;
  46958. instance?: LinesMesh;
  46959. useVertexAlpha?: boolean;
  46960. }, scene?: Nullable<Scene>): LinesMesh;
  46961. }
  46962. }
  46963. declare module "babylonjs/XR/features/WebXRControllerTeleportation" {
  46964. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  46965. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  46966. import { WebXRInput } from "babylonjs/XR/webXRInput";
  46967. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46968. import { Vector3 } from "babylonjs/Maths/math.vector";
  46969. import { Material } from "babylonjs/Materials/material";
  46970. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  46971. import { Scene } from "babylonjs/scene";
  46972. /**
  46973. * The options container for the teleportation module
  46974. */
  46975. export interface IWebXRTeleportationOptions {
  46976. /**
  46977. * if provided, this scene will be used to render meshes.
  46978. */
  46979. customUtilityLayerScene?: Scene;
  46980. /**
  46981. * Values to configure the default target mesh
  46982. */
  46983. defaultTargetMeshOptions?: {
  46984. /**
  46985. * Fill color of the teleportation area
  46986. */
  46987. teleportationFillColor?: string;
  46988. /**
  46989. * Border color for the teleportation area
  46990. */
  46991. teleportationBorderColor?: string;
  46992. /**
  46993. * Disable the mesh's animation sequence
  46994. */
  46995. disableAnimation?: boolean;
  46996. /**
  46997. * Disable lighting on the material or the ring and arrow
  46998. */
  46999. disableLighting?: boolean;
  47000. /**
  47001. * Override the default material of the torus and arrow
  47002. */
  47003. torusArrowMaterial?: Material;
  47004. };
  47005. /**
  47006. * A list of meshes to use as floor meshes.
  47007. * Meshes can be added and removed after initializing the feature using the
  47008. * addFloorMesh and removeFloorMesh functions
  47009. * If empty, rotation will still work
  47010. */
  47011. floorMeshes?: AbstractMesh[];
  47012. /**
  47013. * use this rendering group id for the meshes (optional)
  47014. */
  47015. renderingGroupId?: number;
  47016. /**
  47017. * Should teleportation move only to snap points
  47018. */
  47019. snapPointsOnly?: boolean;
  47020. /**
  47021. * An array of points to which the teleportation will snap to.
  47022. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  47023. */
  47024. snapPositions?: Vector3[];
  47025. /**
  47026. * How close should the teleportation ray be in order to snap to position.
  47027. * Default to 0.8 units (meters)
  47028. */
  47029. snapToPositionRadius?: number;
  47030. /**
  47031. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  47032. * If you want to support rotation, make sure your mesh has a direction indicator.
  47033. *
  47034. * When left untouched, the default mesh will be initialized.
  47035. */
  47036. teleportationTargetMesh?: AbstractMesh;
  47037. /**
  47038. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  47039. */
  47040. timeToTeleport?: number;
  47041. /**
  47042. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  47043. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  47044. */
  47045. useMainComponentOnly?: boolean;
  47046. /**
  47047. * Should meshes created here be added to a utility layer or the main scene
  47048. */
  47049. useUtilityLayer?: boolean;
  47050. /**
  47051. * Babylon XR Input class for controller
  47052. */
  47053. xrInput: WebXRInput;
  47054. }
  47055. /**
  47056. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  47057. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  47058. * the input of the attached controllers.
  47059. */
  47060. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  47061. private _options;
  47062. private _controllers;
  47063. private _currentTeleportationControllerId;
  47064. private _floorMeshes;
  47065. private _quadraticBezierCurve;
  47066. private _selectionFeature;
  47067. private _snapToPositions;
  47068. private _snappedToPoint;
  47069. private _teleportationRingMaterial?;
  47070. private _tmpRay;
  47071. private _tmpVector;
  47072. /**
  47073. * The module's name
  47074. */
  47075. static readonly Name: string;
  47076. /**
  47077. * The (Babylon) version of this module.
  47078. * This is an integer representing the implementation version.
  47079. * This number does not correspond to the webxr specs version
  47080. */
  47081. static readonly Version: number;
  47082. /**
  47083. * Is movement backwards enabled
  47084. */
  47085. backwardsMovementEnabled: boolean;
  47086. /**
  47087. * Distance to travel when moving backwards
  47088. */
  47089. backwardsTeleportationDistance: number;
  47090. /**
  47091. * The distance from the user to the inspection point in the direction of the controller
  47092. * A higher number will allow the user to move further
  47093. * defaults to 5 (meters, in xr units)
  47094. */
  47095. parabolicCheckRadius: number;
  47096. /**
  47097. * Should the module support parabolic ray on top of direct ray
  47098. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  47099. * Very helpful when moving between floors / different heights
  47100. */
  47101. parabolicRayEnabled: boolean;
  47102. /**
  47103. * How much rotation should be applied when rotating right and left
  47104. */
  47105. rotationAngle: number;
  47106. /**
  47107. * Is rotation enabled when moving forward?
  47108. * Disabling this feature will prevent the user from deciding the direction when teleporting
  47109. */
  47110. rotationEnabled: boolean;
  47111. /**
  47112. * constructs a new anchor system
  47113. * @param _xrSessionManager an instance of WebXRSessionManager
  47114. * @param _options configuration object for this feature
  47115. */
  47116. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  47117. /**
  47118. * Get the snapPointsOnly flag
  47119. */
  47120. get snapPointsOnly(): boolean;
  47121. /**
  47122. * Sets the snapPointsOnly flag
  47123. * @param snapToPoints should teleportation be exclusively to snap points
  47124. */
  47125. set snapPointsOnly(snapToPoints: boolean);
  47126. /**
  47127. * Add a new mesh to the floor meshes array
  47128. * @param mesh the mesh to use as floor mesh
  47129. */
  47130. addFloorMesh(mesh: AbstractMesh): void;
  47131. /**
  47132. * Add a new snap-to point to fix teleportation to this position
  47133. * @param newSnapPoint The new Snap-To point
  47134. */
  47135. addSnapPoint(newSnapPoint: Vector3): void;
  47136. attach(): boolean;
  47137. detach(): boolean;
  47138. dispose(): void;
  47139. /**
  47140. * Remove a mesh from the floor meshes array
  47141. * @param mesh the mesh to remove
  47142. */
  47143. removeFloorMesh(mesh: AbstractMesh): void;
  47144. /**
  47145. * Remove a mesh from the floor meshes array using its name
  47146. * @param name the mesh name to remove
  47147. */
  47148. removeFloorMeshByName(name: string): void;
  47149. /**
  47150. * 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
  47151. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  47152. * @returns was the point found and removed or not
  47153. */
  47154. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  47155. /**
  47156. * This function sets a selection feature that will be disabled when
  47157. * the forward ray is shown and will be reattached when hidden.
  47158. * This is used to remove the selection rays when moving.
  47159. * @param selectionFeature the feature to disable when forward movement is enabled
  47160. */
  47161. setSelectionFeature(selectionFeature: IWebXRFeature): void;
  47162. protected _onXRFrame(_xrFrame: XRFrame): void;
  47163. private _attachController;
  47164. private _createDefaultTargetMesh;
  47165. private _detachController;
  47166. private _findClosestSnapPointWithRadius;
  47167. private _setTargetMeshPosition;
  47168. private _setTargetMeshVisibility;
  47169. private _showParabolicPath;
  47170. private _teleportForward;
  47171. }
  47172. }
  47173. declare module "babylonjs/XR/webXRDefaultExperience" {
  47174. import { WebXRExperienceHelper } from "babylonjs/XR/webXRExperienceHelper";
  47175. import { Scene } from "babylonjs/scene";
  47176. import { WebXRInput, IWebXRInputOptions } from "babylonjs/XR/webXRInput";
  47177. import { WebXRControllerPointerSelection } from "babylonjs/XR/features/WebXRControllerPointerSelection";
  47178. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  47179. import { WebXREnterExitUI, WebXREnterExitUIOptions } from "babylonjs/XR/webXREnterExitUI";
  47180. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47181. import { WebXRManagedOutputCanvasOptions } from "babylonjs/XR/webXRManagedOutputCanvas";
  47182. import { WebXRMotionControllerTeleportation } from "babylonjs/XR/features/WebXRControllerTeleportation";
  47183. /**
  47184. * Options for the default xr helper
  47185. */
  47186. export class WebXRDefaultExperienceOptions {
  47187. /**
  47188. * Enable or disable default UI to enter XR
  47189. */
  47190. disableDefaultUI?: boolean;
  47191. /**
  47192. * Should teleportation not initialize. defaults to false.
  47193. */
  47194. disableTeleportation?: boolean;
  47195. /**
  47196. * Floor meshes that will be used for teleport
  47197. */
  47198. floorMeshes?: Array<AbstractMesh>;
  47199. /**
  47200. * If set to true, the first frame will not be used to reset position
  47201. * The first frame is mainly used when copying transformation from the old camera
  47202. * Mainly used in AR
  47203. */
  47204. ignoreNativeCameraTransformation?: boolean;
  47205. /**
  47206. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  47207. */
  47208. inputOptions?: IWebXRInputOptions;
  47209. /**
  47210. * optional configuration for the output canvas
  47211. */
  47212. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  47213. /**
  47214. * optional UI options. This can be used among other to change session mode and reference space type
  47215. */
  47216. uiOptions?: WebXREnterExitUIOptions;
  47217. /**
  47218. * When loading teleportation and pointer select, use stable versions instead of latest.
  47219. */
  47220. useStablePlugins?: boolean;
  47221. /**
  47222. * An optional rendering group id that will be set globally for teleportation, pointer selection and default controller meshes
  47223. */
  47224. renderingGroupId?: number;
  47225. /**
  47226. * A list of optional features to init the session with
  47227. * If set to true, all features we support will be added
  47228. */
  47229. optionalFeatures?: boolean | string[];
  47230. }
  47231. /**
  47232. * Default experience which provides a similar setup to the previous webVRExperience
  47233. */
  47234. export class WebXRDefaultExperience {
  47235. /**
  47236. * Base experience
  47237. */
  47238. baseExperience: WebXRExperienceHelper;
  47239. /**
  47240. * Enables ui for entering/exiting xr
  47241. */
  47242. enterExitUI: WebXREnterExitUI;
  47243. /**
  47244. * Input experience extension
  47245. */
  47246. input: WebXRInput;
  47247. /**
  47248. * Enables laser pointer and selection
  47249. */
  47250. pointerSelection: WebXRControllerPointerSelection;
  47251. /**
  47252. * Default target xr should render to
  47253. */
  47254. renderTarget: WebXRRenderTarget;
  47255. /**
  47256. * Enables teleportation
  47257. */
  47258. teleportation: WebXRMotionControllerTeleportation;
  47259. private constructor();
  47260. /**
  47261. * Creates the default xr experience
  47262. * @param scene scene
  47263. * @param options options for basic configuration
  47264. * @returns resulting WebXRDefaultExperience
  47265. */
  47266. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  47267. /**
  47268. * DIsposes of the experience helper
  47269. */
  47270. dispose(): void;
  47271. }
  47272. }
  47273. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  47274. import { Observable } from "babylonjs/Misc/observable";
  47275. import { Nullable } from "babylonjs/types";
  47276. import { Camera } from "babylonjs/Cameras/camera";
  47277. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  47278. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  47279. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  47280. import { Scene } from "babylonjs/scene";
  47281. import { Vector3 } from "babylonjs/Maths/math.vector";
  47282. import { Color3 } from "babylonjs/Maths/math.color";
  47283. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  47284. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47285. import { Mesh } from "babylonjs/Meshes/mesh";
  47286. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  47287. import { EasingFunction } from "babylonjs/Animations/easing";
  47288. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  47289. import "babylonjs/Meshes/Builders/groundBuilder";
  47290. import "babylonjs/Meshes/Builders/torusBuilder";
  47291. import "babylonjs/Meshes/Builders/cylinderBuilder";
  47292. import "babylonjs/Gamepads/gamepadSceneComponent";
  47293. import "babylonjs/Animations/animatable";
  47294. import { WebXRDefaultExperience } from "babylonjs/XR/webXRDefaultExperience";
  47295. /**
  47296. * Options to modify the vr teleportation behavior.
  47297. */
  47298. export interface VRTeleportationOptions {
  47299. /**
  47300. * The name of the mesh which should be used as the teleportation floor. (default: null)
  47301. */
  47302. floorMeshName?: string;
  47303. /**
  47304. * A list of meshes to be used as the teleportation floor. (default: empty)
  47305. */
  47306. floorMeshes?: Mesh[];
  47307. /**
  47308. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  47309. */
  47310. teleportationMode?: number;
  47311. /**
  47312. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  47313. */
  47314. teleportationTime?: number;
  47315. /**
  47316. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  47317. */
  47318. teleportationSpeed?: number;
  47319. /**
  47320. * The easing function used in the animation or null for Linear. (default CircleEase)
  47321. */
  47322. easingFunction?: EasingFunction;
  47323. }
  47324. /**
  47325. * Options to modify the vr experience helper's behavior.
  47326. */
  47327. export interface VRExperienceHelperOptions extends WebVROptions {
  47328. /**
  47329. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  47330. */
  47331. createDeviceOrientationCamera?: boolean;
  47332. /**
  47333. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  47334. */
  47335. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  47336. /**
  47337. * Uses the main button on the controller to toggle the laser casted. (default: true)
  47338. */
  47339. laserToggle?: boolean;
  47340. /**
  47341. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  47342. */
  47343. floorMeshes?: Mesh[];
  47344. /**
  47345. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  47346. */
  47347. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  47348. /**
  47349. * Defines if WebXR should be used instead of WebVR (if available)
  47350. */
  47351. useXR?: boolean;
  47352. }
  47353. /**
  47354. * Event containing information after VR has been entered
  47355. */
  47356. export class OnAfterEnteringVRObservableEvent {
  47357. /**
  47358. * If entering vr was successful
  47359. */
  47360. success: boolean;
  47361. }
  47362. /**
  47363. * Helps to quickly add VR support to an existing scene.
  47364. * See http://doc.babylonjs.com/how_to/webvr_helper
  47365. */
  47366. export class VRExperienceHelper {
  47367. /** Options to modify the vr experience helper's behavior. */
  47368. webVROptions: VRExperienceHelperOptions;
  47369. private _scene;
  47370. private _position;
  47371. private _btnVR;
  47372. private _btnVRDisplayed;
  47373. private _webVRsupported;
  47374. private _webVRready;
  47375. private _webVRrequesting;
  47376. private _webVRpresenting;
  47377. private _hasEnteredVR;
  47378. private _fullscreenVRpresenting;
  47379. private _inputElement;
  47380. private _webVRCamera;
  47381. private _vrDeviceOrientationCamera;
  47382. private _deviceOrientationCamera;
  47383. private _existingCamera;
  47384. private _onKeyDown;
  47385. private _onVrDisplayPresentChange;
  47386. private _onVRDisplayChanged;
  47387. private _onVRRequestPresentStart;
  47388. private _onVRRequestPresentComplete;
  47389. /**
  47390. * 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)
  47391. */
  47392. enableGazeEvenWhenNoPointerLock: boolean;
  47393. /**
  47394. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  47395. */
  47396. exitVROnDoubleTap: boolean;
  47397. /**
  47398. * Observable raised right before entering VR.
  47399. */
  47400. onEnteringVRObservable: Observable<VRExperienceHelper>;
  47401. /**
  47402. * Observable raised when entering VR has completed.
  47403. */
  47404. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  47405. /**
  47406. * Observable raised when exiting VR.
  47407. */
  47408. onExitingVRObservable: Observable<VRExperienceHelper>;
  47409. /**
  47410. * Observable raised when controller mesh is loaded.
  47411. */
  47412. onControllerMeshLoadedObservable: Observable<WebVRController>;
  47413. /** Return this.onEnteringVRObservable
  47414. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  47415. */
  47416. get onEnteringVR(): Observable<VRExperienceHelper>;
  47417. /** Return this.onExitingVRObservable
  47418. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  47419. */
  47420. get onExitingVR(): Observable<VRExperienceHelper>;
  47421. /** Return this.onControllerMeshLoadedObservable
  47422. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  47423. */
  47424. get onControllerMeshLoaded(): Observable<WebVRController>;
  47425. private _rayLength;
  47426. private _useCustomVRButton;
  47427. private _teleportationRequested;
  47428. private _teleportActive;
  47429. private _floorMeshName;
  47430. private _floorMeshesCollection;
  47431. private _teleportationMode;
  47432. private _teleportationTime;
  47433. private _teleportationSpeed;
  47434. private _teleportationEasing;
  47435. private _rotationAllowed;
  47436. private _teleportBackwardsVector;
  47437. private _teleportationTarget;
  47438. private _isDefaultTeleportationTarget;
  47439. private _postProcessMove;
  47440. private _teleportationFillColor;
  47441. private _teleportationBorderColor;
  47442. private _rotationAngle;
  47443. private _haloCenter;
  47444. private _cameraGazer;
  47445. private _padSensibilityUp;
  47446. private _padSensibilityDown;
  47447. private _leftController;
  47448. private _rightController;
  47449. private _gazeColor;
  47450. private _laserColor;
  47451. private _pickedLaserColor;
  47452. private _pickedGazeColor;
  47453. /**
  47454. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  47455. */
  47456. onNewMeshSelected: Observable<AbstractMesh>;
  47457. /**
  47458. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  47459. * This observable will provide the mesh and the controller used to select the mesh
  47460. */
  47461. onMeshSelectedWithController: Observable<{
  47462. mesh: AbstractMesh;
  47463. controller: WebVRController;
  47464. }>;
  47465. /**
  47466. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  47467. */
  47468. onNewMeshPicked: Observable<PickingInfo>;
  47469. private _circleEase;
  47470. /**
  47471. * Observable raised before camera teleportation
  47472. */
  47473. onBeforeCameraTeleport: Observable<Vector3>;
  47474. /**
  47475. * Observable raised after camera teleportation
  47476. */
  47477. onAfterCameraTeleport: Observable<Vector3>;
  47478. /**
  47479. * Observable raised when current selected mesh gets unselected
  47480. */
  47481. onSelectedMeshUnselected: Observable<AbstractMesh>;
  47482. private _raySelectionPredicate;
  47483. /**
  47484. * To be optionaly changed by user to define custom ray selection
  47485. */
  47486. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  47487. /**
  47488. * To be optionaly changed by user to define custom selection logic (after ray selection)
  47489. */
  47490. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  47491. /**
  47492. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  47493. */
  47494. teleportationEnabled: boolean;
  47495. private _defaultHeight;
  47496. private _teleportationInitialized;
  47497. private _interactionsEnabled;
  47498. private _interactionsRequested;
  47499. private _displayGaze;
  47500. private _displayLaserPointer;
  47501. /**
  47502. * The mesh used to display where the user is going to teleport.
  47503. */
  47504. get teleportationTarget(): Mesh;
  47505. /**
  47506. * Sets the mesh to be used to display where the user is going to teleport.
  47507. */
  47508. set teleportationTarget(value: Mesh);
  47509. /**
  47510. * 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
  47511. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  47512. * See http://doc.babylonjs.com/resources/baking_transformations
  47513. */
  47514. get gazeTrackerMesh(): Mesh;
  47515. set gazeTrackerMesh(value: Mesh);
  47516. /**
  47517. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  47518. */
  47519. updateGazeTrackerScale: boolean;
  47520. /**
  47521. * If the gaze trackers color should be updated when selecting meshes
  47522. */
  47523. updateGazeTrackerColor: boolean;
  47524. /**
  47525. * If the controller laser color should be updated when selecting meshes
  47526. */
  47527. updateControllerLaserColor: boolean;
  47528. /**
  47529. * The gaze tracking mesh corresponding to the left controller
  47530. */
  47531. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  47532. /**
  47533. * The gaze tracking mesh corresponding to the right controller
  47534. */
  47535. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  47536. /**
  47537. * If the ray of the gaze should be displayed.
  47538. */
  47539. get displayGaze(): boolean;
  47540. /**
  47541. * Sets if the ray of the gaze should be displayed.
  47542. */
  47543. set displayGaze(value: boolean);
  47544. /**
  47545. * If the ray of the LaserPointer should be displayed.
  47546. */
  47547. get displayLaserPointer(): boolean;
  47548. /**
  47549. * Sets if the ray of the LaserPointer should be displayed.
  47550. */
  47551. set displayLaserPointer(value: boolean);
  47552. /**
  47553. * The deviceOrientationCamera used as the camera when not in VR.
  47554. */
  47555. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  47556. /**
  47557. * Based on the current WebVR support, returns the current VR camera used.
  47558. */
  47559. get currentVRCamera(): Nullable<Camera>;
  47560. /**
  47561. * The webVRCamera which is used when in VR.
  47562. */
  47563. get webVRCamera(): WebVRFreeCamera;
  47564. /**
  47565. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  47566. */
  47567. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  47568. /**
  47569. * The html button that is used to trigger entering into VR.
  47570. */
  47571. get vrButton(): Nullable<HTMLButtonElement>;
  47572. private get _teleportationRequestInitiated();
  47573. /**
  47574. * Defines whether or not Pointer lock should be requested when switching to
  47575. * full screen.
  47576. */
  47577. requestPointerLockOnFullScreen: boolean;
  47578. /**
  47579. * If asking to force XR, this will be populated with the default xr experience
  47580. */
  47581. xr: WebXRDefaultExperience;
  47582. /**
  47583. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  47584. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  47585. */
  47586. xrTestDone: boolean;
  47587. /**
  47588. * Instantiates a VRExperienceHelper.
  47589. * Helps to quickly add VR support to an existing scene.
  47590. * @param scene The scene the VRExperienceHelper belongs to.
  47591. * @param webVROptions Options to modify the vr experience helper's behavior.
  47592. */
  47593. constructor(scene: Scene,
  47594. /** Options to modify the vr experience helper's behavior. */
  47595. webVROptions?: VRExperienceHelperOptions);
  47596. private completeVRInit;
  47597. private _onDefaultMeshLoaded;
  47598. private _onResize;
  47599. private _onFullscreenChange;
  47600. /**
  47601. * Gets a value indicating if we are currently in VR mode.
  47602. */
  47603. get isInVRMode(): boolean;
  47604. private onVrDisplayPresentChange;
  47605. private onVRDisplayChanged;
  47606. private moveButtonToBottomRight;
  47607. private displayVRButton;
  47608. private updateButtonVisibility;
  47609. private _cachedAngularSensibility;
  47610. /**
  47611. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  47612. * Otherwise, will use the fullscreen API.
  47613. */
  47614. enterVR(): void;
  47615. /**
  47616. * Attempt to exit VR, or fullscreen.
  47617. */
  47618. exitVR(): void;
  47619. /**
  47620. * The position of the vr experience helper.
  47621. */
  47622. get position(): Vector3;
  47623. /**
  47624. * Sets the position of the vr experience helper.
  47625. */
  47626. set position(value: Vector3);
  47627. /**
  47628. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  47629. */
  47630. enableInteractions(): void;
  47631. private get _noControllerIsActive();
  47632. private beforeRender;
  47633. private _isTeleportationFloor;
  47634. /**
  47635. * Adds a floor mesh to be used for teleportation.
  47636. * @param floorMesh the mesh to be used for teleportation.
  47637. */
  47638. addFloorMesh(floorMesh: Mesh): void;
  47639. /**
  47640. * Removes a floor mesh from being used for teleportation.
  47641. * @param floorMesh the mesh to be removed.
  47642. */
  47643. removeFloorMesh(floorMesh: Mesh): void;
  47644. /**
  47645. * Enables interactions and teleportation using the VR controllers and gaze.
  47646. * @param vrTeleportationOptions options to modify teleportation behavior.
  47647. */
  47648. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  47649. private _onNewGamepadConnected;
  47650. private _tryEnableInteractionOnController;
  47651. private _onNewGamepadDisconnected;
  47652. private _enableInteractionOnController;
  47653. private _checkTeleportWithRay;
  47654. private _checkRotate;
  47655. private _checkTeleportBackwards;
  47656. private _enableTeleportationOnController;
  47657. private _createTeleportationCircles;
  47658. private _displayTeleportationTarget;
  47659. private _hideTeleportationTarget;
  47660. private _rotateCamera;
  47661. private _moveTeleportationSelectorTo;
  47662. private _workingVector;
  47663. private _workingQuaternion;
  47664. private _workingMatrix;
  47665. /**
  47666. * Time Constant Teleportation Mode
  47667. */
  47668. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  47669. /**
  47670. * Speed Constant Teleportation Mode
  47671. */
  47672. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  47673. /**
  47674. * Teleports the users feet to the desired location
  47675. * @param location The location where the user's feet should be placed
  47676. */
  47677. teleportCamera(location: Vector3): void;
  47678. private _convertNormalToDirectionOfRay;
  47679. private _castRayAndSelectObject;
  47680. private _notifySelectedMeshUnselected;
  47681. /**
  47682. * Permanently set new colors for the laser pointer
  47683. * @param color the new laser color
  47684. * @param pickedColor the new laser color when picked mesh detected
  47685. */
  47686. setLaserColor(color: Color3, pickedColor?: Color3): void;
  47687. /**
  47688. * Set lighting enabled / disabled on the laser pointer of both controllers
  47689. * @param enabled should the lighting be enabled on the laser pointer
  47690. */
  47691. setLaserLightingState(enabled?: boolean): void;
  47692. /**
  47693. * Permanently set new colors for the gaze pointer
  47694. * @param color the new gaze color
  47695. * @param pickedColor the new gaze color when picked mesh detected
  47696. */
  47697. setGazeColor(color: Color3, pickedColor?: Color3): void;
  47698. /**
  47699. * Sets the color of the laser ray from the vr controllers.
  47700. * @param color new color for the ray.
  47701. */
  47702. changeLaserColor(color: Color3): void;
  47703. /**
  47704. * Sets the color of the ray from the vr headsets gaze.
  47705. * @param color new color for the ray.
  47706. */
  47707. changeGazeColor(color: Color3): void;
  47708. /**
  47709. * Exits VR and disposes of the vr experience helper
  47710. */
  47711. dispose(): void;
  47712. /**
  47713. * Gets the name of the VRExperienceHelper class
  47714. * @returns "VRExperienceHelper"
  47715. */
  47716. getClassName(): string;
  47717. }
  47718. }
  47719. declare module "babylonjs/Cameras/VR/index" {
  47720. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  47721. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  47722. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  47723. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  47724. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  47725. export * from "babylonjs/Cameras/VR/webVRCamera";
  47726. }
  47727. declare module "babylonjs/Cameras/RigModes/index" {
  47728. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  47729. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  47730. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  47731. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  47732. }
  47733. declare module "babylonjs/Cameras/index" {
  47734. export * from "babylonjs/Cameras/Inputs/index";
  47735. export * from "babylonjs/Cameras/cameraInputsManager";
  47736. export * from "babylonjs/Cameras/camera";
  47737. export * from "babylonjs/Cameras/targetCamera";
  47738. export * from "babylonjs/Cameras/freeCamera";
  47739. export * from "babylonjs/Cameras/freeCameraInputsManager";
  47740. export * from "babylonjs/Cameras/touchCamera";
  47741. export * from "babylonjs/Cameras/arcRotateCamera";
  47742. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  47743. export * from "babylonjs/Cameras/deviceOrientationCamera";
  47744. export * from "babylonjs/Cameras/flyCamera";
  47745. export * from "babylonjs/Cameras/flyCameraInputsManager";
  47746. export * from "babylonjs/Cameras/followCamera";
  47747. export * from "babylonjs/Cameras/followCameraInputsManager";
  47748. export * from "babylonjs/Cameras/gamepadCamera";
  47749. export * from "babylonjs/Cameras/Stereoscopic/index";
  47750. export * from "babylonjs/Cameras/universalCamera";
  47751. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  47752. export * from "babylonjs/Cameras/VR/index";
  47753. export * from "babylonjs/Cameras/RigModes/index";
  47754. }
  47755. declare module "babylonjs/Collisions/index" {
  47756. export * from "babylonjs/Collisions/collider";
  47757. export * from "babylonjs/Collisions/collisionCoordinator";
  47758. export * from "babylonjs/Collisions/pickingInfo";
  47759. export * from "babylonjs/Collisions/intersectionInfo";
  47760. export * from "babylonjs/Collisions/meshCollisionData";
  47761. }
  47762. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  47763. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  47764. import { Vector3 } from "babylonjs/Maths/math.vector";
  47765. import { Ray } from "babylonjs/Culling/ray";
  47766. import { Plane } from "babylonjs/Maths/math.plane";
  47767. /**
  47768. * Contains an array of blocks representing the octree
  47769. */
  47770. export interface IOctreeContainer<T> {
  47771. /**
  47772. * Blocks within the octree
  47773. */
  47774. blocks: Array<OctreeBlock<T>>;
  47775. }
  47776. /**
  47777. * Class used to store a cell in an octree
  47778. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  47779. */
  47780. export class OctreeBlock<T> {
  47781. /**
  47782. * Gets the content of the current block
  47783. */
  47784. entries: T[];
  47785. /**
  47786. * Gets the list of block children
  47787. */
  47788. blocks: Array<OctreeBlock<T>>;
  47789. private _depth;
  47790. private _maxDepth;
  47791. private _capacity;
  47792. private _minPoint;
  47793. private _maxPoint;
  47794. private _boundingVectors;
  47795. private _creationFunc;
  47796. /**
  47797. * Creates a new block
  47798. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  47799. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  47800. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  47801. * @param depth defines the current depth of this block in the octree
  47802. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  47803. * @param creationFunc defines a callback to call when an element is added to the block
  47804. */
  47805. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  47806. /**
  47807. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  47808. */
  47809. get capacity(): number;
  47810. /**
  47811. * Gets the minimum vector (in world space) of the block's bounding box
  47812. */
  47813. get minPoint(): Vector3;
  47814. /**
  47815. * Gets the maximum vector (in world space) of the block's bounding box
  47816. */
  47817. get maxPoint(): Vector3;
  47818. /**
  47819. * Add a new element to this block
  47820. * @param entry defines the element to add
  47821. */
  47822. addEntry(entry: T): void;
  47823. /**
  47824. * Remove an element from this block
  47825. * @param entry defines the element to remove
  47826. */
  47827. removeEntry(entry: T): void;
  47828. /**
  47829. * Add an array of elements to this block
  47830. * @param entries defines the array of elements to add
  47831. */
  47832. addEntries(entries: T[]): void;
  47833. /**
  47834. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  47835. * @param frustumPlanes defines the frustum planes to test
  47836. * @param selection defines the array to store current content if selection is positive
  47837. * @param allowDuplicate defines if the selection array can contains duplicated entries
  47838. */
  47839. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  47840. /**
  47841. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  47842. * @param sphereCenter defines the bounding sphere center
  47843. * @param sphereRadius defines the bounding sphere radius
  47844. * @param selection defines the array to store current content if selection is positive
  47845. * @param allowDuplicate defines if the selection array can contains duplicated entries
  47846. */
  47847. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  47848. /**
  47849. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  47850. * @param ray defines the ray to test with
  47851. * @param selection defines the array to store current content if selection is positive
  47852. */
  47853. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  47854. /**
  47855. * Subdivide the content into child blocks (this block will then be empty)
  47856. */
  47857. createInnerBlocks(): void;
  47858. /**
  47859. * @hidden
  47860. */
  47861. 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;
  47862. }
  47863. }
  47864. declare module "babylonjs/Culling/Octrees/octree" {
  47865. import { SmartArray } from "babylonjs/Misc/smartArray";
  47866. import { Vector3 } from "babylonjs/Maths/math.vector";
  47867. import { SubMesh } from "babylonjs/Meshes/subMesh";
  47868. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47869. import { Ray } from "babylonjs/Culling/ray";
  47870. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  47871. import { Plane } from "babylonjs/Maths/math.plane";
  47872. /**
  47873. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  47874. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  47875. */
  47876. export class Octree<T> {
  47877. /** 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.) */
  47878. maxDepth: number;
  47879. /**
  47880. * Blocks within the octree containing objects
  47881. */
  47882. blocks: Array<OctreeBlock<T>>;
  47883. /**
  47884. * Content stored in the octree
  47885. */
  47886. dynamicContent: T[];
  47887. private _maxBlockCapacity;
  47888. private _selectionContent;
  47889. private _creationFunc;
  47890. /**
  47891. * Creates a octree
  47892. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  47893. * @param creationFunc function to be used to instatiate the octree
  47894. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  47895. * @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.)
  47896. */
  47897. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  47898. /** 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.) */
  47899. maxDepth?: number);
  47900. /**
  47901. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  47902. * @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);
  47903. * @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);
  47904. * @param entries meshes to be added to the octree blocks
  47905. */
  47906. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  47907. /**
  47908. * Adds a mesh to the octree
  47909. * @param entry Mesh to add to the octree
  47910. */
  47911. addMesh(entry: T): void;
  47912. /**
  47913. * Remove an element from the octree
  47914. * @param entry defines the element to remove
  47915. */
  47916. removeMesh(entry: T): void;
  47917. /**
  47918. * Selects an array of meshes within the frustum
  47919. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  47920. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  47921. * @returns array of meshes within the frustum
  47922. */
  47923. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  47924. /**
  47925. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  47926. * @param sphereCenter defines the bounding sphere center
  47927. * @param sphereRadius defines the bounding sphere radius
  47928. * @param allowDuplicate defines if the selection array can contains duplicated entries
  47929. * @returns an array of objects that intersect the sphere
  47930. */
  47931. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  47932. /**
  47933. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  47934. * @param ray defines the ray to test with
  47935. * @returns array of intersected objects
  47936. */
  47937. intersectsRay(ray: Ray): SmartArray<T>;
  47938. /**
  47939. * Adds a mesh into the octree block if it intersects the block
  47940. */
  47941. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  47942. /**
  47943. * Adds a submesh into the octree block if it intersects the block
  47944. */
  47945. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  47946. }
  47947. }
  47948. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  47949. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  47950. import { Scene } from "babylonjs/scene";
  47951. import { SubMesh } from "babylonjs/Meshes/subMesh";
  47952. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47953. import { Ray } from "babylonjs/Culling/ray";
  47954. import { Octree } from "babylonjs/Culling/Octrees/octree";
  47955. import { Collider } from "babylonjs/Collisions/collider";
  47956. module "babylonjs/scene" {
  47957. interface Scene {
  47958. /**
  47959. * @hidden
  47960. * Backing Filed
  47961. */
  47962. _selectionOctree: Octree<AbstractMesh>;
  47963. /**
  47964. * Gets the octree used to boost mesh selection (picking)
  47965. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  47966. */
  47967. selectionOctree: Octree<AbstractMesh>;
  47968. /**
  47969. * Creates or updates the octree used to boost selection (picking)
  47970. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  47971. * @param maxCapacity defines the maximum capacity per leaf
  47972. * @param maxDepth defines the maximum depth of the octree
  47973. * @returns an octree of AbstractMesh
  47974. */
  47975. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  47976. }
  47977. }
  47978. module "babylonjs/Meshes/abstractMesh" {
  47979. interface AbstractMesh {
  47980. /**
  47981. * @hidden
  47982. * Backing Field
  47983. */
  47984. _submeshesOctree: Octree<SubMesh>;
  47985. /**
  47986. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  47987. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  47988. * @param maxCapacity defines the maximum size of each block (64 by default)
  47989. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  47990. * @returns the new octree
  47991. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  47992. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  47993. */
  47994. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  47995. }
  47996. }
  47997. /**
  47998. * Defines the octree scene component responsible to manage any octrees
  47999. * in a given scene.
  48000. */
  48001. export class OctreeSceneComponent {
  48002. /**
  48003. * The component name help to identify the component in the list of scene components.
  48004. */
  48005. readonly name: string;
  48006. /**
  48007. * The scene the component belongs to.
  48008. */
  48009. scene: Scene;
  48010. /**
  48011. * Indicates if the meshes have been checked to make sure they are isEnabled()
  48012. */
  48013. readonly checksIsEnabled: boolean;
  48014. /**
  48015. * Creates a new instance of the component for the given scene
  48016. * @param scene Defines the scene to register the component in
  48017. */
  48018. constructor(scene: Scene);
  48019. /**
  48020. * Registers the component in a given scene
  48021. */
  48022. register(): void;
  48023. /**
  48024. * Return the list of active meshes
  48025. * @returns the list of active meshes
  48026. */
  48027. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  48028. /**
  48029. * Return the list of active sub meshes
  48030. * @param mesh The mesh to get the candidates sub meshes from
  48031. * @returns the list of active sub meshes
  48032. */
  48033. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  48034. private _tempRay;
  48035. /**
  48036. * Return the list of sub meshes intersecting with a given local ray
  48037. * @param mesh defines the mesh to find the submesh for
  48038. * @param localRay defines the ray in local space
  48039. * @returns the list of intersecting sub meshes
  48040. */
  48041. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  48042. /**
  48043. * Return the list of sub meshes colliding with a collider
  48044. * @param mesh defines the mesh to find the submesh for
  48045. * @param collider defines the collider to evaluate the collision against
  48046. * @returns the list of colliding sub meshes
  48047. */
  48048. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  48049. /**
  48050. * Rebuilds the elements related to this component in case of
  48051. * context lost for instance.
  48052. */
  48053. rebuild(): void;
  48054. /**
  48055. * Disposes the component and the associated ressources.
  48056. */
  48057. dispose(): void;
  48058. }
  48059. }
  48060. declare module "babylonjs/Culling/Octrees/index" {
  48061. export * from "babylonjs/Culling/Octrees/octree";
  48062. export * from "babylonjs/Culling/Octrees/octreeBlock";
  48063. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  48064. }
  48065. declare module "babylonjs/Culling/index" {
  48066. export * from "babylonjs/Culling/boundingBox";
  48067. export * from "babylonjs/Culling/boundingInfo";
  48068. export * from "babylonjs/Culling/boundingSphere";
  48069. export * from "babylonjs/Culling/Octrees/index";
  48070. export * from "babylonjs/Culling/ray";
  48071. }
  48072. declare module "babylonjs/Gizmos/gizmo" {
  48073. import { Nullable } from "babylonjs/types";
  48074. import { IDisposable } from "babylonjs/scene";
  48075. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48076. import { Mesh } from "babylonjs/Meshes/mesh";
  48077. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  48078. /**
  48079. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  48080. */
  48081. export class Gizmo implements IDisposable {
  48082. /** The utility layer the gizmo will be added to */
  48083. gizmoLayer: UtilityLayerRenderer;
  48084. /**
  48085. * The root mesh of the gizmo
  48086. */
  48087. _rootMesh: Mesh;
  48088. private _attachedMesh;
  48089. /**
  48090. * Ratio for the scale of the gizmo (Default: 1)
  48091. */
  48092. scaleRatio: number;
  48093. /**
  48094. * If a custom mesh has been set (Default: false)
  48095. */
  48096. protected _customMeshSet: boolean;
  48097. /**
  48098. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  48099. * * When set, interactions will be enabled
  48100. */
  48101. get attachedMesh(): Nullable<AbstractMesh>;
  48102. set attachedMesh(value: Nullable<AbstractMesh>);
  48103. /**
  48104. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  48105. * @param mesh The mesh to replace the default mesh of the gizmo
  48106. */
  48107. setCustomMesh(mesh: Mesh): void;
  48108. /**
  48109. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  48110. */
  48111. updateGizmoRotationToMatchAttachedMesh: boolean;
  48112. /**
  48113. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  48114. */
  48115. updateGizmoPositionToMatchAttachedMesh: boolean;
  48116. /**
  48117. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  48118. */
  48119. updateScale: boolean;
  48120. protected _interactionsEnabled: boolean;
  48121. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  48122. private _beforeRenderObserver;
  48123. private _tempVector;
  48124. /**
  48125. * Creates a gizmo
  48126. * @param gizmoLayer The utility layer the gizmo will be added to
  48127. */
  48128. constructor(
  48129. /** The utility layer the gizmo will be added to */
  48130. gizmoLayer?: UtilityLayerRenderer);
  48131. /**
  48132. * Updates the gizmo to match the attached mesh's position/rotation
  48133. */
  48134. protected _update(): void;
  48135. /**
  48136. * Disposes of the gizmo
  48137. */
  48138. dispose(): void;
  48139. }
  48140. }
  48141. declare module "babylonjs/Gizmos/planeDragGizmo" {
  48142. import { Observable } from "babylonjs/Misc/observable";
  48143. import { Nullable } from "babylonjs/types";
  48144. import { Vector3 } from "babylonjs/Maths/math.vector";
  48145. import { Color3 } from "babylonjs/Maths/math.color";
  48146. import { TransformNode } from "babylonjs/Meshes/transformNode";
  48147. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48148. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  48149. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  48150. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  48151. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  48152. import { Scene } from "babylonjs/scene";
  48153. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  48154. /**
  48155. * Single plane drag gizmo
  48156. */
  48157. export class PlaneDragGizmo extends Gizmo {
  48158. /**
  48159. * Drag behavior responsible for the gizmos dragging interactions
  48160. */
  48161. dragBehavior: PointerDragBehavior;
  48162. private _pointerObserver;
  48163. /**
  48164. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  48165. */
  48166. snapDistance: number;
  48167. /**
  48168. * Event that fires each time the gizmo snaps to a new location.
  48169. * * snapDistance is the the change in distance
  48170. */
  48171. onSnapObservable: Observable<{
  48172. snapDistance: number;
  48173. }>;
  48174. private _plane;
  48175. private _coloredMaterial;
  48176. private _hoverMaterial;
  48177. private _isEnabled;
  48178. private _parent;
  48179. /** @hidden */
  48180. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  48181. /** @hidden */
  48182. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  48183. /**
  48184. * Creates a PlaneDragGizmo
  48185. * @param gizmoLayer The utility layer the gizmo will be added to
  48186. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  48187. * @param color The color of the gizmo
  48188. */
  48189. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  48190. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  48191. /**
  48192. * If the gizmo is enabled
  48193. */
  48194. set isEnabled(value: boolean);
  48195. get isEnabled(): boolean;
  48196. /**
  48197. * Disposes of the gizmo
  48198. */
  48199. dispose(): void;
  48200. }
  48201. }
  48202. declare module "babylonjs/Gizmos/positionGizmo" {
  48203. import { Observable } from "babylonjs/Misc/observable";
  48204. import { Nullable } from "babylonjs/types";
  48205. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48206. import { Mesh } from "babylonjs/Meshes/mesh";
  48207. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  48208. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  48209. import { PlaneDragGizmo } from "babylonjs/Gizmos/planeDragGizmo";
  48210. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  48211. /**
  48212. * Gizmo that enables dragging a mesh along 3 axis
  48213. */
  48214. export class PositionGizmo extends Gizmo {
  48215. /**
  48216. * Internal gizmo used for interactions on the x axis
  48217. */
  48218. xGizmo: AxisDragGizmo;
  48219. /**
  48220. * Internal gizmo used for interactions on the y axis
  48221. */
  48222. yGizmo: AxisDragGizmo;
  48223. /**
  48224. * Internal gizmo used for interactions on the z axis
  48225. */
  48226. zGizmo: AxisDragGizmo;
  48227. /**
  48228. * Internal gizmo used for interactions on the yz plane
  48229. */
  48230. xPlaneGizmo: PlaneDragGizmo;
  48231. /**
  48232. * Internal gizmo used for interactions on the xz plane
  48233. */
  48234. yPlaneGizmo: PlaneDragGizmo;
  48235. /**
  48236. * Internal gizmo used for interactions on the xy plane
  48237. */
  48238. zPlaneGizmo: PlaneDragGizmo;
  48239. /**
  48240. * private variables
  48241. */
  48242. private _meshAttached;
  48243. private _updateGizmoRotationToMatchAttachedMesh;
  48244. private _snapDistance;
  48245. private _scaleRatio;
  48246. /** Fires an event when any of it's sub gizmos are dragged */
  48247. onDragStartObservable: Observable<unknown>;
  48248. /** Fires an event when any of it's sub gizmos are released from dragging */
  48249. onDragEndObservable: Observable<unknown>;
  48250. /**
  48251. * If set to true, planar drag is enabled
  48252. */
  48253. private _planarGizmoEnabled;
  48254. get attachedMesh(): Nullable<AbstractMesh>;
  48255. set attachedMesh(mesh: Nullable<AbstractMesh>);
  48256. /**
  48257. * Creates a PositionGizmo
  48258. * @param gizmoLayer The utility layer the gizmo will be added to
  48259. */
  48260. constructor(gizmoLayer?: UtilityLayerRenderer);
  48261. /**
  48262. * If the planar drag gizmo is enabled
  48263. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  48264. */
  48265. set planarGizmoEnabled(value: boolean);
  48266. get planarGizmoEnabled(): boolean;
  48267. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  48268. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  48269. /**
  48270. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  48271. */
  48272. set snapDistance(value: number);
  48273. get snapDistance(): number;
  48274. /**
  48275. * Ratio for the scale of the gizmo (Default: 1)
  48276. */
  48277. set scaleRatio(value: number);
  48278. get scaleRatio(): number;
  48279. /**
  48280. * Disposes of the gizmo
  48281. */
  48282. dispose(): void;
  48283. /**
  48284. * CustomMeshes are not supported by this gizmo
  48285. * @param mesh The mesh to replace the default mesh of the gizmo
  48286. */
  48287. setCustomMesh(mesh: Mesh): void;
  48288. }
  48289. }
  48290. declare module "babylonjs/Gizmos/axisDragGizmo" {
  48291. import { Observable } from "babylonjs/Misc/observable";
  48292. import { Nullable } from "babylonjs/types";
  48293. import { Vector3 } from "babylonjs/Maths/math.vector";
  48294. import { TransformNode } from "babylonjs/Meshes/transformNode";
  48295. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48296. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  48297. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  48298. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  48299. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  48300. import { Scene } from "babylonjs/scene";
  48301. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  48302. import { Color3 } from "babylonjs/Maths/math.color";
  48303. /**
  48304. * Single axis drag gizmo
  48305. */
  48306. export class AxisDragGizmo extends Gizmo {
  48307. /**
  48308. * Drag behavior responsible for the gizmos dragging interactions
  48309. */
  48310. dragBehavior: PointerDragBehavior;
  48311. private _pointerObserver;
  48312. /**
  48313. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  48314. */
  48315. snapDistance: number;
  48316. /**
  48317. * Event that fires each time the gizmo snaps to a new location.
  48318. * * snapDistance is the the change in distance
  48319. */
  48320. onSnapObservable: Observable<{
  48321. snapDistance: number;
  48322. }>;
  48323. private _isEnabled;
  48324. private _parent;
  48325. private _arrow;
  48326. private _coloredMaterial;
  48327. private _hoverMaterial;
  48328. /** @hidden */
  48329. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  48330. /** @hidden */
  48331. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  48332. /**
  48333. * Creates an AxisDragGizmo
  48334. * @param gizmoLayer The utility layer the gizmo will be added to
  48335. * @param dragAxis The axis which the gizmo will be able to drag on
  48336. * @param color The color of the gizmo
  48337. */
  48338. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  48339. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  48340. /**
  48341. * If the gizmo is enabled
  48342. */
  48343. set isEnabled(value: boolean);
  48344. get isEnabled(): boolean;
  48345. /**
  48346. * Disposes of the gizmo
  48347. */
  48348. dispose(): void;
  48349. }
  48350. }
  48351. declare module "babylonjs/Debug/axesViewer" {
  48352. import { Vector3 } from "babylonjs/Maths/math.vector";
  48353. import { Nullable } from "babylonjs/types";
  48354. import { Scene } from "babylonjs/scene";
  48355. import { TransformNode } from "babylonjs/Meshes/transformNode";
  48356. /**
  48357. * The Axes viewer will show 3 axes in a specific point in space
  48358. */
  48359. export class AxesViewer {
  48360. private _xAxis;
  48361. private _yAxis;
  48362. private _zAxis;
  48363. private _scaleLinesFactor;
  48364. private _instanced;
  48365. /**
  48366. * Gets the hosting scene
  48367. */
  48368. scene: Scene;
  48369. /**
  48370. * Gets or sets a number used to scale line length
  48371. */
  48372. scaleLines: number;
  48373. /** Gets the node hierarchy used to render x-axis */
  48374. get xAxis(): TransformNode;
  48375. /** Gets the node hierarchy used to render y-axis */
  48376. get yAxis(): TransformNode;
  48377. /** Gets the node hierarchy used to render z-axis */
  48378. get zAxis(): TransformNode;
  48379. /**
  48380. * Creates a new AxesViewer
  48381. * @param scene defines the hosting scene
  48382. * @param scaleLines defines a number used to scale line length (1 by default)
  48383. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  48384. * @param xAxis defines the node hierarchy used to render the x-axis
  48385. * @param yAxis defines the node hierarchy used to render the y-axis
  48386. * @param zAxis defines the node hierarchy used to render the z-axis
  48387. */
  48388. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  48389. /**
  48390. * Force the viewer to update
  48391. * @param position defines the position of the viewer
  48392. * @param xaxis defines the x axis of the viewer
  48393. * @param yaxis defines the y axis of the viewer
  48394. * @param zaxis defines the z axis of the viewer
  48395. */
  48396. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  48397. /**
  48398. * Creates an instance of this axes viewer.
  48399. * @returns a new axes viewer with instanced meshes
  48400. */
  48401. createInstance(): AxesViewer;
  48402. /** Releases resources */
  48403. dispose(): void;
  48404. private static _SetRenderingGroupId;
  48405. }
  48406. }
  48407. declare module "babylonjs/Debug/boneAxesViewer" {
  48408. import { Nullable } from "babylonjs/types";
  48409. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  48410. import { Vector3 } from "babylonjs/Maths/math.vector";
  48411. import { Mesh } from "babylonjs/Meshes/mesh";
  48412. import { Bone } from "babylonjs/Bones/bone";
  48413. import { Scene } from "babylonjs/scene";
  48414. /**
  48415. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  48416. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  48417. */
  48418. export class BoneAxesViewer extends AxesViewer {
  48419. /**
  48420. * Gets or sets the target mesh where to display the axes viewer
  48421. */
  48422. mesh: Nullable<Mesh>;
  48423. /**
  48424. * Gets or sets the target bone where to display the axes viewer
  48425. */
  48426. bone: Nullable<Bone>;
  48427. /** Gets current position */
  48428. pos: Vector3;
  48429. /** Gets direction of X axis */
  48430. xaxis: Vector3;
  48431. /** Gets direction of Y axis */
  48432. yaxis: Vector3;
  48433. /** Gets direction of Z axis */
  48434. zaxis: Vector3;
  48435. /**
  48436. * Creates a new BoneAxesViewer
  48437. * @param scene defines the hosting scene
  48438. * @param bone defines the target bone
  48439. * @param mesh defines the target mesh
  48440. * @param scaleLines defines a scaling factor for line length (1 by default)
  48441. */
  48442. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  48443. /**
  48444. * Force the viewer to update
  48445. */
  48446. update(): void;
  48447. /** Releases resources */
  48448. dispose(): void;
  48449. }
  48450. }
  48451. declare module "babylonjs/Debug/debugLayer" {
  48452. import { Scene } from "babylonjs/scene";
  48453. /**
  48454. * Interface used to define scene explorer extensibility option
  48455. */
  48456. export interface IExplorerExtensibilityOption {
  48457. /**
  48458. * Define the option label
  48459. */
  48460. label: string;
  48461. /**
  48462. * Defines the action to execute on click
  48463. */
  48464. action: (entity: any) => void;
  48465. }
  48466. /**
  48467. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  48468. */
  48469. export interface IExplorerExtensibilityGroup {
  48470. /**
  48471. * Defines a predicate to test if a given type mut be extended
  48472. */
  48473. predicate: (entity: any) => boolean;
  48474. /**
  48475. * Gets the list of options added to a type
  48476. */
  48477. entries: IExplorerExtensibilityOption[];
  48478. }
  48479. /**
  48480. * Interface used to define the options to use to create the Inspector
  48481. */
  48482. export interface IInspectorOptions {
  48483. /**
  48484. * Display in overlay mode (default: false)
  48485. */
  48486. overlay?: boolean;
  48487. /**
  48488. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  48489. */
  48490. globalRoot?: HTMLElement;
  48491. /**
  48492. * Display the Scene explorer
  48493. */
  48494. showExplorer?: boolean;
  48495. /**
  48496. * Display the property inspector
  48497. */
  48498. showInspector?: boolean;
  48499. /**
  48500. * Display in embed mode (both panes on the right)
  48501. */
  48502. embedMode?: boolean;
  48503. /**
  48504. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  48505. */
  48506. handleResize?: boolean;
  48507. /**
  48508. * Allow the panes to popup (default: true)
  48509. */
  48510. enablePopup?: boolean;
  48511. /**
  48512. * Allow the panes to be closed by users (default: true)
  48513. */
  48514. enableClose?: boolean;
  48515. /**
  48516. * Optional list of extensibility entries
  48517. */
  48518. explorerExtensibility?: IExplorerExtensibilityGroup[];
  48519. /**
  48520. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  48521. */
  48522. inspectorURL?: string;
  48523. /**
  48524. * Optional initial tab (default to DebugLayerTab.Properties)
  48525. */
  48526. initialTab?: DebugLayerTab;
  48527. }
  48528. module "babylonjs/scene" {
  48529. interface Scene {
  48530. /**
  48531. * @hidden
  48532. * Backing field
  48533. */
  48534. _debugLayer: DebugLayer;
  48535. /**
  48536. * Gets the debug layer (aka Inspector) associated with the scene
  48537. * @see http://doc.babylonjs.com/features/playground_debuglayer
  48538. */
  48539. debugLayer: DebugLayer;
  48540. }
  48541. }
  48542. /**
  48543. * Enum of inspector action tab
  48544. */
  48545. export enum DebugLayerTab {
  48546. /**
  48547. * Properties tag (default)
  48548. */
  48549. Properties = 0,
  48550. /**
  48551. * Debug tab
  48552. */
  48553. Debug = 1,
  48554. /**
  48555. * Statistics tab
  48556. */
  48557. Statistics = 2,
  48558. /**
  48559. * Tools tab
  48560. */
  48561. Tools = 3,
  48562. /**
  48563. * Settings tab
  48564. */
  48565. Settings = 4
  48566. }
  48567. /**
  48568. * The debug layer (aka Inspector) is the go to tool in order to better understand
  48569. * what is happening in your scene
  48570. * @see http://doc.babylonjs.com/features/playground_debuglayer
  48571. */
  48572. export class DebugLayer {
  48573. /**
  48574. * Define the url to get the inspector script from.
  48575. * By default it uses the babylonjs CDN.
  48576. * @ignoreNaming
  48577. */
  48578. static InspectorURL: string;
  48579. private _scene;
  48580. private BJSINSPECTOR;
  48581. private _onPropertyChangedObservable?;
  48582. /**
  48583. * Observable triggered when a property is changed through the inspector.
  48584. */
  48585. get onPropertyChangedObservable(): any;
  48586. /**
  48587. * Instantiates a new debug layer.
  48588. * The debug layer (aka Inspector) is the go to tool in order to better understand
  48589. * what is happening in your scene
  48590. * @see http://doc.babylonjs.com/features/playground_debuglayer
  48591. * @param scene Defines the scene to inspect
  48592. */
  48593. constructor(scene: Scene);
  48594. /** Creates the inspector window. */
  48595. private _createInspector;
  48596. /**
  48597. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  48598. * @param entity defines the entity to select
  48599. * @param lineContainerTitle defines the specific block to highlight
  48600. */
  48601. select(entity: any, lineContainerTitle?: string): void;
  48602. /** Get the inspector from bundle or global */
  48603. private _getGlobalInspector;
  48604. /**
  48605. * Get if the inspector is visible or not.
  48606. * @returns true if visible otherwise, false
  48607. */
  48608. isVisible(): boolean;
  48609. /**
  48610. * Hide the inspector and close its window.
  48611. */
  48612. hide(): void;
  48613. /**
  48614. * Update the scene in the inspector
  48615. */
  48616. setAsActiveScene(): void;
  48617. /**
  48618. * Launch the debugLayer.
  48619. * @param config Define the configuration of the inspector
  48620. * @return a promise fulfilled when the debug layer is visible
  48621. */
  48622. show(config?: IInspectorOptions): Promise<DebugLayer>;
  48623. }
  48624. }
  48625. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  48626. import { Nullable } from "babylonjs/types";
  48627. import { Scene } from "babylonjs/scene";
  48628. import { Vector4 } from "babylonjs/Maths/math.vector";
  48629. import { Color4 } from "babylonjs/Maths/math.color";
  48630. import { Mesh } from "babylonjs/Meshes/mesh";
  48631. /**
  48632. * Class containing static functions to help procedurally build meshes
  48633. */
  48634. export class BoxBuilder {
  48635. /**
  48636. * Creates a box mesh
  48637. * * The parameter `size` sets the size (float) of each box side (default 1)
  48638. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  48639. * * 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)
  48640. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  48641. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48642. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  48643. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48644. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  48645. * @param name defines the name of the mesh
  48646. * @param options defines the options used to create the mesh
  48647. * @param scene defines the hosting scene
  48648. * @returns the box mesh
  48649. */
  48650. static CreateBox(name: string, options: {
  48651. size?: number;
  48652. width?: number;
  48653. height?: number;
  48654. depth?: number;
  48655. faceUV?: Vector4[];
  48656. faceColors?: Color4[];
  48657. sideOrientation?: number;
  48658. frontUVs?: Vector4;
  48659. backUVs?: Vector4;
  48660. wrap?: boolean;
  48661. topBaseAt?: number;
  48662. bottomBaseAt?: number;
  48663. updatable?: boolean;
  48664. }, scene?: Nullable<Scene>): Mesh;
  48665. }
  48666. }
  48667. declare module "babylonjs/Debug/physicsViewer" {
  48668. import { Nullable } from "babylonjs/types";
  48669. import { Scene } from "babylonjs/scene";
  48670. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48671. import { Mesh } from "babylonjs/Meshes/mesh";
  48672. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  48673. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  48674. /**
  48675. * Used to show the physics impostor around the specific mesh
  48676. */
  48677. export class PhysicsViewer {
  48678. /** @hidden */
  48679. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  48680. /** @hidden */
  48681. protected _meshes: Array<Nullable<AbstractMesh>>;
  48682. /** @hidden */
  48683. protected _scene: Nullable<Scene>;
  48684. /** @hidden */
  48685. protected _numMeshes: number;
  48686. /** @hidden */
  48687. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  48688. private _renderFunction;
  48689. private _utilityLayer;
  48690. private _debugBoxMesh;
  48691. private _debugSphereMesh;
  48692. private _debugCylinderMesh;
  48693. private _debugMaterial;
  48694. private _debugMeshMeshes;
  48695. /**
  48696. * Creates a new PhysicsViewer
  48697. * @param scene defines the hosting scene
  48698. */
  48699. constructor(scene: Scene);
  48700. /** @hidden */
  48701. protected _updateDebugMeshes(): void;
  48702. /**
  48703. * Renders a specified physic impostor
  48704. * @param impostor defines the impostor to render
  48705. * @param targetMesh defines the mesh represented by the impostor
  48706. * @returns the new debug mesh used to render the impostor
  48707. */
  48708. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  48709. /**
  48710. * Hides a specified physic impostor
  48711. * @param impostor defines the impostor to hide
  48712. */
  48713. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  48714. private _getDebugMaterial;
  48715. private _getDebugBoxMesh;
  48716. private _getDebugSphereMesh;
  48717. private _getDebugCylinderMesh;
  48718. private _getDebugMeshMesh;
  48719. private _getDebugMesh;
  48720. /** Releases all resources */
  48721. dispose(): void;
  48722. }
  48723. }
  48724. declare module "babylonjs/Debug/rayHelper" {
  48725. import { Nullable } from "babylonjs/types";
  48726. import { Ray } from "babylonjs/Culling/ray";
  48727. import { Vector3 } from "babylonjs/Maths/math.vector";
  48728. import { Color3 } from "babylonjs/Maths/math.color";
  48729. import { Scene } from "babylonjs/scene";
  48730. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48731. import "babylonjs/Meshes/Builders/linesBuilder";
  48732. /**
  48733. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  48734. * in order to better appreciate the issue one might have.
  48735. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  48736. */
  48737. export class RayHelper {
  48738. /**
  48739. * Defines the ray we are currently tryin to visualize.
  48740. */
  48741. ray: Nullable<Ray>;
  48742. private _renderPoints;
  48743. private _renderLine;
  48744. private _renderFunction;
  48745. private _scene;
  48746. private _updateToMeshFunction;
  48747. private _attachedToMesh;
  48748. private _meshSpaceDirection;
  48749. private _meshSpaceOrigin;
  48750. /**
  48751. * Helper function to create a colored helper in a scene in one line.
  48752. * @param ray Defines the ray we are currently tryin to visualize
  48753. * @param scene Defines the scene the ray is used in
  48754. * @param color Defines the color we want to see the ray in
  48755. * @returns The newly created ray helper.
  48756. */
  48757. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  48758. /**
  48759. * Instantiate a new ray helper.
  48760. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  48761. * in order to better appreciate the issue one might have.
  48762. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  48763. * @param ray Defines the ray we are currently tryin to visualize
  48764. */
  48765. constructor(ray: Ray);
  48766. /**
  48767. * Shows the ray we are willing to debug.
  48768. * @param scene Defines the scene the ray needs to be rendered in
  48769. * @param color Defines the color the ray needs to be rendered in
  48770. */
  48771. show(scene: Scene, color?: Color3): void;
  48772. /**
  48773. * Hides the ray we are debugging.
  48774. */
  48775. hide(): void;
  48776. private _render;
  48777. /**
  48778. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  48779. * @param mesh Defines the mesh we want the helper attached to
  48780. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  48781. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  48782. * @param length Defines the length of the ray
  48783. */
  48784. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  48785. /**
  48786. * Detach the ray helper from the mesh it has previously been attached to.
  48787. */
  48788. detachFromMesh(): void;
  48789. private _updateToMesh;
  48790. /**
  48791. * Dispose the helper and release its associated resources.
  48792. */
  48793. dispose(): void;
  48794. }
  48795. }
  48796. declare module "babylonjs/Debug/skeletonViewer" {
  48797. import { Color3 } from "babylonjs/Maths/math.color";
  48798. import { Scene } from "babylonjs/scene";
  48799. import { Nullable } from "babylonjs/types";
  48800. import { Skeleton } from "babylonjs/Bones/skeleton";
  48801. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48802. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  48803. /**
  48804. * Class used to render a debug view of a given skeleton
  48805. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  48806. */
  48807. export class SkeletonViewer {
  48808. /** defines the skeleton to render */
  48809. skeleton: Skeleton;
  48810. /** defines the mesh attached to the skeleton */
  48811. mesh: AbstractMesh;
  48812. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  48813. autoUpdateBonesMatrices: boolean;
  48814. /** defines the rendering group id to use with the viewer */
  48815. renderingGroupId: number;
  48816. /** Gets or sets the color used to render the skeleton */
  48817. color: Color3;
  48818. private _scene;
  48819. private _debugLines;
  48820. private _debugMesh;
  48821. private _isEnabled;
  48822. private _renderFunction;
  48823. private _utilityLayer;
  48824. /**
  48825. * Returns the mesh used to render the bones
  48826. */
  48827. get debugMesh(): Nullable<LinesMesh>;
  48828. /**
  48829. * Creates a new SkeletonViewer
  48830. * @param skeleton defines the skeleton to render
  48831. * @param mesh defines the mesh attached to the skeleton
  48832. * @param scene defines the hosting scene
  48833. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  48834. * @param renderingGroupId defines the rendering group id to use with the viewer
  48835. */
  48836. constructor(
  48837. /** defines the skeleton to render */
  48838. skeleton: Skeleton,
  48839. /** defines the mesh attached to the skeleton */
  48840. mesh: AbstractMesh, scene: Scene,
  48841. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  48842. autoUpdateBonesMatrices?: boolean,
  48843. /** defines the rendering group id to use with the viewer */
  48844. renderingGroupId?: number);
  48845. /** Gets or sets a boolean indicating if the viewer is enabled */
  48846. set isEnabled(value: boolean);
  48847. get isEnabled(): boolean;
  48848. private _getBonePosition;
  48849. private _getLinesForBonesWithLength;
  48850. private _getLinesForBonesNoLength;
  48851. /** Update the viewer to sync with current skeleton state */
  48852. update(): void;
  48853. /** Release associated resources */
  48854. dispose(): void;
  48855. }
  48856. }
  48857. declare module "babylonjs/Debug/index" {
  48858. export * from "babylonjs/Debug/axesViewer";
  48859. export * from "babylonjs/Debug/boneAxesViewer";
  48860. export * from "babylonjs/Debug/debugLayer";
  48861. export * from "babylonjs/Debug/physicsViewer";
  48862. export * from "babylonjs/Debug/rayHelper";
  48863. export * from "babylonjs/Debug/skeletonViewer";
  48864. }
  48865. declare module "babylonjs/DeviceInput/deviceInputSystem" {
  48866. import { Observable } from "babylonjs/Misc/observable";
  48867. import { Engine } from "babylonjs/Engines/engine";
  48868. import { IDisposable } from "babylonjs/scene";
  48869. import { Nullable } from "babylonjs/types";
  48870. /**
  48871. * This class will take all inputs from Keyboard, Pointer, and
  48872. * any Gamepads and provide a polling system that all devices
  48873. * will use. This class assumes that there will only be one
  48874. * pointer device and one keyboard.
  48875. */
  48876. export class DeviceInputSystem implements IDisposable {
  48877. /** POINTER_DEVICE */
  48878. static readonly POINTER_DEVICE: string;
  48879. /** KEYBOARD_DEVICE */
  48880. static readonly KEYBOARD_DEVICE: string;
  48881. /**
  48882. * Observable to be triggered when a device is connected
  48883. */
  48884. onDeviceConnectedObservable: Observable<string>;
  48885. /**
  48886. * Observable to be triggered when a device is disconnected
  48887. */
  48888. onDeviceDisconnectedObservable: Observable<string>;
  48889. private _inputs;
  48890. private _gamepads;
  48891. private _keyboardActive;
  48892. private _pointerActive;
  48893. private _elementToAttachTo;
  48894. private _keyboardDownEvent;
  48895. private _keyboardUpEvent;
  48896. private _pointerMoveEvent;
  48897. private _pointerDownEvent;
  48898. private _pointerUpEvent;
  48899. private _gamepadConnectedEvent;
  48900. private _gamepadDisconnectedEvent;
  48901. private static _MAX_KEYCODES;
  48902. private static _MAX_POINTER_INPUTS;
  48903. /**
  48904. * Default Constructor
  48905. * @param engine - engine to pull input element from
  48906. */
  48907. constructor(engine: Engine);
  48908. /**
  48909. * Checks for current device input value, given an id and input index
  48910. * @param deviceName Id of connected device
  48911. * @param inputIndex Index of device input
  48912. * @returns Current value of input
  48913. */
  48914. pollInput(deviceName: string, inputIndex: number): Nullable<number>;
  48915. /**
  48916. * Dispose of all the eventlisteners and clears the observables
  48917. */
  48918. dispose(): void;
  48919. /**
  48920. * Add device and inputs to device map
  48921. * @param deviceName Assigned name of device (may be SN)
  48922. * @param numberOfInputs Number of input entries to create for given device
  48923. */
  48924. private _registerDevice;
  48925. /**
  48926. * Given a specific device name, remove that device from the device map
  48927. * @param deviceName Name of device to be removed
  48928. */
  48929. private _unregisterDevice;
  48930. /**
  48931. * Handle all actions that come from keyboard interaction
  48932. */
  48933. private _handleKeyActions;
  48934. /**
  48935. * Handle all actions that come from pointer interaction
  48936. */
  48937. private _handlePointerActions;
  48938. /**
  48939. * Handle all actions that come from gamepad interaction
  48940. */
  48941. private _handleGamepadActions;
  48942. /**
  48943. * Update all non-event based devices with each frame
  48944. */
  48945. private _updateDevice;
  48946. }
  48947. }
  48948. declare module "babylonjs/DeviceInput/index" {
  48949. export * from "babylonjs/DeviceInput/deviceInputSystem";
  48950. }
  48951. declare module "babylonjs/Engines/nullEngine" {
  48952. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  48953. import { Engine } from "babylonjs/Engines/engine";
  48954. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  48955. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  48956. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48957. import { Effect } from "babylonjs/Materials/effect";
  48958. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  48959. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  48960. import { IColor4Like, IViewportLike } from "babylonjs/Maths/math.like";
  48961. import { ISceneLike } from "babylonjs/Engines/thinEngine";
  48962. /**
  48963. * Options to create the null engine
  48964. */
  48965. export class NullEngineOptions {
  48966. /**
  48967. * Render width (Default: 512)
  48968. */
  48969. renderWidth: number;
  48970. /**
  48971. * Render height (Default: 256)
  48972. */
  48973. renderHeight: number;
  48974. /**
  48975. * Texture size (Default: 512)
  48976. */
  48977. textureSize: number;
  48978. /**
  48979. * If delta time between frames should be constant
  48980. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  48981. */
  48982. deterministicLockstep: boolean;
  48983. /**
  48984. * Maximum about of steps between frames (Default: 4)
  48985. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  48986. */
  48987. lockstepMaxSteps: number;
  48988. }
  48989. /**
  48990. * The null engine class provides support for headless version of babylon.js.
  48991. * This can be used in server side scenario or for testing purposes
  48992. */
  48993. export class NullEngine extends Engine {
  48994. private _options;
  48995. /**
  48996. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  48997. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  48998. * @returns true if engine is in deterministic lock step mode
  48999. */
  49000. isDeterministicLockStep(): boolean;
  49001. /**
  49002. * Gets the max steps when engine is running in deterministic lock step
  49003. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  49004. * @returns the max steps
  49005. */
  49006. getLockstepMaxSteps(): number;
  49007. /**
  49008. * Gets the current hardware scaling level.
  49009. * By default the hardware scaling level is computed from the window device ratio.
  49010. * 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.
  49011. * @returns a number indicating the current hardware scaling level
  49012. */
  49013. getHardwareScalingLevel(): number;
  49014. constructor(options?: NullEngineOptions);
  49015. /**
  49016. * Creates a vertex buffer
  49017. * @param vertices the data for the vertex buffer
  49018. * @returns the new WebGL static buffer
  49019. */
  49020. createVertexBuffer(vertices: FloatArray): DataBuffer;
  49021. /**
  49022. * Creates a new index buffer
  49023. * @param indices defines the content of the index buffer
  49024. * @param updatable defines if the index buffer must be updatable
  49025. * @returns a new webGL buffer
  49026. */
  49027. createIndexBuffer(indices: IndicesArray): DataBuffer;
  49028. /**
  49029. * Clear the current render buffer or the current render target (if any is set up)
  49030. * @param color defines the color to use
  49031. * @param backBuffer defines if the back buffer must be cleared
  49032. * @param depth defines if the depth buffer must be cleared
  49033. * @param stencil defines if the stencil buffer must be cleared
  49034. */
  49035. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  49036. /**
  49037. * Gets the current render width
  49038. * @param useScreen defines if screen size must be used (or the current render target if any)
  49039. * @returns a number defining the current render width
  49040. */
  49041. getRenderWidth(useScreen?: boolean): number;
  49042. /**
  49043. * Gets the current render height
  49044. * @param useScreen defines if screen size must be used (or the current render target if any)
  49045. * @returns a number defining the current render height
  49046. */
  49047. getRenderHeight(useScreen?: boolean): number;
  49048. /**
  49049. * Set the WebGL's viewport
  49050. * @param viewport defines the viewport element to be used
  49051. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  49052. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  49053. */
  49054. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  49055. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  49056. /**
  49057. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  49058. * @param pipelineContext defines the pipeline context to use
  49059. * @param uniformsNames defines the list of uniform names
  49060. * @returns an array of webGL uniform locations
  49061. */
  49062. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  49063. /**
  49064. * Gets the lsit of active attributes for a given webGL program
  49065. * @param pipelineContext defines the pipeline context to use
  49066. * @param attributesNames defines the list of attribute names to get
  49067. * @returns an array of indices indicating the offset of each attribute
  49068. */
  49069. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  49070. /**
  49071. * Binds an effect to the webGL context
  49072. * @param effect defines the effect to bind
  49073. */
  49074. bindSamplers(effect: Effect): void;
  49075. /**
  49076. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  49077. * @param effect defines the effect to activate
  49078. */
  49079. enableEffect(effect: Effect): void;
  49080. /**
  49081. * Set various states to the webGL context
  49082. * @param culling defines backface culling state
  49083. * @param zOffset defines the value to apply to zOffset (0 by default)
  49084. * @param force defines if states must be applied even if cache is up to date
  49085. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  49086. */
  49087. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  49088. /**
  49089. * Set the value of an uniform to an array of int32
  49090. * @param uniform defines the webGL uniform location where to store the value
  49091. * @param array defines the array of int32 to store
  49092. */
  49093. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  49094. /**
  49095. * Set the value of an uniform to an array of int32 (stored as vec2)
  49096. * @param uniform defines the webGL uniform location where to store the value
  49097. * @param array defines the array of int32 to store
  49098. */
  49099. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  49100. /**
  49101. * Set the value of an uniform to an array of int32 (stored as vec3)
  49102. * @param uniform defines the webGL uniform location where to store the value
  49103. * @param array defines the array of int32 to store
  49104. */
  49105. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  49106. /**
  49107. * Set the value of an uniform to an array of int32 (stored as vec4)
  49108. * @param uniform defines the webGL uniform location where to store the value
  49109. * @param array defines the array of int32 to store
  49110. */
  49111. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  49112. /**
  49113. * Set the value of an uniform to an array of float32
  49114. * @param uniform defines the webGL uniform location where to store the value
  49115. * @param array defines the array of float32 to store
  49116. */
  49117. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  49118. /**
  49119. * Set the value of an uniform to an array of float32 (stored as vec2)
  49120. * @param uniform defines the webGL uniform location where to store the value
  49121. * @param array defines the array of float32 to store
  49122. */
  49123. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  49124. /**
  49125. * Set the value of an uniform to an array of float32 (stored as vec3)
  49126. * @param uniform defines the webGL uniform location where to store the value
  49127. * @param array defines the array of float32 to store
  49128. */
  49129. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  49130. /**
  49131. * Set the value of an uniform to an array of float32 (stored as vec4)
  49132. * @param uniform defines the webGL uniform location where to store the value
  49133. * @param array defines the array of float32 to store
  49134. */
  49135. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  49136. /**
  49137. * Set the value of an uniform to an array of number
  49138. * @param uniform defines the webGL uniform location where to store the value
  49139. * @param array defines the array of number to store
  49140. */
  49141. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  49142. /**
  49143. * Set the value of an uniform to an array of number (stored as vec2)
  49144. * @param uniform defines the webGL uniform location where to store the value
  49145. * @param array defines the array of number to store
  49146. */
  49147. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  49148. /**
  49149. * Set the value of an uniform to an array of number (stored as vec3)
  49150. * @param uniform defines the webGL uniform location where to store the value
  49151. * @param array defines the array of number to store
  49152. */
  49153. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  49154. /**
  49155. * Set the value of an uniform to an array of number (stored as vec4)
  49156. * @param uniform defines the webGL uniform location where to store the value
  49157. * @param array defines the array of number to store
  49158. */
  49159. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  49160. /**
  49161. * Set the value of an uniform to an array of float32 (stored as matrices)
  49162. * @param uniform defines the webGL uniform location where to store the value
  49163. * @param matrices defines the array of float32 to store
  49164. */
  49165. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  49166. /**
  49167. * Set the value of an uniform to a matrix (3x3)
  49168. * @param uniform defines the webGL uniform location where to store the value
  49169. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  49170. */
  49171. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  49172. /**
  49173. * Set the value of an uniform to a matrix (2x2)
  49174. * @param uniform defines the webGL uniform location where to store the value
  49175. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  49176. */
  49177. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  49178. /**
  49179. * Set the value of an uniform to a number (float)
  49180. * @param uniform defines the webGL uniform location where to store the value
  49181. * @param value defines the float number to store
  49182. */
  49183. setFloat(uniform: WebGLUniformLocation, value: number): void;
  49184. /**
  49185. * Set the value of an uniform to a vec2
  49186. * @param uniform defines the webGL uniform location where to store the value
  49187. * @param x defines the 1st component of the value
  49188. * @param y defines the 2nd component of the value
  49189. */
  49190. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  49191. /**
  49192. * Set the value of an uniform to a vec3
  49193. * @param uniform defines the webGL uniform location where to store the value
  49194. * @param x defines the 1st component of the value
  49195. * @param y defines the 2nd component of the value
  49196. * @param z defines the 3rd component of the value
  49197. */
  49198. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  49199. /**
  49200. * Set the value of an uniform to a boolean
  49201. * @param uniform defines the webGL uniform location where to store the value
  49202. * @param bool defines the boolean to store
  49203. */
  49204. setBool(uniform: WebGLUniformLocation, bool: number): void;
  49205. /**
  49206. * Set the value of an uniform to a vec4
  49207. * @param uniform defines the webGL uniform location where to store the value
  49208. * @param x defines the 1st component of the value
  49209. * @param y defines the 2nd component of the value
  49210. * @param z defines the 3rd component of the value
  49211. * @param w defines the 4th component of the value
  49212. */
  49213. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  49214. /**
  49215. * Sets the current alpha mode
  49216. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  49217. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  49218. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  49219. */
  49220. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  49221. /**
  49222. * Bind webGl buffers directly to the webGL context
  49223. * @param vertexBuffers defines the vertex buffer to bind
  49224. * @param indexBuffer defines the index buffer to bind
  49225. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  49226. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  49227. * @param effect defines the effect associated with the vertex buffer
  49228. */
  49229. bindBuffers(vertexBuffers: {
  49230. [key: string]: VertexBuffer;
  49231. }, indexBuffer: DataBuffer, effect: Effect): void;
  49232. /**
  49233. * Force the entire cache to be cleared
  49234. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  49235. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  49236. */
  49237. wipeCaches(bruteForce?: boolean): void;
  49238. /**
  49239. * Send a draw order
  49240. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  49241. * @param indexStart defines the starting index
  49242. * @param indexCount defines the number of index to draw
  49243. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  49244. */
  49245. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  49246. /**
  49247. * Draw a list of indexed primitives
  49248. * @param fillMode defines the primitive to use
  49249. * @param indexStart defines the starting index
  49250. * @param indexCount defines the number of index to draw
  49251. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  49252. */
  49253. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  49254. /**
  49255. * Draw a list of unindexed primitives
  49256. * @param fillMode defines the primitive to use
  49257. * @param verticesStart defines the index of first vertex to draw
  49258. * @param verticesCount defines the count of vertices to draw
  49259. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  49260. */
  49261. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  49262. /** @hidden */
  49263. _createTexture(): WebGLTexture;
  49264. /** @hidden */
  49265. _releaseTexture(texture: InternalTexture): void;
  49266. /**
  49267. * Usually called from Texture.ts.
  49268. * Passed information to create a WebGLTexture
  49269. * @param urlArg defines a value which contains one of the following:
  49270. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  49271. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  49272. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  49273. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  49274. * @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)
  49275. * @param scene needed for loading to the correct scene
  49276. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  49277. * @param onLoad optional callback to be called upon successful completion
  49278. * @param onError optional callback to be called upon failure
  49279. * @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
  49280. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  49281. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  49282. * @param forcedExtension defines the extension to use to pick the right loader
  49283. * @param mimeType defines an optional mime type
  49284. * @returns a InternalTexture for assignment back into BABYLON.Texture
  49285. */
  49286. 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;
  49287. /**
  49288. * Creates a new render target texture
  49289. * @param size defines the size of the texture
  49290. * @param options defines the options used to create the texture
  49291. * @returns a new render target texture stored in an InternalTexture
  49292. */
  49293. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  49294. /**
  49295. * Update the sampling mode of a given texture
  49296. * @param samplingMode defines the required sampling mode
  49297. * @param texture defines the texture to update
  49298. */
  49299. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  49300. /**
  49301. * Binds the frame buffer to the specified texture.
  49302. * @param texture The texture to render to or null for the default canvas
  49303. * @param faceIndex The face of the texture to render to in case of cube texture
  49304. * @param requiredWidth The width of the target to render to
  49305. * @param requiredHeight The height of the target to render to
  49306. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  49307. * @param lodLevel defines le lod level to bind to the frame buffer
  49308. */
  49309. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  49310. /**
  49311. * Unbind the current render target texture from the webGL context
  49312. * @param texture defines the render target texture to unbind
  49313. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  49314. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  49315. */
  49316. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  49317. /**
  49318. * Creates a dynamic vertex buffer
  49319. * @param vertices the data for the dynamic vertex buffer
  49320. * @returns the new WebGL dynamic buffer
  49321. */
  49322. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  49323. /**
  49324. * Update the content of a dynamic texture
  49325. * @param texture defines the texture to update
  49326. * @param canvas defines the canvas containing the source
  49327. * @param invertY defines if data must be stored with Y axis inverted
  49328. * @param premulAlpha defines if alpha is stored as premultiplied
  49329. * @param format defines the format of the data
  49330. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  49331. */
  49332. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  49333. /**
  49334. * Gets a boolean indicating if all created effects are ready
  49335. * @returns true if all effects are ready
  49336. */
  49337. areAllEffectsReady(): boolean;
  49338. /**
  49339. * @hidden
  49340. * Get the current error code of the webGL context
  49341. * @returns the error code
  49342. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  49343. */
  49344. getError(): number;
  49345. /** @hidden */
  49346. _getUnpackAlignement(): number;
  49347. /** @hidden */
  49348. _unpackFlipY(value: boolean): void;
  49349. /**
  49350. * Update a dynamic index buffer
  49351. * @param indexBuffer defines the target index buffer
  49352. * @param indices defines the data to update
  49353. * @param offset defines the offset in the target index buffer where update should start
  49354. */
  49355. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  49356. /**
  49357. * Updates a dynamic vertex buffer.
  49358. * @param vertexBuffer the vertex buffer to update
  49359. * @param vertices the data used to update the vertex buffer
  49360. * @param byteOffset the byte offset of the data (optional)
  49361. * @param byteLength the byte length of the data (optional)
  49362. */
  49363. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  49364. /** @hidden */
  49365. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  49366. /** @hidden */
  49367. _bindTexture(channel: number, texture: InternalTexture): void;
  49368. protected _deleteBuffer(buffer: WebGLBuffer): void;
  49369. /**
  49370. * 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
  49371. */
  49372. releaseEffects(): void;
  49373. displayLoadingUI(): void;
  49374. hideLoadingUI(): void;
  49375. /** @hidden */
  49376. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  49377. /** @hidden */
  49378. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  49379. /** @hidden */
  49380. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  49381. /** @hidden */
  49382. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  49383. }
  49384. }
  49385. declare module "babylonjs/Instrumentation/timeToken" {
  49386. import { Nullable } from "babylonjs/types";
  49387. /**
  49388. * @hidden
  49389. **/
  49390. export class _TimeToken {
  49391. _startTimeQuery: Nullable<WebGLQuery>;
  49392. _endTimeQuery: Nullable<WebGLQuery>;
  49393. _timeElapsedQuery: Nullable<WebGLQuery>;
  49394. _timeElapsedQueryEnded: boolean;
  49395. }
  49396. }
  49397. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  49398. import { Nullable, int } from "babylonjs/types";
  49399. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  49400. /** @hidden */
  49401. export class _OcclusionDataStorage {
  49402. /** @hidden */
  49403. occlusionInternalRetryCounter: number;
  49404. /** @hidden */
  49405. isOcclusionQueryInProgress: boolean;
  49406. /** @hidden */
  49407. isOccluded: boolean;
  49408. /** @hidden */
  49409. occlusionRetryCount: number;
  49410. /** @hidden */
  49411. occlusionType: number;
  49412. /** @hidden */
  49413. occlusionQueryAlgorithmType: number;
  49414. }
  49415. module "babylonjs/Engines/engine" {
  49416. interface Engine {
  49417. /**
  49418. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  49419. * @return the new query
  49420. */
  49421. createQuery(): WebGLQuery;
  49422. /**
  49423. * Delete and release a webGL query
  49424. * @param query defines the query to delete
  49425. * @return the current engine
  49426. */
  49427. deleteQuery(query: WebGLQuery): Engine;
  49428. /**
  49429. * Check if a given query has resolved and got its value
  49430. * @param query defines the query to check
  49431. * @returns true if the query got its value
  49432. */
  49433. isQueryResultAvailable(query: WebGLQuery): boolean;
  49434. /**
  49435. * Gets the value of a given query
  49436. * @param query defines the query to check
  49437. * @returns the value of the query
  49438. */
  49439. getQueryResult(query: WebGLQuery): number;
  49440. /**
  49441. * Initiates an occlusion query
  49442. * @param algorithmType defines the algorithm to use
  49443. * @param query defines the query to use
  49444. * @returns the current engine
  49445. * @see http://doc.babylonjs.com/features/occlusionquery
  49446. */
  49447. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  49448. /**
  49449. * Ends an occlusion query
  49450. * @see http://doc.babylonjs.com/features/occlusionquery
  49451. * @param algorithmType defines the algorithm to use
  49452. * @returns the current engine
  49453. */
  49454. endOcclusionQuery(algorithmType: number): Engine;
  49455. /**
  49456. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  49457. * Please note that only one query can be issued at a time
  49458. * @returns a time token used to track the time span
  49459. */
  49460. startTimeQuery(): Nullable<_TimeToken>;
  49461. /**
  49462. * Ends a time query
  49463. * @param token defines the token used to measure the time span
  49464. * @returns the time spent (in ns)
  49465. */
  49466. endTimeQuery(token: _TimeToken): int;
  49467. /** @hidden */
  49468. _currentNonTimestampToken: Nullable<_TimeToken>;
  49469. /** @hidden */
  49470. _createTimeQuery(): WebGLQuery;
  49471. /** @hidden */
  49472. _deleteTimeQuery(query: WebGLQuery): void;
  49473. /** @hidden */
  49474. _getGlAlgorithmType(algorithmType: number): number;
  49475. /** @hidden */
  49476. _getTimeQueryResult(query: WebGLQuery): any;
  49477. /** @hidden */
  49478. _getTimeQueryAvailability(query: WebGLQuery): any;
  49479. }
  49480. }
  49481. module "babylonjs/Meshes/abstractMesh" {
  49482. interface AbstractMesh {
  49483. /**
  49484. * Backing filed
  49485. * @hidden
  49486. */
  49487. __occlusionDataStorage: _OcclusionDataStorage;
  49488. /**
  49489. * Access property
  49490. * @hidden
  49491. */
  49492. _occlusionDataStorage: _OcclusionDataStorage;
  49493. /**
  49494. * 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.
  49495. * The default value is -1 which means don't break the query and wait till the result
  49496. * @see http://doc.babylonjs.com/features/occlusionquery
  49497. */
  49498. occlusionRetryCount: number;
  49499. /**
  49500. * 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:
  49501. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  49502. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  49503. * * 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.
  49504. * @see http://doc.babylonjs.com/features/occlusionquery
  49505. */
  49506. occlusionType: number;
  49507. /**
  49508. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  49509. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  49510. * * 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.
  49511. * @see http://doc.babylonjs.com/features/occlusionquery
  49512. */
  49513. occlusionQueryAlgorithmType: number;
  49514. /**
  49515. * 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
  49516. * @see http://doc.babylonjs.com/features/occlusionquery
  49517. */
  49518. isOccluded: boolean;
  49519. /**
  49520. * Flag to check the progress status of the query
  49521. * @see http://doc.babylonjs.com/features/occlusionquery
  49522. */
  49523. isOcclusionQueryInProgress: boolean;
  49524. }
  49525. }
  49526. }
  49527. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  49528. import { Nullable } from "babylonjs/types";
  49529. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  49530. /** @hidden */
  49531. export var _forceTransformFeedbackToBundle: boolean;
  49532. module "babylonjs/Engines/engine" {
  49533. interface Engine {
  49534. /**
  49535. * Creates a webGL transform feedback object
  49536. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  49537. * @returns the webGL transform feedback object
  49538. */
  49539. createTransformFeedback(): WebGLTransformFeedback;
  49540. /**
  49541. * Delete a webGL transform feedback object
  49542. * @param value defines the webGL transform feedback object to delete
  49543. */
  49544. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  49545. /**
  49546. * Bind a webGL transform feedback object to the webgl context
  49547. * @param value defines the webGL transform feedback object to bind
  49548. */
  49549. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  49550. /**
  49551. * Begins a transform feedback operation
  49552. * @param usePoints defines if points or triangles must be used
  49553. */
  49554. beginTransformFeedback(usePoints: boolean): void;
  49555. /**
  49556. * Ends a transform feedback operation
  49557. */
  49558. endTransformFeedback(): void;
  49559. /**
  49560. * Specify the varyings to use with transform feedback
  49561. * @param program defines the associated webGL program
  49562. * @param value defines the list of strings representing the varying names
  49563. */
  49564. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  49565. /**
  49566. * Bind a webGL buffer for a transform feedback operation
  49567. * @param value defines the webGL buffer to bind
  49568. */
  49569. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  49570. }
  49571. }
  49572. }
  49573. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  49574. import { Scene } from "babylonjs/scene";
  49575. import { Engine } from "babylonjs/Engines/engine";
  49576. import { Texture } from "babylonjs/Materials/Textures/texture";
  49577. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  49578. import "babylonjs/Engines/Extensions/engine.multiRender";
  49579. /**
  49580. * Creation options of the multi render target texture.
  49581. */
  49582. export interface IMultiRenderTargetOptions {
  49583. /**
  49584. * Define if the texture needs to create mip maps after render.
  49585. */
  49586. generateMipMaps?: boolean;
  49587. /**
  49588. * Define the types of all the draw buffers we want to create
  49589. */
  49590. types?: number[];
  49591. /**
  49592. * Define the sampling modes of all the draw buffers we want to create
  49593. */
  49594. samplingModes?: number[];
  49595. /**
  49596. * Define if a depth buffer is required
  49597. */
  49598. generateDepthBuffer?: boolean;
  49599. /**
  49600. * Define if a stencil buffer is required
  49601. */
  49602. generateStencilBuffer?: boolean;
  49603. /**
  49604. * Define if a depth texture is required instead of a depth buffer
  49605. */
  49606. generateDepthTexture?: boolean;
  49607. /**
  49608. * Define the number of desired draw buffers
  49609. */
  49610. textureCount?: number;
  49611. /**
  49612. * Define if aspect ratio should be adapted to the texture or stay the scene one
  49613. */
  49614. doNotChangeAspectRatio?: boolean;
  49615. /**
  49616. * Define the default type of the buffers we are creating
  49617. */
  49618. defaultType?: number;
  49619. }
  49620. /**
  49621. * A multi render target, like a render target provides the ability to render to a texture.
  49622. * Unlike the render target, it can render to several draw buffers in one draw.
  49623. * This is specially interesting in deferred rendering or for any effects requiring more than
  49624. * just one color from a single pass.
  49625. */
  49626. export class MultiRenderTarget extends RenderTargetTexture {
  49627. private _internalTextures;
  49628. private _textures;
  49629. private _multiRenderTargetOptions;
  49630. /**
  49631. * Get if draw buffers are currently supported by the used hardware and browser.
  49632. */
  49633. get isSupported(): boolean;
  49634. /**
  49635. * Get the list of textures generated by the multi render target.
  49636. */
  49637. get textures(): Texture[];
  49638. /**
  49639. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  49640. */
  49641. get depthTexture(): Texture;
  49642. /**
  49643. * Set the wrapping mode on U of all the textures we are rendering to.
  49644. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  49645. */
  49646. set wrapU(wrap: number);
  49647. /**
  49648. * Set the wrapping mode on V of all the textures we are rendering to.
  49649. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  49650. */
  49651. set wrapV(wrap: number);
  49652. /**
  49653. * Instantiate a new multi render target texture.
  49654. * A multi render target, like a render target provides the ability to render to a texture.
  49655. * Unlike the render target, it can render to several draw buffers in one draw.
  49656. * This is specially interesting in deferred rendering or for any effects requiring more than
  49657. * just one color from a single pass.
  49658. * @param name Define the name of the texture
  49659. * @param size Define the size of the buffers to render to
  49660. * @param count Define the number of target we are rendering into
  49661. * @param scene Define the scene the texture belongs to
  49662. * @param options Define the options used to create the multi render target
  49663. */
  49664. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  49665. /** @hidden */
  49666. _rebuild(): void;
  49667. private _createInternalTextures;
  49668. private _createTextures;
  49669. /**
  49670. * Define the number of samples used if MSAA is enabled.
  49671. */
  49672. get samples(): number;
  49673. set samples(value: number);
  49674. /**
  49675. * Resize all the textures in the multi render target.
  49676. * Be carrefull as it will recreate all the data in the new texture.
  49677. * @param size Define the new size
  49678. */
  49679. resize(size: any): void;
  49680. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  49681. /**
  49682. * Dispose the render targets and their associated resources
  49683. */
  49684. dispose(): void;
  49685. /**
  49686. * Release all the underlying texture used as draw buffers.
  49687. */
  49688. releaseInternalTextures(): void;
  49689. }
  49690. }
  49691. declare module "babylonjs/Engines/Extensions/engine.multiRender" {
  49692. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49693. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  49694. import { Nullable } from "babylonjs/types";
  49695. module "babylonjs/Engines/thinEngine" {
  49696. interface ThinEngine {
  49697. /**
  49698. * Unbind a list of render target textures from the webGL context
  49699. * This is used only when drawBuffer extension or webGL2 are active
  49700. * @param textures defines the render target textures to unbind
  49701. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  49702. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  49703. */
  49704. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  49705. /**
  49706. * Create a multi render target texture
  49707. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  49708. * @param size defines the size of the texture
  49709. * @param options defines the creation options
  49710. * @returns the cube texture as an InternalTexture
  49711. */
  49712. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  49713. /**
  49714. * Update the sample count for a given multiple render target texture
  49715. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  49716. * @param textures defines the textures to update
  49717. * @param samples defines the sample count to set
  49718. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  49719. */
  49720. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  49721. }
  49722. }
  49723. }
  49724. declare module "babylonjs/Engines/Extensions/engine.views" {
  49725. import { Camera } from "babylonjs/Cameras/camera";
  49726. import { Nullable } from "babylonjs/types";
  49727. /**
  49728. * Class used to define an additional view for the engine
  49729. * @see https://doc.babylonjs.com/how_to/multi_canvases
  49730. */
  49731. export class EngineView {
  49732. /** Defines the canvas where to render the view */
  49733. target: HTMLCanvasElement;
  49734. /** Defines an optional camera used to render the view (will use active camera else) */
  49735. camera?: Camera;
  49736. }
  49737. module "babylonjs/Engines/engine" {
  49738. interface Engine {
  49739. /**
  49740. * Gets or sets the HTML element to use for attaching events
  49741. */
  49742. inputElement: Nullable<HTMLElement>;
  49743. /**
  49744. * Gets the current engine view
  49745. * @see https://doc.babylonjs.com/how_to/multi_canvases
  49746. */
  49747. activeView: Nullable<EngineView>;
  49748. /** Gets or sets the list of views */
  49749. views: EngineView[];
  49750. /**
  49751. * Register a new child canvas
  49752. * @param canvas defines the canvas to register
  49753. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  49754. * @returns the associated view
  49755. */
  49756. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  49757. /**
  49758. * Remove a registered child canvas
  49759. * @param canvas defines the canvas to remove
  49760. * @returns the current engine
  49761. */
  49762. unRegisterView(canvas: HTMLCanvasElement): Engine;
  49763. }
  49764. }
  49765. }
  49766. declare module "babylonjs/Engines/Extensions/engine.textureSelector" {
  49767. import { Nullable } from "babylonjs/types";
  49768. module "babylonjs/Engines/engine" {
  49769. interface Engine {
  49770. /** @hidden */
  49771. _excludedCompressedTextures: string[];
  49772. /** @hidden */
  49773. _textureFormatInUse: string;
  49774. /**
  49775. * Gets the list of texture formats supported
  49776. */
  49777. readonly texturesSupported: Array<string>;
  49778. /**
  49779. * Gets the texture format in use
  49780. */
  49781. readonly textureFormatInUse: Nullable<string>;
  49782. /**
  49783. * Set the compressed texture extensions or file names to skip.
  49784. *
  49785. * @param skippedFiles defines the list of those texture files you want to skip
  49786. * Example: [".dds", ".env", "myfile.png"]
  49787. */
  49788. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  49789. /**
  49790. * Set the compressed texture format to use, based on the formats you have, and the formats
  49791. * supported by the hardware / browser.
  49792. *
  49793. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  49794. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  49795. * to API arguments needed to compressed textures. This puts the burden on the container
  49796. * generator to house the arcane code for determining these for current & future formats.
  49797. *
  49798. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  49799. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  49800. *
  49801. * Note: The result of this call is not taken into account when a texture is base64.
  49802. *
  49803. * @param formatsAvailable defines the list of those format families you have created
  49804. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  49805. *
  49806. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  49807. * @returns The extension selected.
  49808. */
  49809. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  49810. }
  49811. }
  49812. }
  49813. declare module "babylonjs/Engines/Extensions/index" {
  49814. export * from "babylonjs/Engines/Extensions/engine.alpha";
  49815. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  49816. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  49817. export * from "babylonjs/Engines/Extensions/engine.multiview";
  49818. export * from "babylonjs/Engines/Extensions/engine.rawTexture";
  49819. export * from "babylonjs/Engines/Extensions/engine.dynamicTexture";
  49820. export * from "babylonjs/Engines/Extensions/engine.videoTexture";
  49821. export * from "babylonjs/Engines/Extensions/engine.multiRender";
  49822. export * from "babylonjs/Engines/Extensions/engine.cubeTexture";
  49823. export * from "babylonjs/Engines/Extensions/engine.renderTarget";
  49824. export * from "babylonjs/Engines/Extensions/engine.renderTargetCube";
  49825. export * from "babylonjs/Engines/Extensions/engine.webVR";
  49826. export * from "babylonjs/Engines/Extensions/engine.uniformBuffer";
  49827. export * from "babylonjs/Engines/Extensions/engine.views";
  49828. export * from "babylonjs/Engines/Extensions/engine.readTexture";
  49829. import "babylonjs/Engines/Extensions/engine.textureSelector";
  49830. export * from "babylonjs/Engines/Extensions/engine.textureSelector";
  49831. }
  49832. declare module "babylonjs/Misc/HighDynamicRange/panoramaToCubemap" {
  49833. import { Nullable } from "babylonjs/types";
  49834. /**
  49835. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  49836. */
  49837. export interface CubeMapInfo {
  49838. /**
  49839. * The pixel array for the front face.
  49840. * This is stored in format, left to right, up to down format.
  49841. */
  49842. front: Nullable<ArrayBufferView>;
  49843. /**
  49844. * The pixel array for the back face.
  49845. * This is stored in format, left to right, up to down format.
  49846. */
  49847. back: Nullable<ArrayBufferView>;
  49848. /**
  49849. * The pixel array for the left face.
  49850. * This is stored in format, left to right, up to down format.
  49851. */
  49852. left: Nullable<ArrayBufferView>;
  49853. /**
  49854. * The pixel array for the right face.
  49855. * This is stored in format, left to right, up to down format.
  49856. */
  49857. right: Nullable<ArrayBufferView>;
  49858. /**
  49859. * The pixel array for the up face.
  49860. * This is stored in format, left to right, up to down format.
  49861. */
  49862. up: Nullable<ArrayBufferView>;
  49863. /**
  49864. * The pixel array for the down face.
  49865. * This is stored in format, left to right, up to down format.
  49866. */
  49867. down: Nullable<ArrayBufferView>;
  49868. /**
  49869. * The size of the cubemap stored.
  49870. *
  49871. * Each faces will be size * size pixels.
  49872. */
  49873. size: number;
  49874. /**
  49875. * The format of the texture.
  49876. *
  49877. * RGBA, RGB.
  49878. */
  49879. format: number;
  49880. /**
  49881. * The type of the texture data.
  49882. *
  49883. * UNSIGNED_INT, FLOAT.
  49884. */
  49885. type: number;
  49886. /**
  49887. * Specifies whether the texture is in gamma space.
  49888. */
  49889. gammaSpace: boolean;
  49890. }
  49891. /**
  49892. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  49893. */
  49894. export class PanoramaToCubeMapTools {
  49895. private static FACE_LEFT;
  49896. private static FACE_RIGHT;
  49897. private static FACE_FRONT;
  49898. private static FACE_BACK;
  49899. private static FACE_DOWN;
  49900. private static FACE_UP;
  49901. /**
  49902. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  49903. *
  49904. * @param float32Array The source data.
  49905. * @param inputWidth The width of the input panorama.
  49906. * @param inputHeight The height of the input panorama.
  49907. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  49908. * @return The cubemap data
  49909. */
  49910. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  49911. private static CreateCubemapTexture;
  49912. private static CalcProjectionSpherical;
  49913. }
  49914. }
  49915. declare module "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial" {
  49916. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  49917. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49918. import { Nullable } from "babylonjs/types";
  49919. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  49920. /**
  49921. * Helper class dealing with the extraction of spherical polynomial dataArray
  49922. * from a cube map.
  49923. */
  49924. export class CubeMapToSphericalPolynomialTools {
  49925. private static FileFaces;
  49926. /**
  49927. * Converts a texture to the according Spherical Polynomial data.
  49928. * This extracts the first 3 orders only as they are the only one used in the lighting.
  49929. *
  49930. * @param texture The texture to extract the information from.
  49931. * @return The Spherical Polynomial data.
  49932. */
  49933. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  49934. /**
  49935. * Converts a cubemap to the according Spherical Polynomial data.
  49936. * This extracts the first 3 orders only as they are the only one used in the lighting.
  49937. *
  49938. * @param cubeInfo The Cube map to extract the information from.
  49939. * @return The Spherical Polynomial data.
  49940. */
  49941. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  49942. }
  49943. }
  49944. declare module "babylonjs/Materials/Textures/baseTexture.polynomial" {
  49945. import { Nullable } from "babylonjs/types";
  49946. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  49947. module "babylonjs/Materials/Textures/baseTexture" {
  49948. interface BaseTexture {
  49949. /**
  49950. * Get the polynomial representation of the texture data.
  49951. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  49952. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  49953. */
  49954. sphericalPolynomial: Nullable<SphericalPolynomial>;
  49955. }
  49956. }
  49957. }
  49958. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  49959. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  49960. /** @hidden */
  49961. export var rgbdEncodePixelShader: {
  49962. name: string;
  49963. shader: string;
  49964. };
  49965. }
  49966. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  49967. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  49968. /** @hidden */
  49969. export var rgbdDecodePixelShader: {
  49970. name: string;
  49971. shader: string;
  49972. };
  49973. }
  49974. declare module "babylonjs/Misc/environmentTextureTools" {
  49975. import { Nullable } from "babylonjs/types";
  49976. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  49977. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49978. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49979. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  49980. import "babylonjs/Engines/Extensions/engine.readTexture";
  49981. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  49982. import "babylonjs/Shaders/rgbdEncode.fragment";
  49983. import "babylonjs/Shaders/rgbdDecode.fragment";
  49984. /**
  49985. * Raw texture data and descriptor sufficient for WebGL texture upload
  49986. */
  49987. export interface EnvironmentTextureInfo {
  49988. /**
  49989. * Version of the environment map
  49990. */
  49991. version: number;
  49992. /**
  49993. * Width of image
  49994. */
  49995. width: number;
  49996. /**
  49997. * Irradiance information stored in the file.
  49998. */
  49999. irradiance: any;
  50000. /**
  50001. * Specular information stored in the file.
  50002. */
  50003. specular: any;
  50004. }
  50005. /**
  50006. * Defines One Image in the file. It requires only the position in the file
  50007. * as well as the length.
  50008. */
  50009. interface BufferImageData {
  50010. /**
  50011. * Length of the image data.
  50012. */
  50013. length: number;
  50014. /**
  50015. * Position of the data from the null terminator delimiting the end of the JSON.
  50016. */
  50017. position: number;
  50018. }
  50019. /**
  50020. * Defines the specular data enclosed in the file.
  50021. * This corresponds to the version 1 of the data.
  50022. */
  50023. export interface EnvironmentTextureSpecularInfoV1 {
  50024. /**
  50025. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  50026. */
  50027. specularDataPosition?: number;
  50028. /**
  50029. * This contains all the images data needed to reconstruct the cubemap.
  50030. */
  50031. mipmaps: Array<BufferImageData>;
  50032. /**
  50033. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  50034. */
  50035. lodGenerationScale: number;
  50036. }
  50037. /**
  50038. * Sets of helpers addressing the serialization and deserialization of environment texture
  50039. * stored in a BabylonJS env file.
  50040. * Those files are usually stored as .env files.
  50041. */
  50042. export class EnvironmentTextureTools {
  50043. /**
  50044. * Magic number identifying the env file.
  50045. */
  50046. private static _MagicBytes;
  50047. /**
  50048. * Gets the environment info from an env file.
  50049. * @param data The array buffer containing the .env bytes.
  50050. * @returns the environment file info (the json header) if successfully parsed.
  50051. */
  50052. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  50053. /**
  50054. * Creates an environment texture from a loaded cube texture.
  50055. * @param texture defines the cube texture to convert in env file
  50056. * @return a promise containing the environment data if succesfull.
  50057. */
  50058. static CreateEnvTextureAsync(texture: BaseTexture): Promise<ArrayBuffer>;
  50059. /**
  50060. * Creates a JSON representation of the spherical data.
  50061. * @param texture defines the texture containing the polynomials
  50062. * @return the JSON representation of the spherical info
  50063. */
  50064. private static _CreateEnvTextureIrradiance;
  50065. /**
  50066. * Creates the ArrayBufferViews used for initializing environment texture image data.
  50067. * @param data the image data
  50068. * @param info parameters that determine what views will be created for accessing the underlying buffer
  50069. * @return the views described by info providing access to the underlying buffer
  50070. */
  50071. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  50072. /**
  50073. * Uploads the texture info contained in the env file to the GPU.
  50074. * @param texture defines the internal texture to upload to
  50075. * @param data defines the data to load
  50076. * @param info defines the texture info retrieved through the GetEnvInfo method
  50077. * @returns a promise
  50078. */
  50079. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  50080. private static _OnImageReadyAsync;
  50081. /**
  50082. * Uploads the levels of image data to the GPU.
  50083. * @param texture defines the internal texture to upload to
  50084. * @param imageData defines the array buffer views of image data [mipmap][face]
  50085. * @returns a promise
  50086. */
  50087. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  50088. /**
  50089. * Uploads spherical polynomials information to the texture.
  50090. * @param texture defines the texture we are trying to upload the information to
  50091. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  50092. */
  50093. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  50094. /** @hidden */
  50095. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  50096. }
  50097. }
  50098. declare module "babylonjs/Maths/math.vertexFormat" {
  50099. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  50100. /**
  50101. * Contains position and normal vectors for a vertex
  50102. */
  50103. export class PositionNormalVertex {
  50104. /** the position of the vertex (defaut: 0,0,0) */
  50105. position: Vector3;
  50106. /** the normal of the vertex (defaut: 0,1,0) */
  50107. normal: Vector3;
  50108. /**
  50109. * Creates a PositionNormalVertex
  50110. * @param position the position of the vertex (defaut: 0,0,0)
  50111. * @param normal the normal of the vertex (defaut: 0,1,0)
  50112. */
  50113. constructor(
  50114. /** the position of the vertex (defaut: 0,0,0) */
  50115. position?: Vector3,
  50116. /** the normal of the vertex (defaut: 0,1,0) */
  50117. normal?: Vector3);
  50118. /**
  50119. * Clones the PositionNormalVertex
  50120. * @returns the cloned PositionNormalVertex
  50121. */
  50122. clone(): PositionNormalVertex;
  50123. }
  50124. /**
  50125. * Contains position, normal and uv vectors for a vertex
  50126. */
  50127. export class PositionNormalTextureVertex {
  50128. /** the position of the vertex (defaut: 0,0,0) */
  50129. position: Vector3;
  50130. /** the normal of the vertex (defaut: 0,1,0) */
  50131. normal: Vector3;
  50132. /** the uv of the vertex (default: 0,0) */
  50133. uv: Vector2;
  50134. /**
  50135. * Creates a PositionNormalTextureVertex
  50136. * @param position the position of the vertex (defaut: 0,0,0)
  50137. * @param normal the normal of the vertex (defaut: 0,1,0)
  50138. * @param uv the uv of the vertex (default: 0,0)
  50139. */
  50140. constructor(
  50141. /** the position of the vertex (defaut: 0,0,0) */
  50142. position?: Vector3,
  50143. /** the normal of the vertex (defaut: 0,1,0) */
  50144. normal?: Vector3,
  50145. /** the uv of the vertex (default: 0,0) */
  50146. uv?: Vector2);
  50147. /**
  50148. * Clones the PositionNormalTextureVertex
  50149. * @returns the cloned PositionNormalTextureVertex
  50150. */
  50151. clone(): PositionNormalTextureVertex;
  50152. }
  50153. }
  50154. declare module "babylonjs/Maths/math" {
  50155. export * from "babylonjs/Maths/math.axis";
  50156. export * from "babylonjs/Maths/math.color";
  50157. export * from "babylonjs/Maths/math.constants";
  50158. export * from "babylonjs/Maths/math.frustum";
  50159. export * from "babylonjs/Maths/math.path";
  50160. export * from "babylonjs/Maths/math.plane";
  50161. export * from "babylonjs/Maths/math.size";
  50162. export * from "babylonjs/Maths/math.vector";
  50163. export * from "babylonjs/Maths/math.vertexFormat";
  50164. export * from "babylonjs/Maths/math.viewport";
  50165. }
  50166. declare module "babylonjs/Engines/Native/nativeShaderProcessor" {
  50167. import { WebGL2ShaderProcessor } from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  50168. /** @hidden */
  50169. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  50170. private _genericAttributeLocation;
  50171. private _varyingLocationCount;
  50172. private _varyingLocationMap;
  50173. private _replacements;
  50174. private _textureCount;
  50175. private _uniforms;
  50176. lineProcessor(line: string): string;
  50177. attributeProcessor(attribute: string): string;
  50178. varyingProcessor(varying: string, isFragment: boolean): string;
  50179. uniformProcessor(uniform: string): string;
  50180. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  50181. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  50182. }
  50183. }
  50184. declare module "babylonjs/Engines/nativeEngine" {
  50185. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  50186. import { Engine } from "babylonjs/Engines/engine";
  50187. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  50188. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  50189. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50190. import { Effect } from "babylonjs/Materials/effect";
  50191. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  50192. import { Matrix, Viewport, Color3 } from "babylonjs/Maths/math";
  50193. import { IColor4Like } from "babylonjs/Maths/math.like";
  50194. import { Scene } from "babylonjs/scene";
  50195. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  50196. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  50197. import { ISceneLike } from "babylonjs/Engines/thinEngine";
  50198. /**
  50199. * Container for accessors for natively-stored mesh data buffers.
  50200. */
  50201. class NativeDataBuffer extends DataBuffer {
  50202. /**
  50203. * Accessor value used to identify/retrieve a natively-stored index buffer.
  50204. */
  50205. nativeIndexBuffer?: any;
  50206. /**
  50207. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  50208. */
  50209. nativeVertexBuffer?: any;
  50210. }
  50211. /** @hidden */
  50212. class NativeTexture extends InternalTexture {
  50213. getInternalTexture(): InternalTexture;
  50214. getViewCount(): number;
  50215. }
  50216. /** @hidden */
  50217. export class NativeEngine extends Engine {
  50218. private readonly _native;
  50219. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  50220. private readonly INVALID_HANDLE;
  50221. getHardwareScalingLevel(): number;
  50222. constructor();
  50223. dispose(): void;
  50224. /**
  50225. * Can be used to override the current requestAnimationFrame requester.
  50226. * @hidden
  50227. */
  50228. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  50229. /**
  50230. * Override default engine behavior.
  50231. * @param color
  50232. * @param backBuffer
  50233. * @param depth
  50234. * @param stencil
  50235. */
  50236. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  50237. /**
  50238. * Gets host document
  50239. * @returns the host document object
  50240. */
  50241. getHostDocument(): Nullable<Document>;
  50242. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  50243. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  50244. createVertexBuffer(data: DataArray): NativeDataBuffer;
  50245. recordVertexArrayObject(vertexBuffers: {
  50246. [key: string]: VertexBuffer;
  50247. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  50248. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  50249. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  50250. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  50251. /**
  50252. * Draw a list of indexed primitives
  50253. * @param fillMode defines the primitive to use
  50254. * @param indexStart defines the starting index
  50255. * @param indexCount defines the number of index to draw
  50256. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  50257. */
  50258. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  50259. /**
  50260. * Draw a list of unindexed primitives
  50261. * @param fillMode defines the primitive to use
  50262. * @param verticesStart defines the index of first vertex to draw
  50263. * @param verticesCount defines the count of vertices to draw
  50264. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  50265. */
  50266. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  50267. createPipelineContext(): IPipelineContext;
  50268. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  50269. /** @hidden */
  50270. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  50271. /** @hidden */
  50272. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  50273. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  50274. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  50275. protected _setProgram(program: WebGLProgram): void;
  50276. _releaseEffect(effect: Effect): void;
  50277. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  50278. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  50279. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  50280. bindSamplers(effect: Effect): void;
  50281. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  50282. getRenderWidth(useScreen?: boolean): number;
  50283. getRenderHeight(useScreen?: boolean): number;
  50284. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  50285. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  50286. /**
  50287. * Set the z offset to apply to current rendering
  50288. * @param value defines the offset to apply
  50289. */
  50290. setZOffset(value: number): void;
  50291. /**
  50292. * Gets the current value of the zOffset
  50293. * @returns the current zOffset state
  50294. */
  50295. getZOffset(): number;
  50296. /**
  50297. * Enable or disable depth buffering
  50298. * @param enable defines the state to set
  50299. */
  50300. setDepthBuffer(enable: boolean): void;
  50301. /**
  50302. * Gets a boolean indicating if depth writing is enabled
  50303. * @returns the current depth writing state
  50304. */
  50305. getDepthWrite(): boolean;
  50306. /**
  50307. * Enable or disable depth writing
  50308. * @param enable defines the state to set
  50309. */
  50310. setDepthWrite(enable: boolean): void;
  50311. /**
  50312. * Enable or disable color writing
  50313. * @param enable defines the state to set
  50314. */
  50315. setColorWrite(enable: boolean): void;
  50316. /**
  50317. * Gets a boolean indicating if color writing is enabled
  50318. * @returns the current color writing state
  50319. */
  50320. getColorWrite(): boolean;
  50321. /**
  50322. * Sets alpha constants used by some alpha blending modes
  50323. * @param r defines the red component
  50324. * @param g defines the green component
  50325. * @param b defines the blue component
  50326. * @param a defines the alpha component
  50327. */
  50328. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  50329. /**
  50330. * Sets the current alpha mode
  50331. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  50332. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  50333. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  50334. */
  50335. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  50336. /**
  50337. * Gets the current alpha mode
  50338. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  50339. * @returns the current alpha mode
  50340. */
  50341. getAlphaMode(): number;
  50342. setInt(uniform: WebGLUniformLocation, int: number): void;
  50343. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  50344. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  50345. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  50346. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  50347. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  50348. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  50349. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  50350. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  50351. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  50352. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  50353. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  50354. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  50355. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  50356. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  50357. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  50358. setFloat(uniform: WebGLUniformLocation, value: number): void;
  50359. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  50360. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  50361. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  50362. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  50363. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  50364. wipeCaches(bruteForce?: boolean): void;
  50365. _createTexture(): WebGLTexture;
  50366. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  50367. /**
  50368. * Usually called from Texture.ts.
  50369. * Passed information to create a WebGLTexture
  50370. * @param url defines a value which contains one of the following:
  50371. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  50372. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  50373. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  50374. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  50375. * @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)
  50376. * @param scene needed for loading to the correct scene
  50377. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  50378. * @param onLoad optional callback to be called upon successful completion
  50379. * @param onError optional callback to be called upon failure
  50380. * @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
  50381. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  50382. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  50383. * @param forcedExtension defines the extension to use to pick the right loader
  50384. * @param mimeType defines an optional mime type
  50385. * @returns a InternalTexture for assignment back into BABYLON.Texture
  50386. */
  50387. 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;
  50388. /**
  50389. * Creates a cube texture
  50390. * @param rootUrl defines the url where the files to load is located
  50391. * @param scene defines the current scene
  50392. * @param files defines the list of files to load (1 per face)
  50393. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  50394. * @param onLoad defines an optional callback raised when the texture is loaded
  50395. * @param onError defines an optional callback raised if there is an issue to load the texture
  50396. * @param format defines the format of the data
  50397. * @param forcedExtension defines the extension to use to pick the right loader
  50398. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  50399. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  50400. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  50401. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  50402. * @returns the cube texture as an InternalTexture
  50403. */
  50404. 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;
  50405. private _getSamplingFilter;
  50406. private static _GetNativeTextureFormat;
  50407. createRenderTargetTexture(size: number | {
  50408. width: number;
  50409. height: number;
  50410. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  50411. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  50412. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  50413. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  50414. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  50415. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  50416. /**
  50417. * Updates a dynamic vertex buffer.
  50418. * @param vertexBuffer the vertex buffer to update
  50419. * @param data the data used to update the vertex buffer
  50420. * @param byteOffset the byte offset of the data (optional)
  50421. * @param byteLength the byte length of the data (optional)
  50422. */
  50423. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  50424. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  50425. private _updateAnisotropicLevel;
  50426. private _getAddressMode;
  50427. /** @hidden */
  50428. _bindTexture(channel: number, texture: InternalTexture): void;
  50429. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  50430. releaseEffects(): void;
  50431. /** @hidden */
  50432. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  50433. /** @hidden */
  50434. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  50435. /** @hidden */
  50436. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  50437. /** @hidden */
  50438. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  50439. }
  50440. }
  50441. declare module "babylonjs/Engines/index" {
  50442. export * from "babylonjs/Engines/constants";
  50443. export * from "babylonjs/Engines/engineCapabilities";
  50444. export * from "babylonjs/Engines/instancingAttributeInfo";
  50445. export * from "babylonjs/Engines/thinEngine";
  50446. export * from "babylonjs/Engines/engine";
  50447. export * from "babylonjs/Engines/engineStore";
  50448. export * from "babylonjs/Engines/nullEngine";
  50449. export * from "babylonjs/Engines/Extensions/index";
  50450. export * from "babylonjs/Engines/IPipelineContext";
  50451. export * from "babylonjs/Engines/WebGL/webGLPipelineContext";
  50452. export * from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  50453. export * from "babylonjs/Engines/nativeEngine";
  50454. }
  50455. declare module "babylonjs/Events/clipboardEvents" {
  50456. /**
  50457. * Gather the list of clipboard event types as constants.
  50458. */
  50459. export class ClipboardEventTypes {
  50460. /**
  50461. * The clipboard event is fired when a copy command is active (pressed).
  50462. */
  50463. static readonly COPY: number;
  50464. /**
  50465. * The clipboard event is fired when a cut command is active (pressed).
  50466. */
  50467. static readonly CUT: number;
  50468. /**
  50469. * The clipboard event is fired when a paste command is active (pressed).
  50470. */
  50471. static readonly PASTE: number;
  50472. }
  50473. /**
  50474. * This class is used to store clipboard related info for the onClipboardObservable event.
  50475. */
  50476. export class ClipboardInfo {
  50477. /**
  50478. * Defines the type of event (BABYLON.ClipboardEventTypes)
  50479. */
  50480. type: number;
  50481. /**
  50482. * Defines the related dom event
  50483. */
  50484. event: ClipboardEvent;
  50485. /**
  50486. *Creates an instance of ClipboardInfo.
  50487. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  50488. * @param event Defines the related dom event
  50489. */
  50490. constructor(
  50491. /**
  50492. * Defines the type of event (BABYLON.ClipboardEventTypes)
  50493. */
  50494. type: number,
  50495. /**
  50496. * Defines the related dom event
  50497. */
  50498. event: ClipboardEvent);
  50499. /**
  50500. * Get the clipboard event's type from the keycode.
  50501. * @param keyCode Defines the keyCode for the current keyboard event.
  50502. * @return {number}
  50503. */
  50504. static GetTypeFromCharacter(keyCode: number): number;
  50505. }
  50506. }
  50507. declare module "babylonjs/Events/index" {
  50508. export * from "babylonjs/Events/keyboardEvents";
  50509. export * from "babylonjs/Events/pointerEvents";
  50510. export * from "babylonjs/Events/clipboardEvents";
  50511. }
  50512. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  50513. import { Scene } from "babylonjs/scene";
  50514. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50515. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  50516. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  50517. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  50518. /**
  50519. * Google Daydream controller
  50520. */
  50521. export class DaydreamController extends WebVRController {
  50522. /**
  50523. * Base Url for the controller model.
  50524. */
  50525. static MODEL_BASE_URL: string;
  50526. /**
  50527. * File name for the controller model.
  50528. */
  50529. static MODEL_FILENAME: string;
  50530. /**
  50531. * Gamepad Id prefix used to identify Daydream Controller.
  50532. */
  50533. static readonly GAMEPAD_ID_PREFIX: string;
  50534. /**
  50535. * Creates a new DaydreamController from a gamepad
  50536. * @param vrGamepad the gamepad that the controller should be created from
  50537. */
  50538. constructor(vrGamepad: any);
  50539. /**
  50540. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  50541. * @param scene scene in which to add meshes
  50542. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  50543. */
  50544. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  50545. /**
  50546. * Called once for each button that changed state since the last frame
  50547. * @param buttonIdx Which button index changed
  50548. * @param state New state of the button
  50549. * @param changes Which properties on the state changed since last frame
  50550. */
  50551. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  50552. }
  50553. }
  50554. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  50555. import { Scene } from "babylonjs/scene";
  50556. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50557. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  50558. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  50559. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  50560. /**
  50561. * Gear VR Controller
  50562. */
  50563. export class GearVRController extends WebVRController {
  50564. /**
  50565. * Base Url for the controller model.
  50566. */
  50567. static MODEL_BASE_URL: string;
  50568. /**
  50569. * File name for the controller model.
  50570. */
  50571. static MODEL_FILENAME: string;
  50572. /**
  50573. * Gamepad Id prefix used to identify this controller.
  50574. */
  50575. static readonly GAMEPAD_ID_PREFIX: string;
  50576. private readonly _buttonIndexToObservableNameMap;
  50577. /**
  50578. * Creates a new GearVRController from a gamepad
  50579. * @param vrGamepad the gamepad that the controller should be created from
  50580. */
  50581. constructor(vrGamepad: any);
  50582. /**
  50583. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  50584. * @param scene scene in which to add meshes
  50585. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  50586. */
  50587. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  50588. /**
  50589. * Called once for each button that changed state since the last frame
  50590. * @param buttonIdx Which button index changed
  50591. * @param state New state of the button
  50592. * @param changes Which properties on the state changed since last frame
  50593. */
  50594. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  50595. }
  50596. }
  50597. declare module "babylonjs/Gamepads/Controllers/genericController" {
  50598. import { Scene } from "babylonjs/scene";
  50599. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50600. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  50601. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  50602. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  50603. /**
  50604. * Generic Controller
  50605. */
  50606. export class GenericController extends WebVRController {
  50607. /**
  50608. * Base Url for the controller model.
  50609. */
  50610. static readonly MODEL_BASE_URL: string;
  50611. /**
  50612. * File name for the controller model.
  50613. */
  50614. static readonly MODEL_FILENAME: string;
  50615. /**
  50616. * Creates a new GenericController from a gamepad
  50617. * @param vrGamepad the gamepad that the controller should be created from
  50618. */
  50619. constructor(vrGamepad: any);
  50620. /**
  50621. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  50622. * @param scene scene in which to add meshes
  50623. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  50624. */
  50625. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  50626. /**
  50627. * Called once for each button that changed state since the last frame
  50628. * @param buttonIdx Which button index changed
  50629. * @param state New state of the button
  50630. * @param changes Which properties on the state changed since last frame
  50631. */
  50632. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  50633. }
  50634. }
  50635. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  50636. import { Observable } from "babylonjs/Misc/observable";
  50637. import { Scene } from "babylonjs/scene";
  50638. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50639. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  50640. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  50641. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  50642. /**
  50643. * Oculus Touch Controller
  50644. */
  50645. export class OculusTouchController extends WebVRController {
  50646. /**
  50647. * Base Url for the controller model.
  50648. */
  50649. static MODEL_BASE_URL: string;
  50650. /**
  50651. * File name for the left controller model.
  50652. */
  50653. static MODEL_LEFT_FILENAME: string;
  50654. /**
  50655. * File name for the right controller model.
  50656. */
  50657. static MODEL_RIGHT_FILENAME: string;
  50658. /**
  50659. * Base Url for the Quest controller model.
  50660. */
  50661. static QUEST_MODEL_BASE_URL: string;
  50662. /**
  50663. * @hidden
  50664. * If the controllers are running on a device that needs the updated Quest controller models
  50665. */
  50666. static _IsQuest: boolean;
  50667. /**
  50668. * Fired when the secondary trigger on this controller is modified
  50669. */
  50670. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  50671. /**
  50672. * Fired when the thumb rest on this controller is modified
  50673. */
  50674. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  50675. /**
  50676. * Creates a new OculusTouchController from a gamepad
  50677. * @param vrGamepad the gamepad that the controller should be created from
  50678. */
  50679. constructor(vrGamepad: any);
  50680. /**
  50681. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  50682. * @param scene scene in which to add meshes
  50683. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  50684. */
  50685. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  50686. /**
  50687. * Fired when the A button on this controller is modified
  50688. */
  50689. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50690. /**
  50691. * Fired when the B button on this controller is modified
  50692. */
  50693. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50694. /**
  50695. * Fired when the X button on this controller is modified
  50696. */
  50697. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50698. /**
  50699. * Fired when the Y button on this controller is modified
  50700. */
  50701. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50702. /**
  50703. * Called once for each button that changed state since the last frame
  50704. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  50705. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  50706. * 2) secondary trigger (same)
  50707. * 3) A (right) X (left), touch, pressed = value
  50708. * 4) B / Y
  50709. * 5) thumb rest
  50710. * @param buttonIdx Which button index changed
  50711. * @param state New state of the button
  50712. * @param changes Which properties on the state changed since last frame
  50713. */
  50714. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  50715. }
  50716. }
  50717. declare module "babylonjs/Gamepads/Controllers/viveController" {
  50718. import { Scene } from "babylonjs/scene";
  50719. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50720. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  50721. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  50722. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  50723. import { Observable } from "babylonjs/Misc/observable";
  50724. /**
  50725. * Vive Controller
  50726. */
  50727. export class ViveController extends WebVRController {
  50728. /**
  50729. * Base Url for the controller model.
  50730. */
  50731. static MODEL_BASE_URL: string;
  50732. /**
  50733. * File name for the controller model.
  50734. */
  50735. static MODEL_FILENAME: string;
  50736. /**
  50737. * Creates a new ViveController from a gamepad
  50738. * @param vrGamepad the gamepad that the controller should be created from
  50739. */
  50740. constructor(vrGamepad: any);
  50741. /**
  50742. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  50743. * @param scene scene in which to add meshes
  50744. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  50745. */
  50746. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  50747. /**
  50748. * Fired when the left button on this controller is modified
  50749. */
  50750. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50751. /**
  50752. * Fired when the right button on this controller is modified
  50753. */
  50754. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50755. /**
  50756. * Fired when the menu button on this controller is modified
  50757. */
  50758. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50759. /**
  50760. * Called once for each button that changed state since the last frame
  50761. * Vive mapping:
  50762. * 0: touchpad
  50763. * 1: trigger
  50764. * 2: left AND right buttons
  50765. * 3: menu button
  50766. * @param buttonIdx Which button index changed
  50767. * @param state New state of the button
  50768. * @param changes Which properties on the state changed since last frame
  50769. */
  50770. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  50771. }
  50772. }
  50773. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  50774. import { Observable } from "babylonjs/Misc/observable";
  50775. import { Scene } from "babylonjs/scene";
  50776. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50777. import { Ray } from "babylonjs/Culling/ray";
  50778. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  50779. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  50780. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  50781. /**
  50782. * Defines the WindowsMotionController object that the state of the windows motion controller
  50783. */
  50784. export class WindowsMotionController extends WebVRController {
  50785. /**
  50786. * The base url used to load the left and right controller models
  50787. */
  50788. static MODEL_BASE_URL: string;
  50789. /**
  50790. * The name of the left controller model file
  50791. */
  50792. static MODEL_LEFT_FILENAME: string;
  50793. /**
  50794. * The name of the right controller model file
  50795. */
  50796. static MODEL_RIGHT_FILENAME: string;
  50797. /**
  50798. * The controller name prefix for this controller type
  50799. */
  50800. static readonly GAMEPAD_ID_PREFIX: string;
  50801. /**
  50802. * The controller id pattern for this controller type
  50803. */
  50804. private static readonly GAMEPAD_ID_PATTERN;
  50805. private _loadedMeshInfo;
  50806. protected readonly _mapping: {
  50807. buttons: string[];
  50808. buttonMeshNames: {
  50809. trigger: string;
  50810. menu: string;
  50811. grip: string;
  50812. thumbstick: string;
  50813. trackpad: string;
  50814. };
  50815. buttonObservableNames: {
  50816. trigger: string;
  50817. menu: string;
  50818. grip: string;
  50819. thumbstick: string;
  50820. trackpad: string;
  50821. };
  50822. axisMeshNames: string[];
  50823. pointingPoseMeshName: string;
  50824. };
  50825. /**
  50826. * Fired when the trackpad on this controller is clicked
  50827. */
  50828. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  50829. /**
  50830. * Fired when the trackpad on this controller is modified
  50831. */
  50832. onTrackpadValuesChangedObservable: Observable<StickValues>;
  50833. /**
  50834. * The current x and y values of this controller's trackpad
  50835. */
  50836. trackpad: StickValues;
  50837. /**
  50838. * Creates a new WindowsMotionController from a gamepad
  50839. * @param vrGamepad the gamepad that the controller should be created from
  50840. */
  50841. constructor(vrGamepad: any);
  50842. /**
  50843. * Fired when the trigger on this controller is modified
  50844. */
  50845. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50846. /**
  50847. * Fired when the menu button on this controller is modified
  50848. */
  50849. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50850. /**
  50851. * Fired when the grip button on this controller is modified
  50852. */
  50853. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50854. /**
  50855. * Fired when the thumbstick button on this controller is modified
  50856. */
  50857. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50858. /**
  50859. * Fired when the touchpad button on this controller is modified
  50860. */
  50861. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50862. /**
  50863. * Fired when the touchpad values on this controller are modified
  50864. */
  50865. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  50866. protected _updateTrackpad(): void;
  50867. /**
  50868. * Called once per frame by the engine.
  50869. */
  50870. update(): void;
  50871. /**
  50872. * Called once for each button that changed state since the last frame
  50873. * @param buttonIdx Which button index changed
  50874. * @param state New state of the button
  50875. * @param changes Which properties on the state changed since last frame
  50876. */
  50877. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  50878. /**
  50879. * Moves the buttons on the controller mesh based on their current state
  50880. * @param buttonName the name of the button to move
  50881. * @param buttonValue the value of the button which determines the buttons new position
  50882. */
  50883. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  50884. /**
  50885. * Moves the axis on the controller mesh based on its current state
  50886. * @param axis the index of the axis
  50887. * @param axisValue the value of the axis which determines the meshes new position
  50888. * @hidden
  50889. */
  50890. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  50891. /**
  50892. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  50893. * @param scene scene in which to add meshes
  50894. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  50895. */
  50896. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  50897. /**
  50898. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  50899. * can be transformed by button presses and axes values, based on this._mapping.
  50900. *
  50901. * @param scene scene in which the meshes exist
  50902. * @param meshes list of meshes that make up the controller model to process
  50903. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  50904. */
  50905. private processModel;
  50906. private createMeshInfo;
  50907. /**
  50908. * Gets the ray of the controller in the direction the controller is pointing
  50909. * @param length the length the resulting ray should be
  50910. * @returns a ray in the direction the controller is pointing
  50911. */
  50912. getForwardRay(length?: number): Ray;
  50913. /**
  50914. * Disposes of the controller
  50915. */
  50916. dispose(): void;
  50917. }
  50918. /**
  50919. * This class represents a new windows motion controller in XR.
  50920. */
  50921. export class XRWindowsMotionController extends WindowsMotionController {
  50922. /**
  50923. * Changing the original WIndowsMotionController mapping to fir the new mapping
  50924. */
  50925. protected readonly _mapping: {
  50926. buttons: string[];
  50927. buttonMeshNames: {
  50928. trigger: string;
  50929. menu: string;
  50930. grip: string;
  50931. thumbstick: string;
  50932. trackpad: string;
  50933. };
  50934. buttonObservableNames: {
  50935. trigger: string;
  50936. menu: string;
  50937. grip: string;
  50938. thumbstick: string;
  50939. trackpad: string;
  50940. };
  50941. axisMeshNames: string[];
  50942. pointingPoseMeshName: string;
  50943. };
  50944. /**
  50945. * Construct a new XR-Based windows motion controller
  50946. *
  50947. * @param gamepadInfo the gamepad object from the browser
  50948. */
  50949. constructor(gamepadInfo: any);
  50950. /**
  50951. * holds the thumbstick values (X,Y)
  50952. */
  50953. thumbstickValues: StickValues;
  50954. /**
  50955. * Fired when the thumbstick on this controller is clicked
  50956. */
  50957. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  50958. /**
  50959. * Fired when the thumbstick on this controller is modified
  50960. */
  50961. onThumbstickValuesChangedObservable: Observable<StickValues>;
  50962. /**
  50963. * Fired when the touchpad button on this controller is modified
  50964. */
  50965. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  50966. /**
  50967. * Fired when the touchpad values on this controller are modified
  50968. */
  50969. onTrackpadValuesChangedObservable: Observable<StickValues>;
  50970. /**
  50971. * Fired when the thumbstick button on this controller is modified
  50972. * here to prevent breaking changes
  50973. */
  50974. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50975. /**
  50976. * updating the thumbstick(!) and not the trackpad.
  50977. * This is named this way due to the difference between WebVR and XR and to avoid
  50978. * changing the parent class.
  50979. */
  50980. protected _updateTrackpad(): void;
  50981. /**
  50982. * Disposes the class with joy
  50983. */
  50984. dispose(): void;
  50985. }
  50986. }
  50987. declare module "babylonjs/Gamepads/Controllers/index" {
  50988. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  50989. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  50990. export * from "babylonjs/Gamepads/Controllers/genericController";
  50991. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  50992. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  50993. export * from "babylonjs/Gamepads/Controllers/viveController";
  50994. export * from "babylonjs/Gamepads/Controllers/webVRController";
  50995. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  50996. }
  50997. declare module "babylonjs/Gamepads/index" {
  50998. export * from "babylonjs/Gamepads/Controllers/index";
  50999. export * from "babylonjs/Gamepads/gamepad";
  51000. export * from "babylonjs/Gamepads/gamepadManager";
  51001. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  51002. export * from "babylonjs/Gamepads/xboxGamepad";
  51003. export * from "babylonjs/Gamepads/dualShockGamepad";
  51004. }
  51005. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  51006. import { Scene } from "babylonjs/scene";
  51007. import { Vector4 } from "babylonjs/Maths/math.vector";
  51008. import { Color4 } from "babylonjs/Maths/math.color";
  51009. import { Mesh } from "babylonjs/Meshes/mesh";
  51010. import { Nullable } from "babylonjs/types";
  51011. /**
  51012. * Class containing static functions to help procedurally build meshes
  51013. */
  51014. export class PolyhedronBuilder {
  51015. /**
  51016. * Creates a polyhedron mesh
  51017. * * 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
  51018. * * The parameter `size` (positive float, default 1) sets the polygon size
  51019. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  51020. * * 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`
  51021. * * 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
  51022. * * 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)`)
  51023. * * 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
  51024. * * 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
  51025. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51026. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51027. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51028. * @param name defines the name of the mesh
  51029. * @param options defines the options used to create the mesh
  51030. * @param scene defines the hosting scene
  51031. * @returns the polyhedron mesh
  51032. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  51033. */
  51034. static CreatePolyhedron(name: string, options: {
  51035. type?: number;
  51036. size?: number;
  51037. sizeX?: number;
  51038. sizeY?: number;
  51039. sizeZ?: number;
  51040. custom?: any;
  51041. faceUV?: Vector4[];
  51042. faceColors?: Color4[];
  51043. flat?: boolean;
  51044. updatable?: boolean;
  51045. sideOrientation?: number;
  51046. frontUVs?: Vector4;
  51047. backUVs?: Vector4;
  51048. }, scene?: Nullable<Scene>): Mesh;
  51049. }
  51050. }
  51051. declare module "babylonjs/Gizmos/scaleGizmo" {
  51052. import { Observable } from "babylonjs/Misc/observable";
  51053. import { Nullable } from "babylonjs/types";
  51054. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51055. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  51056. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  51057. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  51058. /**
  51059. * Gizmo that enables scaling a mesh along 3 axis
  51060. */
  51061. export class ScaleGizmo extends Gizmo {
  51062. /**
  51063. * Internal gizmo used for interactions on the x axis
  51064. */
  51065. xGizmo: AxisScaleGizmo;
  51066. /**
  51067. * Internal gizmo used for interactions on the y axis
  51068. */
  51069. yGizmo: AxisScaleGizmo;
  51070. /**
  51071. * Internal gizmo used for interactions on the z axis
  51072. */
  51073. zGizmo: AxisScaleGizmo;
  51074. /**
  51075. * Internal gizmo used to scale all axis equally
  51076. */
  51077. uniformScaleGizmo: AxisScaleGizmo;
  51078. private _meshAttached;
  51079. private _updateGizmoRotationToMatchAttachedMesh;
  51080. private _snapDistance;
  51081. private _scaleRatio;
  51082. private _uniformScalingMesh;
  51083. private _octahedron;
  51084. private _sensitivity;
  51085. /** Fires an event when any of it's sub gizmos are dragged */
  51086. onDragStartObservable: Observable<unknown>;
  51087. /** Fires an event when any of it's sub gizmos are released from dragging */
  51088. onDragEndObservable: Observable<unknown>;
  51089. get attachedMesh(): Nullable<AbstractMesh>;
  51090. set attachedMesh(mesh: Nullable<AbstractMesh>);
  51091. /**
  51092. * Creates a ScaleGizmo
  51093. * @param gizmoLayer The utility layer the gizmo will be added to
  51094. */
  51095. constructor(gizmoLayer?: UtilityLayerRenderer);
  51096. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  51097. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  51098. /**
  51099. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  51100. */
  51101. set snapDistance(value: number);
  51102. get snapDistance(): number;
  51103. /**
  51104. * Ratio for the scale of the gizmo (Default: 1)
  51105. */
  51106. set scaleRatio(value: number);
  51107. get scaleRatio(): number;
  51108. /**
  51109. * Sensitivity factor for dragging (Default: 1)
  51110. */
  51111. set sensitivity(value: number);
  51112. get sensitivity(): number;
  51113. /**
  51114. * Disposes of the gizmo
  51115. */
  51116. dispose(): void;
  51117. }
  51118. }
  51119. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  51120. import { Observable } from "babylonjs/Misc/observable";
  51121. import { Nullable } from "babylonjs/types";
  51122. import { Vector3 } from "babylonjs/Maths/math.vector";
  51123. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51124. import { Mesh } from "babylonjs/Meshes/mesh";
  51125. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  51126. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  51127. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  51128. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  51129. import { Color3 } from "babylonjs/Maths/math.color";
  51130. /**
  51131. * Single axis scale gizmo
  51132. */
  51133. export class AxisScaleGizmo extends Gizmo {
  51134. /**
  51135. * Drag behavior responsible for the gizmos dragging interactions
  51136. */
  51137. dragBehavior: PointerDragBehavior;
  51138. private _pointerObserver;
  51139. /**
  51140. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  51141. */
  51142. snapDistance: number;
  51143. /**
  51144. * Event that fires each time the gizmo snaps to a new location.
  51145. * * snapDistance is the the change in distance
  51146. */
  51147. onSnapObservable: Observable<{
  51148. snapDistance: number;
  51149. }>;
  51150. /**
  51151. * If the scaling operation should be done on all axis (default: false)
  51152. */
  51153. uniformScaling: boolean;
  51154. /**
  51155. * Custom sensitivity value for the drag strength
  51156. */
  51157. sensitivity: number;
  51158. private _isEnabled;
  51159. private _parent;
  51160. private _arrow;
  51161. private _coloredMaterial;
  51162. private _hoverMaterial;
  51163. /**
  51164. * Creates an AxisScaleGizmo
  51165. * @param gizmoLayer The utility layer the gizmo will be added to
  51166. * @param dragAxis The axis which the gizmo will be able to scale on
  51167. * @param color The color of the gizmo
  51168. */
  51169. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  51170. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  51171. /**
  51172. * If the gizmo is enabled
  51173. */
  51174. set isEnabled(value: boolean);
  51175. get isEnabled(): boolean;
  51176. /**
  51177. * Disposes of the gizmo
  51178. */
  51179. dispose(): void;
  51180. /**
  51181. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  51182. * @param mesh The mesh to replace the default mesh of the gizmo
  51183. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  51184. */
  51185. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  51186. }
  51187. }
  51188. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  51189. import { Observable } from "babylonjs/Misc/observable";
  51190. import { Nullable } from "babylonjs/types";
  51191. import { Vector3 } from "babylonjs/Maths/math.vector";
  51192. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51193. import { Mesh } from "babylonjs/Meshes/mesh";
  51194. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  51195. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  51196. import { Color3 } from "babylonjs/Maths/math.color";
  51197. import "babylonjs/Meshes/Builders/boxBuilder";
  51198. /**
  51199. * Bounding box gizmo
  51200. */
  51201. export class BoundingBoxGizmo extends Gizmo {
  51202. private _lineBoundingBox;
  51203. private _rotateSpheresParent;
  51204. private _scaleBoxesParent;
  51205. private _boundingDimensions;
  51206. private _renderObserver;
  51207. private _pointerObserver;
  51208. private _scaleDragSpeed;
  51209. private _tmpQuaternion;
  51210. private _tmpVector;
  51211. private _tmpRotationMatrix;
  51212. /**
  51213. * 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)
  51214. */
  51215. ignoreChildren: boolean;
  51216. /**
  51217. * 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)
  51218. */
  51219. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  51220. /**
  51221. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  51222. */
  51223. rotationSphereSize: number;
  51224. /**
  51225. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  51226. */
  51227. scaleBoxSize: number;
  51228. /**
  51229. * 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)
  51230. */
  51231. fixedDragMeshScreenSize: boolean;
  51232. /**
  51233. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  51234. */
  51235. fixedDragMeshScreenSizeDistanceFactor: number;
  51236. /**
  51237. * Fired when a rotation sphere or scale box is dragged
  51238. */
  51239. onDragStartObservable: Observable<{}>;
  51240. /**
  51241. * Fired when a scale box is dragged
  51242. */
  51243. onScaleBoxDragObservable: Observable<{}>;
  51244. /**
  51245. * Fired when a scale box drag is ended
  51246. */
  51247. onScaleBoxDragEndObservable: Observable<{}>;
  51248. /**
  51249. * Fired when a rotation sphere is dragged
  51250. */
  51251. onRotationSphereDragObservable: Observable<{}>;
  51252. /**
  51253. * Fired when a rotation sphere drag is ended
  51254. */
  51255. onRotationSphereDragEndObservable: Observable<{}>;
  51256. /**
  51257. * 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)
  51258. */
  51259. scalePivot: Nullable<Vector3>;
  51260. /**
  51261. * Mesh used as a pivot to rotate the attached mesh
  51262. */
  51263. private _anchorMesh;
  51264. private _existingMeshScale;
  51265. private _dragMesh;
  51266. private pointerDragBehavior;
  51267. private coloredMaterial;
  51268. private hoverColoredMaterial;
  51269. /**
  51270. * Sets the color of the bounding box gizmo
  51271. * @param color the color to set
  51272. */
  51273. setColor(color: Color3): void;
  51274. /**
  51275. * Creates an BoundingBoxGizmo
  51276. * @param gizmoLayer The utility layer the gizmo will be added to
  51277. * @param color The color of the gizmo
  51278. */
  51279. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  51280. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  51281. private _selectNode;
  51282. /**
  51283. * Updates the bounding box information for the Gizmo
  51284. */
  51285. updateBoundingBox(): void;
  51286. private _updateRotationSpheres;
  51287. private _updateScaleBoxes;
  51288. /**
  51289. * Enables rotation on the specified axis and disables rotation on the others
  51290. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  51291. */
  51292. setEnabledRotationAxis(axis: string): void;
  51293. /**
  51294. * Enables/disables scaling
  51295. * @param enable if scaling should be enabled
  51296. * @param homogeneousScaling defines if scaling should only be homogeneous
  51297. */
  51298. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  51299. private _updateDummy;
  51300. /**
  51301. * Enables a pointer drag behavior on the bounding box of the gizmo
  51302. */
  51303. enableDragBehavior(): void;
  51304. /**
  51305. * Disposes of the gizmo
  51306. */
  51307. dispose(): void;
  51308. /**
  51309. * 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)
  51310. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  51311. * @returns the bounding box mesh with the passed in mesh as a child
  51312. */
  51313. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  51314. /**
  51315. * CustomMeshes are not supported by this gizmo
  51316. * @param mesh The mesh to replace the default mesh of the gizmo
  51317. */
  51318. setCustomMesh(mesh: Mesh): void;
  51319. }
  51320. }
  51321. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  51322. import { Observable } from "babylonjs/Misc/observable";
  51323. import { Nullable } from "babylonjs/types";
  51324. import { Vector3 } from "babylonjs/Maths/math.vector";
  51325. import { Color3 } from "babylonjs/Maths/math.color";
  51326. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51327. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  51328. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  51329. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  51330. import "babylonjs/Meshes/Builders/linesBuilder";
  51331. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  51332. /**
  51333. * Single plane rotation gizmo
  51334. */
  51335. export class PlaneRotationGizmo extends Gizmo {
  51336. /**
  51337. * Drag behavior responsible for the gizmos dragging interactions
  51338. */
  51339. dragBehavior: PointerDragBehavior;
  51340. private _pointerObserver;
  51341. /**
  51342. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  51343. */
  51344. snapDistance: number;
  51345. /**
  51346. * Event that fires each time the gizmo snaps to a new location.
  51347. * * snapDistance is the the change in distance
  51348. */
  51349. onSnapObservable: Observable<{
  51350. snapDistance: number;
  51351. }>;
  51352. private _isEnabled;
  51353. private _parent;
  51354. /**
  51355. * Creates a PlaneRotationGizmo
  51356. * @param gizmoLayer The utility layer the gizmo will be added to
  51357. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  51358. * @param color The color of the gizmo
  51359. * @param tessellation Amount of tessellation to be used when creating rotation circles
  51360. * @param useEulerRotation Use and update Euler angle instead of quaternion
  51361. */
  51362. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  51363. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  51364. /**
  51365. * If the gizmo is enabled
  51366. */
  51367. set isEnabled(value: boolean);
  51368. get isEnabled(): boolean;
  51369. /**
  51370. * Disposes of the gizmo
  51371. */
  51372. dispose(): void;
  51373. }
  51374. }
  51375. declare module "babylonjs/Gizmos/rotationGizmo" {
  51376. import { Observable } from "babylonjs/Misc/observable";
  51377. import { Nullable } from "babylonjs/types";
  51378. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51379. import { Mesh } from "babylonjs/Meshes/mesh";
  51380. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  51381. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  51382. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  51383. /**
  51384. * Gizmo that enables rotating a mesh along 3 axis
  51385. */
  51386. export class RotationGizmo extends Gizmo {
  51387. /**
  51388. * Internal gizmo used for interactions on the x axis
  51389. */
  51390. xGizmo: PlaneRotationGizmo;
  51391. /**
  51392. * Internal gizmo used for interactions on the y axis
  51393. */
  51394. yGizmo: PlaneRotationGizmo;
  51395. /**
  51396. * Internal gizmo used for interactions on the z axis
  51397. */
  51398. zGizmo: PlaneRotationGizmo;
  51399. /** Fires an event when any of it's sub gizmos are dragged */
  51400. onDragStartObservable: Observable<unknown>;
  51401. /** Fires an event when any of it's sub gizmos are released from dragging */
  51402. onDragEndObservable: Observable<unknown>;
  51403. private _meshAttached;
  51404. get attachedMesh(): Nullable<AbstractMesh>;
  51405. set attachedMesh(mesh: Nullable<AbstractMesh>);
  51406. /**
  51407. * Creates a RotationGizmo
  51408. * @param gizmoLayer The utility layer the gizmo will be added to
  51409. * @param tessellation Amount of tessellation to be used when creating rotation circles
  51410. * @param useEulerRotation Use and update Euler angle instead of quaternion
  51411. */
  51412. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  51413. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  51414. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  51415. /**
  51416. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  51417. */
  51418. set snapDistance(value: number);
  51419. get snapDistance(): number;
  51420. /**
  51421. * Ratio for the scale of the gizmo (Default: 1)
  51422. */
  51423. set scaleRatio(value: number);
  51424. get scaleRatio(): number;
  51425. /**
  51426. * Disposes of the gizmo
  51427. */
  51428. dispose(): void;
  51429. /**
  51430. * CustomMeshes are not supported by this gizmo
  51431. * @param mesh The mesh to replace the default mesh of the gizmo
  51432. */
  51433. setCustomMesh(mesh: Mesh): void;
  51434. }
  51435. }
  51436. declare module "babylonjs/Gizmos/gizmoManager" {
  51437. import { Observable } from "babylonjs/Misc/observable";
  51438. import { Nullable } from "babylonjs/types";
  51439. import { Scene, IDisposable } from "babylonjs/scene";
  51440. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51441. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  51442. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  51443. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  51444. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  51445. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  51446. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  51447. /**
  51448. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  51449. */
  51450. export class GizmoManager implements IDisposable {
  51451. private scene;
  51452. /**
  51453. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  51454. */
  51455. gizmos: {
  51456. positionGizmo: Nullable<PositionGizmo>;
  51457. rotationGizmo: Nullable<RotationGizmo>;
  51458. scaleGizmo: Nullable<ScaleGizmo>;
  51459. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  51460. };
  51461. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  51462. clearGizmoOnEmptyPointerEvent: boolean;
  51463. /** Fires an event when the manager is attached to a mesh */
  51464. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  51465. private _gizmosEnabled;
  51466. private _pointerObserver;
  51467. private _attachedMesh;
  51468. private _boundingBoxColor;
  51469. private _defaultUtilityLayer;
  51470. private _defaultKeepDepthUtilityLayer;
  51471. /**
  51472. * When bounding box gizmo is enabled, this can be used to track drag/end events
  51473. */
  51474. boundingBoxDragBehavior: SixDofDragBehavior;
  51475. /**
  51476. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  51477. */
  51478. attachableMeshes: Nullable<Array<AbstractMesh>>;
  51479. /**
  51480. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  51481. */
  51482. usePointerToAttachGizmos: boolean;
  51483. /**
  51484. * Utility layer that the bounding box gizmo belongs to
  51485. */
  51486. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  51487. /**
  51488. * Utility layer that all gizmos besides bounding box belong to
  51489. */
  51490. get utilityLayer(): UtilityLayerRenderer;
  51491. /**
  51492. * Instatiates a gizmo manager
  51493. * @param scene the scene to overlay the gizmos on top of
  51494. */
  51495. constructor(scene: Scene);
  51496. /**
  51497. * Attaches a set of gizmos to the specified mesh
  51498. * @param mesh The mesh the gizmo's should be attached to
  51499. */
  51500. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  51501. /**
  51502. * If the position gizmo is enabled
  51503. */
  51504. set positionGizmoEnabled(value: boolean);
  51505. get positionGizmoEnabled(): boolean;
  51506. /**
  51507. * If the rotation gizmo is enabled
  51508. */
  51509. set rotationGizmoEnabled(value: boolean);
  51510. get rotationGizmoEnabled(): boolean;
  51511. /**
  51512. * If the scale gizmo is enabled
  51513. */
  51514. set scaleGizmoEnabled(value: boolean);
  51515. get scaleGizmoEnabled(): boolean;
  51516. /**
  51517. * If the boundingBox gizmo is enabled
  51518. */
  51519. set boundingBoxGizmoEnabled(value: boolean);
  51520. get boundingBoxGizmoEnabled(): boolean;
  51521. /**
  51522. * Disposes of the gizmo manager
  51523. */
  51524. dispose(): void;
  51525. }
  51526. }
  51527. declare module "babylonjs/Lights/directionalLight" {
  51528. import { Camera } from "babylonjs/Cameras/camera";
  51529. import { Scene } from "babylonjs/scene";
  51530. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  51531. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51532. import { Light } from "babylonjs/Lights/light";
  51533. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  51534. import { Effect } from "babylonjs/Materials/effect";
  51535. /**
  51536. * A directional light is defined by a direction (what a surprise!).
  51537. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  51538. * 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.
  51539. * Documentation: https://doc.babylonjs.com/babylon101/lights
  51540. */
  51541. export class DirectionalLight extends ShadowLight {
  51542. private _shadowFrustumSize;
  51543. /**
  51544. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  51545. */
  51546. get shadowFrustumSize(): number;
  51547. /**
  51548. * Specifies a fix frustum size for the shadow generation.
  51549. */
  51550. set shadowFrustumSize(value: number);
  51551. private _shadowOrthoScale;
  51552. /**
  51553. * Gets the shadow projection scale against the optimal computed one.
  51554. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  51555. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  51556. */
  51557. get shadowOrthoScale(): number;
  51558. /**
  51559. * Sets the shadow projection scale against the optimal computed one.
  51560. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  51561. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  51562. */
  51563. set shadowOrthoScale(value: number);
  51564. /**
  51565. * Automatically compute the projection matrix to best fit (including all the casters)
  51566. * on each frame.
  51567. */
  51568. autoUpdateExtends: boolean;
  51569. /**
  51570. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  51571. * on each frame. autoUpdateExtends must be set to true for this to work
  51572. */
  51573. autoCalcShadowZBounds: boolean;
  51574. private _orthoLeft;
  51575. private _orthoRight;
  51576. private _orthoTop;
  51577. private _orthoBottom;
  51578. /**
  51579. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  51580. * The directional light is emitted from everywhere in the given direction.
  51581. * It can cast shadows.
  51582. * Documentation : https://doc.babylonjs.com/babylon101/lights
  51583. * @param name The friendly name of the light
  51584. * @param direction The direction of the light
  51585. * @param scene The scene the light belongs to
  51586. */
  51587. constructor(name: string, direction: Vector3, scene: Scene);
  51588. /**
  51589. * Returns the string "DirectionalLight".
  51590. * @return The class name
  51591. */
  51592. getClassName(): string;
  51593. /**
  51594. * Returns the integer 1.
  51595. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  51596. */
  51597. getTypeID(): number;
  51598. /**
  51599. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  51600. * Returns the DirectionalLight Shadow projection matrix.
  51601. */
  51602. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  51603. /**
  51604. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  51605. * Returns the DirectionalLight Shadow projection matrix.
  51606. */
  51607. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  51608. /**
  51609. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  51610. * Returns the DirectionalLight Shadow projection matrix.
  51611. */
  51612. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  51613. protected _buildUniformLayout(): void;
  51614. /**
  51615. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  51616. * @param effect The effect to update
  51617. * @param lightIndex The index of the light in the effect to update
  51618. * @returns The directional light
  51619. */
  51620. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  51621. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  51622. /**
  51623. * Gets the minZ used for shadow according to both the scene and the light.
  51624. *
  51625. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  51626. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  51627. * @param activeCamera The camera we are returning the min for
  51628. * @returns the depth min z
  51629. */
  51630. getDepthMinZ(activeCamera: Camera): number;
  51631. /**
  51632. * Gets the maxZ used for shadow according to both the scene and the light.
  51633. *
  51634. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  51635. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  51636. * @param activeCamera The camera we are returning the max for
  51637. * @returns the depth max z
  51638. */
  51639. getDepthMaxZ(activeCamera: Camera): number;
  51640. /**
  51641. * Prepares the list of defines specific to the light type.
  51642. * @param defines the list of defines
  51643. * @param lightIndex defines the index of the light for the effect
  51644. */
  51645. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  51646. }
  51647. }
  51648. declare module "babylonjs/Meshes/Builders/hemisphereBuilder" {
  51649. import { Mesh } from "babylonjs/Meshes/mesh";
  51650. /**
  51651. * Class containing static functions to help procedurally build meshes
  51652. */
  51653. export class HemisphereBuilder {
  51654. /**
  51655. * Creates a hemisphere mesh
  51656. * @param name defines the name of the mesh
  51657. * @param options defines the options used to create the mesh
  51658. * @param scene defines the hosting scene
  51659. * @returns the hemisphere mesh
  51660. */
  51661. static CreateHemisphere(name: string, options: {
  51662. segments?: number;
  51663. diameter?: number;
  51664. sideOrientation?: number;
  51665. }, scene: any): Mesh;
  51666. }
  51667. }
  51668. declare module "babylonjs/Lights/spotLight" {
  51669. import { Nullable } from "babylonjs/types";
  51670. import { Scene } from "babylonjs/scene";
  51671. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  51672. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51673. import { Effect } from "babylonjs/Materials/effect";
  51674. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51675. import { Light } from "babylonjs/Lights/light";
  51676. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  51677. /**
  51678. * A spot light is defined by a position, a direction, an angle, and an exponent.
  51679. * These values define a cone of light starting from the position, emitting toward the direction.
  51680. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  51681. * and the exponent defines the speed of the decay of the light with distance (reach).
  51682. * Documentation: https://doc.babylonjs.com/babylon101/lights
  51683. */
  51684. export class SpotLight extends ShadowLight {
  51685. private _angle;
  51686. private _innerAngle;
  51687. private _cosHalfAngle;
  51688. private _lightAngleScale;
  51689. private _lightAngleOffset;
  51690. /**
  51691. * Gets the cone angle of the spot light in Radians.
  51692. */
  51693. get angle(): number;
  51694. /**
  51695. * Sets the cone angle of the spot light in Radians.
  51696. */
  51697. set angle(value: number);
  51698. /**
  51699. * Only used in gltf falloff mode, this defines the angle where
  51700. * the directional falloff will start before cutting at angle which could be seen
  51701. * as outer angle.
  51702. */
  51703. get innerAngle(): number;
  51704. /**
  51705. * Only used in gltf falloff mode, this defines the angle where
  51706. * the directional falloff will start before cutting at angle which could be seen
  51707. * as outer angle.
  51708. */
  51709. set innerAngle(value: number);
  51710. private _shadowAngleScale;
  51711. /**
  51712. * Allows scaling the angle of the light for shadow generation only.
  51713. */
  51714. get shadowAngleScale(): number;
  51715. /**
  51716. * Allows scaling the angle of the light for shadow generation only.
  51717. */
  51718. set shadowAngleScale(value: number);
  51719. /**
  51720. * The light decay speed with the distance from the emission spot.
  51721. */
  51722. exponent: number;
  51723. private _projectionTextureMatrix;
  51724. /**
  51725. * Allows reading the projecton texture
  51726. */
  51727. get projectionTextureMatrix(): Matrix;
  51728. protected _projectionTextureLightNear: number;
  51729. /**
  51730. * Gets the near clip of the Spotlight for texture projection.
  51731. */
  51732. get projectionTextureLightNear(): number;
  51733. /**
  51734. * Sets the near clip of the Spotlight for texture projection.
  51735. */
  51736. set projectionTextureLightNear(value: number);
  51737. protected _projectionTextureLightFar: number;
  51738. /**
  51739. * Gets the far clip of the Spotlight for texture projection.
  51740. */
  51741. get projectionTextureLightFar(): number;
  51742. /**
  51743. * Sets the far clip of the Spotlight for texture projection.
  51744. */
  51745. set projectionTextureLightFar(value: number);
  51746. protected _projectionTextureUpDirection: Vector3;
  51747. /**
  51748. * Gets the Up vector of the Spotlight for texture projection.
  51749. */
  51750. get projectionTextureUpDirection(): Vector3;
  51751. /**
  51752. * Sets the Up vector of the Spotlight for texture projection.
  51753. */
  51754. set projectionTextureUpDirection(value: Vector3);
  51755. private _projectionTexture;
  51756. /**
  51757. * Gets the projection texture of the light.
  51758. */
  51759. get projectionTexture(): Nullable<BaseTexture>;
  51760. /**
  51761. * Sets the projection texture of the light.
  51762. */
  51763. set projectionTexture(value: Nullable<BaseTexture>);
  51764. private _projectionTextureViewLightDirty;
  51765. private _projectionTextureProjectionLightDirty;
  51766. private _projectionTextureDirty;
  51767. private _projectionTextureViewTargetVector;
  51768. private _projectionTextureViewLightMatrix;
  51769. private _projectionTextureProjectionLightMatrix;
  51770. private _projectionTextureScalingMatrix;
  51771. /**
  51772. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  51773. * It can cast shadows.
  51774. * Documentation : https://doc.babylonjs.com/babylon101/lights
  51775. * @param name The light friendly name
  51776. * @param position The position of the spot light in the scene
  51777. * @param direction The direction of the light in the scene
  51778. * @param angle The cone angle of the light in Radians
  51779. * @param exponent The light decay speed with the distance from the emission spot
  51780. * @param scene The scene the lights belongs to
  51781. */
  51782. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  51783. /**
  51784. * Returns the string "SpotLight".
  51785. * @returns the class name
  51786. */
  51787. getClassName(): string;
  51788. /**
  51789. * Returns the integer 2.
  51790. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  51791. */
  51792. getTypeID(): number;
  51793. /**
  51794. * Overrides the direction setter to recompute the projection texture view light Matrix.
  51795. */
  51796. protected _setDirection(value: Vector3): void;
  51797. /**
  51798. * Overrides the position setter to recompute the projection texture view light Matrix.
  51799. */
  51800. protected _setPosition(value: Vector3): void;
  51801. /**
  51802. * 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.
  51803. * Returns the SpotLight.
  51804. */
  51805. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  51806. protected _computeProjectionTextureViewLightMatrix(): void;
  51807. protected _computeProjectionTextureProjectionLightMatrix(): void;
  51808. /**
  51809. * Main function for light texture projection matrix computing.
  51810. */
  51811. protected _computeProjectionTextureMatrix(): void;
  51812. protected _buildUniformLayout(): void;
  51813. private _computeAngleValues;
  51814. /**
  51815. * Sets the passed Effect "effect" with the Light textures.
  51816. * @param effect The effect to update
  51817. * @param lightIndex The index of the light in the effect to update
  51818. * @returns The light
  51819. */
  51820. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  51821. /**
  51822. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  51823. * @param effect The effect to update
  51824. * @param lightIndex The index of the light in the effect to update
  51825. * @returns The spot light
  51826. */
  51827. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  51828. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  51829. /**
  51830. * Disposes the light and the associated resources.
  51831. */
  51832. dispose(): void;
  51833. /**
  51834. * Prepares the list of defines specific to the light type.
  51835. * @param defines the list of defines
  51836. * @param lightIndex defines the index of the light for the effect
  51837. */
  51838. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  51839. }
  51840. }
  51841. declare module "babylonjs/Gizmos/lightGizmo" {
  51842. import { Nullable } from "babylonjs/types";
  51843. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  51844. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  51845. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  51846. import { Light } from "babylonjs/Lights/light";
  51847. /**
  51848. * Gizmo that enables viewing a light
  51849. */
  51850. export class LightGizmo extends Gizmo {
  51851. private _lightMesh;
  51852. private _material;
  51853. private _cachedPosition;
  51854. private _cachedForward;
  51855. private _attachedMeshParent;
  51856. /**
  51857. * Creates a LightGizmo
  51858. * @param gizmoLayer The utility layer the gizmo will be added to
  51859. */
  51860. constructor(gizmoLayer?: UtilityLayerRenderer);
  51861. private _light;
  51862. /**
  51863. * The light that the gizmo is attached to
  51864. */
  51865. set light(light: Nullable<Light>);
  51866. get light(): Nullable<Light>;
  51867. /**
  51868. * Gets the material used to render the light gizmo
  51869. */
  51870. get material(): StandardMaterial;
  51871. /**
  51872. * @hidden
  51873. * Updates the gizmo to match the attached mesh's position/rotation
  51874. */
  51875. protected _update(): void;
  51876. private static _Scale;
  51877. /**
  51878. * Creates the lines for a light mesh
  51879. */
  51880. private static _CreateLightLines;
  51881. /**
  51882. * Disposes of the light gizmo
  51883. */
  51884. dispose(): void;
  51885. private static _CreateHemisphericLightMesh;
  51886. private static _CreatePointLightMesh;
  51887. private static _CreateSpotLightMesh;
  51888. private static _CreateDirectionalLightMesh;
  51889. }
  51890. }
  51891. declare module "babylonjs/Gizmos/index" {
  51892. export * from "babylonjs/Gizmos/axisDragGizmo";
  51893. export * from "babylonjs/Gizmos/axisScaleGizmo";
  51894. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  51895. export * from "babylonjs/Gizmos/gizmo";
  51896. export * from "babylonjs/Gizmos/gizmoManager";
  51897. export * from "babylonjs/Gizmos/planeRotationGizmo";
  51898. export * from "babylonjs/Gizmos/positionGizmo";
  51899. export * from "babylonjs/Gizmos/rotationGizmo";
  51900. export * from "babylonjs/Gizmos/scaleGizmo";
  51901. export * from "babylonjs/Gizmos/lightGizmo";
  51902. export * from "babylonjs/Gizmos/planeDragGizmo";
  51903. }
  51904. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  51905. /** @hidden */
  51906. export var backgroundFragmentDeclaration: {
  51907. name: string;
  51908. shader: string;
  51909. };
  51910. }
  51911. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  51912. /** @hidden */
  51913. export var backgroundUboDeclaration: {
  51914. name: string;
  51915. shader: string;
  51916. };
  51917. }
  51918. declare module "babylonjs/Shaders/background.fragment" {
  51919. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  51920. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  51921. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  51922. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  51923. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  51924. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  51925. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  51926. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  51927. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  51928. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  51929. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  51930. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  51931. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  51932. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  51933. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  51934. /** @hidden */
  51935. export var backgroundPixelShader: {
  51936. name: string;
  51937. shader: string;
  51938. };
  51939. }
  51940. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  51941. /** @hidden */
  51942. export var backgroundVertexDeclaration: {
  51943. name: string;
  51944. shader: string;
  51945. };
  51946. }
  51947. declare module "babylonjs/Shaders/background.vertex" {
  51948. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  51949. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  51950. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  51951. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  51952. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  51953. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  51954. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  51955. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  51956. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  51957. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  51958. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  51959. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  51960. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  51961. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  51962. /** @hidden */
  51963. export var backgroundVertexShader: {
  51964. name: string;
  51965. shader: string;
  51966. };
  51967. }
  51968. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  51969. import { Nullable, int, float } from "babylonjs/types";
  51970. import { Scene } from "babylonjs/scene";
  51971. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  51972. import { SubMesh } from "babylonjs/Meshes/subMesh";
  51973. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51974. import { Mesh } from "babylonjs/Meshes/mesh";
  51975. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  51976. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  51977. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  51978. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51979. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  51980. import { Color3 } from "babylonjs/Maths/math.color";
  51981. import "babylonjs/Shaders/background.fragment";
  51982. import "babylonjs/Shaders/background.vertex";
  51983. /**
  51984. * Background material used to create an efficient environement around your scene.
  51985. */
  51986. export class BackgroundMaterial extends PushMaterial {
  51987. /**
  51988. * Standard reflectance value at parallel view angle.
  51989. */
  51990. static StandardReflectance0: number;
  51991. /**
  51992. * Standard reflectance value at grazing angle.
  51993. */
  51994. static StandardReflectance90: number;
  51995. protected _primaryColor: Color3;
  51996. /**
  51997. * Key light Color (multiply against the environement texture)
  51998. */
  51999. primaryColor: Color3;
  52000. protected __perceptualColor: Nullable<Color3>;
  52001. /**
  52002. * Experimental Internal Use Only.
  52003. *
  52004. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  52005. * This acts as a helper to set the primary color to a more "human friendly" value.
  52006. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  52007. * output color as close as possible from the chosen value.
  52008. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  52009. * part of lighting setup.)
  52010. */
  52011. get _perceptualColor(): Nullable<Color3>;
  52012. set _perceptualColor(value: Nullable<Color3>);
  52013. protected _primaryColorShadowLevel: float;
  52014. /**
  52015. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  52016. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  52017. */
  52018. get primaryColorShadowLevel(): float;
  52019. set primaryColorShadowLevel(value: float);
  52020. protected _primaryColorHighlightLevel: float;
  52021. /**
  52022. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  52023. * The primary color is used at the level chosen to define what the white area would look.
  52024. */
  52025. get primaryColorHighlightLevel(): float;
  52026. set primaryColorHighlightLevel(value: float);
  52027. protected _reflectionTexture: Nullable<BaseTexture>;
  52028. /**
  52029. * Reflection Texture used in the material.
  52030. * Should be author in a specific way for the best result (refer to the documentation).
  52031. */
  52032. reflectionTexture: Nullable<BaseTexture>;
  52033. protected _reflectionBlur: float;
  52034. /**
  52035. * Reflection Texture level of blur.
  52036. *
  52037. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  52038. * texture twice.
  52039. */
  52040. reflectionBlur: float;
  52041. protected _diffuseTexture: Nullable<BaseTexture>;
  52042. /**
  52043. * Diffuse Texture used in the material.
  52044. * Should be author in a specific way for the best result (refer to the documentation).
  52045. */
  52046. diffuseTexture: Nullable<BaseTexture>;
  52047. protected _shadowLights: Nullable<IShadowLight[]>;
  52048. /**
  52049. * Specify the list of lights casting shadow on the material.
  52050. * All scene shadow lights will be included if null.
  52051. */
  52052. shadowLights: Nullable<IShadowLight[]>;
  52053. protected _shadowLevel: float;
  52054. /**
  52055. * Helps adjusting the shadow to a softer level if required.
  52056. * 0 means black shadows and 1 means no shadows.
  52057. */
  52058. shadowLevel: float;
  52059. protected _sceneCenter: Vector3;
  52060. /**
  52061. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  52062. * It is usually zero but might be interesting to modify according to your setup.
  52063. */
  52064. sceneCenter: Vector3;
  52065. protected _opacityFresnel: boolean;
  52066. /**
  52067. * This helps specifying that the material is falling off to the sky box at grazing angle.
  52068. * This helps ensuring a nice transition when the camera goes under the ground.
  52069. */
  52070. opacityFresnel: boolean;
  52071. protected _reflectionFresnel: boolean;
  52072. /**
  52073. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  52074. * This helps adding a mirror texture on the ground.
  52075. */
  52076. reflectionFresnel: boolean;
  52077. protected _reflectionFalloffDistance: number;
  52078. /**
  52079. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  52080. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  52081. */
  52082. reflectionFalloffDistance: number;
  52083. protected _reflectionAmount: number;
  52084. /**
  52085. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  52086. */
  52087. reflectionAmount: number;
  52088. protected _reflectionReflectance0: number;
  52089. /**
  52090. * This specifies the weight of the reflection at grazing angle.
  52091. */
  52092. reflectionReflectance0: number;
  52093. protected _reflectionReflectance90: number;
  52094. /**
  52095. * This specifies the weight of the reflection at a perpendicular point of view.
  52096. */
  52097. reflectionReflectance90: number;
  52098. /**
  52099. * Sets the reflection reflectance fresnel values according to the default standard
  52100. * empirically know to work well :-)
  52101. */
  52102. set reflectionStandardFresnelWeight(value: number);
  52103. protected _useRGBColor: boolean;
  52104. /**
  52105. * Helps to directly use the maps channels instead of their level.
  52106. */
  52107. useRGBColor: boolean;
  52108. protected _enableNoise: boolean;
  52109. /**
  52110. * This helps reducing the banding effect that could occur on the background.
  52111. */
  52112. enableNoise: boolean;
  52113. /**
  52114. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  52115. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  52116. * Recommended to be keep at 1.0 except for special cases.
  52117. */
  52118. get fovMultiplier(): number;
  52119. set fovMultiplier(value: number);
  52120. private _fovMultiplier;
  52121. /**
  52122. * Enable the FOV adjustment feature controlled by fovMultiplier.
  52123. */
  52124. useEquirectangularFOV: boolean;
  52125. private _maxSimultaneousLights;
  52126. /**
  52127. * Number of Simultaneous lights allowed on the material.
  52128. */
  52129. maxSimultaneousLights: int;
  52130. /**
  52131. * Default configuration related to image processing available in the Background Material.
  52132. */
  52133. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  52134. /**
  52135. * Keep track of the image processing observer to allow dispose and replace.
  52136. */
  52137. private _imageProcessingObserver;
  52138. /**
  52139. * Attaches a new image processing configuration to the PBR Material.
  52140. * @param configuration (if null the scene configuration will be use)
  52141. */
  52142. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  52143. /**
  52144. * Gets the image processing configuration used either in this material.
  52145. */
  52146. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  52147. /**
  52148. * Sets the Default image processing configuration used either in the this material.
  52149. *
  52150. * If sets to null, the scene one is in use.
  52151. */
  52152. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  52153. /**
  52154. * Gets wether the color curves effect is enabled.
  52155. */
  52156. get cameraColorCurvesEnabled(): boolean;
  52157. /**
  52158. * Sets wether the color curves effect is enabled.
  52159. */
  52160. set cameraColorCurvesEnabled(value: boolean);
  52161. /**
  52162. * Gets wether the color grading effect is enabled.
  52163. */
  52164. get cameraColorGradingEnabled(): boolean;
  52165. /**
  52166. * Gets wether the color grading effect is enabled.
  52167. */
  52168. set cameraColorGradingEnabled(value: boolean);
  52169. /**
  52170. * Gets wether tonemapping is enabled or not.
  52171. */
  52172. get cameraToneMappingEnabled(): boolean;
  52173. /**
  52174. * Sets wether tonemapping is enabled or not
  52175. */
  52176. set cameraToneMappingEnabled(value: boolean);
  52177. /**
  52178. * The camera exposure used on this material.
  52179. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  52180. * This corresponds to a photographic exposure.
  52181. */
  52182. get cameraExposure(): float;
  52183. /**
  52184. * The camera exposure used on this material.
  52185. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  52186. * This corresponds to a photographic exposure.
  52187. */
  52188. set cameraExposure(value: float);
  52189. /**
  52190. * Gets The camera contrast used on this material.
  52191. */
  52192. get cameraContrast(): float;
  52193. /**
  52194. * Sets The camera contrast used on this material.
  52195. */
  52196. set cameraContrast(value: float);
  52197. /**
  52198. * Gets the Color Grading 2D Lookup Texture.
  52199. */
  52200. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  52201. /**
  52202. * Sets the Color Grading 2D Lookup Texture.
  52203. */
  52204. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  52205. /**
  52206. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  52207. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  52208. * 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;
  52209. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  52210. */
  52211. get cameraColorCurves(): Nullable<ColorCurves>;
  52212. /**
  52213. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  52214. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  52215. * 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;
  52216. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  52217. */
  52218. set cameraColorCurves(value: Nullable<ColorCurves>);
  52219. /**
  52220. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  52221. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  52222. */
  52223. switchToBGR: boolean;
  52224. private _renderTargets;
  52225. private _reflectionControls;
  52226. private _white;
  52227. private _primaryShadowColor;
  52228. private _primaryHighlightColor;
  52229. /**
  52230. * Instantiates a Background Material in the given scene
  52231. * @param name The friendly name of the material
  52232. * @param scene The scene to add the material to
  52233. */
  52234. constructor(name: string, scene: Scene);
  52235. /**
  52236. * Gets a boolean indicating that current material needs to register RTT
  52237. */
  52238. get hasRenderTargetTextures(): boolean;
  52239. /**
  52240. * The entire material has been created in order to prevent overdraw.
  52241. * @returns false
  52242. */
  52243. needAlphaTesting(): boolean;
  52244. /**
  52245. * The entire material has been created in order to prevent overdraw.
  52246. * @returns true if blending is enable
  52247. */
  52248. needAlphaBlending(): boolean;
  52249. /**
  52250. * Checks wether the material is ready to be rendered for a given mesh.
  52251. * @param mesh The mesh to render
  52252. * @param subMesh The submesh to check against
  52253. * @param useInstances Specify wether or not the material is used with instances
  52254. * @returns true if all the dependencies are ready (Textures, Effects...)
  52255. */
  52256. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  52257. /**
  52258. * Compute the primary color according to the chosen perceptual color.
  52259. */
  52260. private _computePrimaryColorFromPerceptualColor;
  52261. /**
  52262. * Compute the highlights and shadow colors according to their chosen levels.
  52263. */
  52264. private _computePrimaryColors;
  52265. /**
  52266. * Build the uniform buffer used in the material.
  52267. */
  52268. buildUniformLayout(): void;
  52269. /**
  52270. * Unbind the material.
  52271. */
  52272. unbind(): void;
  52273. /**
  52274. * Bind only the world matrix to the material.
  52275. * @param world The world matrix to bind.
  52276. */
  52277. bindOnlyWorldMatrix(world: Matrix): void;
  52278. /**
  52279. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  52280. * @param world The world matrix to bind.
  52281. * @param subMesh The submesh to bind for.
  52282. */
  52283. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  52284. /**
  52285. * Checks to see if a texture is used in the material.
  52286. * @param texture - Base texture to use.
  52287. * @returns - Boolean specifying if a texture is used in the material.
  52288. */
  52289. hasTexture(texture: BaseTexture): boolean;
  52290. /**
  52291. * Dispose the material.
  52292. * @param forceDisposeEffect Force disposal of the associated effect.
  52293. * @param forceDisposeTextures Force disposal of the associated textures.
  52294. */
  52295. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  52296. /**
  52297. * Clones the material.
  52298. * @param name The cloned name.
  52299. * @returns The cloned material.
  52300. */
  52301. clone(name: string): BackgroundMaterial;
  52302. /**
  52303. * Serializes the current material to its JSON representation.
  52304. * @returns The JSON representation.
  52305. */
  52306. serialize(): any;
  52307. /**
  52308. * Gets the class name of the material
  52309. * @returns "BackgroundMaterial"
  52310. */
  52311. getClassName(): string;
  52312. /**
  52313. * Parse a JSON input to create back a background material.
  52314. * @param source The JSON data to parse
  52315. * @param scene The scene to create the parsed material in
  52316. * @param rootUrl The root url of the assets the material depends upon
  52317. * @returns the instantiated BackgroundMaterial.
  52318. */
  52319. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  52320. }
  52321. }
  52322. declare module "babylonjs/Helpers/environmentHelper" {
  52323. import { Observable } from "babylonjs/Misc/observable";
  52324. import { Nullable } from "babylonjs/types";
  52325. import { Scene } from "babylonjs/scene";
  52326. import { Vector3 } from "babylonjs/Maths/math.vector";
  52327. import { Color3 } from "babylonjs/Maths/math.color";
  52328. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52329. import { Mesh } from "babylonjs/Meshes/mesh";
  52330. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52331. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  52332. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  52333. import "babylonjs/Meshes/Builders/planeBuilder";
  52334. import "babylonjs/Meshes/Builders/boxBuilder";
  52335. /**
  52336. * Represents the different options available during the creation of
  52337. * a Environment helper.
  52338. *
  52339. * This can control the default ground, skybox and image processing setup of your scene.
  52340. */
  52341. export interface IEnvironmentHelperOptions {
  52342. /**
  52343. * Specifies whether or not to create a ground.
  52344. * True by default.
  52345. */
  52346. createGround: boolean;
  52347. /**
  52348. * Specifies the ground size.
  52349. * 15 by default.
  52350. */
  52351. groundSize: number;
  52352. /**
  52353. * The texture used on the ground for the main color.
  52354. * Comes from the BabylonJS CDN by default.
  52355. *
  52356. * Remarks: Can be either a texture or a url.
  52357. */
  52358. groundTexture: string | BaseTexture;
  52359. /**
  52360. * The color mixed in the ground texture by default.
  52361. * BabylonJS clearColor by default.
  52362. */
  52363. groundColor: Color3;
  52364. /**
  52365. * Specifies the ground opacity.
  52366. * 1 by default.
  52367. */
  52368. groundOpacity: number;
  52369. /**
  52370. * Enables the ground to receive shadows.
  52371. * True by default.
  52372. */
  52373. enableGroundShadow: boolean;
  52374. /**
  52375. * Helps preventing the shadow to be fully black on the ground.
  52376. * 0.5 by default.
  52377. */
  52378. groundShadowLevel: number;
  52379. /**
  52380. * Creates a mirror texture attach to the ground.
  52381. * false by default.
  52382. */
  52383. enableGroundMirror: boolean;
  52384. /**
  52385. * Specifies the ground mirror size ratio.
  52386. * 0.3 by default as the default kernel is 64.
  52387. */
  52388. groundMirrorSizeRatio: number;
  52389. /**
  52390. * Specifies the ground mirror blur kernel size.
  52391. * 64 by default.
  52392. */
  52393. groundMirrorBlurKernel: number;
  52394. /**
  52395. * Specifies the ground mirror visibility amount.
  52396. * 1 by default
  52397. */
  52398. groundMirrorAmount: number;
  52399. /**
  52400. * Specifies the ground mirror reflectance weight.
  52401. * This uses the standard weight of the background material to setup the fresnel effect
  52402. * of the mirror.
  52403. * 1 by default.
  52404. */
  52405. groundMirrorFresnelWeight: number;
  52406. /**
  52407. * Specifies the ground mirror Falloff distance.
  52408. * This can helps reducing the size of the reflection.
  52409. * 0 by Default.
  52410. */
  52411. groundMirrorFallOffDistance: number;
  52412. /**
  52413. * Specifies the ground mirror texture type.
  52414. * Unsigned Int by Default.
  52415. */
  52416. groundMirrorTextureType: number;
  52417. /**
  52418. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  52419. * the shown objects.
  52420. */
  52421. groundYBias: number;
  52422. /**
  52423. * Specifies whether or not to create a skybox.
  52424. * True by default.
  52425. */
  52426. createSkybox: boolean;
  52427. /**
  52428. * Specifies the skybox size.
  52429. * 20 by default.
  52430. */
  52431. skyboxSize: number;
  52432. /**
  52433. * The texture used on the skybox for the main color.
  52434. * Comes from the BabylonJS CDN by default.
  52435. *
  52436. * Remarks: Can be either a texture or a url.
  52437. */
  52438. skyboxTexture: string | BaseTexture;
  52439. /**
  52440. * The color mixed in the skybox texture by default.
  52441. * BabylonJS clearColor by default.
  52442. */
  52443. skyboxColor: Color3;
  52444. /**
  52445. * The background rotation around the Y axis of the scene.
  52446. * This helps aligning the key lights of your scene with the background.
  52447. * 0 by default.
  52448. */
  52449. backgroundYRotation: number;
  52450. /**
  52451. * Compute automatically the size of the elements to best fit with the scene.
  52452. */
  52453. sizeAuto: boolean;
  52454. /**
  52455. * Default position of the rootMesh if autoSize is not true.
  52456. */
  52457. rootPosition: Vector3;
  52458. /**
  52459. * Sets up the image processing in the scene.
  52460. * true by default.
  52461. */
  52462. setupImageProcessing: boolean;
  52463. /**
  52464. * The texture used as your environment texture in the scene.
  52465. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  52466. *
  52467. * Remarks: Can be either a texture or a url.
  52468. */
  52469. environmentTexture: string | BaseTexture;
  52470. /**
  52471. * The value of the exposure to apply to the scene.
  52472. * 0.6 by default if setupImageProcessing is true.
  52473. */
  52474. cameraExposure: number;
  52475. /**
  52476. * The value of the contrast to apply to the scene.
  52477. * 1.6 by default if setupImageProcessing is true.
  52478. */
  52479. cameraContrast: number;
  52480. /**
  52481. * Specifies whether or not tonemapping should be enabled in the scene.
  52482. * true by default if setupImageProcessing is true.
  52483. */
  52484. toneMappingEnabled: boolean;
  52485. }
  52486. /**
  52487. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  52488. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  52489. * It also helps with the default setup of your imageProcessing configuration.
  52490. */
  52491. export class EnvironmentHelper {
  52492. /**
  52493. * Default ground texture URL.
  52494. */
  52495. private static _groundTextureCDNUrl;
  52496. /**
  52497. * Default skybox texture URL.
  52498. */
  52499. private static _skyboxTextureCDNUrl;
  52500. /**
  52501. * Default environment texture URL.
  52502. */
  52503. private static _environmentTextureCDNUrl;
  52504. /**
  52505. * Creates the default options for the helper.
  52506. */
  52507. private static _getDefaultOptions;
  52508. private _rootMesh;
  52509. /**
  52510. * Gets the root mesh created by the helper.
  52511. */
  52512. get rootMesh(): Mesh;
  52513. private _skybox;
  52514. /**
  52515. * Gets the skybox created by the helper.
  52516. */
  52517. get skybox(): Nullable<Mesh>;
  52518. private _skyboxTexture;
  52519. /**
  52520. * Gets the skybox texture created by the helper.
  52521. */
  52522. get skyboxTexture(): Nullable<BaseTexture>;
  52523. private _skyboxMaterial;
  52524. /**
  52525. * Gets the skybox material created by the helper.
  52526. */
  52527. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  52528. private _ground;
  52529. /**
  52530. * Gets the ground mesh created by the helper.
  52531. */
  52532. get ground(): Nullable<Mesh>;
  52533. private _groundTexture;
  52534. /**
  52535. * Gets the ground texture created by the helper.
  52536. */
  52537. get groundTexture(): Nullable<BaseTexture>;
  52538. private _groundMirror;
  52539. /**
  52540. * Gets the ground mirror created by the helper.
  52541. */
  52542. get groundMirror(): Nullable<MirrorTexture>;
  52543. /**
  52544. * Gets the ground mirror render list to helps pushing the meshes
  52545. * you wish in the ground reflection.
  52546. */
  52547. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  52548. private _groundMaterial;
  52549. /**
  52550. * Gets the ground material created by the helper.
  52551. */
  52552. get groundMaterial(): Nullable<BackgroundMaterial>;
  52553. /**
  52554. * Stores the creation options.
  52555. */
  52556. private readonly _scene;
  52557. private _options;
  52558. /**
  52559. * This observable will be notified with any error during the creation of the environment,
  52560. * mainly texture creation errors.
  52561. */
  52562. onErrorObservable: Observable<{
  52563. message?: string;
  52564. exception?: any;
  52565. }>;
  52566. /**
  52567. * constructor
  52568. * @param options Defines the options we want to customize the helper
  52569. * @param scene The scene to add the material to
  52570. */
  52571. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  52572. /**
  52573. * Updates the background according to the new options
  52574. * @param options
  52575. */
  52576. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  52577. /**
  52578. * Sets the primary color of all the available elements.
  52579. * @param color the main color to affect to the ground and the background
  52580. */
  52581. setMainColor(color: Color3): void;
  52582. /**
  52583. * Setup the image processing according to the specified options.
  52584. */
  52585. private _setupImageProcessing;
  52586. /**
  52587. * Setup the environment texture according to the specified options.
  52588. */
  52589. private _setupEnvironmentTexture;
  52590. /**
  52591. * Setup the background according to the specified options.
  52592. */
  52593. private _setupBackground;
  52594. /**
  52595. * Get the scene sizes according to the setup.
  52596. */
  52597. private _getSceneSize;
  52598. /**
  52599. * Setup the ground according to the specified options.
  52600. */
  52601. private _setupGround;
  52602. /**
  52603. * Setup the ground material according to the specified options.
  52604. */
  52605. private _setupGroundMaterial;
  52606. /**
  52607. * Setup the ground diffuse texture according to the specified options.
  52608. */
  52609. private _setupGroundDiffuseTexture;
  52610. /**
  52611. * Setup the ground mirror texture according to the specified options.
  52612. */
  52613. private _setupGroundMirrorTexture;
  52614. /**
  52615. * Setup the ground to receive the mirror texture.
  52616. */
  52617. private _setupMirrorInGroundMaterial;
  52618. /**
  52619. * Setup the skybox according to the specified options.
  52620. */
  52621. private _setupSkybox;
  52622. /**
  52623. * Setup the skybox material according to the specified options.
  52624. */
  52625. private _setupSkyboxMaterial;
  52626. /**
  52627. * Setup the skybox reflection texture according to the specified options.
  52628. */
  52629. private _setupSkyboxReflectionTexture;
  52630. private _errorHandler;
  52631. /**
  52632. * Dispose all the elements created by the Helper.
  52633. */
  52634. dispose(): void;
  52635. }
  52636. }
  52637. declare module "babylonjs/Helpers/photoDome" {
  52638. import { Observable } from "babylonjs/Misc/observable";
  52639. import { Nullable } from "babylonjs/types";
  52640. import { Scene } from "babylonjs/scene";
  52641. import { TransformNode } from "babylonjs/Meshes/transformNode";
  52642. import { Mesh } from "babylonjs/Meshes/mesh";
  52643. import { Texture } from "babylonjs/Materials/Textures/texture";
  52644. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  52645. import "babylonjs/Meshes/Builders/sphereBuilder";
  52646. /**
  52647. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  52648. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  52649. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  52650. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  52651. */
  52652. export class PhotoDome extends TransformNode {
  52653. /**
  52654. * Define the image as a Monoscopic panoramic 360 image.
  52655. */
  52656. static readonly MODE_MONOSCOPIC: number;
  52657. /**
  52658. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  52659. */
  52660. static readonly MODE_TOPBOTTOM: number;
  52661. /**
  52662. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  52663. */
  52664. static readonly MODE_SIDEBYSIDE: number;
  52665. private _useDirectMapping;
  52666. /**
  52667. * The texture being displayed on the sphere
  52668. */
  52669. protected _photoTexture: Texture;
  52670. /**
  52671. * Gets or sets the texture being displayed on the sphere
  52672. */
  52673. get photoTexture(): Texture;
  52674. set photoTexture(value: Texture);
  52675. /**
  52676. * Observable raised when an error occured while loading the 360 image
  52677. */
  52678. onLoadErrorObservable: Observable<string>;
  52679. /**
  52680. * The skybox material
  52681. */
  52682. protected _material: BackgroundMaterial;
  52683. /**
  52684. * The surface used for the skybox
  52685. */
  52686. protected _mesh: Mesh;
  52687. /**
  52688. * Gets the mesh used for the skybox.
  52689. */
  52690. get mesh(): Mesh;
  52691. /**
  52692. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  52693. * Also see the options.resolution property.
  52694. */
  52695. get fovMultiplier(): number;
  52696. set fovMultiplier(value: number);
  52697. private _imageMode;
  52698. /**
  52699. * Gets or set the current video mode for the video. It can be:
  52700. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  52701. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  52702. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  52703. */
  52704. get imageMode(): number;
  52705. set imageMode(value: number);
  52706. /**
  52707. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  52708. * @param name Element's name, child elements will append suffixes for their own names.
  52709. * @param urlsOfPhoto defines the url of the photo to display
  52710. * @param options defines an object containing optional or exposed sub element properties
  52711. * @param onError defines a callback called when an error occured while loading the texture
  52712. */
  52713. constructor(name: string, urlOfPhoto: string, options: {
  52714. resolution?: number;
  52715. size?: number;
  52716. useDirectMapping?: boolean;
  52717. faceForward?: boolean;
  52718. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  52719. private _onBeforeCameraRenderObserver;
  52720. private _changeImageMode;
  52721. /**
  52722. * Releases resources associated with this node.
  52723. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  52724. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  52725. */
  52726. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  52727. }
  52728. }
  52729. declare module "babylonjs/Misc/rgbdTextureTools" {
  52730. import "babylonjs/Shaders/rgbdDecode.fragment";
  52731. import "babylonjs/Engines/Extensions/engine.renderTarget";
  52732. import { Texture } from "babylonjs/Materials/Textures/texture";
  52733. /**
  52734. * Class used to host RGBD texture specific utilities
  52735. */
  52736. export class RGBDTextureTools {
  52737. /**
  52738. * Expand the RGBD Texture from RGBD to Half Float if possible.
  52739. * @param texture the texture to expand.
  52740. */
  52741. static ExpandRGBDTexture(texture: Texture): void;
  52742. }
  52743. }
  52744. declare module "babylonjs/Misc/brdfTextureTools" {
  52745. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52746. import { Scene } from "babylonjs/scene";
  52747. /**
  52748. * Class used to host texture specific utilities
  52749. */
  52750. export class BRDFTextureTools {
  52751. /**
  52752. * Prevents texture cache collision
  52753. */
  52754. private static _instanceNumber;
  52755. /**
  52756. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  52757. * @param scene defines the hosting scene
  52758. * @returns the environment BRDF texture
  52759. */
  52760. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  52761. private static _environmentBRDFBase64Texture;
  52762. }
  52763. }
  52764. declare module "babylonjs/Materials/PBR/pbrClearCoatConfiguration" {
  52765. import { Nullable } from "babylonjs/types";
  52766. import { Color3 } from "babylonjs/Maths/math.color";
  52767. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52768. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  52769. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  52770. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  52771. import { Engine } from "babylonjs/Engines/engine";
  52772. import { Scene } from "babylonjs/scene";
  52773. /**
  52774. * @hidden
  52775. */
  52776. export interface IMaterialClearCoatDefines {
  52777. CLEARCOAT: boolean;
  52778. CLEARCOAT_DEFAULTIOR: boolean;
  52779. CLEARCOAT_TEXTURE: boolean;
  52780. CLEARCOAT_TEXTUREDIRECTUV: number;
  52781. CLEARCOAT_BUMP: boolean;
  52782. CLEARCOAT_BUMPDIRECTUV: number;
  52783. CLEARCOAT_TINT: boolean;
  52784. CLEARCOAT_TINT_TEXTURE: boolean;
  52785. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  52786. /** @hidden */
  52787. _areTexturesDirty: boolean;
  52788. }
  52789. /**
  52790. * Define the code related to the clear coat parameters of the pbr material.
  52791. */
  52792. export class PBRClearCoatConfiguration {
  52793. /**
  52794. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  52795. * The default fits with a polyurethane material.
  52796. */
  52797. private static readonly _DefaultIndexOfRefraction;
  52798. private _isEnabled;
  52799. /**
  52800. * Defines if the clear coat is enabled in the material.
  52801. */
  52802. isEnabled: boolean;
  52803. /**
  52804. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  52805. */
  52806. intensity: number;
  52807. /**
  52808. * Defines the clear coat layer roughness.
  52809. */
  52810. roughness: number;
  52811. private _indexOfRefraction;
  52812. /**
  52813. * Defines the index of refraction of the clear coat.
  52814. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  52815. * The default fits with a polyurethane material.
  52816. * Changing the default value is more performance intensive.
  52817. */
  52818. indexOfRefraction: number;
  52819. private _texture;
  52820. /**
  52821. * Stores the clear coat values in a texture.
  52822. */
  52823. texture: Nullable<BaseTexture>;
  52824. private _bumpTexture;
  52825. /**
  52826. * Define the clear coat specific bump texture.
  52827. */
  52828. bumpTexture: Nullable<BaseTexture>;
  52829. private _isTintEnabled;
  52830. /**
  52831. * Defines if the clear coat tint is enabled in the material.
  52832. */
  52833. isTintEnabled: boolean;
  52834. /**
  52835. * Defines the clear coat tint of the material.
  52836. * This is only use if tint is enabled
  52837. */
  52838. tintColor: Color3;
  52839. /**
  52840. * Defines the distance at which the tint color should be found in the
  52841. * clear coat media.
  52842. * This is only use if tint is enabled
  52843. */
  52844. tintColorAtDistance: number;
  52845. /**
  52846. * Defines the clear coat layer thickness.
  52847. * This is only use if tint is enabled
  52848. */
  52849. tintThickness: number;
  52850. private _tintTexture;
  52851. /**
  52852. * Stores the clear tint values in a texture.
  52853. * rgb is tint
  52854. * a is a thickness factor
  52855. */
  52856. tintTexture: Nullable<BaseTexture>;
  52857. /** @hidden */
  52858. private _internalMarkAllSubMeshesAsTexturesDirty;
  52859. /** @hidden */
  52860. _markAllSubMeshesAsTexturesDirty(): void;
  52861. /**
  52862. * Instantiate a new istance of clear coat configuration.
  52863. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  52864. */
  52865. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  52866. /**
  52867. * Gets wehter the submesh is ready to be used or not.
  52868. * @param defines the list of "defines" to update.
  52869. * @param scene defines the scene the material belongs to.
  52870. * @param engine defines the engine the material belongs to.
  52871. * @param disableBumpMap defines wether the material disables bump or not.
  52872. * @returns - boolean indicating that the submesh is ready or not.
  52873. */
  52874. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  52875. /**
  52876. * Checks to see if a texture is used in the material.
  52877. * @param defines the list of "defines" to update.
  52878. * @param scene defines the scene to the material belongs to.
  52879. */
  52880. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  52881. /**
  52882. * Binds the material data.
  52883. * @param uniformBuffer defines the Uniform buffer to fill in.
  52884. * @param scene defines the scene the material belongs to.
  52885. * @param engine defines the engine the material belongs to.
  52886. * @param disableBumpMap defines wether the material disables bump or not.
  52887. * @param isFrozen defines wether the material is frozen or not.
  52888. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  52889. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  52890. */
  52891. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  52892. /**
  52893. * Checks to see if a texture is used in the material.
  52894. * @param texture - Base texture to use.
  52895. * @returns - Boolean specifying if a texture is used in the material.
  52896. */
  52897. hasTexture(texture: BaseTexture): boolean;
  52898. /**
  52899. * Returns an array of the actively used textures.
  52900. * @param activeTextures Array of BaseTextures
  52901. */
  52902. getActiveTextures(activeTextures: BaseTexture[]): void;
  52903. /**
  52904. * Returns the animatable textures.
  52905. * @param animatables Array of animatable textures.
  52906. */
  52907. getAnimatables(animatables: IAnimatable[]): void;
  52908. /**
  52909. * Disposes the resources of the material.
  52910. * @param forceDisposeTextures - Forces the disposal of all textures.
  52911. */
  52912. dispose(forceDisposeTextures?: boolean): void;
  52913. /**
  52914. * Get the current class name of the texture useful for serialization or dynamic coding.
  52915. * @returns "PBRClearCoatConfiguration"
  52916. */
  52917. getClassName(): string;
  52918. /**
  52919. * Add fallbacks to the effect fallbacks list.
  52920. * @param defines defines the Base texture to use.
  52921. * @param fallbacks defines the current fallback list.
  52922. * @param currentRank defines the current fallback rank.
  52923. * @returns the new fallback rank.
  52924. */
  52925. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  52926. /**
  52927. * Add the required uniforms to the current list.
  52928. * @param uniforms defines the current uniform list.
  52929. */
  52930. static AddUniforms(uniforms: string[]): void;
  52931. /**
  52932. * Add the required samplers to the current list.
  52933. * @param samplers defines the current sampler list.
  52934. */
  52935. static AddSamplers(samplers: string[]): void;
  52936. /**
  52937. * Add the required uniforms to the current buffer.
  52938. * @param uniformBuffer defines the current uniform buffer.
  52939. */
  52940. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  52941. /**
  52942. * Makes a duplicate of the current configuration into another one.
  52943. * @param clearCoatConfiguration define the config where to copy the info
  52944. */
  52945. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  52946. /**
  52947. * Serializes this clear coat configuration.
  52948. * @returns - An object with the serialized config.
  52949. */
  52950. serialize(): any;
  52951. /**
  52952. * Parses a anisotropy Configuration from a serialized object.
  52953. * @param source - Serialized object.
  52954. * @param scene Defines the scene we are parsing for
  52955. * @param rootUrl Defines the rootUrl to load from
  52956. */
  52957. parse(source: any, scene: Scene, rootUrl: string): void;
  52958. }
  52959. }
  52960. declare module "babylonjs/Materials/PBR/pbrAnisotropicConfiguration" {
  52961. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  52962. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52963. import { Vector2 } from "babylonjs/Maths/math.vector";
  52964. import { Scene } from "babylonjs/scene";
  52965. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52966. import { Nullable } from "babylonjs/types";
  52967. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  52968. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  52969. /**
  52970. * @hidden
  52971. */
  52972. export interface IMaterialAnisotropicDefines {
  52973. ANISOTROPIC: boolean;
  52974. ANISOTROPIC_TEXTURE: boolean;
  52975. ANISOTROPIC_TEXTUREDIRECTUV: number;
  52976. MAINUV1: boolean;
  52977. _areTexturesDirty: boolean;
  52978. _needUVs: boolean;
  52979. }
  52980. /**
  52981. * Define the code related to the anisotropic parameters of the pbr material.
  52982. */
  52983. export class PBRAnisotropicConfiguration {
  52984. private _isEnabled;
  52985. /**
  52986. * Defines if the anisotropy is enabled in the material.
  52987. */
  52988. isEnabled: boolean;
  52989. /**
  52990. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  52991. */
  52992. intensity: number;
  52993. /**
  52994. * Defines if the effect is along the tangents, bitangents or in between.
  52995. * By default, the effect is "strectching" the highlights along the tangents.
  52996. */
  52997. direction: Vector2;
  52998. private _texture;
  52999. /**
  53000. * Stores the anisotropy values in a texture.
  53001. * rg is direction (like normal from -1 to 1)
  53002. * b is a intensity
  53003. */
  53004. texture: Nullable<BaseTexture>;
  53005. /** @hidden */
  53006. private _internalMarkAllSubMeshesAsTexturesDirty;
  53007. /** @hidden */
  53008. _markAllSubMeshesAsTexturesDirty(): void;
  53009. /**
  53010. * Instantiate a new istance of anisotropy configuration.
  53011. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  53012. */
  53013. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  53014. /**
  53015. * Specifies that the submesh is ready to be used.
  53016. * @param defines the list of "defines" to update.
  53017. * @param scene defines the scene the material belongs to.
  53018. * @returns - boolean indicating that the submesh is ready or not.
  53019. */
  53020. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  53021. /**
  53022. * Checks to see if a texture is used in the material.
  53023. * @param defines the list of "defines" to update.
  53024. * @param mesh the mesh we are preparing the defines for.
  53025. * @param scene defines the scene the material belongs to.
  53026. */
  53027. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  53028. /**
  53029. * Binds the material data.
  53030. * @param uniformBuffer defines the Uniform buffer to fill in.
  53031. * @param scene defines the scene the material belongs to.
  53032. * @param isFrozen defines wether the material is frozen or not.
  53033. */
  53034. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  53035. /**
  53036. * Checks to see if a texture is used in the material.
  53037. * @param texture - Base texture to use.
  53038. * @returns - Boolean specifying if a texture is used in the material.
  53039. */
  53040. hasTexture(texture: BaseTexture): boolean;
  53041. /**
  53042. * Returns an array of the actively used textures.
  53043. * @param activeTextures Array of BaseTextures
  53044. */
  53045. getActiveTextures(activeTextures: BaseTexture[]): void;
  53046. /**
  53047. * Returns the animatable textures.
  53048. * @param animatables Array of animatable textures.
  53049. */
  53050. getAnimatables(animatables: IAnimatable[]): void;
  53051. /**
  53052. * Disposes the resources of the material.
  53053. * @param forceDisposeTextures - Forces the disposal of all textures.
  53054. */
  53055. dispose(forceDisposeTextures?: boolean): void;
  53056. /**
  53057. * Get the current class name of the texture useful for serialization or dynamic coding.
  53058. * @returns "PBRAnisotropicConfiguration"
  53059. */
  53060. getClassName(): string;
  53061. /**
  53062. * Add fallbacks to the effect fallbacks list.
  53063. * @param defines defines the Base texture to use.
  53064. * @param fallbacks defines the current fallback list.
  53065. * @param currentRank defines the current fallback rank.
  53066. * @returns the new fallback rank.
  53067. */
  53068. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  53069. /**
  53070. * Add the required uniforms to the current list.
  53071. * @param uniforms defines the current uniform list.
  53072. */
  53073. static AddUniforms(uniforms: string[]): void;
  53074. /**
  53075. * Add the required uniforms to the current buffer.
  53076. * @param uniformBuffer defines the current uniform buffer.
  53077. */
  53078. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  53079. /**
  53080. * Add the required samplers to the current list.
  53081. * @param samplers defines the current sampler list.
  53082. */
  53083. static AddSamplers(samplers: string[]): void;
  53084. /**
  53085. * Makes a duplicate of the current configuration into another one.
  53086. * @param anisotropicConfiguration define the config where to copy the info
  53087. */
  53088. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  53089. /**
  53090. * Serializes this anisotropy configuration.
  53091. * @returns - An object with the serialized config.
  53092. */
  53093. serialize(): any;
  53094. /**
  53095. * Parses a anisotropy Configuration from a serialized object.
  53096. * @param source - Serialized object.
  53097. * @param scene Defines the scene we are parsing for
  53098. * @param rootUrl Defines the rootUrl to load from
  53099. */
  53100. parse(source: any, scene: Scene, rootUrl: string): void;
  53101. }
  53102. }
  53103. declare module "babylonjs/Materials/PBR/pbrBRDFConfiguration" {
  53104. import { Scene } from "babylonjs/scene";
  53105. /**
  53106. * @hidden
  53107. */
  53108. export interface IMaterialBRDFDefines {
  53109. BRDF_V_HEIGHT_CORRELATED: boolean;
  53110. MS_BRDF_ENERGY_CONSERVATION: boolean;
  53111. SPHERICAL_HARMONICS: boolean;
  53112. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  53113. /** @hidden */
  53114. _areMiscDirty: boolean;
  53115. }
  53116. /**
  53117. * Define the code related to the BRDF parameters of the pbr material.
  53118. */
  53119. export class PBRBRDFConfiguration {
  53120. /**
  53121. * Default value used for the energy conservation.
  53122. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  53123. */
  53124. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  53125. /**
  53126. * Default value used for the Smith Visibility Height Correlated mode.
  53127. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  53128. */
  53129. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  53130. /**
  53131. * Default value used for the IBL diffuse part.
  53132. * This can help switching back to the polynomials mode globally which is a tiny bit
  53133. * less GPU intensive at the drawback of a lower quality.
  53134. */
  53135. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  53136. /**
  53137. * Default value used for activating energy conservation for the specular workflow.
  53138. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  53139. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  53140. */
  53141. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  53142. private _useEnergyConservation;
  53143. /**
  53144. * Defines if the material uses energy conservation.
  53145. */
  53146. useEnergyConservation: boolean;
  53147. private _useSmithVisibilityHeightCorrelated;
  53148. /**
  53149. * LEGACY Mode set to false
  53150. * Defines if the material uses height smith correlated visibility term.
  53151. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  53152. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  53153. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  53154. * Not relying on height correlated will also disable energy conservation.
  53155. */
  53156. useSmithVisibilityHeightCorrelated: boolean;
  53157. private _useSphericalHarmonics;
  53158. /**
  53159. * LEGACY Mode set to false
  53160. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  53161. * diffuse part of the IBL.
  53162. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  53163. * to the ground truth.
  53164. */
  53165. useSphericalHarmonics: boolean;
  53166. private _useSpecularGlossinessInputEnergyConservation;
  53167. /**
  53168. * Defines if the material uses energy conservation, when the specular workflow is active.
  53169. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  53170. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  53171. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  53172. */
  53173. useSpecularGlossinessInputEnergyConservation: boolean;
  53174. /** @hidden */
  53175. private _internalMarkAllSubMeshesAsMiscDirty;
  53176. /** @hidden */
  53177. _markAllSubMeshesAsMiscDirty(): void;
  53178. /**
  53179. * Instantiate a new istance of clear coat configuration.
  53180. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  53181. */
  53182. constructor(markAllSubMeshesAsMiscDirty: () => void);
  53183. /**
  53184. * Checks to see if a texture is used in the material.
  53185. * @param defines the list of "defines" to update.
  53186. */
  53187. prepareDefines(defines: IMaterialBRDFDefines): void;
  53188. /**
  53189. * Get the current class name of the texture useful for serialization or dynamic coding.
  53190. * @returns "PBRClearCoatConfiguration"
  53191. */
  53192. getClassName(): string;
  53193. /**
  53194. * Makes a duplicate of the current configuration into another one.
  53195. * @param brdfConfiguration define the config where to copy the info
  53196. */
  53197. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  53198. /**
  53199. * Serializes this BRDF configuration.
  53200. * @returns - An object with the serialized config.
  53201. */
  53202. serialize(): any;
  53203. /**
  53204. * Parses a anisotropy Configuration from a serialized object.
  53205. * @param source - Serialized object.
  53206. * @param scene Defines the scene we are parsing for
  53207. * @param rootUrl Defines the rootUrl to load from
  53208. */
  53209. parse(source: any, scene: Scene, rootUrl: string): void;
  53210. }
  53211. }
  53212. declare module "babylonjs/Materials/PBR/pbrSheenConfiguration" {
  53213. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  53214. import { Color3 } from "babylonjs/Maths/math.color";
  53215. import { Scene } from "babylonjs/scene";
  53216. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53217. import { Nullable } from "babylonjs/types";
  53218. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  53219. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  53220. /**
  53221. * @hidden
  53222. */
  53223. export interface IMaterialSheenDefines {
  53224. SHEEN: boolean;
  53225. SHEEN_TEXTURE: boolean;
  53226. SHEEN_TEXTUREDIRECTUV: number;
  53227. SHEEN_LINKWITHALBEDO: boolean;
  53228. SHEEN_ROUGHNESS: boolean;
  53229. SHEEN_ALBEDOSCALING: boolean;
  53230. /** @hidden */
  53231. _areTexturesDirty: boolean;
  53232. }
  53233. /**
  53234. * Define the code related to the Sheen parameters of the pbr material.
  53235. */
  53236. export class PBRSheenConfiguration {
  53237. private _isEnabled;
  53238. /**
  53239. * Defines if the material uses sheen.
  53240. */
  53241. isEnabled: boolean;
  53242. private _linkSheenWithAlbedo;
  53243. /**
  53244. * Defines if the sheen is linked to the sheen color.
  53245. */
  53246. linkSheenWithAlbedo: boolean;
  53247. /**
  53248. * Defines the sheen intensity.
  53249. */
  53250. intensity: number;
  53251. /**
  53252. * Defines the sheen color.
  53253. */
  53254. color: Color3;
  53255. private _texture;
  53256. /**
  53257. * Stores the sheen tint values in a texture.
  53258. * rgb is tint
  53259. * a is a intensity
  53260. */
  53261. texture: Nullable<BaseTexture>;
  53262. private _roughness;
  53263. /**
  53264. * Defines the sheen roughness.
  53265. * It is not taken into account if linkSheenWithAlbedo is true.
  53266. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  53267. */
  53268. roughness: Nullable<number>;
  53269. private _albedoScaling;
  53270. /**
  53271. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  53272. * It allows the strength of the sheen effect to not depend on the base color of the material,
  53273. * making it easier to setup and tweak the effect
  53274. */
  53275. albedoScaling: boolean;
  53276. /** @hidden */
  53277. private _internalMarkAllSubMeshesAsTexturesDirty;
  53278. /** @hidden */
  53279. _markAllSubMeshesAsTexturesDirty(): void;
  53280. /**
  53281. * Instantiate a new istance of clear coat configuration.
  53282. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  53283. */
  53284. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  53285. /**
  53286. * Specifies that the submesh is ready to be used.
  53287. * @param defines the list of "defines" to update.
  53288. * @param scene defines the scene the material belongs to.
  53289. * @returns - boolean indicating that the submesh is ready or not.
  53290. */
  53291. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  53292. /**
  53293. * Checks to see if a texture is used in the material.
  53294. * @param defines the list of "defines" to update.
  53295. * @param scene defines the scene the material belongs to.
  53296. */
  53297. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  53298. /**
  53299. * Binds the material data.
  53300. * @param uniformBuffer defines the Uniform buffer to fill in.
  53301. * @param scene defines the scene the material belongs to.
  53302. * @param isFrozen defines wether the material is frozen or not.
  53303. */
  53304. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  53305. /**
  53306. * Checks to see if a texture is used in the material.
  53307. * @param texture - Base texture to use.
  53308. * @returns - Boolean specifying if a texture is used in the material.
  53309. */
  53310. hasTexture(texture: BaseTexture): boolean;
  53311. /**
  53312. * Returns an array of the actively used textures.
  53313. * @param activeTextures Array of BaseTextures
  53314. */
  53315. getActiveTextures(activeTextures: BaseTexture[]): void;
  53316. /**
  53317. * Returns the animatable textures.
  53318. * @param animatables Array of animatable textures.
  53319. */
  53320. getAnimatables(animatables: IAnimatable[]): void;
  53321. /**
  53322. * Disposes the resources of the material.
  53323. * @param forceDisposeTextures - Forces the disposal of all textures.
  53324. */
  53325. dispose(forceDisposeTextures?: boolean): void;
  53326. /**
  53327. * Get the current class name of the texture useful for serialization or dynamic coding.
  53328. * @returns "PBRSheenConfiguration"
  53329. */
  53330. getClassName(): string;
  53331. /**
  53332. * Add fallbacks to the effect fallbacks list.
  53333. * @param defines defines the Base texture to use.
  53334. * @param fallbacks defines the current fallback list.
  53335. * @param currentRank defines the current fallback rank.
  53336. * @returns the new fallback rank.
  53337. */
  53338. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  53339. /**
  53340. * Add the required uniforms to the current list.
  53341. * @param uniforms defines the current uniform list.
  53342. */
  53343. static AddUniforms(uniforms: string[]): void;
  53344. /**
  53345. * Add the required uniforms to the current buffer.
  53346. * @param uniformBuffer defines the current uniform buffer.
  53347. */
  53348. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  53349. /**
  53350. * Add the required samplers to the current list.
  53351. * @param samplers defines the current sampler list.
  53352. */
  53353. static AddSamplers(samplers: string[]): void;
  53354. /**
  53355. * Makes a duplicate of the current configuration into another one.
  53356. * @param sheenConfiguration define the config where to copy the info
  53357. */
  53358. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  53359. /**
  53360. * Serializes this BRDF configuration.
  53361. * @returns - An object with the serialized config.
  53362. */
  53363. serialize(): any;
  53364. /**
  53365. * Parses a anisotropy Configuration from a serialized object.
  53366. * @param source - Serialized object.
  53367. * @param scene Defines the scene we are parsing for
  53368. * @param rootUrl Defines the rootUrl to load from
  53369. */
  53370. parse(source: any, scene: Scene, rootUrl: string): void;
  53371. }
  53372. }
  53373. declare module "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration" {
  53374. import { Nullable } from "babylonjs/types";
  53375. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  53376. import { Color3 } from "babylonjs/Maths/math.color";
  53377. import { SmartArray } from "babylonjs/Misc/smartArray";
  53378. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53379. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  53380. import { Effect } from "babylonjs/Materials/effect";
  53381. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  53382. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  53383. import { Engine } from "babylonjs/Engines/engine";
  53384. import { Scene } from "babylonjs/scene";
  53385. /**
  53386. * @hidden
  53387. */
  53388. export interface IMaterialSubSurfaceDefines {
  53389. SUBSURFACE: boolean;
  53390. SS_REFRACTION: boolean;
  53391. SS_TRANSLUCENCY: boolean;
  53392. SS_SCATERRING: boolean;
  53393. SS_THICKNESSANDMASK_TEXTURE: boolean;
  53394. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  53395. SS_REFRACTIONMAP_3D: boolean;
  53396. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  53397. SS_LODINREFRACTIONALPHA: boolean;
  53398. SS_GAMMAREFRACTION: boolean;
  53399. SS_RGBDREFRACTION: boolean;
  53400. SS_LINEARSPECULARREFRACTION: boolean;
  53401. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  53402. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  53403. /** @hidden */
  53404. _areTexturesDirty: boolean;
  53405. }
  53406. /**
  53407. * Define the code related to the sub surface parameters of the pbr material.
  53408. */
  53409. export class PBRSubSurfaceConfiguration {
  53410. private _isRefractionEnabled;
  53411. /**
  53412. * Defines if the refraction is enabled in the material.
  53413. */
  53414. isRefractionEnabled: boolean;
  53415. private _isTranslucencyEnabled;
  53416. /**
  53417. * Defines if the translucency is enabled in the material.
  53418. */
  53419. isTranslucencyEnabled: boolean;
  53420. private _isScatteringEnabled;
  53421. /**
  53422. * Defines the refraction intensity of the material.
  53423. * The refraction when enabled replaces the Diffuse part of the material.
  53424. * The intensity helps transitionning between diffuse and refraction.
  53425. */
  53426. refractionIntensity: number;
  53427. /**
  53428. * Defines the translucency intensity of the material.
  53429. * When translucency has been enabled, this defines how much of the "translucency"
  53430. * is addded to the diffuse part of the material.
  53431. */
  53432. translucencyIntensity: number;
  53433. /**
  53434. * Defines the scattering intensity of the material.
  53435. * When scattering has been enabled, this defines how much of the "scattered light"
  53436. * is addded to the diffuse part of the material.
  53437. */
  53438. scatteringIntensity: number;
  53439. private _thicknessTexture;
  53440. /**
  53441. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  53442. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  53443. * 0 would mean minimumThickness
  53444. * 1 would mean maximumThickness
  53445. * The other channels might be use as a mask to vary the different effects intensity.
  53446. */
  53447. thicknessTexture: Nullable<BaseTexture>;
  53448. private _refractionTexture;
  53449. /**
  53450. * Defines the texture to use for refraction.
  53451. */
  53452. refractionTexture: Nullable<BaseTexture>;
  53453. private _indexOfRefraction;
  53454. /**
  53455. * Defines the index of refraction used in the material.
  53456. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  53457. */
  53458. indexOfRefraction: number;
  53459. private _invertRefractionY;
  53460. /**
  53461. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  53462. */
  53463. invertRefractionY: boolean;
  53464. private _linkRefractionWithTransparency;
  53465. /**
  53466. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  53467. * Materials half opaque for instance using refraction could benefit from this control.
  53468. */
  53469. linkRefractionWithTransparency: boolean;
  53470. /**
  53471. * Defines the minimum thickness stored in the thickness map.
  53472. * If no thickness map is defined, this value will be used to simulate thickness.
  53473. */
  53474. minimumThickness: number;
  53475. /**
  53476. * Defines the maximum thickness stored in the thickness map.
  53477. */
  53478. maximumThickness: number;
  53479. /**
  53480. * Defines the volume tint of the material.
  53481. * This is used for both translucency and scattering.
  53482. */
  53483. tintColor: Color3;
  53484. /**
  53485. * Defines the distance at which the tint color should be found in the media.
  53486. * This is used for refraction only.
  53487. */
  53488. tintColorAtDistance: number;
  53489. /**
  53490. * Defines how far each channel transmit through the media.
  53491. * It is defined as a color to simplify it selection.
  53492. */
  53493. diffusionDistance: Color3;
  53494. private _useMaskFromThicknessTexture;
  53495. /**
  53496. * Stores the intensity of the different subsurface effects in the thickness texture.
  53497. * * the green channel is the translucency intensity.
  53498. * * the blue channel is the scattering intensity.
  53499. * * the alpha channel is the refraction intensity.
  53500. */
  53501. useMaskFromThicknessTexture: boolean;
  53502. /** @hidden */
  53503. private _internalMarkAllSubMeshesAsTexturesDirty;
  53504. /** @hidden */
  53505. _markAllSubMeshesAsTexturesDirty(): void;
  53506. /**
  53507. * Instantiate a new istance of sub surface configuration.
  53508. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  53509. */
  53510. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  53511. /**
  53512. * Gets wehter the submesh is ready to be used or not.
  53513. * @param defines the list of "defines" to update.
  53514. * @param scene defines the scene the material belongs to.
  53515. * @returns - boolean indicating that the submesh is ready or not.
  53516. */
  53517. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  53518. /**
  53519. * Checks to see if a texture is used in the material.
  53520. * @param defines the list of "defines" to update.
  53521. * @param scene defines the scene to the material belongs to.
  53522. */
  53523. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  53524. /**
  53525. * Binds the material data.
  53526. * @param uniformBuffer defines the Uniform buffer to fill in.
  53527. * @param scene defines the scene the material belongs to.
  53528. * @param engine defines the engine the material belongs to.
  53529. * @param isFrozen defines wether the material is frozen or not.
  53530. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  53531. */
  53532. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  53533. /**
  53534. * Unbinds the material from the mesh.
  53535. * @param activeEffect defines the effect that should be unbound from.
  53536. * @returns true if unbound, otherwise false
  53537. */
  53538. unbind(activeEffect: Effect): boolean;
  53539. /**
  53540. * Returns the texture used for refraction or null if none is used.
  53541. * @param scene defines the scene the material belongs to.
  53542. * @returns - Refraction texture if present. If no refraction texture and refraction
  53543. * is linked with transparency, returns environment texture. Otherwise, returns null.
  53544. */
  53545. private _getRefractionTexture;
  53546. /**
  53547. * Returns true if alpha blending should be disabled.
  53548. */
  53549. get disableAlphaBlending(): boolean;
  53550. /**
  53551. * Fills the list of render target textures.
  53552. * @param renderTargets the list of render targets to update
  53553. */
  53554. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  53555. /**
  53556. * Checks to see if a texture is used in the material.
  53557. * @param texture - Base texture to use.
  53558. * @returns - Boolean specifying if a texture is used in the material.
  53559. */
  53560. hasTexture(texture: BaseTexture): boolean;
  53561. /**
  53562. * Gets a boolean indicating that current material needs to register RTT
  53563. * @returns true if this uses a render target otherwise false.
  53564. */
  53565. hasRenderTargetTextures(): boolean;
  53566. /**
  53567. * Returns an array of the actively used textures.
  53568. * @param activeTextures Array of BaseTextures
  53569. */
  53570. getActiveTextures(activeTextures: BaseTexture[]): void;
  53571. /**
  53572. * Returns the animatable textures.
  53573. * @param animatables Array of animatable textures.
  53574. */
  53575. getAnimatables(animatables: IAnimatable[]): void;
  53576. /**
  53577. * Disposes the resources of the material.
  53578. * @param forceDisposeTextures - Forces the disposal of all textures.
  53579. */
  53580. dispose(forceDisposeTextures?: boolean): void;
  53581. /**
  53582. * Get the current class name of the texture useful for serialization or dynamic coding.
  53583. * @returns "PBRSubSurfaceConfiguration"
  53584. */
  53585. getClassName(): string;
  53586. /**
  53587. * Add fallbacks to the effect fallbacks list.
  53588. * @param defines defines the Base texture to use.
  53589. * @param fallbacks defines the current fallback list.
  53590. * @param currentRank defines the current fallback rank.
  53591. * @returns the new fallback rank.
  53592. */
  53593. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  53594. /**
  53595. * Add the required uniforms to the current list.
  53596. * @param uniforms defines the current uniform list.
  53597. */
  53598. static AddUniforms(uniforms: string[]): void;
  53599. /**
  53600. * Add the required samplers to the current list.
  53601. * @param samplers defines the current sampler list.
  53602. */
  53603. static AddSamplers(samplers: string[]): void;
  53604. /**
  53605. * Add the required uniforms to the current buffer.
  53606. * @param uniformBuffer defines the current uniform buffer.
  53607. */
  53608. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  53609. /**
  53610. * Makes a duplicate of the current configuration into another one.
  53611. * @param configuration define the config where to copy the info
  53612. */
  53613. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  53614. /**
  53615. * Serializes this Sub Surface configuration.
  53616. * @returns - An object with the serialized config.
  53617. */
  53618. serialize(): any;
  53619. /**
  53620. * Parses a anisotropy Configuration from a serialized object.
  53621. * @param source - Serialized object.
  53622. * @param scene Defines the scene we are parsing for
  53623. * @param rootUrl Defines the rootUrl to load from
  53624. */
  53625. parse(source: any, scene: Scene, rootUrl: string): void;
  53626. }
  53627. }
  53628. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  53629. /** @hidden */
  53630. export var pbrFragmentDeclaration: {
  53631. name: string;
  53632. shader: string;
  53633. };
  53634. }
  53635. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  53636. /** @hidden */
  53637. export var pbrUboDeclaration: {
  53638. name: string;
  53639. shader: string;
  53640. };
  53641. }
  53642. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration" {
  53643. /** @hidden */
  53644. export var pbrFragmentExtraDeclaration: {
  53645. name: string;
  53646. shader: string;
  53647. };
  53648. }
  53649. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration" {
  53650. /** @hidden */
  53651. export var pbrFragmentSamplersDeclaration: {
  53652. name: string;
  53653. shader: string;
  53654. };
  53655. }
  53656. declare module "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions" {
  53657. /** @hidden */
  53658. export var pbrHelperFunctions: {
  53659. name: string;
  53660. shader: string;
  53661. };
  53662. }
  53663. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  53664. /** @hidden */
  53665. export var harmonicsFunctions: {
  53666. name: string;
  53667. shader: string;
  53668. };
  53669. }
  53670. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions" {
  53671. /** @hidden */
  53672. export var pbrDirectLightingSetupFunctions: {
  53673. name: string;
  53674. shader: string;
  53675. };
  53676. }
  53677. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions" {
  53678. /** @hidden */
  53679. export var pbrDirectLightingFalloffFunctions: {
  53680. name: string;
  53681. shader: string;
  53682. };
  53683. }
  53684. declare module "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions" {
  53685. /** @hidden */
  53686. export var pbrBRDFFunctions: {
  53687. name: string;
  53688. shader: string;
  53689. };
  53690. }
  53691. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions" {
  53692. /** @hidden */
  53693. export var pbrDirectLightingFunctions: {
  53694. name: string;
  53695. shader: string;
  53696. };
  53697. }
  53698. declare module "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions" {
  53699. /** @hidden */
  53700. export var pbrIBLFunctions: {
  53701. name: string;
  53702. shader: string;
  53703. };
  53704. }
  53705. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAlbedoOpacity" {
  53706. /** @hidden */
  53707. export var pbrBlockAlbedoOpacity: {
  53708. name: string;
  53709. shader: string;
  53710. };
  53711. }
  53712. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflectivity" {
  53713. /** @hidden */
  53714. export var pbrBlockReflectivity: {
  53715. name: string;
  53716. shader: string;
  53717. };
  53718. }
  53719. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAmbientOcclusion" {
  53720. /** @hidden */
  53721. export var pbrBlockAmbientOcclusion: {
  53722. name: string;
  53723. shader: string;
  53724. };
  53725. }
  53726. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAlphaFresnel" {
  53727. /** @hidden */
  53728. export var pbrBlockAlphaFresnel: {
  53729. name: string;
  53730. shader: string;
  53731. };
  53732. }
  53733. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAnisotropic" {
  53734. /** @hidden */
  53735. export var pbrBlockAnisotropic: {
  53736. name: string;
  53737. shader: string;
  53738. };
  53739. }
  53740. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflection" {
  53741. /** @hidden */
  53742. export var pbrBlockReflection: {
  53743. name: string;
  53744. shader: string;
  53745. };
  53746. }
  53747. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockSheen" {
  53748. /** @hidden */
  53749. export var pbrBlockSheen: {
  53750. name: string;
  53751. shader: string;
  53752. };
  53753. }
  53754. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockClearcoat" {
  53755. /** @hidden */
  53756. export var pbrBlockClearcoat: {
  53757. name: string;
  53758. shader: string;
  53759. };
  53760. }
  53761. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockSubSurface" {
  53762. /** @hidden */
  53763. export var pbrBlockSubSurface: {
  53764. name: string;
  53765. shader: string;
  53766. };
  53767. }
  53768. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockNormalGeometric" {
  53769. /** @hidden */
  53770. export var pbrBlockNormalGeometric: {
  53771. name: string;
  53772. shader: string;
  53773. };
  53774. }
  53775. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockNormalFinal" {
  53776. /** @hidden */
  53777. export var pbrBlockNormalFinal: {
  53778. name: string;
  53779. shader: string;
  53780. };
  53781. }
  53782. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockGeometryInfo" {
  53783. /** @hidden */
  53784. export var pbrBlockGeometryInfo: {
  53785. name: string;
  53786. shader: string;
  53787. };
  53788. }
  53789. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance0" {
  53790. /** @hidden */
  53791. export var pbrBlockReflectance0: {
  53792. name: string;
  53793. shader: string;
  53794. };
  53795. }
  53796. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance" {
  53797. /** @hidden */
  53798. export var pbrBlockReflectance: {
  53799. name: string;
  53800. shader: string;
  53801. };
  53802. }
  53803. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockDirectLighting" {
  53804. /** @hidden */
  53805. export var pbrBlockDirectLighting: {
  53806. name: string;
  53807. shader: string;
  53808. };
  53809. }
  53810. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockFinalLitComponents" {
  53811. /** @hidden */
  53812. export var pbrBlockFinalLitComponents: {
  53813. name: string;
  53814. shader: string;
  53815. };
  53816. }
  53817. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockFinalUnlitComponents" {
  53818. /** @hidden */
  53819. export var pbrBlockFinalUnlitComponents: {
  53820. name: string;
  53821. shader: string;
  53822. };
  53823. }
  53824. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockFinalColorComposition" {
  53825. /** @hidden */
  53826. export var pbrBlockFinalColorComposition: {
  53827. name: string;
  53828. shader: string;
  53829. };
  53830. }
  53831. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockImageProcessing" {
  53832. /** @hidden */
  53833. export var pbrBlockImageProcessing: {
  53834. name: string;
  53835. shader: string;
  53836. };
  53837. }
  53838. declare module "babylonjs/Shaders/ShadersInclude/pbrDebug" {
  53839. /** @hidden */
  53840. export var pbrDebug: {
  53841. name: string;
  53842. shader: string;
  53843. };
  53844. }
  53845. declare module "babylonjs/Shaders/pbr.fragment" {
  53846. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  53847. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  53848. import "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration";
  53849. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  53850. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  53851. import "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration";
  53852. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  53853. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  53854. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  53855. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  53856. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  53857. import "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions";
  53858. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  53859. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  53860. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  53861. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions";
  53862. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions";
  53863. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  53864. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions";
  53865. import "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions";
  53866. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  53867. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  53868. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  53869. import "babylonjs/Shaders/ShadersInclude/pbrBlockAlbedoOpacity";
  53870. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflectivity";
  53871. import "babylonjs/Shaders/ShadersInclude/pbrBlockAmbientOcclusion";
  53872. import "babylonjs/Shaders/ShadersInclude/pbrBlockAlphaFresnel";
  53873. import "babylonjs/Shaders/ShadersInclude/pbrBlockAnisotropic";
  53874. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflection";
  53875. import "babylonjs/Shaders/ShadersInclude/pbrBlockSheen";
  53876. import "babylonjs/Shaders/ShadersInclude/pbrBlockClearcoat";
  53877. import "babylonjs/Shaders/ShadersInclude/pbrBlockSubSurface";
  53878. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  53879. import "babylonjs/Shaders/ShadersInclude/pbrBlockNormalGeometric";
  53880. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  53881. import "babylonjs/Shaders/ShadersInclude/pbrBlockNormalFinal";
  53882. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  53883. import "babylonjs/Shaders/ShadersInclude/pbrBlockGeometryInfo";
  53884. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance0";
  53885. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance";
  53886. import "babylonjs/Shaders/ShadersInclude/pbrBlockDirectLighting";
  53887. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  53888. import "babylonjs/Shaders/ShadersInclude/pbrBlockFinalLitComponents";
  53889. import "babylonjs/Shaders/ShadersInclude/pbrBlockFinalUnlitComponents";
  53890. import "babylonjs/Shaders/ShadersInclude/pbrBlockFinalColorComposition";
  53891. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  53892. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  53893. import "babylonjs/Shaders/ShadersInclude/pbrBlockImageProcessing";
  53894. import "babylonjs/Shaders/ShadersInclude/pbrDebug";
  53895. /** @hidden */
  53896. export var pbrPixelShader: {
  53897. name: string;
  53898. shader: string;
  53899. };
  53900. }
  53901. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  53902. /** @hidden */
  53903. export var pbrVertexDeclaration: {
  53904. name: string;
  53905. shader: string;
  53906. };
  53907. }
  53908. declare module "babylonjs/Shaders/pbr.vertex" {
  53909. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  53910. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  53911. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  53912. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  53913. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  53914. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  53915. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  53916. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  53917. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  53918. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  53919. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  53920. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  53921. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  53922. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  53923. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  53924. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  53925. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  53926. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  53927. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  53928. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  53929. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  53930. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  53931. /** @hidden */
  53932. export var pbrVertexShader: {
  53933. name: string;
  53934. shader: string;
  53935. };
  53936. }
  53937. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  53938. import { Nullable } from "babylonjs/types";
  53939. import { Scene } from "babylonjs/scene";
  53940. import { Matrix } from "babylonjs/Maths/math.vector";
  53941. import { SubMesh } from "babylonjs/Meshes/subMesh";
  53942. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53943. import { Mesh } from "babylonjs/Meshes/mesh";
  53944. import { IMaterialClearCoatDefines, PBRClearCoatConfiguration } from "babylonjs/Materials/PBR/pbrClearCoatConfiguration";
  53945. import { IMaterialAnisotropicDefines, PBRAnisotropicConfiguration } from "babylonjs/Materials/PBR/pbrAnisotropicConfiguration";
  53946. import { IMaterialBRDFDefines, PBRBRDFConfiguration } from "babylonjs/Materials/PBR/pbrBRDFConfiguration";
  53947. import { IMaterialSheenDefines, PBRSheenConfiguration } from "babylonjs/Materials/PBR/pbrSheenConfiguration";
  53948. import { IMaterialSubSurfaceDefines, PBRSubSurfaceConfiguration } from "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration";
  53949. import { Color3 } from "babylonjs/Maths/math.color";
  53950. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  53951. import { Material, IMaterialCompilationOptions } from "babylonjs/Materials/material";
  53952. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  53953. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  53954. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53955. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  53956. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  53957. import "babylonjs/Shaders/pbr.fragment";
  53958. import "babylonjs/Shaders/pbr.vertex";
  53959. /**
  53960. * Manages the defines for the PBR Material.
  53961. * @hidden
  53962. */
  53963. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  53964. PBR: boolean;
  53965. MAINUV1: boolean;
  53966. MAINUV2: boolean;
  53967. UV1: boolean;
  53968. UV2: boolean;
  53969. ALBEDO: boolean;
  53970. GAMMAALBEDO: boolean;
  53971. ALBEDODIRECTUV: number;
  53972. VERTEXCOLOR: boolean;
  53973. AMBIENT: boolean;
  53974. AMBIENTDIRECTUV: number;
  53975. AMBIENTINGRAYSCALE: boolean;
  53976. OPACITY: boolean;
  53977. VERTEXALPHA: boolean;
  53978. OPACITYDIRECTUV: number;
  53979. OPACITYRGB: boolean;
  53980. ALPHATEST: boolean;
  53981. DEPTHPREPASS: boolean;
  53982. ALPHABLEND: boolean;
  53983. ALPHAFROMALBEDO: boolean;
  53984. ALPHATESTVALUE: string;
  53985. SPECULAROVERALPHA: boolean;
  53986. RADIANCEOVERALPHA: boolean;
  53987. ALPHAFRESNEL: boolean;
  53988. LINEARALPHAFRESNEL: boolean;
  53989. PREMULTIPLYALPHA: boolean;
  53990. EMISSIVE: boolean;
  53991. EMISSIVEDIRECTUV: number;
  53992. REFLECTIVITY: boolean;
  53993. REFLECTIVITYDIRECTUV: number;
  53994. SPECULARTERM: boolean;
  53995. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  53996. MICROSURFACEAUTOMATIC: boolean;
  53997. LODBASEDMICROSFURACE: boolean;
  53998. MICROSURFACEMAP: boolean;
  53999. MICROSURFACEMAPDIRECTUV: number;
  54000. METALLICWORKFLOW: boolean;
  54001. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  54002. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  54003. METALLNESSSTOREINMETALMAPBLUE: boolean;
  54004. AOSTOREINMETALMAPRED: boolean;
  54005. METALLICF0FACTORFROMMETALLICMAP: boolean;
  54006. ENVIRONMENTBRDF: boolean;
  54007. ENVIRONMENTBRDF_RGBD: boolean;
  54008. NORMAL: boolean;
  54009. TANGENT: boolean;
  54010. BUMP: boolean;
  54011. BUMPDIRECTUV: number;
  54012. OBJECTSPACE_NORMALMAP: boolean;
  54013. PARALLAX: boolean;
  54014. PARALLAXOCCLUSION: boolean;
  54015. NORMALXYSCALE: boolean;
  54016. LIGHTMAP: boolean;
  54017. LIGHTMAPDIRECTUV: number;
  54018. USELIGHTMAPASSHADOWMAP: boolean;
  54019. GAMMALIGHTMAP: boolean;
  54020. RGBDLIGHTMAP: boolean;
  54021. REFLECTION: boolean;
  54022. REFLECTIONMAP_3D: boolean;
  54023. REFLECTIONMAP_SPHERICAL: boolean;
  54024. REFLECTIONMAP_PLANAR: boolean;
  54025. REFLECTIONMAP_CUBIC: boolean;
  54026. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  54027. REFLECTIONMAP_PROJECTION: boolean;
  54028. REFLECTIONMAP_SKYBOX: boolean;
  54029. REFLECTIONMAP_EXPLICIT: boolean;
  54030. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  54031. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  54032. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  54033. INVERTCUBICMAP: boolean;
  54034. USESPHERICALFROMREFLECTIONMAP: boolean;
  54035. USEIRRADIANCEMAP: boolean;
  54036. SPHERICAL_HARMONICS: boolean;
  54037. USESPHERICALINVERTEX: boolean;
  54038. REFLECTIONMAP_OPPOSITEZ: boolean;
  54039. LODINREFLECTIONALPHA: boolean;
  54040. GAMMAREFLECTION: boolean;
  54041. RGBDREFLECTION: boolean;
  54042. LINEARSPECULARREFLECTION: boolean;
  54043. RADIANCEOCCLUSION: boolean;
  54044. HORIZONOCCLUSION: boolean;
  54045. INSTANCES: boolean;
  54046. NUM_BONE_INFLUENCERS: number;
  54047. BonesPerMesh: number;
  54048. BONETEXTURE: boolean;
  54049. NONUNIFORMSCALING: boolean;
  54050. MORPHTARGETS: boolean;
  54051. MORPHTARGETS_NORMAL: boolean;
  54052. MORPHTARGETS_TANGENT: boolean;
  54053. MORPHTARGETS_UV: boolean;
  54054. NUM_MORPH_INFLUENCERS: number;
  54055. IMAGEPROCESSING: boolean;
  54056. VIGNETTE: boolean;
  54057. VIGNETTEBLENDMODEMULTIPLY: boolean;
  54058. VIGNETTEBLENDMODEOPAQUE: boolean;
  54059. TONEMAPPING: boolean;
  54060. TONEMAPPING_ACES: boolean;
  54061. CONTRAST: boolean;
  54062. COLORCURVES: boolean;
  54063. COLORGRADING: boolean;
  54064. COLORGRADING3D: boolean;
  54065. SAMPLER3DGREENDEPTH: boolean;
  54066. SAMPLER3DBGRMAP: boolean;
  54067. IMAGEPROCESSINGPOSTPROCESS: boolean;
  54068. EXPOSURE: boolean;
  54069. MULTIVIEW: boolean;
  54070. USEPHYSICALLIGHTFALLOFF: boolean;
  54071. USEGLTFLIGHTFALLOFF: boolean;
  54072. TWOSIDEDLIGHTING: boolean;
  54073. SHADOWFLOAT: boolean;
  54074. CLIPPLANE: boolean;
  54075. CLIPPLANE2: boolean;
  54076. CLIPPLANE3: boolean;
  54077. CLIPPLANE4: boolean;
  54078. CLIPPLANE5: boolean;
  54079. CLIPPLANE6: boolean;
  54080. POINTSIZE: boolean;
  54081. FOG: boolean;
  54082. LOGARITHMICDEPTH: boolean;
  54083. FORCENORMALFORWARD: boolean;
  54084. SPECULARAA: boolean;
  54085. CLEARCOAT: boolean;
  54086. CLEARCOAT_DEFAULTIOR: boolean;
  54087. CLEARCOAT_TEXTURE: boolean;
  54088. CLEARCOAT_TEXTUREDIRECTUV: number;
  54089. CLEARCOAT_BUMP: boolean;
  54090. CLEARCOAT_BUMPDIRECTUV: number;
  54091. CLEARCOAT_TINT: boolean;
  54092. CLEARCOAT_TINT_TEXTURE: boolean;
  54093. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  54094. ANISOTROPIC: boolean;
  54095. ANISOTROPIC_TEXTURE: boolean;
  54096. ANISOTROPIC_TEXTUREDIRECTUV: number;
  54097. BRDF_V_HEIGHT_CORRELATED: boolean;
  54098. MS_BRDF_ENERGY_CONSERVATION: boolean;
  54099. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  54100. SHEEN: boolean;
  54101. SHEEN_TEXTURE: boolean;
  54102. SHEEN_TEXTUREDIRECTUV: number;
  54103. SHEEN_LINKWITHALBEDO: boolean;
  54104. SHEEN_ROUGHNESS: boolean;
  54105. SHEEN_ALBEDOSCALING: boolean;
  54106. SUBSURFACE: boolean;
  54107. SS_REFRACTION: boolean;
  54108. SS_TRANSLUCENCY: boolean;
  54109. SS_SCATERRING: boolean;
  54110. SS_THICKNESSANDMASK_TEXTURE: boolean;
  54111. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  54112. SS_REFRACTIONMAP_3D: boolean;
  54113. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  54114. SS_LODINREFRACTIONALPHA: boolean;
  54115. SS_GAMMAREFRACTION: boolean;
  54116. SS_RGBDREFRACTION: boolean;
  54117. SS_LINEARSPECULARREFRACTION: boolean;
  54118. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  54119. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  54120. UNLIT: boolean;
  54121. DEBUGMODE: number;
  54122. /**
  54123. * Initializes the PBR Material defines.
  54124. */
  54125. constructor();
  54126. /**
  54127. * Resets the PBR Material defines.
  54128. */
  54129. reset(): void;
  54130. }
  54131. /**
  54132. * The Physically based material base class of BJS.
  54133. *
  54134. * This offers the main features of a standard PBR material.
  54135. * For more information, please refer to the documentation :
  54136. * https://doc.babylonjs.com/how_to/physically_based_rendering
  54137. */
  54138. export abstract class PBRBaseMaterial extends PushMaterial {
  54139. /**
  54140. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  54141. */
  54142. static readonly PBRMATERIAL_OPAQUE: number;
  54143. /**
  54144. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  54145. */
  54146. static readonly PBRMATERIAL_ALPHATEST: number;
  54147. /**
  54148. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  54149. */
  54150. static readonly PBRMATERIAL_ALPHABLEND: number;
  54151. /**
  54152. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  54153. * They are also discarded below the alpha cutoff threshold to improve performances.
  54154. */
  54155. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  54156. /**
  54157. * Defines the default value of how much AO map is occluding the analytical lights
  54158. * (point spot...).
  54159. */
  54160. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  54161. /**
  54162. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  54163. */
  54164. static readonly LIGHTFALLOFF_PHYSICAL: number;
  54165. /**
  54166. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  54167. * to enhance interoperability with other engines.
  54168. */
  54169. static readonly LIGHTFALLOFF_GLTF: number;
  54170. /**
  54171. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  54172. * to enhance interoperability with other materials.
  54173. */
  54174. static readonly LIGHTFALLOFF_STANDARD: number;
  54175. /**
  54176. * Intensity of the direct lights e.g. the four lights available in your scene.
  54177. * This impacts both the direct diffuse and specular highlights.
  54178. */
  54179. protected _directIntensity: number;
  54180. /**
  54181. * Intensity of the emissive part of the material.
  54182. * This helps controlling the emissive effect without modifying the emissive color.
  54183. */
  54184. protected _emissiveIntensity: number;
  54185. /**
  54186. * Intensity of the environment e.g. how much the environment will light the object
  54187. * either through harmonics for rough material or through the refelction for shiny ones.
  54188. */
  54189. protected _environmentIntensity: number;
  54190. /**
  54191. * This is a special control allowing the reduction of the specular highlights coming from the
  54192. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  54193. */
  54194. protected _specularIntensity: number;
  54195. /**
  54196. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  54197. */
  54198. private _lightingInfos;
  54199. /**
  54200. * Debug Control allowing disabling the bump map on this material.
  54201. */
  54202. protected _disableBumpMap: boolean;
  54203. /**
  54204. * AKA Diffuse Texture in standard nomenclature.
  54205. */
  54206. protected _albedoTexture: Nullable<BaseTexture>;
  54207. /**
  54208. * AKA Occlusion Texture in other nomenclature.
  54209. */
  54210. protected _ambientTexture: Nullable<BaseTexture>;
  54211. /**
  54212. * AKA Occlusion Texture Intensity in other nomenclature.
  54213. */
  54214. protected _ambientTextureStrength: number;
  54215. /**
  54216. * Defines how much the AO map is occluding the analytical lights (point spot...).
  54217. * 1 means it completely occludes it
  54218. * 0 mean it has no impact
  54219. */
  54220. protected _ambientTextureImpactOnAnalyticalLights: number;
  54221. /**
  54222. * Stores the alpha values in a texture.
  54223. */
  54224. protected _opacityTexture: Nullable<BaseTexture>;
  54225. /**
  54226. * Stores the reflection values in a texture.
  54227. */
  54228. protected _reflectionTexture: Nullable<BaseTexture>;
  54229. /**
  54230. * Stores the emissive values in a texture.
  54231. */
  54232. protected _emissiveTexture: Nullable<BaseTexture>;
  54233. /**
  54234. * AKA Specular texture in other nomenclature.
  54235. */
  54236. protected _reflectivityTexture: Nullable<BaseTexture>;
  54237. /**
  54238. * Used to switch from specular/glossiness to metallic/roughness workflow.
  54239. */
  54240. protected _metallicTexture: Nullable<BaseTexture>;
  54241. /**
  54242. * Specifies the metallic scalar of the metallic/roughness workflow.
  54243. * Can also be used to scale the metalness values of the metallic texture.
  54244. */
  54245. protected _metallic: Nullable<number>;
  54246. /**
  54247. * Specifies the roughness scalar of the metallic/roughness workflow.
  54248. * Can also be used to scale the roughness values of the metallic texture.
  54249. */
  54250. protected _roughness: Nullable<number>;
  54251. /**
  54252. * Specifies the an F0 factor to help configuring the material F0.
  54253. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  54254. * to 0.5 the previously hard coded value stays the same.
  54255. * Can also be used to scale the F0 values of the metallic texture.
  54256. */
  54257. protected _metallicF0Factor: number;
  54258. /**
  54259. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  54260. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  54261. * your expectation as it multiplies with the texture data.
  54262. */
  54263. protected _useMetallicF0FactorFromMetallicTexture: boolean;
  54264. /**
  54265. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  54266. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  54267. */
  54268. protected _microSurfaceTexture: Nullable<BaseTexture>;
  54269. /**
  54270. * Stores surface normal data used to displace a mesh in a texture.
  54271. */
  54272. protected _bumpTexture: Nullable<BaseTexture>;
  54273. /**
  54274. * Stores the pre-calculated light information of a mesh in a texture.
  54275. */
  54276. protected _lightmapTexture: Nullable<BaseTexture>;
  54277. /**
  54278. * The color of a material in ambient lighting.
  54279. */
  54280. protected _ambientColor: Color3;
  54281. /**
  54282. * AKA Diffuse Color in other nomenclature.
  54283. */
  54284. protected _albedoColor: Color3;
  54285. /**
  54286. * AKA Specular Color in other nomenclature.
  54287. */
  54288. protected _reflectivityColor: Color3;
  54289. /**
  54290. * The color applied when light is reflected from a material.
  54291. */
  54292. protected _reflectionColor: Color3;
  54293. /**
  54294. * The color applied when light is emitted from a material.
  54295. */
  54296. protected _emissiveColor: Color3;
  54297. /**
  54298. * AKA Glossiness in other nomenclature.
  54299. */
  54300. protected _microSurface: number;
  54301. /**
  54302. * Specifies that the material will use the light map as a show map.
  54303. */
  54304. protected _useLightmapAsShadowmap: boolean;
  54305. /**
  54306. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  54307. * makes the reflect vector face the model (under horizon).
  54308. */
  54309. protected _useHorizonOcclusion: boolean;
  54310. /**
  54311. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  54312. * too much the area relying on ambient texture to define their ambient occlusion.
  54313. */
  54314. protected _useRadianceOcclusion: boolean;
  54315. /**
  54316. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  54317. */
  54318. protected _useAlphaFromAlbedoTexture: boolean;
  54319. /**
  54320. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  54321. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  54322. */
  54323. protected _useSpecularOverAlpha: boolean;
  54324. /**
  54325. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  54326. */
  54327. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  54328. /**
  54329. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  54330. */
  54331. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  54332. /**
  54333. * Specifies if the metallic texture contains the roughness information in its green channel.
  54334. */
  54335. protected _useRoughnessFromMetallicTextureGreen: boolean;
  54336. /**
  54337. * Specifies if the metallic texture contains the metallness information in its blue channel.
  54338. */
  54339. protected _useMetallnessFromMetallicTextureBlue: boolean;
  54340. /**
  54341. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  54342. */
  54343. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  54344. /**
  54345. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  54346. */
  54347. protected _useAmbientInGrayScale: boolean;
  54348. /**
  54349. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  54350. * The material will try to infer what glossiness each pixel should be.
  54351. */
  54352. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  54353. /**
  54354. * Defines the falloff type used in this material.
  54355. * It by default is Physical.
  54356. */
  54357. protected _lightFalloff: number;
  54358. /**
  54359. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  54360. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  54361. */
  54362. protected _useRadianceOverAlpha: boolean;
  54363. /**
  54364. * Allows using an object space normal map (instead of tangent space).
  54365. */
  54366. protected _useObjectSpaceNormalMap: boolean;
  54367. /**
  54368. * Allows using the bump map in parallax mode.
  54369. */
  54370. protected _useParallax: boolean;
  54371. /**
  54372. * Allows using the bump map in parallax occlusion mode.
  54373. */
  54374. protected _useParallaxOcclusion: boolean;
  54375. /**
  54376. * Controls the scale bias of the parallax mode.
  54377. */
  54378. protected _parallaxScaleBias: number;
  54379. /**
  54380. * If sets to true, disables all the lights affecting the material.
  54381. */
  54382. protected _disableLighting: boolean;
  54383. /**
  54384. * Number of Simultaneous lights allowed on the material.
  54385. */
  54386. protected _maxSimultaneousLights: number;
  54387. /**
  54388. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  54389. */
  54390. protected _invertNormalMapX: boolean;
  54391. /**
  54392. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  54393. */
  54394. protected _invertNormalMapY: boolean;
  54395. /**
  54396. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  54397. */
  54398. protected _twoSidedLighting: boolean;
  54399. /**
  54400. * Defines the alpha limits in alpha test mode.
  54401. */
  54402. protected _alphaCutOff: number;
  54403. /**
  54404. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  54405. */
  54406. protected _forceAlphaTest: boolean;
  54407. /**
  54408. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  54409. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  54410. */
  54411. protected _useAlphaFresnel: boolean;
  54412. /**
  54413. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  54414. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  54415. */
  54416. protected _useLinearAlphaFresnel: boolean;
  54417. /**
  54418. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  54419. * from cos thetav and roughness:
  54420. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  54421. */
  54422. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  54423. /**
  54424. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  54425. */
  54426. protected _forceIrradianceInFragment: boolean;
  54427. /**
  54428. * Force normal to face away from face.
  54429. */
  54430. protected _forceNormalForward: boolean;
  54431. /**
  54432. * Enables specular anti aliasing in the PBR shader.
  54433. * It will both interacts on the Geometry for analytical and IBL lighting.
  54434. * It also prefilter the roughness map based on the bump values.
  54435. */
  54436. protected _enableSpecularAntiAliasing: boolean;
  54437. /**
  54438. * Default configuration related to image processing available in the PBR Material.
  54439. */
  54440. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  54441. /**
  54442. * Keep track of the image processing observer to allow dispose and replace.
  54443. */
  54444. private _imageProcessingObserver;
  54445. /**
  54446. * Attaches a new image processing configuration to the PBR Material.
  54447. * @param configuration
  54448. */
  54449. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  54450. /**
  54451. * Stores the available render targets.
  54452. */
  54453. private _renderTargets;
  54454. /**
  54455. * Sets the global ambient color for the material used in lighting calculations.
  54456. */
  54457. private _globalAmbientColor;
  54458. /**
  54459. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  54460. */
  54461. private _useLogarithmicDepth;
  54462. /**
  54463. * If set to true, no lighting calculations will be applied.
  54464. */
  54465. private _unlit;
  54466. private _debugMode;
  54467. /**
  54468. * @hidden
  54469. * This is reserved for the inspector.
  54470. * Defines the material debug mode.
  54471. * It helps seeing only some components of the material while troubleshooting.
  54472. */
  54473. debugMode: number;
  54474. /**
  54475. * @hidden
  54476. * This is reserved for the inspector.
  54477. * Specify from where on screen the debug mode should start.
  54478. * The value goes from -1 (full screen) to 1 (not visible)
  54479. * It helps with side by side comparison against the final render
  54480. * This defaults to -1
  54481. */
  54482. private debugLimit;
  54483. /**
  54484. * @hidden
  54485. * This is reserved for the inspector.
  54486. * As the default viewing range might not be enough (if the ambient is really small for instance)
  54487. * You can use the factor to better multiply the final value.
  54488. */
  54489. private debugFactor;
  54490. /**
  54491. * Defines the clear coat layer parameters for the material.
  54492. */
  54493. readonly clearCoat: PBRClearCoatConfiguration;
  54494. /**
  54495. * Defines the anisotropic parameters for the material.
  54496. */
  54497. readonly anisotropy: PBRAnisotropicConfiguration;
  54498. /**
  54499. * Defines the BRDF parameters for the material.
  54500. */
  54501. readonly brdf: PBRBRDFConfiguration;
  54502. /**
  54503. * Defines the Sheen parameters for the material.
  54504. */
  54505. readonly sheen: PBRSheenConfiguration;
  54506. /**
  54507. * Defines the SubSurface parameters for the material.
  54508. */
  54509. readonly subSurface: PBRSubSurfaceConfiguration;
  54510. protected _rebuildInParallel: boolean;
  54511. /**
  54512. * Instantiates a new PBRMaterial instance.
  54513. *
  54514. * @param name The material name
  54515. * @param scene The scene the material will be use in.
  54516. */
  54517. constructor(name: string, scene: Scene);
  54518. /**
  54519. * Gets a boolean indicating that current material needs to register RTT
  54520. */
  54521. get hasRenderTargetTextures(): boolean;
  54522. /**
  54523. * Gets the name of the material class.
  54524. */
  54525. getClassName(): string;
  54526. /**
  54527. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  54528. */
  54529. get useLogarithmicDepth(): boolean;
  54530. /**
  54531. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  54532. */
  54533. set useLogarithmicDepth(value: boolean);
  54534. /**
  54535. * Returns true if alpha blending should be disabled.
  54536. */
  54537. protected get _disableAlphaBlending(): boolean;
  54538. /**
  54539. * Specifies whether or not this material should be rendered in alpha blend mode.
  54540. */
  54541. needAlphaBlending(): boolean;
  54542. /**
  54543. * Specifies whether or not this material should be rendered in alpha test mode.
  54544. */
  54545. needAlphaTesting(): boolean;
  54546. /**
  54547. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  54548. */
  54549. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  54550. /**
  54551. * Gets the texture used for the alpha test.
  54552. */
  54553. getAlphaTestTexture(): Nullable<BaseTexture>;
  54554. /**
  54555. * Specifies that the submesh is ready to be used.
  54556. * @param mesh - BJS mesh.
  54557. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  54558. * @param useInstances - Specifies that instances should be used.
  54559. * @returns - boolean indicating that the submesh is ready or not.
  54560. */
  54561. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  54562. /**
  54563. * Specifies if the material uses metallic roughness workflow.
  54564. * @returns boolean specifiying if the material uses metallic roughness workflow.
  54565. */
  54566. isMetallicWorkflow(): boolean;
  54567. private _prepareEffect;
  54568. private _prepareDefines;
  54569. /**
  54570. * Force shader compilation
  54571. */
  54572. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  54573. /**
  54574. * Initializes the uniform buffer layout for the shader.
  54575. */
  54576. buildUniformLayout(): void;
  54577. /**
  54578. * Unbinds the material from the mesh
  54579. */
  54580. unbind(): void;
  54581. /**
  54582. * Binds the submesh data.
  54583. * @param world - The world matrix.
  54584. * @param mesh - The BJS mesh.
  54585. * @param subMesh - A submesh of the BJS mesh.
  54586. */
  54587. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  54588. /**
  54589. * Returns the animatable textures.
  54590. * @returns - Array of animatable textures.
  54591. */
  54592. getAnimatables(): IAnimatable[];
  54593. /**
  54594. * Returns the texture used for reflections.
  54595. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  54596. */
  54597. private _getReflectionTexture;
  54598. /**
  54599. * Returns an array of the actively used textures.
  54600. * @returns - Array of BaseTextures
  54601. */
  54602. getActiveTextures(): BaseTexture[];
  54603. /**
  54604. * Checks to see if a texture is used in the material.
  54605. * @param texture - Base texture to use.
  54606. * @returns - Boolean specifying if a texture is used in the material.
  54607. */
  54608. hasTexture(texture: BaseTexture): boolean;
  54609. /**
  54610. * Disposes the resources of the material.
  54611. * @param forceDisposeEffect - Forces the disposal of effects.
  54612. * @param forceDisposeTextures - Forces the disposal of all textures.
  54613. */
  54614. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  54615. }
  54616. }
  54617. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  54618. import { Nullable } from "babylonjs/types";
  54619. import { Scene } from "babylonjs/scene";
  54620. import { Color3 } from "babylonjs/Maths/math.color";
  54621. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  54622. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  54623. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54624. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  54625. /**
  54626. * The Physically based material of BJS.
  54627. *
  54628. * This offers the main features of a standard PBR material.
  54629. * For more information, please refer to the documentation :
  54630. * https://doc.babylonjs.com/how_to/physically_based_rendering
  54631. */
  54632. export class PBRMaterial extends PBRBaseMaterial {
  54633. /**
  54634. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  54635. */
  54636. static readonly PBRMATERIAL_OPAQUE: number;
  54637. /**
  54638. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  54639. */
  54640. static readonly PBRMATERIAL_ALPHATEST: number;
  54641. /**
  54642. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  54643. */
  54644. static readonly PBRMATERIAL_ALPHABLEND: number;
  54645. /**
  54646. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  54647. * They are also discarded below the alpha cutoff threshold to improve performances.
  54648. */
  54649. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  54650. /**
  54651. * Defines the default value of how much AO map is occluding the analytical lights
  54652. * (point spot...).
  54653. */
  54654. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  54655. /**
  54656. * Intensity of the direct lights e.g. the four lights available in your scene.
  54657. * This impacts both the direct diffuse and specular highlights.
  54658. */
  54659. directIntensity: number;
  54660. /**
  54661. * Intensity of the emissive part of the material.
  54662. * This helps controlling the emissive effect without modifying the emissive color.
  54663. */
  54664. emissiveIntensity: number;
  54665. /**
  54666. * Intensity of the environment e.g. how much the environment will light the object
  54667. * either through harmonics for rough material or through the refelction for shiny ones.
  54668. */
  54669. environmentIntensity: number;
  54670. /**
  54671. * This is a special control allowing the reduction of the specular highlights coming from the
  54672. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  54673. */
  54674. specularIntensity: number;
  54675. /**
  54676. * Debug Control allowing disabling the bump map on this material.
  54677. */
  54678. disableBumpMap: boolean;
  54679. /**
  54680. * AKA Diffuse Texture in standard nomenclature.
  54681. */
  54682. albedoTexture: BaseTexture;
  54683. /**
  54684. * AKA Occlusion Texture in other nomenclature.
  54685. */
  54686. ambientTexture: BaseTexture;
  54687. /**
  54688. * AKA Occlusion Texture Intensity in other nomenclature.
  54689. */
  54690. ambientTextureStrength: number;
  54691. /**
  54692. * Defines how much the AO map is occluding the analytical lights (point spot...).
  54693. * 1 means it completely occludes it
  54694. * 0 mean it has no impact
  54695. */
  54696. ambientTextureImpactOnAnalyticalLights: number;
  54697. /**
  54698. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  54699. */
  54700. opacityTexture: BaseTexture;
  54701. /**
  54702. * Stores the reflection values in a texture.
  54703. */
  54704. reflectionTexture: Nullable<BaseTexture>;
  54705. /**
  54706. * Stores the emissive values in a texture.
  54707. */
  54708. emissiveTexture: BaseTexture;
  54709. /**
  54710. * AKA Specular texture in other nomenclature.
  54711. */
  54712. reflectivityTexture: BaseTexture;
  54713. /**
  54714. * Used to switch from specular/glossiness to metallic/roughness workflow.
  54715. */
  54716. metallicTexture: BaseTexture;
  54717. /**
  54718. * Specifies the metallic scalar of the metallic/roughness workflow.
  54719. * Can also be used to scale the metalness values of the metallic texture.
  54720. */
  54721. metallic: Nullable<number>;
  54722. /**
  54723. * Specifies the roughness scalar of the metallic/roughness workflow.
  54724. * Can also be used to scale the roughness values of the metallic texture.
  54725. */
  54726. roughness: Nullable<number>;
  54727. /**
  54728. * Specifies the an F0 factor to help configuring the material F0.
  54729. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  54730. * to 0.5 the previously hard coded value stays the same.
  54731. * Can also be used to scale the F0 values of the metallic texture.
  54732. */
  54733. metallicF0Factor: number;
  54734. /**
  54735. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  54736. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  54737. * your expectation as it multiplies with the texture data.
  54738. */
  54739. useMetallicF0FactorFromMetallicTexture: boolean;
  54740. /**
  54741. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  54742. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  54743. */
  54744. microSurfaceTexture: BaseTexture;
  54745. /**
  54746. * Stores surface normal data used to displace a mesh in a texture.
  54747. */
  54748. bumpTexture: BaseTexture;
  54749. /**
  54750. * Stores the pre-calculated light information of a mesh in a texture.
  54751. */
  54752. lightmapTexture: BaseTexture;
  54753. /**
  54754. * Stores the refracted light information in a texture.
  54755. */
  54756. get refractionTexture(): Nullable<BaseTexture>;
  54757. set refractionTexture(value: Nullable<BaseTexture>);
  54758. /**
  54759. * The color of a material in ambient lighting.
  54760. */
  54761. ambientColor: Color3;
  54762. /**
  54763. * AKA Diffuse Color in other nomenclature.
  54764. */
  54765. albedoColor: Color3;
  54766. /**
  54767. * AKA Specular Color in other nomenclature.
  54768. */
  54769. reflectivityColor: Color3;
  54770. /**
  54771. * The color reflected from the material.
  54772. */
  54773. reflectionColor: Color3;
  54774. /**
  54775. * The color emitted from the material.
  54776. */
  54777. emissiveColor: Color3;
  54778. /**
  54779. * AKA Glossiness in other nomenclature.
  54780. */
  54781. microSurface: number;
  54782. /**
  54783. * source material index of refraction (IOR)' / 'destination material IOR.
  54784. */
  54785. get indexOfRefraction(): number;
  54786. set indexOfRefraction(value: number);
  54787. /**
  54788. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  54789. */
  54790. get invertRefractionY(): boolean;
  54791. set invertRefractionY(value: boolean);
  54792. /**
  54793. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  54794. * Materials half opaque for instance using refraction could benefit from this control.
  54795. */
  54796. get linkRefractionWithTransparency(): boolean;
  54797. set linkRefractionWithTransparency(value: boolean);
  54798. /**
  54799. * If true, the light map contains occlusion information instead of lighting info.
  54800. */
  54801. useLightmapAsShadowmap: boolean;
  54802. /**
  54803. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  54804. */
  54805. useAlphaFromAlbedoTexture: boolean;
  54806. /**
  54807. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  54808. */
  54809. forceAlphaTest: boolean;
  54810. /**
  54811. * Defines the alpha limits in alpha test mode.
  54812. */
  54813. alphaCutOff: number;
  54814. /**
  54815. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  54816. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  54817. */
  54818. useSpecularOverAlpha: boolean;
  54819. /**
  54820. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  54821. */
  54822. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  54823. /**
  54824. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  54825. */
  54826. useRoughnessFromMetallicTextureAlpha: boolean;
  54827. /**
  54828. * Specifies if the metallic texture contains the roughness information in its green channel.
  54829. */
  54830. useRoughnessFromMetallicTextureGreen: boolean;
  54831. /**
  54832. * Specifies if the metallic texture contains the metallness information in its blue channel.
  54833. */
  54834. useMetallnessFromMetallicTextureBlue: boolean;
  54835. /**
  54836. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  54837. */
  54838. useAmbientOcclusionFromMetallicTextureRed: boolean;
  54839. /**
  54840. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  54841. */
  54842. useAmbientInGrayScale: boolean;
  54843. /**
  54844. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  54845. * The material will try to infer what glossiness each pixel should be.
  54846. */
  54847. useAutoMicroSurfaceFromReflectivityMap: boolean;
  54848. /**
  54849. * BJS is using an harcoded light falloff based on a manually sets up range.
  54850. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  54851. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  54852. */
  54853. get usePhysicalLightFalloff(): boolean;
  54854. /**
  54855. * BJS is using an harcoded light falloff based on a manually sets up range.
  54856. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  54857. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  54858. */
  54859. set usePhysicalLightFalloff(value: boolean);
  54860. /**
  54861. * In order to support the falloff compatibility with gltf, a special mode has been added
  54862. * to reproduce the gltf light falloff.
  54863. */
  54864. get useGLTFLightFalloff(): boolean;
  54865. /**
  54866. * In order to support the falloff compatibility with gltf, a special mode has been added
  54867. * to reproduce the gltf light falloff.
  54868. */
  54869. set useGLTFLightFalloff(value: boolean);
  54870. /**
  54871. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  54872. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  54873. */
  54874. useRadianceOverAlpha: boolean;
  54875. /**
  54876. * Allows using an object space normal map (instead of tangent space).
  54877. */
  54878. useObjectSpaceNormalMap: boolean;
  54879. /**
  54880. * Allows using the bump map in parallax mode.
  54881. */
  54882. useParallax: boolean;
  54883. /**
  54884. * Allows using the bump map in parallax occlusion mode.
  54885. */
  54886. useParallaxOcclusion: boolean;
  54887. /**
  54888. * Controls the scale bias of the parallax mode.
  54889. */
  54890. parallaxScaleBias: number;
  54891. /**
  54892. * If sets to true, disables all the lights affecting the material.
  54893. */
  54894. disableLighting: boolean;
  54895. /**
  54896. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  54897. */
  54898. forceIrradianceInFragment: boolean;
  54899. /**
  54900. * Number of Simultaneous lights allowed on the material.
  54901. */
  54902. maxSimultaneousLights: number;
  54903. /**
  54904. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  54905. */
  54906. invertNormalMapX: boolean;
  54907. /**
  54908. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  54909. */
  54910. invertNormalMapY: boolean;
  54911. /**
  54912. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  54913. */
  54914. twoSidedLighting: boolean;
  54915. /**
  54916. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  54917. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  54918. */
  54919. useAlphaFresnel: boolean;
  54920. /**
  54921. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  54922. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  54923. */
  54924. useLinearAlphaFresnel: boolean;
  54925. /**
  54926. * Let user defines the brdf lookup texture used for IBL.
  54927. * A default 8bit version is embedded but you could point at :
  54928. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  54929. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  54930. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  54931. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  54932. */
  54933. environmentBRDFTexture: Nullable<BaseTexture>;
  54934. /**
  54935. * Force normal to face away from face.
  54936. */
  54937. forceNormalForward: boolean;
  54938. /**
  54939. * Enables specular anti aliasing in the PBR shader.
  54940. * It will both interacts on the Geometry for analytical and IBL lighting.
  54941. * It also prefilter the roughness map based on the bump values.
  54942. */
  54943. enableSpecularAntiAliasing: boolean;
  54944. /**
  54945. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  54946. * makes the reflect vector face the model (under horizon).
  54947. */
  54948. useHorizonOcclusion: boolean;
  54949. /**
  54950. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  54951. * too much the area relying on ambient texture to define their ambient occlusion.
  54952. */
  54953. useRadianceOcclusion: boolean;
  54954. /**
  54955. * If set to true, no lighting calculations will be applied.
  54956. */
  54957. unlit: boolean;
  54958. /**
  54959. * Gets the image processing configuration used either in this material.
  54960. */
  54961. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  54962. /**
  54963. * Sets the Default image processing configuration used either in the this material.
  54964. *
  54965. * If sets to null, the scene one is in use.
  54966. */
  54967. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  54968. /**
  54969. * Gets wether the color curves effect is enabled.
  54970. */
  54971. get cameraColorCurvesEnabled(): boolean;
  54972. /**
  54973. * Sets wether the color curves effect is enabled.
  54974. */
  54975. set cameraColorCurvesEnabled(value: boolean);
  54976. /**
  54977. * Gets wether the color grading effect is enabled.
  54978. */
  54979. get cameraColorGradingEnabled(): boolean;
  54980. /**
  54981. * Gets wether the color grading effect is enabled.
  54982. */
  54983. set cameraColorGradingEnabled(value: boolean);
  54984. /**
  54985. * Gets wether tonemapping is enabled or not.
  54986. */
  54987. get cameraToneMappingEnabled(): boolean;
  54988. /**
  54989. * Sets wether tonemapping is enabled or not
  54990. */
  54991. set cameraToneMappingEnabled(value: boolean);
  54992. /**
  54993. * The camera exposure used on this material.
  54994. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  54995. * This corresponds to a photographic exposure.
  54996. */
  54997. get cameraExposure(): number;
  54998. /**
  54999. * The camera exposure used on this material.
  55000. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  55001. * This corresponds to a photographic exposure.
  55002. */
  55003. set cameraExposure(value: number);
  55004. /**
  55005. * Gets The camera contrast used on this material.
  55006. */
  55007. get cameraContrast(): number;
  55008. /**
  55009. * Sets The camera contrast used on this material.
  55010. */
  55011. set cameraContrast(value: number);
  55012. /**
  55013. * Gets the Color Grading 2D Lookup Texture.
  55014. */
  55015. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  55016. /**
  55017. * Sets the Color Grading 2D Lookup Texture.
  55018. */
  55019. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  55020. /**
  55021. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  55022. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  55023. * 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;
  55024. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  55025. */
  55026. get cameraColorCurves(): Nullable<ColorCurves>;
  55027. /**
  55028. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  55029. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  55030. * 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;
  55031. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  55032. */
  55033. set cameraColorCurves(value: Nullable<ColorCurves>);
  55034. /**
  55035. * Instantiates a new PBRMaterial instance.
  55036. *
  55037. * @param name The material name
  55038. * @param scene The scene the material will be use in.
  55039. */
  55040. constructor(name: string, scene: Scene);
  55041. /**
  55042. * Returns the name of this material class.
  55043. */
  55044. getClassName(): string;
  55045. /**
  55046. * Makes a duplicate of the current material.
  55047. * @param name - name to use for the new material.
  55048. */
  55049. clone(name: string): PBRMaterial;
  55050. /**
  55051. * Serializes this PBR Material.
  55052. * @returns - An object with the serialized material.
  55053. */
  55054. serialize(): any;
  55055. /**
  55056. * Parses a PBR Material from a serialized object.
  55057. * @param source - Serialized object.
  55058. * @param scene - BJS scene instance.
  55059. * @param rootUrl - url for the scene object
  55060. * @returns - PBRMaterial
  55061. */
  55062. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  55063. }
  55064. }
  55065. declare module "babylonjs/Misc/dds" {
  55066. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  55067. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  55068. import { Nullable } from "babylonjs/types";
  55069. import { Scene } from "babylonjs/scene";
  55070. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  55071. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  55072. /**
  55073. * Direct draw surface info
  55074. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  55075. */
  55076. export interface DDSInfo {
  55077. /**
  55078. * Width of the texture
  55079. */
  55080. width: number;
  55081. /**
  55082. * Width of the texture
  55083. */
  55084. height: number;
  55085. /**
  55086. * Number of Mipmaps for the texture
  55087. * @see https://en.wikipedia.org/wiki/Mipmap
  55088. */
  55089. mipmapCount: number;
  55090. /**
  55091. * If the textures format is a known fourCC format
  55092. * @see https://www.fourcc.org/
  55093. */
  55094. isFourCC: boolean;
  55095. /**
  55096. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  55097. */
  55098. isRGB: boolean;
  55099. /**
  55100. * If the texture is a lumincance format
  55101. */
  55102. isLuminance: boolean;
  55103. /**
  55104. * If this is a cube texture
  55105. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  55106. */
  55107. isCube: boolean;
  55108. /**
  55109. * If the texture is a compressed format eg. FOURCC_DXT1
  55110. */
  55111. isCompressed: boolean;
  55112. /**
  55113. * The dxgiFormat of the texture
  55114. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  55115. */
  55116. dxgiFormat: number;
  55117. /**
  55118. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  55119. */
  55120. textureType: number;
  55121. /**
  55122. * Sphericle polynomial created for the dds texture
  55123. */
  55124. sphericalPolynomial?: SphericalPolynomial;
  55125. }
  55126. /**
  55127. * Class used to provide DDS decompression tools
  55128. */
  55129. export class DDSTools {
  55130. /**
  55131. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  55132. */
  55133. static StoreLODInAlphaChannel: boolean;
  55134. /**
  55135. * Gets DDS information from an array buffer
  55136. * @param data defines the array buffer view to read data from
  55137. * @returns the DDS information
  55138. */
  55139. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  55140. private static _FloatView;
  55141. private static _Int32View;
  55142. private static _ToHalfFloat;
  55143. private static _FromHalfFloat;
  55144. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  55145. private static _GetHalfFloatRGBAArrayBuffer;
  55146. private static _GetFloatRGBAArrayBuffer;
  55147. private static _GetFloatAsUIntRGBAArrayBuffer;
  55148. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  55149. private static _GetRGBAArrayBuffer;
  55150. private static _ExtractLongWordOrder;
  55151. private static _GetRGBArrayBuffer;
  55152. private static _GetLuminanceArrayBuffer;
  55153. /**
  55154. * Uploads DDS Levels to a Babylon Texture
  55155. * @hidden
  55156. */
  55157. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  55158. }
  55159. module "babylonjs/Engines/thinEngine" {
  55160. interface ThinEngine {
  55161. /**
  55162. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  55163. * @param rootUrl defines the url where the file to load is located
  55164. * @param scene defines the current scene
  55165. * @param lodScale defines scale to apply to the mip map selection
  55166. * @param lodOffset defines offset to apply to the mip map selection
  55167. * @param onLoad defines an optional callback raised when the texture is loaded
  55168. * @param onError defines an optional callback raised if there is an issue to load the texture
  55169. * @param format defines the format of the data
  55170. * @param forcedExtension defines the extension to use to pick the right loader
  55171. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  55172. * @returns the cube texture as an InternalTexture
  55173. */
  55174. 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;
  55175. }
  55176. }
  55177. }
  55178. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  55179. import { Nullable } from "babylonjs/types";
  55180. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  55181. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  55182. /**
  55183. * Implementation of the DDS Texture Loader.
  55184. * @hidden
  55185. */
  55186. export class _DDSTextureLoader implements IInternalTextureLoader {
  55187. /**
  55188. * Defines wether the loader supports cascade loading the different faces.
  55189. */
  55190. readonly supportCascades: boolean;
  55191. /**
  55192. * This returns if the loader support the current file information.
  55193. * @param extension defines the file extension of the file being loaded
  55194. * @returns true if the loader can load the specified file
  55195. */
  55196. canLoad(extension: string): boolean;
  55197. /**
  55198. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  55199. * @param data contains the texture data
  55200. * @param texture defines the BabylonJS internal texture
  55201. * @param createPolynomials will be true if polynomials have been requested
  55202. * @param onLoad defines the callback to trigger once the texture is ready
  55203. * @param onError defines the callback to trigger in case of error
  55204. */
  55205. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  55206. /**
  55207. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  55208. * @param data contains the texture data
  55209. * @param texture defines the BabylonJS internal texture
  55210. * @param callback defines the method to call once ready to upload
  55211. */
  55212. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  55213. }
  55214. }
  55215. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  55216. import { Nullable } from "babylonjs/types";
  55217. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  55218. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  55219. /**
  55220. * Implementation of the ENV Texture Loader.
  55221. * @hidden
  55222. */
  55223. export class _ENVTextureLoader implements IInternalTextureLoader {
  55224. /**
  55225. * Defines wether the loader supports cascade loading the different faces.
  55226. */
  55227. readonly supportCascades: boolean;
  55228. /**
  55229. * This returns if the loader support the current file information.
  55230. * @param extension defines the file extension of the file being loaded
  55231. * @returns true if the loader can load the specified file
  55232. */
  55233. canLoad(extension: string): boolean;
  55234. /**
  55235. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  55236. * @param data contains the texture data
  55237. * @param texture defines the BabylonJS internal texture
  55238. * @param createPolynomials will be true if polynomials have been requested
  55239. * @param onLoad defines the callback to trigger once the texture is ready
  55240. * @param onError defines the callback to trigger in case of error
  55241. */
  55242. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  55243. /**
  55244. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  55245. * @param data contains the texture data
  55246. * @param texture defines the BabylonJS internal texture
  55247. * @param callback defines the method to call once ready to upload
  55248. */
  55249. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  55250. }
  55251. }
  55252. declare module "babylonjs/Misc/khronosTextureContainer" {
  55253. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  55254. /**
  55255. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  55256. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  55257. */
  55258. export class KhronosTextureContainer {
  55259. /** contents of the KTX container file */
  55260. data: ArrayBufferView;
  55261. private static HEADER_LEN;
  55262. private static COMPRESSED_2D;
  55263. private static COMPRESSED_3D;
  55264. private static TEX_2D;
  55265. private static TEX_3D;
  55266. /**
  55267. * Gets the openGL type
  55268. */
  55269. glType: number;
  55270. /**
  55271. * Gets the openGL type size
  55272. */
  55273. glTypeSize: number;
  55274. /**
  55275. * Gets the openGL format
  55276. */
  55277. glFormat: number;
  55278. /**
  55279. * Gets the openGL internal format
  55280. */
  55281. glInternalFormat: number;
  55282. /**
  55283. * Gets the base internal format
  55284. */
  55285. glBaseInternalFormat: number;
  55286. /**
  55287. * Gets image width in pixel
  55288. */
  55289. pixelWidth: number;
  55290. /**
  55291. * Gets image height in pixel
  55292. */
  55293. pixelHeight: number;
  55294. /**
  55295. * Gets image depth in pixels
  55296. */
  55297. pixelDepth: number;
  55298. /**
  55299. * Gets the number of array elements
  55300. */
  55301. numberOfArrayElements: number;
  55302. /**
  55303. * Gets the number of faces
  55304. */
  55305. numberOfFaces: number;
  55306. /**
  55307. * Gets the number of mipmap levels
  55308. */
  55309. numberOfMipmapLevels: number;
  55310. /**
  55311. * Gets the bytes of key value data
  55312. */
  55313. bytesOfKeyValueData: number;
  55314. /**
  55315. * Gets the load type
  55316. */
  55317. loadType: number;
  55318. /**
  55319. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  55320. */
  55321. isInvalid: boolean;
  55322. /**
  55323. * Creates a new KhronosTextureContainer
  55324. * @param data contents of the KTX container file
  55325. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  55326. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  55327. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  55328. */
  55329. constructor(
  55330. /** contents of the KTX container file */
  55331. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  55332. /**
  55333. * Uploads KTX content to a Babylon Texture.
  55334. * It is assumed that the texture has already been created & is currently bound
  55335. * @hidden
  55336. */
  55337. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  55338. private _upload2DCompressedLevels;
  55339. /**
  55340. * Checks if the given data starts with a KTX file identifier.
  55341. * @param data the data to check
  55342. * @returns true if the data is a KTX file or false otherwise
  55343. */
  55344. static IsValid(data: ArrayBufferView): boolean;
  55345. }
  55346. }
  55347. declare module "babylonjs/Misc/khronosTextureContainer2" {
  55348. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  55349. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  55350. /**
  55351. * Class for loading KTX2 files
  55352. * !!! Experimental Extension Subject to Changes !!!
  55353. * @hidden
  55354. */
  55355. export class KhronosTextureContainer2 {
  55356. private static _ModulePromise;
  55357. private static _TranscodeFormat;
  55358. constructor(engine: ThinEngine);
  55359. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture): Promise<void>;
  55360. private _determineTranscodeFormat;
  55361. /**
  55362. * Checks if the given data starts with a KTX2 file identifier.
  55363. * @param data the data to check
  55364. * @returns true if the data is a KTX2 file or false otherwise
  55365. */
  55366. static IsValid(data: ArrayBufferView): boolean;
  55367. }
  55368. }
  55369. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  55370. import { Nullable } from "babylonjs/types";
  55371. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  55372. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  55373. /**
  55374. * Implementation of the KTX Texture Loader.
  55375. * @hidden
  55376. */
  55377. export class _KTXTextureLoader implements IInternalTextureLoader {
  55378. /**
  55379. * Defines wether the loader supports cascade loading the different faces.
  55380. */
  55381. readonly supportCascades: boolean;
  55382. /**
  55383. * This returns if the loader support the current file information.
  55384. * @param extension defines the file extension of the file being loaded
  55385. * @returns true if the loader can load the specified file
  55386. */
  55387. canLoad(extension: string): boolean;
  55388. /**
  55389. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  55390. * @param data contains the texture data
  55391. * @param texture defines the BabylonJS internal texture
  55392. * @param createPolynomials will be true if polynomials have been requested
  55393. * @param onLoad defines the callback to trigger once the texture is ready
  55394. * @param onError defines the callback to trigger in case of error
  55395. */
  55396. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  55397. /**
  55398. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  55399. * @param data contains the texture data
  55400. * @param texture defines the BabylonJS internal texture
  55401. * @param callback defines the method to call once ready to upload
  55402. */
  55403. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  55404. }
  55405. }
  55406. declare module "babylonjs/Helpers/sceneHelpers" {
  55407. import { Nullable } from "babylonjs/types";
  55408. import { Mesh } from "babylonjs/Meshes/mesh";
  55409. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55410. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  55411. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  55412. import "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  55413. import "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  55414. import "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  55415. import "babylonjs/Meshes/Builders/boxBuilder";
  55416. import { WebXRDefaultExperience, WebXRDefaultExperienceOptions } from "babylonjs/XR/webXRDefaultExperience";
  55417. /** @hidden */
  55418. export var _forceSceneHelpersToBundle: boolean;
  55419. module "babylonjs/scene" {
  55420. interface Scene {
  55421. /**
  55422. * Creates a default light for the scene.
  55423. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  55424. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  55425. */
  55426. createDefaultLight(replace?: boolean): void;
  55427. /**
  55428. * Creates a default camera for the scene.
  55429. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  55430. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  55431. * @param replace has default false, when true replaces the active camera in the scene
  55432. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  55433. */
  55434. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  55435. /**
  55436. * Creates a default camera and a default light.
  55437. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  55438. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  55439. * @param replace has the default false, when true replaces the active camera/light in the scene
  55440. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  55441. */
  55442. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  55443. /**
  55444. * Creates a new sky box
  55445. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  55446. * @param environmentTexture defines the texture to use as environment texture
  55447. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  55448. * @param scale defines the overall scale of the skybox
  55449. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  55450. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  55451. * @returns a new mesh holding the sky box
  55452. */
  55453. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  55454. /**
  55455. * Creates a new environment
  55456. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  55457. * @param options defines the options you can use to configure the environment
  55458. * @returns the new EnvironmentHelper
  55459. */
  55460. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  55461. /**
  55462. * Creates a new VREXperienceHelper
  55463. * @see http://doc.babylonjs.com/how_to/webvr_helper
  55464. * @param webVROptions defines the options used to create the new VREXperienceHelper
  55465. * @returns a new VREXperienceHelper
  55466. */
  55467. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  55468. /**
  55469. * Creates a new WebXRDefaultExperience
  55470. * @see http://doc.babylonjs.com/how_to/webxr
  55471. * @param options experience options
  55472. * @returns a promise for a new WebXRDefaultExperience
  55473. */
  55474. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  55475. }
  55476. }
  55477. }
  55478. declare module "babylonjs/Helpers/videoDome" {
  55479. import { Scene } from "babylonjs/scene";
  55480. import { TransformNode } from "babylonjs/Meshes/transformNode";
  55481. import { Mesh } from "babylonjs/Meshes/mesh";
  55482. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  55483. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  55484. import "babylonjs/Meshes/Builders/sphereBuilder";
  55485. /**
  55486. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  55487. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  55488. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  55489. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  55490. */
  55491. export class VideoDome extends TransformNode {
  55492. /**
  55493. * Define the video source as a Monoscopic panoramic 360 video.
  55494. */
  55495. static readonly MODE_MONOSCOPIC: number;
  55496. /**
  55497. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  55498. */
  55499. static readonly MODE_TOPBOTTOM: number;
  55500. /**
  55501. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  55502. */
  55503. static readonly MODE_SIDEBYSIDE: number;
  55504. private _halfDome;
  55505. private _useDirectMapping;
  55506. /**
  55507. * The video texture being displayed on the sphere
  55508. */
  55509. protected _videoTexture: VideoTexture;
  55510. /**
  55511. * Gets the video texture being displayed on the sphere
  55512. */
  55513. get videoTexture(): VideoTexture;
  55514. /**
  55515. * The skybox material
  55516. */
  55517. protected _material: BackgroundMaterial;
  55518. /**
  55519. * The surface used for the skybox
  55520. */
  55521. protected _mesh: Mesh;
  55522. /**
  55523. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  55524. */
  55525. private _halfDomeMask;
  55526. /**
  55527. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  55528. * Also see the options.resolution property.
  55529. */
  55530. get fovMultiplier(): number;
  55531. set fovMultiplier(value: number);
  55532. private _videoMode;
  55533. /**
  55534. * Gets or set the current video mode for the video. It can be:
  55535. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  55536. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  55537. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  55538. */
  55539. get videoMode(): number;
  55540. set videoMode(value: number);
  55541. /**
  55542. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  55543. *
  55544. */
  55545. get halfDome(): boolean;
  55546. /**
  55547. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  55548. */
  55549. set halfDome(enabled: boolean);
  55550. /**
  55551. * Oberserver used in Stereoscopic VR Mode.
  55552. */
  55553. private _onBeforeCameraRenderObserver;
  55554. /**
  55555. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  55556. * @param name Element's name, child elements will append suffixes for their own names.
  55557. * @param urlsOrVideo defines the url(s) or the video element to use
  55558. * @param options An object containing optional or exposed sub element properties
  55559. */
  55560. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  55561. resolution?: number;
  55562. clickToPlay?: boolean;
  55563. autoPlay?: boolean;
  55564. loop?: boolean;
  55565. size?: number;
  55566. poster?: string;
  55567. faceForward?: boolean;
  55568. useDirectMapping?: boolean;
  55569. halfDomeMode?: boolean;
  55570. }, scene: Scene);
  55571. private _changeVideoMode;
  55572. /**
  55573. * Releases resources associated with this node.
  55574. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  55575. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  55576. */
  55577. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  55578. }
  55579. }
  55580. declare module "babylonjs/Helpers/index" {
  55581. export * from "babylonjs/Helpers/environmentHelper";
  55582. export * from "babylonjs/Helpers/photoDome";
  55583. export * from "babylonjs/Helpers/sceneHelpers";
  55584. export * from "babylonjs/Helpers/videoDome";
  55585. }
  55586. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  55587. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  55588. import { IDisposable } from "babylonjs/scene";
  55589. import { Engine } from "babylonjs/Engines/engine";
  55590. /**
  55591. * This class can be used to get instrumentation data from a Babylon engine
  55592. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  55593. */
  55594. export class EngineInstrumentation implements IDisposable {
  55595. /**
  55596. * Define the instrumented engine.
  55597. */
  55598. engine: Engine;
  55599. private _captureGPUFrameTime;
  55600. private _gpuFrameTimeToken;
  55601. private _gpuFrameTime;
  55602. private _captureShaderCompilationTime;
  55603. private _shaderCompilationTime;
  55604. private _onBeginFrameObserver;
  55605. private _onEndFrameObserver;
  55606. private _onBeforeShaderCompilationObserver;
  55607. private _onAfterShaderCompilationObserver;
  55608. /**
  55609. * Gets the perf counter used for GPU frame time
  55610. */
  55611. get gpuFrameTimeCounter(): PerfCounter;
  55612. /**
  55613. * Gets the GPU frame time capture status
  55614. */
  55615. get captureGPUFrameTime(): boolean;
  55616. /**
  55617. * Enable or disable the GPU frame time capture
  55618. */
  55619. set captureGPUFrameTime(value: boolean);
  55620. /**
  55621. * Gets the perf counter used for shader compilation time
  55622. */
  55623. get shaderCompilationTimeCounter(): PerfCounter;
  55624. /**
  55625. * Gets the shader compilation time capture status
  55626. */
  55627. get captureShaderCompilationTime(): boolean;
  55628. /**
  55629. * Enable or disable the shader compilation time capture
  55630. */
  55631. set captureShaderCompilationTime(value: boolean);
  55632. /**
  55633. * Instantiates a new engine instrumentation.
  55634. * This class can be used to get instrumentation data from a Babylon engine
  55635. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  55636. * @param engine Defines the engine to instrument
  55637. */
  55638. constructor(
  55639. /**
  55640. * Define the instrumented engine.
  55641. */
  55642. engine: Engine);
  55643. /**
  55644. * Dispose and release associated resources.
  55645. */
  55646. dispose(): void;
  55647. }
  55648. }
  55649. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  55650. import { Scene, IDisposable } from "babylonjs/scene";
  55651. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  55652. /**
  55653. * This class can be used to get instrumentation data from a Babylon engine
  55654. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  55655. */
  55656. export class SceneInstrumentation implements IDisposable {
  55657. /**
  55658. * Defines the scene to instrument
  55659. */
  55660. scene: Scene;
  55661. private _captureActiveMeshesEvaluationTime;
  55662. private _activeMeshesEvaluationTime;
  55663. private _captureRenderTargetsRenderTime;
  55664. private _renderTargetsRenderTime;
  55665. private _captureFrameTime;
  55666. private _frameTime;
  55667. private _captureRenderTime;
  55668. private _renderTime;
  55669. private _captureInterFrameTime;
  55670. private _interFrameTime;
  55671. private _captureParticlesRenderTime;
  55672. private _particlesRenderTime;
  55673. private _captureSpritesRenderTime;
  55674. private _spritesRenderTime;
  55675. private _capturePhysicsTime;
  55676. private _physicsTime;
  55677. private _captureAnimationsTime;
  55678. private _animationsTime;
  55679. private _captureCameraRenderTime;
  55680. private _cameraRenderTime;
  55681. private _onBeforeActiveMeshesEvaluationObserver;
  55682. private _onAfterActiveMeshesEvaluationObserver;
  55683. private _onBeforeRenderTargetsRenderObserver;
  55684. private _onAfterRenderTargetsRenderObserver;
  55685. private _onAfterRenderObserver;
  55686. private _onBeforeDrawPhaseObserver;
  55687. private _onAfterDrawPhaseObserver;
  55688. private _onBeforeAnimationsObserver;
  55689. private _onBeforeParticlesRenderingObserver;
  55690. private _onAfterParticlesRenderingObserver;
  55691. private _onBeforeSpritesRenderingObserver;
  55692. private _onAfterSpritesRenderingObserver;
  55693. private _onBeforePhysicsObserver;
  55694. private _onAfterPhysicsObserver;
  55695. private _onAfterAnimationsObserver;
  55696. private _onBeforeCameraRenderObserver;
  55697. private _onAfterCameraRenderObserver;
  55698. /**
  55699. * Gets the perf counter used for active meshes evaluation time
  55700. */
  55701. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  55702. /**
  55703. * Gets the active meshes evaluation time capture status
  55704. */
  55705. get captureActiveMeshesEvaluationTime(): boolean;
  55706. /**
  55707. * Enable or disable the active meshes evaluation time capture
  55708. */
  55709. set captureActiveMeshesEvaluationTime(value: boolean);
  55710. /**
  55711. * Gets the perf counter used for render targets render time
  55712. */
  55713. get renderTargetsRenderTimeCounter(): PerfCounter;
  55714. /**
  55715. * Gets the render targets render time capture status
  55716. */
  55717. get captureRenderTargetsRenderTime(): boolean;
  55718. /**
  55719. * Enable or disable the render targets render time capture
  55720. */
  55721. set captureRenderTargetsRenderTime(value: boolean);
  55722. /**
  55723. * Gets the perf counter used for particles render time
  55724. */
  55725. get particlesRenderTimeCounter(): PerfCounter;
  55726. /**
  55727. * Gets the particles render time capture status
  55728. */
  55729. get captureParticlesRenderTime(): boolean;
  55730. /**
  55731. * Enable or disable the particles render time capture
  55732. */
  55733. set captureParticlesRenderTime(value: boolean);
  55734. /**
  55735. * Gets the perf counter used for sprites render time
  55736. */
  55737. get spritesRenderTimeCounter(): PerfCounter;
  55738. /**
  55739. * Gets the sprites render time capture status
  55740. */
  55741. get captureSpritesRenderTime(): boolean;
  55742. /**
  55743. * Enable or disable the sprites render time capture
  55744. */
  55745. set captureSpritesRenderTime(value: boolean);
  55746. /**
  55747. * Gets the perf counter used for physics time
  55748. */
  55749. get physicsTimeCounter(): PerfCounter;
  55750. /**
  55751. * Gets the physics time capture status
  55752. */
  55753. get capturePhysicsTime(): boolean;
  55754. /**
  55755. * Enable or disable the physics time capture
  55756. */
  55757. set capturePhysicsTime(value: boolean);
  55758. /**
  55759. * Gets the perf counter used for animations time
  55760. */
  55761. get animationsTimeCounter(): PerfCounter;
  55762. /**
  55763. * Gets the animations time capture status
  55764. */
  55765. get captureAnimationsTime(): boolean;
  55766. /**
  55767. * Enable or disable the animations time capture
  55768. */
  55769. set captureAnimationsTime(value: boolean);
  55770. /**
  55771. * Gets the perf counter used for frame time capture
  55772. */
  55773. get frameTimeCounter(): PerfCounter;
  55774. /**
  55775. * Gets the frame time capture status
  55776. */
  55777. get captureFrameTime(): boolean;
  55778. /**
  55779. * Enable or disable the frame time capture
  55780. */
  55781. set captureFrameTime(value: boolean);
  55782. /**
  55783. * Gets the perf counter used for inter-frames time capture
  55784. */
  55785. get interFrameTimeCounter(): PerfCounter;
  55786. /**
  55787. * Gets the inter-frames time capture status
  55788. */
  55789. get captureInterFrameTime(): boolean;
  55790. /**
  55791. * Enable or disable the inter-frames time capture
  55792. */
  55793. set captureInterFrameTime(value: boolean);
  55794. /**
  55795. * Gets the perf counter used for render time capture
  55796. */
  55797. get renderTimeCounter(): PerfCounter;
  55798. /**
  55799. * Gets the render time capture status
  55800. */
  55801. get captureRenderTime(): boolean;
  55802. /**
  55803. * Enable or disable the render time capture
  55804. */
  55805. set captureRenderTime(value: boolean);
  55806. /**
  55807. * Gets the perf counter used for camera render time capture
  55808. */
  55809. get cameraRenderTimeCounter(): PerfCounter;
  55810. /**
  55811. * Gets the camera render time capture status
  55812. */
  55813. get captureCameraRenderTime(): boolean;
  55814. /**
  55815. * Enable or disable the camera render time capture
  55816. */
  55817. set captureCameraRenderTime(value: boolean);
  55818. /**
  55819. * Gets the perf counter used for draw calls
  55820. */
  55821. get drawCallsCounter(): PerfCounter;
  55822. /**
  55823. * Instantiates a new scene instrumentation.
  55824. * This class can be used to get instrumentation data from a Babylon engine
  55825. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  55826. * @param scene Defines the scene to instrument
  55827. */
  55828. constructor(
  55829. /**
  55830. * Defines the scene to instrument
  55831. */
  55832. scene: Scene);
  55833. /**
  55834. * Dispose and release associated resources.
  55835. */
  55836. dispose(): void;
  55837. }
  55838. }
  55839. declare module "babylonjs/Instrumentation/index" {
  55840. export * from "babylonjs/Instrumentation/engineInstrumentation";
  55841. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  55842. export * from "babylonjs/Instrumentation/timeToken";
  55843. }
  55844. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  55845. /** @hidden */
  55846. export var glowMapGenerationPixelShader: {
  55847. name: string;
  55848. shader: string;
  55849. };
  55850. }
  55851. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  55852. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  55853. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  55854. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  55855. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  55856. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  55857. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  55858. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  55859. /** @hidden */
  55860. export var glowMapGenerationVertexShader: {
  55861. name: string;
  55862. shader: string;
  55863. };
  55864. }
  55865. declare module "babylonjs/Layers/effectLayer" {
  55866. import { Observable } from "babylonjs/Misc/observable";
  55867. import { Nullable } from "babylonjs/types";
  55868. import { Camera } from "babylonjs/Cameras/camera";
  55869. import { Scene } from "babylonjs/scene";
  55870. import { ISize } from "babylonjs/Maths/math.size";
  55871. import { Color4 } from "babylonjs/Maths/math.color";
  55872. import { Engine } from "babylonjs/Engines/engine";
  55873. import { SubMesh } from "babylonjs/Meshes/subMesh";
  55874. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55875. import { Mesh } from "babylonjs/Meshes/mesh";
  55876. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  55877. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55878. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  55879. import { Effect } from "babylonjs/Materials/effect";
  55880. import { Material } from "babylonjs/Materials/material";
  55881. import "babylonjs/Shaders/glowMapGeneration.fragment";
  55882. import "babylonjs/Shaders/glowMapGeneration.vertex";
  55883. /**
  55884. * Effect layer options. This helps customizing the behaviour
  55885. * of the effect layer.
  55886. */
  55887. export interface IEffectLayerOptions {
  55888. /**
  55889. * Multiplication factor apply to the canvas size to compute the render target size
  55890. * used to generated the objects (the smaller the faster).
  55891. */
  55892. mainTextureRatio: number;
  55893. /**
  55894. * Enforces a fixed size texture to ensure effect stability across devices.
  55895. */
  55896. mainTextureFixedSize?: number;
  55897. /**
  55898. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  55899. */
  55900. alphaBlendingMode: number;
  55901. /**
  55902. * The camera attached to the layer.
  55903. */
  55904. camera: Nullable<Camera>;
  55905. /**
  55906. * The rendering group to draw the layer in.
  55907. */
  55908. renderingGroupId: number;
  55909. }
  55910. /**
  55911. * The effect layer Helps adding post process effect blended with the main pass.
  55912. *
  55913. * This can be for instance use to generate glow or higlight effects on the scene.
  55914. *
  55915. * The effect layer class can not be used directly and is intented to inherited from to be
  55916. * customized per effects.
  55917. */
  55918. export abstract class EffectLayer {
  55919. private _vertexBuffers;
  55920. private _indexBuffer;
  55921. private _cachedDefines;
  55922. private _effectLayerMapGenerationEffect;
  55923. private _effectLayerOptions;
  55924. private _mergeEffect;
  55925. protected _scene: Scene;
  55926. protected _engine: Engine;
  55927. protected _maxSize: number;
  55928. protected _mainTextureDesiredSize: ISize;
  55929. protected _mainTexture: RenderTargetTexture;
  55930. protected _shouldRender: boolean;
  55931. protected _postProcesses: PostProcess[];
  55932. protected _textures: BaseTexture[];
  55933. protected _emissiveTextureAndColor: {
  55934. texture: Nullable<BaseTexture>;
  55935. color: Color4;
  55936. };
  55937. /**
  55938. * The name of the layer
  55939. */
  55940. name: string;
  55941. /**
  55942. * The clear color of the texture used to generate the glow map.
  55943. */
  55944. neutralColor: Color4;
  55945. /**
  55946. * Specifies whether the highlight layer is enabled or not.
  55947. */
  55948. isEnabled: boolean;
  55949. /**
  55950. * Gets the camera attached to the layer.
  55951. */
  55952. get camera(): Nullable<Camera>;
  55953. /**
  55954. * Gets the rendering group id the layer should render in.
  55955. */
  55956. get renderingGroupId(): number;
  55957. set renderingGroupId(renderingGroupId: number);
  55958. /**
  55959. * An event triggered when the effect layer has been disposed.
  55960. */
  55961. onDisposeObservable: Observable<EffectLayer>;
  55962. /**
  55963. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  55964. */
  55965. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  55966. /**
  55967. * An event triggered when the generated texture is being merged in the scene.
  55968. */
  55969. onBeforeComposeObservable: Observable<EffectLayer>;
  55970. /**
  55971. * An event triggered when the mesh is rendered into the effect render target.
  55972. */
  55973. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  55974. /**
  55975. * An event triggered after the mesh has been rendered into the effect render target.
  55976. */
  55977. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  55978. /**
  55979. * An event triggered when the generated texture has been merged in the scene.
  55980. */
  55981. onAfterComposeObservable: Observable<EffectLayer>;
  55982. /**
  55983. * An event triggered when the efffect layer changes its size.
  55984. */
  55985. onSizeChangedObservable: Observable<EffectLayer>;
  55986. /** @hidden */
  55987. static _SceneComponentInitialization: (scene: Scene) => void;
  55988. /**
  55989. * Instantiates a new effect Layer and references it in the scene.
  55990. * @param name The name of the layer
  55991. * @param scene The scene to use the layer in
  55992. */
  55993. constructor(
  55994. /** The Friendly of the effect in the scene */
  55995. name: string, scene: Scene);
  55996. /**
  55997. * Get the effect name of the layer.
  55998. * @return The effect name
  55999. */
  56000. abstract getEffectName(): string;
  56001. /**
  56002. * Checks for the readiness of the element composing the layer.
  56003. * @param subMesh the mesh to check for
  56004. * @param useInstances specify whether or not to use instances to render the mesh
  56005. * @return true if ready otherwise, false
  56006. */
  56007. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  56008. /**
  56009. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  56010. * @returns true if the effect requires stencil during the main canvas render pass.
  56011. */
  56012. abstract needStencil(): boolean;
  56013. /**
  56014. * Create the merge effect. This is the shader use to blit the information back
  56015. * to the main canvas at the end of the scene rendering.
  56016. * @returns The effect containing the shader used to merge the effect on the main canvas
  56017. */
  56018. protected abstract _createMergeEffect(): Effect;
  56019. /**
  56020. * Creates the render target textures and post processes used in the effect layer.
  56021. */
  56022. protected abstract _createTextureAndPostProcesses(): void;
  56023. /**
  56024. * Implementation specific of rendering the generating effect on the main canvas.
  56025. * @param effect The effect used to render through
  56026. */
  56027. protected abstract _internalRender(effect: Effect): void;
  56028. /**
  56029. * Sets the required values for both the emissive texture and and the main color.
  56030. */
  56031. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  56032. /**
  56033. * Free any resources and references associated to a mesh.
  56034. * Internal use
  56035. * @param mesh The mesh to free.
  56036. */
  56037. abstract _disposeMesh(mesh: Mesh): void;
  56038. /**
  56039. * Serializes this layer (Glow or Highlight for example)
  56040. * @returns a serialized layer object
  56041. */
  56042. abstract serialize?(): any;
  56043. /**
  56044. * Initializes the effect layer with the required options.
  56045. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  56046. */
  56047. protected _init(options: Partial<IEffectLayerOptions>): void;
  56048. /**
  56049. * Generates the index buffer of the full screen quad blending to the main canvas.
  56050. */
  56051. private _generateIndexBuffer;
  56052. /**
  56053. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  56054. */
  56055. private _generateVertexBuffer;
  56056. /**
  56057. * Sets the main texture desired size which is the closest power of two
  56058. * of the engine canvas size.
  56059. */
  56060. private _setMainTextureSize;
  56061. /**
  56062. * Creates the main texture for the effect layer.
  56063. */
  56064. protected _createMainTexture(): void;
  56065. /**
  56066. * Adds specific effects defines.
  56067. * @param defines The defines to add specifics to.
  56068. */
  56069. protected _addCustomEffectDefines(defines: string[]): void;
  56070. /**
  56071. * Checks for the readiness of the element composing the layer.
  56072. * @param subMesh the mesh to check for
  56073. * @param useInstances specify whether or not to use instances to render the mesh
  56074. * @param emissiveTexture the associated emissive texture used to generate the glow
  56075. * @return true if ready otherwise, false
  56076. */
  56077. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  56078. /**
  56079. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  56080. */
  56081. render(): void;
  56082. /**
  56083. * Determine if a given mesh will be used in the current effect.
  56084. * @param mesh mesh to test
  56085. * @returns true if the mesh will be used
  56086. */
  56087. hasMesh(mesh: AbstractMesh): boolean;
  56088. /**
  56089. * Returns true if the layer contains information to display, otherwise false.
  56090. * @returns true if the glow layer should be rendered
  56091. */
  56092. shouldRender(): boolean;
  56093. /**
  56094. * Returns true if the mesh should render, otherwise false.
  56095. * @param mesh The mesh to render
  56096. * @returns true if it should render otherwise false
  56097. */
  56098. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  56099. /**
  56100. * Returns true if the mesh can be rendered, otherwise false.
  56101. * @param mesh The mesh to render
  56102. * @param material The material used on the mesh
  56103. * @returns true if it can be rendered otherwise false
  56104. */
  56105. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  56106. /**
  56107. * Returns true if the mesh should render, otherwise false.
  56108. * @param mesh The mesh to render
  56109. * @returns true if it should render otherwise false
  56110. */
  56111. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  56112. /**
  56113. * Renders the submesh passed in parameter to the generation map.
  56114. */
  56115. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  56116. /**
  56117. * Defines whether the current material of the mesh should be use to render the effect.
  56118. * @param mesh defines the current mesh to render
  56119. */
  56120. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  56121. /**
  56122. * Rebuild the required buffers.
  56123. * @hidden Internal use only.
  56124. */
  56125. _rebuild(): void;
  56126. /**
  56127. * Dispose only the render target textures and post process.
  56128. */
  56129. private _disposeTextureAndPostProcesses;
  56130. /**
  56131. * Dispose the highlight layer and free resources.
  56132. */
  56133. dispose(): void;
  56134. /**
  56135. * Gets the class name of the effect layer
  56136. * @returns the string with the class name of the effect layer
  56137. */
  56138. getClassName(): string;
  56139. /**
  56140. * Creates an effect layer from parsed effect layer data
  56141. * @param parsedEffectLayer defines effect layer data
  56142. * @param scene defines the current scene
  56143. * @param rootUrl defines the root URL containing the effect layer information
  56144. * @returns a parsed effect Layer
  56145. */
  56146. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  56147. }
  56148. }
  56149. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  56150. import { Scene } from "babylonjs/scene";
  56151. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  56152. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  56153. import { AbstractScene } from "babylonjs/abstractScene";
  56154. module "babylonjs/abstractScene" {
  56155. interface AbstractScene {
  56156. /**
  56157. * The list of effect layers (highlights/glow) added to the scene
  56158. * @see http://doc.babylonjs.com/how_to/highlight_layer
  56159. * @see http://doc.babylonjs.com/how_to/glow_layer
  56160. */
  56161. effectLayers: Array<EffectLayer>;
  56162. /**
  56163. * Removes the given effect layer from this scene.
  56164. * @param toRemove defines the effect layer to remove
  56165. * @returns the index of the removed effect layer
  56166. */
  56167. removeEffectLayer(toRemove: EffectLayer): number;
  56168. /**
  56169. * Adds the given effect layer to this scene
  56170. * @param newEffectLayer defines the effect layer to add
  56171. */
  56172. addEffectLayer(newEffectLayer: EffectLayer): void;
  56173. }
  56174. }
  56175. /**
  56176. * Defines the layer scene component responsible to manage any effect layers
  56177. * in a given scene.
  56178. */
  56179. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  56180. /**
  56181. * The component name helpfull to identify the component in the list of scene components.
  56182. */
  56183. readonly name: string;
  56184. /**
  56185. * The scene the component belongs to.
  56186. */
  56187. scene: Scene;
  56188. private _engine;
  56189. private _renderEffects;
  56190. private _needStencil;
  56191. private _previousStencilState;
  56192. /**
  56193. * Creates a new instance of the component for the given scene
  56194. * @param scene Defines the scene to register the component in
  56195. */
  56196. constructor(scene: Scene);
  56197. /**
  56198. * Registers the component in a given scene
  56199. */
  56200. register(): void;
  56201. /**
  56202. * Rebuilds the elements related to this component in case of
  56203. * context lost for instance.
  56204. */
  56205. rebuild(): void;
  56206. /**
  56207. * Serializes the component data to the specified json object
  56208. * @param serializationObject The object to serialize to
  56209. */
  56210. serialize(serializationObject: any): void;
  56211. /**
  56212. * Adds all the elements from the container to the scene
  56213. * @param container the container holding the elements
  56214. */
  56215. addFromContainer(container: AbstractScene): void;
  56216. /**
  56217. * Removes all the elements in the container from the scene
  56218. * @param container contains the elements to remove
  56219. * @param dispose if the removed element should be disposed (default: false)
  56220. */
  56221. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  56222. /**
  56223. * Disposes the component and the associated ressources.
  56224. */
  56225. dispose(): void;
  56226. private _isReadyForMesh;
  56227. private _renderMainTexture;
  56228. private _setStencil;
  56229. private _setStencilBack;
  56230. private _draw;
  56231. private _drawCamera;
  56232. private _drawRenderingGroup;
  56233. }
  56234. }
  56235. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  56236. /** @hidden */
  56237. export var glowMapMergePixelShader: {
  56238. name: string;
  56239. shader: string;
  56240. };
  56241. }
  56242. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  56243. /** @hidden */
  56244. export var glowMapMergeVertexShader: {
  56245. name: string;
  56246. shader: string;
  56247. };
  56248. }
  56249. declare module "babylonjs/Layers/glowLayer" {
  56250. import { Nullable } from "babylonjs/types";
  56251. import { Camera } from "babylonjs/Cameras/camera";
  56252. import { Scene } from "babylonjs/scene";
  56253. import { SubMesh } from "babylonjs/Meshes/subMesh";
  56254. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56255. import { Mesh } from "babylonjs/Meshes/mesh";
  56256. import { Texture } from "babylonjs/Materials/Textures/texture";
  56257. import { Effect } from "babylonjs/Materials/effect";
  56258. import { Material } from "babylonjs/Materials/material";
  56259. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  56260. import { Color4 } from "babylonjs/Maths/math.color";
  56261. import "babylonjs/Shaders/glowMapMerge.fragment";
  56262. import "babylonjs/Shaders/glowMapMerge.vertex";
  56263. import "babylonjs/Layers/effectLayerSceneComponent";
  56264. module "babylonjs/abstractScene" {
  56265. interface AbstractScene {
  56266. /**
  56267. * Return a the first highlight layer of the scene with a given name.
  56268. * @param name The name of the highlight layer to look for.
  56269. * @return The highlight layer if found otherwise null.
  56270. */
  56271. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  56272. }
  56273. }
  56274. /**
  56275. * Glow layer options. This helps customizing the behaviour
  56276. * of the glow layer.
  56277. */
  56278. export interface IGlowLayerOptions {
  56279. /**
  56280. * Multiplication factor apply to the canvas size to compute the render target size
  56281. * used to generated the glowing objects (the smaller the faster).
  56282. */
  56283. mainTextureRatio: number;
  56284. /**
  56285. * Enforces a fixed size texture to ensure resize independant blur.
  56286. */
  56287. mainTextureFixedSize?: number;
  56288. /**
  56289. * How big is the kernel of the blur texture.
  56290. */
  56291. blurKernelSize: number;
  56292. /**
  56293. * The camera attached to the layer.
  56294. */
  56295. camera: Nullable<Camera>;
  56296. /**
  56297. * Enable MSAA by chosing the number of samples.
  56298. */
  56299. mainTextureSamples?: number;
  56300. /**
  56301. * The rendering group to draw the layer in.
  56302. */
  56303. renderingGroupId: number;
  56304. }
  56305. /**
  56306. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  56307. *
  56308. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  56309. *
  56310. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  56311. */
  56312. export class GlowLayer extends EffectLayer {
  56313. /**
  56314. * Effect Name of the layer.
  56315. */
  56316. static readonly EffectName: string;
  56317. /**
  56318. * The default blur kernel size used for the glow.
  56319. */
  56320. static DefaultBlurKernelSize: number;
  56321. /**
  56322. * The default texture size ratio used for the glow.
  56323. */
  56324. static DefaultTextureRatio: number;
  56325. /**
  56326. * Sets the kernel size of the blur.
  56327. */
  56328. set blurKernelSize(value: number);
  56329. /**
  56330. * Gets the kernel size of the blur.
  56331. */
  56332. get blurKernelSize(): number;
  56333. /**
  56334. * Sets the glow intensity.
  56335. */
  56336. set intensity(value: number);
  56337. /**
  56338. * Gets the glow intensity.
  56339. */
  56340. get intensity(): number;
  56341. private _options;
  56342. private _intensity;
  56343. private _horizontalBlurPostprocess1;
  56344. private _verticalBlurPostprocess1;
  56345. private _horizontalBlurPostprocess2;
  56346. private _verticalBlurPostprocess2;
  56347. private _blurTexture1;
  56348. private _blurTexture2;
  56349. private _postProcesses1;
  56350. private _postProcesses2;
  56351. private _includedOnlyMeshes;
  56352. private _excludedMeshes;
  56353. private _meshesUsingTheirOwnMaterials;
  56354. /**
  56355. * Callback used to let the user override the color selection on a per mesh basis
  56356. */
  56357. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  56358. /**
  56359. * Callback used to let the user override the texture selection on a per mesh basis
  56360. */
  56361. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  56362. /**
  56363. * Instantiates a new glow Layer and references it to the scene.
  56364. * @param name The name of the layer
  56365. * @param scene The scene to use the layer in
  56366. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  56367. */
  56368. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  56369. /**
  56370. * Get the effect name of the layer.
  56371. * @return The effect name
  56372. */
  56373. getEffectName(): string;
  56374. /**
  56375. * Create the merge effect. This is the shader use to blit the information back
  56376. * to the main canvas at the end of the scene rendering.
  56377. */
  56378. protected _createMergeEffect(): Effect;
  56379. /**
  56380. * Creates the render target textures and post processes used in the glow layer.
  56381. */
  56382. protected _createTextureAndPostProcesses(): void;
  56383. /**
  56384. * Checks for the readiness of the element composing the layer.
  56385. * @param subMesh the mesh to check for
  56386. * @param useInstances specify wether or not to use instances to render the mesh
  56387. * @param emissiveTexture the associated emissive texture used to generate the glow
  56388. * @return true if ready otherwise, false
  56389. */
  56390. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  56391. /**
  56392. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  56393. */
  56394. needStencil(): boolean;
  56395. /**
  56396. * Returns true if the mesh can be rendered, otherwise false.
  56397. * @param mesh The mesh to render
  56398. * @param material The material used on the mesh
  56399. * @returns true if it can be rendered otherwise false
  56400. */
  56401. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  56402. /**
  56403. * Implementation specific of rendering the generating effect on the main canvas.
  56404. * @param effect The effect used to render through
  56405. */
  56406. protected _internalRender(effect: Effect): void;
  56407. /**
  56408. * Sets the required values for both the emissive texture and and the main color.
  56409. */
  56410. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  56411. /**
  56412. * Returns true if the mesh should render, otherwise false.
  56413. * @param mesh The mesh to render
  56414. * @returns true if it should render otherwise false
  56415. */
  56416. protected _shouldRenderMesh(mesh: Mesh): boolean;
  56417. /**
  56418. * Adds specific effects defines.
  56419. * @param defines The defines to add specifics to.
  56420. */
  56421. protected _addCustomEffectDefines(defines: string[]): void;
  56422. /**
  56423. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  56424. * @param mesh The mesh to exclude from the glow layer
  56425. */
  56426. addExcludedMesh(mesh: Mesh): void;
  56427. /**
  56428. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  56429. * @param mesh The mesh to remove
  56430. */
  56431. removeExcludedMesh(mesh: Mesh): void;
  56432. /**
  56433. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  56434. * @param mesh The mesh to include in the glow layer
  56435. */
  56436. addIncludedOnlyMesh(mesh: Mesh): void;
  56437. /**
  56438. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  56439. * @param mesh The mesh to remove
  56440. */
  56441. removeIncludedOnlyMesh(mesh: Mesh): void;
  56442. /**
  56443. * Determine if a given mesh will be used in the glow layer
  56444. * @param mesh The mesh to test
  56445. * @returns true if the mesh will be highlighted by the current glow layer
  56446. */
  56447. hasMesh(mesh: AbstractMesh): boolean;
  56448. /**
  56449. * Defines whether the current material of the mesh should be use to render the effect.
  56450. * @param mesh defines the current mesh to render
  56451. */
  56452. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  56453. /**
  56454. * Add a mesh to be rendered through its own material and not with emissive only.
  56455. * @param mesh The mesh for which we need to use its material
  56456. */
  56457. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  56458. /**
  56459. * Remove a mesh from being rendered through its own material and not with emissive only.
  56460. * @param mesh The mesh for which we need to not use its material
  56461. */
  56462. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  56463. /**
  56464. * Free any resources and references associated to a mesh.
  56465. * Internal use
  56466. * @param mesh The mesh to free.
  56467. * @hidden
  56468. */
  56469. _disposeMesh(mesh: Mesh): void;
  56470. /**
  56471. * Gets the class name of the effect layer
  56472. * @returns the string with the class name of the effect layer
  56473. */
  56474. getClassName(): string;
  56475. /**
  56476. * Serializes this glow layer
  56477. * @returns a serialized glow layer object
  56478. */
  56479. serialize(): any;
  56480. /**
  56481. * Creates a Glow Layer from parsed glow layer data
  56482. * @param parsedGlowLayer defines glow layer data
  56483. * @param scene defines the current scene
  56484. * @param rootUrl defines the root URL containing the glow layer information
  56485. * @returns a parsed Glow Layer
  56486. */
  56487. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  56488. }
  56489. }
  56490. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  56491. /** @hidden */
  56492. export var glowBlurPostProcessPixelShader: {
  56493. name: string;
  56494. shader: string;
  56495. };
  56496. }
  56497. declare module "babylonjs/Layers/highlightLayer" {
  56498. import { Observable } from "babylonjs/Misc/observable";
  56499. import { Nullable } from "babylonjs/types";
  56500. import { Camera } from "babylonjs/Cameras/camera";
  56501. import { Scene } from "babylonjs/scene";
  56502. import { SubMesh } from "babylonjs/Meshes/subMesh";
  56503. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56504. import { Mesh } from "babylonjs/Meshes/mesh";
  56505. import { Effect } from "babylonjs/Materials/effect";
  56506. import { Material } from "babylonjs/Materials/material";
  56507. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  56508. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  56509. import "babylonjs/Shaders/glowMapMerge.fragment";
  56510. import "babylonjs/Shaders/glowMapMerge.vertex";
  56511. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  56512. module "babylonjs/abstractScene" {
  56513. interface AbstractScene {
  56514. /**
  56515. * Return a the first highlight layer of the scene with a given name.
  56516. * @param name The name of the highlight layer to look for.
  56517. * @return The highlight layer if found otherwise null.
  56518. */
  56519. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  56520. }
  56521. }
  56522. /**
  56523. * Highlight layer options. This helps customizing the behaviour
  56524. * of the highlight layer.
  56525. */
  56526. export interface IHighlightLayerOptions {
  56527. /**
  56528. * Multiplication factor apply to the canvas size to compute the render target size
  56529. * used to generated the glowing objects (the smaller the faster).
  56530. */
  56531. mainTextureRatio: number;
  56532. /**
  56533. * Enforces a fixed size texture to ensure resize independant blur.
  56534. */
  56535. mainTextureFixedSize?: number;
  56536. /**
  56537. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  56538. * of the picture to blur (the smaller the faster).
  56539. */
  56540. blurTextureSizeRatio: number;
  56541. /**
  56542. * How big in texel of the blur texture is the vertical blur.
  56543. */
  56544. blurVerticalSize: number;
  56545. /**
  56546. * How big in texel of the blur texture is the horizontal blur.
  56547. */
  56548. blurHorizontalSize: number;
  56549. /**
  56550. * Alpha blending mode used to apply the blur. Default is combine.
  56551. */
  56552. alphaBlendingMode: number;
  56553. /**
  56554. * The camera attached to the layer.
  56555. */
  56556. camera: Nullable<Camera>;
  56557. /**
  56558. * Should we display highlight as a solid stroke?
  56559. */
  56560. isStroke?: boolean;
  56561. /**
  56562. * The rendering group to draw the layer in.
  56563. */
  56564. renderingGroupId: number;
  56565. }
  56566. /**
  56567. * The highlight layer Helps adding a glow effect around a mesh.
  56568. *
  56569. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  56570. * glowy meshes to your scene.
  56571. *
  56572. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  56573. */
  56574. export class HighlightLayer extends EffectLayer {
  56575. name: string;
  56576. /**
  56577. * Effect Name of the highlight layer.
  56578. */
  56579. static readonly EffectName: string;
  56580. /**
  56581. * The neutral color used during the preparation of the glow effect.
  56582. * This is black by default as the blend operation is a blend operation.
  56583. */
  56584. static NeutralColor: Color4;
  56585. /**
  56586. * Stencil value used for glowing meshes.
  56587. */
  56588. static GlowingMeshStencilReference: number;
  56589. /**
  56590. * Stencil value used for the other meshes in the scene.
  56591. */
  56592. static NormalMeshStencilReference: number;
  56593. /**
  56594. * Specifies whether or not the inner glow is ACTIVE in the layer.
  56595. */
  56596. innerGlow: boolean;
  56597. /**
  56598. * Specifies whether or not the outer glow is ACTIVE in the layer.
  56599. */
  56600. outerGlow: boolean;
  56601. /**
  56602. * Specifies the horizontal size of the blur.
  56603. */
  56604. set blurHorizontalSize(value: number);
  56605. /**
  56606. * Specifies the vertical size of the blur.
  56607. */
  56608. set blurVerticalSize(value: number);
  56609. /**
  56610. * Gets the horizontal size of the blur.
  56611. */
  56612. get blurHorizontalSize(): number;
  56613. /**
  56614. * Gets the vertical size of the blur.
  56615. */
  56616. get blurVerticalSize(): number;
  56617. /**
  56618. * An event triggered when the highlight layer is being blurred.
  56619. */
  56620. onBeforeBlurObservable: Observable<HighlightLayer>;
  56621. /**
  56622. * An event triggered when the highlight layer has been blurred.
  56623. */
  56624. onAfterBlurObservable: Observable<HighlightLayer>;
  56625. private _instanceGlowingMeshStencilReference;
  56626. private _options;
  56627. private _downSamplePostprocess;
  56628. private _horizontalBlurPostprocess;
  56629. private _verticalBlurPostprocess;
  56630. private _blurTexture;
  56631. private _meshes;
  56632. private _excludedMeshes;
  56633. /**
  56634. * Instantiates a new highlight Layer and references it to the scene..
  56635. * @param name The name of the layer
  56636. * @param scene The scene to use the layer in
  56637. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  56638. */
  56639. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  56640. /**
  56641. * Get the effect name of the layer.
  56642. * @return The effect name
  56643. */
  56644. getEffectName(): string;
  56645. /**
  56646. * Create the merge effect. This is the shader use to blit the information back
  56647. * to the main canvas at the end of the scene rendering.
  56648. */
  56649. protected _createMergeEffect(): Effect;
  56650. /**
  56651. * Creates the render target textures and post processes used in the highlight layer.
  56652. */
  56653. protected _createTextureAndPostProcesses(): void;
  56654. /**
  56655. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  56656. */
  56657. needStencil(): boolean;
  56658. /**
  56659. * Checks for the readiness of the element composing the layer.
  56660. * @param subMesh the mesh to check for
  56661. * @param useInstances specify wether or not to use instances to render the mesh
  56662. * @param emissiveTexture the associated emissive texture used to generate the glow
  56663. * @return true if ready otherwise, false
  56664. */
  56665. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  56666. /**
  56667. * Implementation specific of rendering the generating effect on the main canvas.
  56668. * @param effect The effect used to render through
  56669. */
  56670. protected _internalRender(effect: Effect): void;
  56671. /**
  56672. * Returns true if the layer contains information to display, otherwise false.
  56673. */
  56674. shouldRender(): boolean;
  56675. /**
  56676. * Returns true if the mesh should render, otherwise false.
  56677. * @param mesh The mesh to render
  56678. * @returns true if it should render otherwise false
  56679. */
  56680. protected _shouldRenderMesh(mesh: Mesh): boolean;
  56681. /**
  56682. * Adds specific effects defines.
  56683. * @param defines The defines to add specifics to.
  56684. */
  56685. protected _addCustomEffectDefines(defines: string[]): void;
  56686. /**
  56687. * Sets the required values for both the emissive texture and and the main color.
  56688. */
  56689. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  56690. /**
  56691. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  56692. * @param mesh The mesh to exclude from the highlight layer
  56693. */
  56694. addExcludedMesh(mesh: Mesh): void;
  56695. /**
  56696. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  56697. * @param mesh The mesh to highlight
  56698. */
  56699. removeExcludedMesh(mesh: Mesh): void;
  56700. /**
  56701. * Determine if a given mesh will be highlighted by the current HighlightLayer
  56702. * @param mesh mesh to test
  56703. * @returns true if the mesh will be highlighted by the current HighlightLayer
  56704. */
  56705. hasMesh(mesh: AbstractMesh): boolean;
  56706. /**
  56707. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  56708. * @param mesh The mesh to highlight
  56709. * @param color The color of the highlight
  56710. * @param glowEmissiveOnly Extract the glow from the emissive texture
  56711. */
  56712. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  56713. /**
  56714. * Remove a mesh from the highlight layer in order to make it stop glowing.
  56715. * @param mesh The mesh to highlight
  56716. */
  56717. removeMesh(mesh: Mesh): void;
  56718. /**
  56719. * Remove all the meshes currently referenced in the highlight layer
  56720. */
  56721. removeAllMeshes(): void;
  56722. /**
  56723. * Force the stencil to the normal expected value for none glowing parts
  56724. */
  56725. private _defaultStencilReference;
  56726. /**
  56727. * Free any resources and references associated to a mesh.
  56728. * Internal use
  56729. * @param mesh The mesh to free.
  56730. * @hidden
  56731. */
  56732. _disposeMesh(mesh: Mesh): void;
  56733. /**
  56734. * Dispose the highlight layer and free resources.
  56735. */
  56736. dispose(): void;
  56737. /**
  56738. * Gets the class name of the effect layer
  56739. * @returns the string with the class name of the effect layer
  56740. */
  56741. getClassName(): string;
  56742. /**
  56743. * Serializes this Highlight layer
  56744. * @returns a serialized Highlight layer object
  56745. */
  56746. serialize(): any;
  56747. /**
  56748. * Creates a Highlight layer from parsed Highlight layer data
  56749. * @param parsedHightlightLayer defines the Highlight layer data
  56750. * @param scene defines the current scene
  56751. * @param rootUrl defines the root URL containing the Highlight layer information
  56752. * @returns a parsed Highlight layer
  56753. */
  56754. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  56755. }
  56756. }
  56757. declare module "babylonjs/Layers/layerSceneComponent" {
  56758. import { Scene } from "babylonjs/scene";
  56759. import { ISceneComponent } from "babylonjs/sceneComponent";
  56760. import { Layer } from "babylonjs/Layers/layer";
  56761. import { AbstractScene } from "babylonjs/abstractScene";
  56762. module "babylonjs/abstractScene" {
  56763. interface AbstractScene {
  56764. /**
  56765. * The list of layers (background and foreground) of the scene
  56766. */
  56767. layers: Array<Layer>;
  56768. }
  56769. }
  56770. /**
  56771. * Defines the layer scene component responsible to manage any layers
  56772. * in a given scene.
  56773. */
  56774. export class LayerSceneComponent implements ISceneComponent {
  56775. /**
  56776. * The component name helpfull to identify the component in the list of scene components.
  56777. */
  56778. readonly name: string;
  56779. /**
  56780. * The scene the component belongs to.
  56781. */
  56782. scene: Scene;
  56783. private _engine;
  56784. /**
  56785. * Creates a new instance of the component for the given scene
  56786. * @param scene Defines the scene to register the component in
  56787. */
  56788. constructor(scene: Scene);
  56789. /**
  56790. * Registers the component in a given scene
  56791. */
  56792. register(): void;
  56793. /**
  56794. * Rebuilds the elements related to this component in case of
  56795. * context lost for instance.
  56796. */
  56797. rebuild(): void;
  56798. /**
  56799. * Disposes the component and the associated ressources.
  56800. */
  56801. dispose(): void;
  56802. private _draw;
  56803. private _drawCameraPredicate;
  56804. private _drawCameraBackground;
  56805. private _drawCameraForeground;
  56806. private _drawRenderTargetPredicate;
  56807. private _drawRenderTargetBackground;
  56808. private _drawRenderTargetForeground;
  56809. /**
  56810. * Adds all the elements from the container to the scene
  56811. * @param container the container holding the elements
  56812. */
  56813. addFromContainer(container: AbstractScene): void;
  56814. /**
  56815. * Removes all the elements in the container from the scene
  56816. * @param container contains the elements to remove
  56817. * @param dispose if the removed element should be disposed (default: false)
  56818. */
  56819. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  56820. }
  56821. }
  56822. declare module "babylonjs/Shaders/layer.fragment" {
  56823. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  56824. /** @hidden */
  56825. export var layerPixelShader: {
  56826. name: string;
  56827. shader: string;
  56828. };
  56829. }
  56830. declare module "babylonjs/Shaders/layer.vertex" {
  56831. /** @hidden */
  56832. export var layerVertexShader: {
  56833. name: string;
  56834. shader: string;
  56835. };
  56836. }
  56837. declare module "babylonjs/Layers/layer" {
  56838. import { Observable } from "babylonjs/Misc/observable";
  56839. import { Nullable } from "babylonjs/types";
  56840. import { Scene } from "babylonjs/scene";
  56841. import { Vector2 } from "babylonjs/Maths/math.vector";
  56842. import { Color4 } from "babylonjs/Maths/math.color";
  56843. import { Texture } from "babylonjs/Materials/Textures/texture";
  56844. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  56845. import "babylonjs/Shaders/layer.fragment";
  56846. import "babylonjs/Shaders/layer.vertex";
  56847. /**
  56848. * This represents a full screen 2d layer.
  56849. * This can be useful to display a picture in the background of your scene for instance.
  56850. * @see https://www.babylonjs-playground.com/#08A2BS#1
  56851. */
  56852. export class Layer {
  56853. /**
  56854. * Define the name of the layer.
  56855. */
  56856. name: string;
  56857. /**
  56858. * Define the texture the layer should display.
  56859. */
  56860. texture: Nullable<Texture>;
  56861. /**
  56862. * Is the layer in background or foreground.
  56863. */
  56864. isBackground: boolean;
  56865. /**
  56866. * Define the color of the layer (instead of texture).
  56867. */
  56868. color: Color4;
  56869. /**
  56870. * Define the scale of the layer in order to zoom in out of the texture.
  56871. */
  56872. scale: Vector2;
  56873. /**
  56874. * Define an offset for the layer in order to shift the texture.
  56875. */
  56876. offset: Vector2;
  56877. /**
  56878. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  56879. */
  56880. alphaBlendingMode: number;
  56881. /**
  56882. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  56883. * Alpha test will not mix with the background color in case of transparency.
  56884. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  56885. */
  56886. alphaTest: boolean;
  56887. /**
  56888. * Define a mask to restrict the layer to only some of the scene cameras.
  56889. */
  56890. layerMask: number;
  56891. /**
  56892. * Define the list of render target the layer is visible into.
  56893. */
  56894. renderTargetTextures: RenderTargetTexture[];
  56895. /**
  56896. * Define if the layer is only used in renderTarget or if it also
  56897. * renders in the main frame buffer of the canvas.
  56898. */
  56899. renderOnlyInRenderTargetTextures: boolean;
  56900. private _scene;
  56901. private _vertexBuffers;
  56902. private _indexBuffer;
  56903. private _effect;
  56904. private _previousDefines;
  56905. /**
  56906. * An event triggered when the layer is disposed.
  56907. */
  56908. onDisposeObservable: Observable<Layer>;
  56909. private _onDisposeObserver;
  56910. /**
  56911. * Back compatibility with callback before the onDisposeObservable existed.
  56912. * The set callback will be triggered when the layer has been disposed.
  56913. */
  56914. set onDispose(callback: () => void);
  56915. /**
  56916. * An event triggered before rendering the scene
  56917. */
  56918. onBeforeRenderObservable: Observable<Layer>;
  56919. private _onBeforeRenderObserver;
  56920. /**
  56921. * Back compatibility with callback before the onBeforeRenderObservable existed.
  56922. * The set callback will be triggered just before rendering the layer.
  56923. */
  56924. set onBeforeRender(callback: () => void);
  56925. /**
  56926. * An event triggered after rendering the scene
  56927. */
  56928. onAfterRenderObservable: Observable<Layer>;
  56929. private _onAfterRenderObserver;
  56930. /**
  56931. * Back compatibility with callback before the onAfterRenderObservable existed.
  56932. * The set callback will be triggered just after rendering the layer.
  56933. */
  56934. set onAfterRender(callback: () => void);
  56935. /**
  56936. * Instantiates a new layer.
  56937. * This represents a full screen 2d layer.
  56938. * This can be useful to display a picture in the background of your scene for instance.
  56939. * @see https://www.babylonjs-playground.com/#08A2BS#1
  56940. * @param name Define the name of the layer in the scene
  56941. * @param imgUrl Define the url of the texture to display in the layer
  56942. * @param scene Define the scene the layer belongs to
  56943. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  56944. * @param color Defines a color for the layer
  56945. */
  56946. constructor(
  56947. /**
  56948. * Define the name of the layer.
  56949. */
  56950. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  56951. private _createIndexBuffer;
  56952. /** @hidden */
  56953. _rebuild(): void;
  56954. /**
  56955. * Renders the layer in the scene.
  56956. */
  56957. render(): void;
  56958. /**
  56959. * Disposes and releases the associated ressources.
  56960. */
  56961. dispose(): void;
  56962. }
  56963. }
  56964. declare module "babylonjs/Layers/index" {
  56965. export * from "babylonjs/Layers/effectLayer";
  56966. export * from "babylonjs/Layers/effectLayerSceneComponent";
  56967. export * from "babylonjs/Layers/glowLayer";
  56968. export * from "babylonjs/Layers/highlightLayer";
  56969. export * from "babylonjs/Layers/layer";
  56970. export * from "babylonjs/Layers/layerSceneComponent";
  56971. }
  56972. declare module "babylonjs/Shaders/lensFlare.fragment" {
  56973. /** @hidden */
  56974. export var lensFlarePixelShader: {
  56975. name: string;
  56976. shader: string;
  56977. };
  56978. }
  56979. declare module "babylonjs/Shaders/lensFlare.vertex" {
  56980. /** @hidden */
  56981. export var lensFlareVertexShader: {
  56982. name: string;
  56983. shader: string;
  56984. };
  56985. }
  56986. declare module "babylonjs/LensFlares/lensFlareSystem" {
  56987. import { Scene } from "babylonjs/scene";
  56988. import { Vector3 } from "babylonjs/Maths/math.vector";
  56989. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56990. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  56991. import "babylonjs/Shaders/lensFlare.fragment";
  56992. import "babylonjs/Shaders/lensFlare.vertex";
  56993. import { Viewport } from "babylonjs/Maths/math.viewport";
  56994. /**
  56995. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  56996. * It is usually composed of several `lensFlare`.
  56997. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  56998. */
  56999. export class LensFlareSystem {
  57000. /**
  57001. * Define the name of the lens flare system
  57002. */
  57003. name: string;
  57004. /**
  57005. * List of lens flares used in this system.
  57006. */
  57007. lensFlares: LensFlare[];
  57008. /**
  57009. * Define a limit from the border the lens flare can be visible.
  57010. */
  57011. borderLimit: number;
  57012. /**
  57013. * Define a viewport border we do not want to see the lens flare in.
  57014. */
  57015. viewportBorder: number;
  57016. /**
  57017. * Define a predicate which could limit the list of meshes able to occlude the effect.
  57018. */
  57019. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  57020. /**
  57021. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  57022. */
  57023. layerMask: number;
  57024. /**
  57025. * Define the id of the lens flare system in the scene.
  57026. * (equal to name by default)
  57027. */
  57028. id: string;
  57029. private _scene;
  57030. private _emitter;
  57031. private _vertexBuffers;
  57032. private _indexBuffer;
  57033. private _effect;
  57034. private _positionX;
  57035. private _positionY;
  57036. private _isEnabled;
  57037. /** @hidden */
  57038. static _SceneComponentInitialization: (scene: Scene) => void;
  57039. /**
  57040. * Instantiates a lens flare system.
  57041. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  57042. * It is usually composed of several `lensFlare`.
  57043. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  57044. * @param name Define the name of the lens flare system in the scene
  57045. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  57046. * @param scene Define the scene the lens flare system belongs to
  57047. */
  57048. constructor(
  57049. /**
  57050. * Define the name of the lens flare system
  57051. */
  57052. name: string, emitter: any, scene: Scene);
  57053. /**
  57054. * Define if the lens flare system is enabled.
  57055. */
  57056. get isEnabled(): boolean;
  57057. set isEnabled(value: boolean);
  57058. /**
  57059. * Get the scene the effects belongs to.
  57060. * @returns the scene holding the lens flare system
  57061. */
  57062. getScene(): Scene;
  57063. /**
  57064. * Get the emitter of the lens flare system.
  57065. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  57066. * @returns the emitter of the lens flare system
  57067. */
  57068. getEmitter(): any;
  57069. /**
  57070. * Set the emitter of the lens flare system.
  57071. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  57072. * @param newEmitter Define the new emitter of the system
  57073. */
  57074. setEmitter(newEmitter: any): void;
  57075. /**
  57076. * Get the lens flare system emitter position.
  57077. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  57078. * @returns the position
  57079. */
  57080. getEmitterPosition(): Vector3;
  57081. /**
  57082. * @hidden
  57083. */
  57084. computeEffectivePosition(globalViewport: Viewport): boolean;
  57085. /** @hidden */
  57086. _isVisible(): boolean;
  57087. /**
  57088. * @hidden
  57089. */
  57090. render(): boolean;
  57091. /**
  57092. * Dispose and release the lens flare with its associated resources.
  57093. */
  57094. dispose(): void;
  57095. /**
  57096. * Parse a lens flare system from a JSON repressentation
  57097. * @param parsedLensFlareSystem Define the JSON to parse
  57098. * @param scene Define the scene the parsed system should be instantiated in
  57099. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  57100. * @returns the parsed system
  57101. */
  57102. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  57103. /**
  57104. * Serialize the current Lens Flare System into a JSON representation.
  57105. * @returns the serialized JSON
  57106. */
  57107. serialize(): any;
  57108. }
  57109. }
  57110. declare module "babylonjs/LensFlares/lensFlare" {
  57111. import { Nullable } from "babylonjs/types";
  57112. import { Color3 } from "babylonjs/Maths/math.color";
  57113. import { Texture } from "babylonjs/Materials/Textures/texture";
  57114. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  57115. /**
  57116. * This represents one of the lens effect in a `lensFlareSystem`.
  57117. * It controls one of the indiviual texture used in the effect.
  57118. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  57119. */
  57120. export class LensFlare {
  57121. /**
  57122. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  57123. */
  57124. size: number;
  57125. /**
  57126. * 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.
  57127. */
  57128. position: number;
  57129. /**
  57130. * Define the lens color.
  57131. */
  57132. color: Color3;
  57133. /**
  57134. * Define the lens texture.
  57135. */
  57136. texture: Nullable<Texture>;
  57137. /**
  57138. * Define the alpha mode to render this particular lens.
  57139. */
  57140. alphaMode: number;
  57141. private _system;
  57142. /**
  57143. * Creates a new Lens Flare.
  57144. * This represents one of the lens effect in a `lensFlareSystem`.
  57145. * It controls one of the indiviual texture used in the effect.
  57146. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  57147. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  57148. * @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.
  57149. * @param color Define the lens color
  57150. * @param imgUrl Define the lens texture url
  57151. * @param system Define the `lensFlareSystem` this flare is part of
  57152. * @returns The newly created Lens Flare
  57153. */
  57154. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  57155. /**
  57156. * Instantiates a new Lens Flare.
  57157. * This represents one of the lens effect in a `lensFlareSystem`.
  57158. * It controls one of the indiviual texture used in the effect.
  57159. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  57160. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  57161. * @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.
  57162. * @param color Define the lens color
  57163. * @param imgUrl Define the lens texture url
  57164. * @param system Define the `lensFlareSystem` this flare is part of
  57165. */
  57166. constructor(
  57167. /**
  57168. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  57169. */
  57170. size: number,
  57171. /**
  57172. * 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.
  57173. */
  57174. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  57175. /**
  57176. * Dispose and release the lens flare with its associated resources.
  57177. */
  57178. dispose(): void;
  57179. }
  57180. }
  57181. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  57182. import { Nullable } from "babylonjs/types";
  57183. import { Scene } from "babylonjs/scene";
  57184. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  57185. import { AbstractScene } from "babylonjs/abstractScene";
  57186. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  57187. module "babylonjs/abstractScene" {
  57188. interface AbstractScene {
  57189. /**
  57190. * The list of lens flare system added to the scene
  57191. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  57192. */
  57193. lensFlareSystems: Array<LensFlareSystem>;
  57194. /**
  57195. * Removes the given lens flare system from this scene.
  57196. * @param toRemove The lens flare system to remove
  57197. * @returns The index of the removed lens flare system
  57198. */
  57199. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  57200. /**
  57201. * Adds the given lens flare system to this scene
  57202. * @param newLensFlareSystem The lens flare system to add
  57203. */
  57204. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  57205. /**
  57206. * Gets a lens flare system using its name
  57207. * @param name defines the name to look for
  57208. * @returns the lens flare system or null if not found
  57209. */
  57210. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  57211. /**
  57212. * Gets a lens flare system using its id
  57213. * @param id defines the id to look for
  57214. * @returns the lens flare system or null if not found
  57215. */
  57216. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  57217. }
  57218. }
  57219. /**
  57220. * Defines the lens flare scene component responsible to manage any lens flares
  57221. * in a given scene.
  57222. */
  57223. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  57224. /**
  57225. * The component name helpfull to identify the component in the list of scene components.
  57226. */
  57227. readonly name: string;
  57228. /**
  57229. * The scene the component belongs to.
  57230. */
  57231. scene: Scene;
  57232. /**
  57233. * Creates a new instance of the component for the given scene
  57234. * @param scene Defines the scene to register the component in
  57235. */
  57236. constructor(scene: Scene);
  57237. /**
  57238. * Registers the component in a given scene
  57239. */
  57240. register(): void;
  57241. /**
  57242. * Rebuilds the elements related to this component in case of
  57243. * context lost for instance.
  57244. */
  57245. rebuild(): void;
  57246. /**
  57247. * Adds all the elements from the container to the scene
  57248. * @param container the container holding the elements
  57249. */
  57250. addFromContainer(container: AbstractScene): void;
  57251. /**
  57252. * Removes all the elements in the container from the scene
  57253. * @param container contains the elements to remove
  57254. * @param dispose if the removed element should be disposed (default: false)
  57255. */
  57256. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  57257. /**
  57258. * Serializes the component data to the specified json object
  57259. * @param serializationObject The object to serialize to
  57260. */
  57261. serialize(serializationObject: any): void;
  57262. /**
  57263. * Disposes the component and the associated ressources.
  57264. */
  57265. dispose(): void;
  57266. private _draw;
  57267. }
  57268. }
  57269. declare module "babylonjs/LensFlares/index" {
  57270. export * from "babylonjs/LensFlares/lensFlare";
  57271. export * from "babylonjs/LensFlares/lensFlareSystem";
  57272. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  57273. }
  57274. declare module "babylonjs/Shaders/depth.fragment" {
  57275. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  57276. /** @hidden */
  57277. export var depthPixelShader: {
  57278. name: string;
  57279. shader: string;
  57280. };
  57281. }
  57282. declare module "babylonjs/Shaders/depth.vertex" {
  57283. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  57284. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  57285. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  57286. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  57287. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  57288. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  57289. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  57290. /** @hidden */
  57291. export var depthVertexShader: {
  57292. name: string;
  57293. shader: string;
  57294. };
  57295. }
  57296. declare module "babylonjs/Rendering/depthRenderer" {
  57297. import { Nullable } from "babylonjs/types";
  57298. import { SubMesh } from "babylonjs/Meshes/subMesh";
  57299. import { Scene } from "babylonjs/scene";
  57300. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  57301. import { Camera } from "babylonjs/Cameras/camera";
  57302. import "babylonjs/Shaders/depth.fragment";
  57303. import "babylonjs/Shaders/depth.vertex";
  57304. /**
  57305. * This represents a depth renderer in Babylon.
  57306. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  57307. */
  57308. export class DepthRenderer {
  57309. private _scene;
  57310. private _depthMap;
  57311. private _effect;
  57312. private readonly _storeNonLinearDepth;
  57313. private readonly _clearColor;
  57314. /** Get if the depth renderer is using packed depth or not */
  57315. readonly isPacked: boolean;
  57316. private _cachedDefines;
  57317. private _camera;
  57318. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  57319. enabled: boolean;
  57320. /**
  57321. * Specifiess that the depth renderer will only be used within
  57322. * the camera it is created for.
  57323. * This can help forcing its rendering during the camera processing.
  57324. */
  57325. useOnlyInActiveCamera: boolean;
  57326. /** @hidden */
  57327. static _SceneComponentInitialization: (scene: Scene) => void;
  57328. /**
  57329. * Instantiates a depth renderer
  57330. * @param scene The scene the renderer belongs to
  57331. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  57332. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  57333. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  57334. */
  57335. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  57336. /**
  57337. * Creates the depth rendering effect and checks if the effect is ready.
  57338. * @param subMesh The submesh to be used to render the depth map of
  57339. * @param useInstances If multiple world instances should be used
  57340. * @returns if the depth renderer is ready to render the depth map
  57341. */
  57342. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  57343. /**
  57344. * Gets the texture which the depth map will be written to.
  57345. * @returns The depth map texture
  57346. */
  57347. getDepthMap(): RenderTargetTexture;
  57348. /**
  57349. * Disposes of the depth renderer.
  57350. */
  57351. dispose(): void;
  57352. }
  57353. }
  57354. declare module "babylonjs/Shaders/minmaxRedux.fragment" {
  57355. /** @hidden */
  57356. export var minmaxReduxPixelShader: {
  57357. name: string;
  57358. shader: string;
  57359. };
  57360. }
  57361. declare module "babylonjs/Misc/minMaxReducer" {
  57362. import { Nullable } from "babylonjs/types";
  57363. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  57364. import { Camera } from "babylonjs/Cameras/camera";
  57365. import { Observer } from "babylonjs/Misc/observable";
  57366. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  57367. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  57368. import { Observable } from "babylonjs/Misc/observable";
  57369. import "babylonjs/Shaders/minmaxRedux.fragment";
  57370. /**
  57371. * This class computes a min/max reduction from a texture: it means it computes the minimum
  57372. * and maximum values from all values of the texture.
  57373. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  57374. * The source values are read from the red channel of the texture.
  57375. */
  57376. export class MinMaxReducer {
  57377. /**
  57378. * Observable triggered when the computation has been performed
  57379. */
  57380. onAfterReductionPerformed: Observable<{
  57381. min: number;
  57382. max: number;
  57383. }>;
  57384. protected _camera: Camera;
  57385. protected _sourceTexture: Nullable<RenderTargetTexture>;
  57386. protected _reductionSteps: Nullable<Array<PostProcess>>;
  57387. protected _postProcessManager: PostProcessManager;
  57388. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  57389. protected _forceFullscreenViewport: boolean;
  57390. /**
  57391. * Creates a min/max reducer
  57392. * @param camera The camera to use for the post processes
  57393. */
  57394. constructor(camera: Camera);
  57395. /**
  57396. * Gets the texture used to read the values from.
  57397. */
  57398. get sourceTexture(): Nullable<RenderTargetTexture>;
  57399. /**
  57400. * Sets the source texture to read the values from.
  57401. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  57402. * because in such textures '1' value must not be taken into account to compute the maximum
  57403. * as this value is used to clear the texture.
  57404. * Note that the computation is not activated by calling this function, you must call activate() for that!
  57405. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  57406. * @param depthRedux Indicates if the texture is a depth texture or not
  57407. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  57408. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  57409. */
  57410. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  57411. /**
  57412. * Defines the refresh rate of the computation.
  57413. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  57414. */
  57415. get refreshRate(): number;
  57416. set refreshRate(value: number);
  57417. protected _activated: boolean;
  57418. /**
  57419. * Gets the activation status of the reducer
  57420. */
  57421. get activated(): boolean;
  57422. /**
  57423. * Activates the reduction computation.
  57424. * When activated, the observers registered in onAfterReductionPerformed are
  57425. * called after the compuation is performed
  57426. */
  57427. activate(): void;
  57428. /**
  57429. * Deactivates the reduction computation.
  57430. */
  57431. deactivate(): void;
  57432. /**
  57433. * Disposes the min/max reducer
  57434. * @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.
  57435. */
  57436. dispose(disposeAll?: boolean): void;
  57437. }
  57438. }
  57439. declare module "babylonjs/Misc/depthReducer" {
  57440. import { Nullable } from "babylonjs/types";
  57441. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  57442. import { Camera } from "babylonjs/Cameras/camera";
  57443. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  57444. import { MinMaxReducer } from "babylonjs/Misc/minMaxReducer";
  57445. /**
  57446. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  57447. */
  57448. export class DepthReducer extends MinMaxReducer {
  57449. private _depthRenderer;
  57450. private _depthRendererId;
  57451. /**
  57452. * Gets the depth renderer used for the computation.
  57453. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  57454. */
  57455. get depthRenderer(): Nullable<DepthRenderer>;
  57456. /**
  57457. * Creates a depth reducer
  57458. * @param camera The camera used to render the depth texture
  57459. */
  57460. constructor(camera: Camera);
  57461. /**
  57462. * Sets the depth renderer to use to generate the depth map
  57463. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  57464. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  57465. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  57466. */
  57467. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  57468. /** @hidden */
  57469. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  57470. /**
  57471. * Activates the reduction computation.
  57472. * When activated, the observers registered in onAfterReductionPerformed are
  57473. * called after the compuation is performed
  57474. */
  57475. activate(): void;
  57476. /**
  57477. * Deactivates the reduction computation.
  57478. */
  57479. deactivate(): void;
  57480. /**
  57481. * Disposes the depth reducer
  57482. * @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.
  57483. */
  57484. dispose(disposeAll?: boolean): void;
  57485. }
  57486. }
  57487. declare module "babylonjs/Lights/Shadows/cascadedShadowGenerator" {
  57488. import { Nullable } from "babylonjs/types";
  57489. import { Scene } from "babylonjs/scene";
  57490. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  57491. import { SubMesh } from "babylonjs/Meshes/subMesh";
  57492. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57493. import { Effect } from "babylonjs/Materials/effect";
  57494. import "babylonjs/Shaders/shadowMap.fragment";
  57495. import "babylonjs/Shaders/shadowMap.vertex";
  57496. import "babylonjs/Shaders/depthBoxBlur.fragment";
  57497. import { ShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  57498. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  57499. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  57500. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  57501. /**
  57502. * A CSM implementation allowing casting shadows on large scenes.
  57503. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  57504. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  57505. */
  57506. export class CascadedShadowGenerator extends ShadowGenerator {
  57507. private static readonly frustumCornersNDCSpace;
  57508. /**
  57509. * Name of the CSM class
  57510. */
  57511. static CLASSNAME: string;
  57512. /**
  57513. * Defines the default number of cascades used by the CSM.
  57514. */
  57515. static readonly DEFAULT_CASCADES_COUNT: number;
  57516. /**
  57517. * Defines the minimum number of cascades used by the CSM.
  57518. */
  57519. static readonly MIN_CASCADES_COUNT: number;
  57520. /**
  57521. * Defines the maximum number of cascades used by the CSM.
  57522. */
  57523. static readonly MAX_CASCADES_COUNT: number;
  57524. protected _validateFilter(filter: number): number;
  57525. /**
  57526. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  57527. */
  57528. penumbraDarkness: number;
  57529. private _numCascades;
  57530. /**
  57531. * Gets or set the number of cascades used by the CSM.
  57532. */
  57533. get numCascades(): number;
  57534. set numCascades(value: number);
  57535. /**
  57536. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  57537. * The trade off is that you lose some precision in the shadow rendering when enabling this setting.
  57538. */
  57539. stabilizeCascades: boolean;
  57540. private _freezeShadowCastersBoundingInfo;
  57541. private _freezeShadowCastersBoundingInfoObservable;
  57542. /**
  57543. * Enables or disables the shadow casters bounding info computation.
  57544. * If your shadow casters don't move, you can disable this feature.
  57545. * If it is enabled, the bounding box computation is done every frame.
  57546. */
  57547. get freezeShadowCastersBoundingInfo(): boolean;
  57548. set freezeShadowCastersBoundingInfo(freeze: boolean);
  57549. private _scbiMin;
  57550. private _scbiMax;
  57551. protected _computeShadowCastersBoundingInfo(): void;
  57552. protected _shadowCastersBoundingInfo: BoundingInfo;
  57553. /**
  57554. * Gets or sets the shadow casters bounding info.
  57555. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  57556. * so that the system won't overwrite the bounds you provide
  57557. */
  57558. get shadowCastersBoundingInfo(): BoundingInfo;
  57559. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  57560. protected _breaksAreDirty: boolean;
  57561. protected _minDistance: number;
  57562. protected _maxDistance: number;
  57563. /**
  57564. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  57565. *
  57566. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  57567. * If you don't know these values, simply leave them to their defaults and don't call this function.
  57568. * @param min minimal distance for the breaks (default to 0.)
  57569. * @param max maximal distance for the breaks (default to 1.)
  57570. */
  57571. setMinMaxDistance(min: number, max: number): void;
  57572. /** Gets the minimal distance used in the cascade break computation */
  57573. get minDistance(): number;
  57574. /** Gets the maximal distance used in the cascade break computation */
  57575. get maxDistance(): number;
  57576. /**
  57577. * Gets the class name of that object
  57578. * @returns "CascadedShadowGenerator"
  57579. */
  57580. getClassName(): string;
  57581. private _cascadeMinExtents;
  57582. private _cascadeMaxExtents;
  57583. /**
  57584. * Gets a cascade minimum extents
  57585. * @param cascadeIndex index of the cascade
  57586. * @returns the minimum cascade extents
  57587. */
  57588. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  57589. /**
  57590. * Gets a cascade maximum extents
  57591. * @param cascadeIndex index of the cascade
  57592. * @returns the maximum cascade extents
  57593. */
  57594. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  57595. private _cascades;
  57596. private _currentLayer;
  57597. private _viewSpaceFrustumsZ;
  57598. private _viewMatrices;
  57599. private _projectionMatrices;
  57600. private _transformMatrices;
  57601. private _transformMatricesAsArray;
  57602. private _frustumLengths;
  57603. private _lightSizeUVCorrection;
  57604. private _depthCorrection;
  57605. private _frustumCornersWorldSpace;
  57606. private _frustumCenter;
  57607. private _shadowCameraPos;
  57608. private _shadowMaxZ;
  57609. /**
  57610. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  57611. * It defaults to camera.maxZ
  57612. */
  57613. get shadowMaxZ(): number;
  57614. /**
  57615. * Sets the shadow max z distance.
  57616. */
  57617. set shadowMaxZ(value: number);
  57618. protected _debug: boolean;
  57619. /**
  57620. * Gets or sets the debug flag.
  57621. * When enabled, the cascades are materialized by different colors on the screen.
  57622. */
  57623. get debug(): boolean;
  57624. set debug(dbg: boolean);
  57625. private _depthClamp;
  57626. /**
  57627. * Gets or sets the depth clamping value.
  57628. *
  57629. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  57630. * to account for the shadow casters far away.
  57631. *
  57632. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  57633. */
  57634. get depthClamp(): boolean;
  57635. set depthClamp(value: boolean);
  57636. private _cascadeBlendPercentage;
  57637. /**
  57638. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  57639. * It defaults to 0.1 (10% blending).
  57640. */
  57641. get cascadeBlendPercentage(): number;
  57642. set cascadeBlendPercentage(value: number);
  57643. private _lambda;
  57644. /**
  57645. * Gets or set the lambda parameter.
  57646. * This parameter is used to split the camera frustum and create the cascades.
  57647. * 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.
  57648. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  57649. */
  57650. get lambda(): number;
  57651. set lambda(value: number);
  57652. /**
  57653. * Gets the view matrix corresponding to a given cascade
  57654. * @param cascadeNum cascade to retrieve the view matrix from
  57655. * @returns the cascade view matrix
  57656. */
  57657. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  57658. /**
  57659. * Gets the projection matrix corresponding to a given cascade
  57660. * @param cascadeNum cascade to retrieve the projection matrix from
  57661. * @returns the cascade projection matrix
  57662. */
  57663. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  57664. /**
  57665. * Gets the transformation matrix corresponding to a given cascade
  57666. * @param cascadeNum cascade to retrieve the transformation matrix from
  57667. * @returns the cascade transformation matrix
  57668. */
  57669. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  57670. private _depthRenderer;
  57671. /**
  57672. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  57673. *
  57674. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  57675. *
  57676. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  57677. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  57678. * @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
  57679. */
  57680. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  57681. private _depthReducer;
  57682. private _autoCalcDepthBounds;
  57683. /**
  57684. * Gets or sets the autoCalcDepthBounds property.
  57685. *
  57686. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  57687. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  57688. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  57689. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  57690. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  57691. */
  57692. get autoCalcDepthBounds(): boolean;
  57693. set autoCalcDepthBounds(value: boolean);
  57694. /**
  57695. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  57696. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  57697. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  57698. * for setting the refresh rate on the renderer yourself!
  57699. */
  57700. get autoCalcDepthBoundsRefreshRate(): number;
  57701. set autoCalcDepthBoundsRefreshRate(value: number);
  57702. /**
  57703. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  57704. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  57705. * you change the camera near/far planes!
  57706. */
  57707. splitFrustum(): void;
  57708. private _splitFrustum;
  57709. private _computeMatrices;
  57710. private _computeFrustumInWorldSpace;
  57711. private _computeCascadeFrustum;
  57712. /**
  57713. * Support test.
  57714. */
  57715. static get IsSupported(): boolean;
  57716. /** @hidden */
  57717. static _SceneComponentInitialization: (scene: Scene) => void;
  57718. /**
  57719. * Creates a Cascaded Shadow Generator object.
  57720. * A ShadowGenerator is the required tool to use the shadows.
  57721. * Each directional light casting shadows needs to use its own ShadowGenerator.
  57722. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  57723. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  57724. * @param light The directional light object generating the shadows.
  57725. * @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.
  57726. */
  57727. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  57728. protected _initializeGenerator(): void;
  57729. protected _createTargetRenderTexture(): void;
  57730. protected _initializeShadowMap(): void;
  57731. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  57732. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  57733. /**
  57734. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  57735. * @param defines Defines of the material we want to update
  57736. * @param lightIndex Index of the light in the enabled light list of the material
  57737. */
  57738. prepareDefines(defines: any, lightIndex: number): void;
  57739. /**
  57740. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  57741. * defined in the generator but impacting the effect).
  57742. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  57743. * @param effect The effect we are binfing the information for
  57744. */
  57745. bindShadowLight(lightIndex: string, effect: Effect): void;
  57746. /**
  57747. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  57748. * (eq to view projection * shadow projection matrices)
  57749. * @returns The transform matrix used to create the shadow map
  57750. */
  57751. getTransformMatrix(): Matrix;
  57752. /**
  57753. * Disposes the ShadowGenerator.
  57754. * Returns nothing.
  57755. */
  57756. dispose(): void;
  57757. /**
  57758. * Serializes the shadow generator setup to a json object.
  57759. * @returns The serialized JSON object
  57760. */
  57761. serialize(): any;
  57762. /**
  57763. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  57764. * @param parsedShadowGenerator The JSON object to parse
  57765. * @param scene The scene to create the shadow map for
  57766. * @returns The parsed shadow generator
  57767. */
  57768. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  57769. }
  57770. }
  57771. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  57772. import { Scene } from "babylonjs/scene";
  57773. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  57774. import { AbstractScene } from "babylonjs/abstractScene";
  57775. /**
  57776. * Defines the shadow generator component responsible to manage any shadow generators
  57777. * in a given scene.
  57778. */
  57779. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  57780. /**
  57781. * The component name helpfull to identify the component in the list of scene components.
  57782. */
  57783. readonly name: string;
  57784. /**
  57785. * The scene the component belongs to.
  57786. */
  57787. scene: Scene;
  57788. /**
  57789. * Creates a new instance of the component for the given scene
  57790. * @param scene Defines the scene to register the component in
  57791. */
  57792. constructor(scene: Scene);
  57793. /**
  57794. * Registers the component in a given scene
  57795. */
  57796. register(): void;
  57797. /**
  57798. * Rebuilds the elements related to this component in case of
  57799. * context lost for instance.
  57800. */
  57801. rebuild(): void;
  57802. /**
  57803. * Serializes the component data to the specified json object
  57804. * @param serializationObject The object to serialize to
  57805. */
  57806. serialize(serializationObject: any): void;
  57807. /**
  57808. * Adds all the elements from the container to the scene
  57809. * @param container the container holding the elements
  57810. */
  57811. addFromContainer(container: AbstractScene): void;
  57812. /**
  57813. * Removes all the elements in the container from the scene
  57814. * @param container contains the elements to remove
  57815. * @param dispose if the removed element should be disposed (default: false)
  57816. */
  57817. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  57818. /**
  57819. * Rebuilds the elements related to this component in case of
  57820. * context lost for instance.
  57821. */
  57822. dispose(): void;
  57823. private _gatherRenderTargets;
  57824. }
  57825. }
  57826. declare module "babylonjs/Lights/Shadows/index" {
  57827. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  57828. export * from "babylonjs/Lights/Shadows/cascadedShadowGenerator";
  57829. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  57830. }
  57831. declare module "babylonjs/Lights/pointLight" {
  57832. import { Scene } from "babylonjs/scene";
  57833. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  57834. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57835. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  57836. import { Effect } from "babylonjs/Materials/effect";
  57837. /**
  57838. * A point light is a light defined by an unique point in world space.
  57839. * The light is emitted in every direction from this point.
  57840. * A good example of a point light is a standard light bulb.
  57841. * Documentation: https://doc.babylonjs.com/babylon101/lights
  57842. */
  57843. export class PointLight extends ShadowLight {
  57844. private _shadowAngle;
  57845. /**
  57846. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  57847. * This specifies what angle the shadow will use to be created.
  57848. *
  57849. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  57850. */
  57851. get shadowAngle(): number;
  57852. /**
  57853. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  57854. * This specifies what angle the shadow will use to be created.
  57855. *
  57856. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  57857. */
  57858. set shadowAngle(value: number);
  57859. /**
  57860. * Gets the direction if it has been set.
  57861. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  57862. */
  57863. get direction(): Vector3;
  57864. /**
  57865. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  57866. */
  57867. set direction(value: Vector3);
  57868. /**
  57869. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  57870. * A PointLight emits the light in every direction.
  57871. * It can cast shadows.
  57872. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  57873. * ```javascript
  57874. * var pointLight = new PointLight("pl", camera.position, scene);
  57875. * ```
  57876. * Documentation : https://doc.babylonjs.com/babylon101/lights
  57877. * @param name The light friendly name
  57878. * @param position The position of the point light in the scene
  57879. * @param scene The scene the lights belongs to
  57880. */
  57881. constructor(name: string, position: Vector3, scene: Scene);
  57882. /**
  57883. * Returns the string "PointLight"
  57884. * @returns the class name
  57885. */
  57886. getClassName(): string;
  57887. /**
  57888. * Returns the integer 0.
  57889. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  57890. */
  57891. getTypeID(): number;
  57892. /**
  57893. * Specifies wether or not the shadowmap should be a cube texture.
  57894. * @returns true if the shadowmap needs to be a cube texture.
  57895. */
  57896. needCube(): boolean;
  57897. /**
  57898. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  57899. * @param faceIndex The index of the face we are computed the direction to generate shadow
  57900. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  57901. */
  57902. getShadowDirection(faceIndex?: number): Vector3;
  57903. /**
  57904. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  57905. * - fov = PI / 2
  57906. * - aspect ratio : 1.0
  57907. * - z-near and far equal to the active camera minZ and maxZ.
  57908. * Returns the PointLight.
  57909. */
  57910. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  57911. protected _buildUniformLayout(): void;
  57912. /**
  57913. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  57914. * @param effect The effect to update
  57915. * @param lightIndex The index of the light in the effect to update
  57916. * @returns The point light
  57917. */
  57918. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  57919. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  57920. /**
  57921. * Prepares the list of defines specific to the light type.
  57922. * @param defines the list of defines
  57923. * @param lightIndex defines the index of the light for the effect
  57924. */
  57925. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  57926. }
  57927. }
  57928. declare module "babylonjs/Lights/index" {
  57929. export * from "babylonjs/Lights/light";
  57930. export * from "babylonjs/Lights/shadowLight";
  57931. export * from "babylonjs/Lights/Shadows/index";
  57932. export * from "babylonjs/Lights/directionalLight";
  57933. export * from "babylonjs/Lights/hemisphericLight";
  57934. export * from "babylonjs/Lights/pointLight";
  57935. export * from "babylonjs/Lights/spotLight";
  57936. }
  57937. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  57938. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  57939. /**
  57940. * Header information of HDR texture files.
  57941. */
  57942. export interface HDRInfo {
  57943. /**
  57944. * The height of the texture in pixels.
  57945. */
  57946. height: number;
  57947. /**
  57948. * The width of the texture in pixels.
  57949. */
  57950. width: number;
  57951. /**
  57952. * The index of the beginning of the data in the binary file.
  57953. */
  57954. dataPosition: number;
  57955. }
  57956. /**
  57957. * This groups tools to convert HDR texture to native colors array.
  57958. */
  57959. export class HDRTools {
  57960. private static Ldexp;
  57961. private static Rgbe2float;
  57962. private static readStringLine;
  57963. /**
  57964. * Reads header information from an RGBE texture stored in a native array.
  57965. * More information on this format are available here:
  57966. * https://en.wikipedia.org/wiki/RGBE_image_format
  57967. *
  57968. * @param uint8array The binary file stored in native array.
  57969. * @return The header information.
  57970. */
  57971. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  57972. /**
  57973. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  57974. * This RGBE texture needs to store the information as a panorama.
  57975. *
  57976. * More information on this format are available here:
  57977. * https://en.wikipedia.org/wiki/RGBE_image_format
  57978. *
  57979. * @param buffer The binary file stored in an array buffer.
  57980. * @param size The expected size of the extracted cubemap.
  57981. * @return The Cube Map information.
  57982. */
  57983. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  57984. /**
  57985. * Returns the pixels data extracted from an RGBE texture.
  57986. * This pixels will be stored left to right up to down in the R G B order in one array.
  57987. *
  57988. * More information on this format are available here:
  57989. * https://en.wikipedia.org/wiki/RGBE_image_format
  57990. *
  57991. * @param uint8array The binary file stored in an array buffer.
  57992. * @param hdrInfo The header information of the file.
  57993. * @return The pixels data in RGB right to left up to down order.
  57994. */
  57995. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  57996. private static RGBE_ReadPixels_RLE;
  57997. }
  57998. }
  57999. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  58000. import { Nullable } from "babylonjs/types";
  58001. import { Scene } from "babylonjs/scene";
  58002. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  58003. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58004. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  58005. import "babylonjs/Engines/Extensions/engine.rawTexture";
  58006. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  58007. /**
  58008. * This represents a texture coming from an HDR input.
  58009. *
  58010. * The only supported format is currently panorama picture stored in RGBE format.
  58011. * Example of such files can be found on HDRLib: http://hdrlib.com/
  58012. */
  58013. export class HDRCubeTexture extends BaseTexture {
  58014. private static _facesMapping;
  58015. private _generateHarmonics;
  58016. private _noMipmap;
  58017. private _textureMatrix;
  58018. private _size;
  58019. private _onLoad;
  58020. private _onError;
  58021. /**
  58022. * The texture URL.
  58023. */
  58024. url: string;
  58025. /**
  58026. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  58027. */
  58028. coordinatesMode: number;
  58029. protected _isBlocking: boolean;
  58030. /**
  58031. * Sets wether or not the texture is blocking during loading.
  58032. */
  58033. set isBlocking(value: boolean);
  58034. /**
  58035. * Gets wether or not the texture is blocking during loading.
  58036. */
  58037. get isBlocking(): boolean;
  58038. protected _rotationY: number;
  58039. /**
  58040. * Sets texture matrix rotation angle around Y axis in radians.
  58041. */
  58042. set rotationY(value: number);
  58043. /**
  58044. * Gets texture matrix rotation angle around Y axis radians.
  58045. */
  58046. get rotationY(): number;
  58047. /**
  58048. * Gets or sets the center of the bounding box associated with the cube texture
  58049. * It must define where the camera used to render the texture was set
  58050. */
  58051. boundingBoxPosition: Vector3;
  58052. private _boundingBoxSize;
  58053. /**
  58054. * Gets or sets the size of the bounding box associated with the cube texture
  58055. * When defined, the cubemap will switch to local mode
  58056. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  58057. * @example https://www.babylonjs-playground.com/#RNASML
  58058. */
  58059. set boundingBoxSize(value: Vector3);
  58060. get boundingBoxSize(): Vector3;
  58061. /**
  58062. * Instantiates an HDRTexture from the following parameters.
  58063. *
  58064. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  58065. * @param sceneOrEngine The scene or engine the texture will be used in
  58066. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  58067. * @param noMipmap Forces to not generate the mipmap if true
  58068. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  58069. * @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)
  58070. * @param reserved Reserved flag for internal use.
  58071. */
  58072. constructor(url: string, sceneOrEngine: Scene | ThinEngine, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  58073. /**
  58074. * Get the current class name of the texture useful for serialization or dynamic coding.
  58075. * @returns "HDRCubeTexture"
  58076. */
  58077. getClassName(): string;
  58078. /**
  58079. * Occurs when the file is raw .hdr file.
  58080. */
  58081. private loadTexture;
  58082. clone(): HDRCubeTexture;
  58083. delayLoad(): void;
  58084. /**
  58085. * Get the texture reflection matrix used to rotate/transform the reflection.
  58086. * @returns the reflection matrix
  58087. */
  58088. getReflectionTextureMatrix(): Matrix;
  58089. /**
  58090. * Set the texture reflection matrix used to rotate/transform the reflection.
  58091. * @param value Define the reflection matrix to set
  58092. */
  58093. setReflectionTextureMatrix(value: Matrix): void;
  58094. /**
  58095. * Parses a JSON representation of an HDR Texture in order to create the texture
  58096. * @param parsedTexture Define the JSON representation
  58097. * @param scene Define the scene the texture should be created in
  58098. * @param rootUrl Define the root url in case we need to load relative dependencies
  58099. * @returns the newly created texture after parsing
  58100. */
  58101. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  58102. serialize(): any;
  58103. }
  58104. }
  58105. declare module "babylonjs/Physics/physicsEngine" {
  58106. import { Nullable } from "babylonjs/types";
  58107. import { Vector3 } from "babylonjs/Maths/math.vector";
  58108. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  58109. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  58110. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  58111. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  58112. /**
  58113. * Class used to control physics engine
  58114. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  58115. */
  58116. export class PhysicsEngine implements IPhysicsEngine {
  58117. private _physicsPlugin;
  58118. /**
  58119. * Global value used to control the smallest number supported by the simulation
  58120. */
  58121. static Epsilon: number;
  58122. private _impostors;
  58123. private _joints;
  58124. private _subTimeStep;
  58125. /**
  58126. * Gets the gravity vector used by the simulation
  58127. */
  58128. gravity: Vector3;
  58129. /**
  58130. * Factory used to create the default physics plugin.
  58131. * @returns The default physics plugin
  58132. */
  58133. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  58134. /**
  58135. * Creates a new Physics Engine
  58136. * @param gravity defines the gravity vector used by the simulation
  58137. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  58138. */
  58139. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  58140. /**
  58141. * Sets the gravity vector used by the simulation
  58142. * @param gravity defines the gravity vector to use
  58143. */
  58144. setGravity(gravity: Vector3): void;
  58145. /**
  58146. * Set the time step of the physics engine.
  58147. * Default is 1/60.
  58148. * To slow it down, enter 1/600 for example.
  58149. * To speed it up, 1/30
  58150. * @param newTimeStep defines the new timestep to apply to this world.
  58151. */
  58152. setTimeStep(newTimeStep?: number): void;
  58153. /**
  58154. * Get the time step of the physics engine.
  58155. * @returns the current time step
  58156. */
  58157. getTimeStep(): number;
  58158. /**
  58159. * Set the sub time step of the physics engine.
  58160. * Default is 0 meaning there is no sub steps
  58161. * To increase physics resolution precision, set a small value (like 1 ms)
  58162. * @param subTimeStep defines the new sub timestep used for physics resolution.
  58163. */
  58164. setSubTimeStep(subTimeStep?: number): void;
  58165. /**
  58166. * Get the sub time step of the physics engine.
  58167. * @returns the current sub time step
  58168. */
  58169. getSubTimeStep(): number;
  58170. /**
  58171. * Release all resources
  58172. */
  58173. dispose(): void;
  58174. /**
  58175. * Gets the name of the current physics plugin
  58176. * @returns the name of the plugin
  58177. */
  58178. getPhysicsPluginName(): string;
  58179. /**
  58180. * Adding a new impostor for the impostor tracking.
  58181. * This will be done by the impostor itself.
  58182. * @param impostor the impostor to add
  58183. */
  58184. addImpostor(impostor: PhysicsImpostor): void;
  58185. /**
  58186. * Remove an impostor from the engine.
  58187. * This impostor and its mesh will not longer be updated by the physics engine.
  58188. * @param impostor the impostor to remove
  58189. */
  58190. removeImpostor(impostor: PhysicsImpostor): void;
  58191. /**
  58192. * Add a joint to the physics engine
  58193. * @param mainImpostor defines the main impostor to which the joint is added.
  58194. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  58195. * @param joint defines the joint that will connect both impostors.
  58196. */
  58197. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  58198. /**
  58199. * Removes a joint from the simulation
  58200. * @param mainImpostor defines the impostor used with the joint
  58201. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  58202. * @param joint defines the joint to remove
  58203. */
  58204. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  58205. /**
  58206. * Called by the scene. No need to call it.
  58207. * @param delta defines the timespam between frames
  58208. */
  58209. _step(delta: number): void;
  58210. /**
  58211. * Gets the current plugin used to run the simulation
  58212. * @returns current plugin
  58213. */
  58214. getPhysicsPlugin(): IPhysicsEnginePlugin;
  58215. /**
  58216. * Gets the list of physic impostors
  58217. * @returns an array of PhysicsImpostor
  58218. */
  58219. getImpostors(): Array<PhysicsImpostor>;
  58220. /**
  58221. * Gets the impostor for a physics enabled object
  58222. * @param object defines the object impersonated by the impostor
  58223. * @returns the PhysicsImpostor or null if not found
  58224. */
  58225. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  58226. /**
  58227. * Gets the impostor for a physics body object
  58228. * @param body defines physics body used by the impostor
  58229. * @returns the PhysicsImpostor or null if not found
  58230. */
  58231. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  58232. /**
  58233. * Does a raycast in the physics world
  58234. * @param from when should the ray start?
  58235. * @param to when should the ray end?
  58236. * @returns PhysicsRaycastResult
  58237. */
  58238. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  58239. }
  58240. }
  58241. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  58242. import { Nullable } from "babylonjs/types";
  58243. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  58244. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58245. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  58246. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  58247. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  58248. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  58249. /** @hidden */
  58250. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  58251. private _useDeltaForWorldStep;
  58252. world: any;
  58253. name: string;
  58254. private _physicsMaterials;
  58255. private _fixedTimeStep;
  58256. private _cannonRaycastResult;
  58257. private _raycastResult;
  58258. private _physicsBodysToRemoveAfterStep;
  58259. BJSCANNON: any;
  58260. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  58261. setGravity(gravity: Vector3): void;
  58262. setTimeStep(timeStep: number): void;
  58263. getTimeStep(): number;
  58264. executeStep(delta: number): void;
  58265. private _removeMarkedPhysicsBodiesFromWorld;
  58266. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  58267. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  58268. generatePhysicsBody(impostor: PhysicsImpostor): void;
  58269. private _processChildMeshes;
  58270. removePhysicsBody(impostor: PhysicsImpostor): void;
  58271. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  58272. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  58273. private _addMaterial;
  58274. private _checkWithEpsilon;
  58275. private _createShape;
  58276. private _createHeightmap;
  58277. private _minus90X;
  58278. private _plus90X;
  58279. private _tmpPosition;
  58280. private _tmpDeltaPosition;
  58281. private _tmpUnityRotation;
  58282. private _updatePhysicsBodyTransformation;
  58283. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  58284. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  58285. isSupported(): boolean;
  58286. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  58287. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  58288. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  58289. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  58290. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  58291. getBodyMass(impostor: PhysicsImpostor): number;
  58292. getBodyFriction(impostor: PhysicsImpostor): number;
  58293. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  58294. getBodyRestitution(impostor: PhysicsImpostor): number;
  58295. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  58296. sleepBody(impostor: PhysicsImpostor): void;
  58297. wakeUpBody(impostor: PhysicsImpostor): void;
  58298. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  58299. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  58300. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  58301. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  58302. getRadius(impostor: PhysicsImpostor): number;
  58303. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  58304. dispose(): void;
  58305. private _extendNamespace;
  58306. /**
  58307. * Does a raycast in the physics world
  58308. * @param from when should the ray start?
  58309. * @param to when should the ray end?
  58310. * @returns PhysicsRaycastResult
  58311. */
  58312. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  58313. }
  58314. }
  58315. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  58316. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  58317. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  58318. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  58319. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58320. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  58321. import { Nullable } from "babylonjs/types";
  58322. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  58323. /** @hidden */
  58324. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  58325. private _useDeltaForWorldStep;
  58326. world: any;
  58327. name: string;
  58328. BJSOIMO: any;
  58329. private _raycastResult;
  58330. private _fixedTimeStep;
  58331. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, oimoInjection?: any);
  58332. setGravity(gravity: Vector3): void;
  58333. setTimeStep(timeStep: number): void;
  58334. getTimeStep(): number;
  58335. private _tmpImpostorsArray;
  58336. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  58337. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  58338. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  58339. generatePhysicsBody(impostor: PhysicsImpostor): void;
  58340. private _tmpPositionVector;
  58341. removePhysicsBody(impostor: PhysicsImpostor): void;
  58342. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  58343. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  58344. isSupported(): boolean;
  58345. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  58346. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  58347. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  58348. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  58349. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  58350. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  58351. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  58352. getBodyMass(impostor: PhysicsImpostor): number;
  58353. getBodyFriction(impostor: PhysicsImpostor): number;
  58354. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  58355. getBodyRestitution(impostor: PhysicsImpostor): number;
  58356. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  58357. sleepBody(impostor: PhysicsImpostor): void;
  58358. wakeUpBody(impostor: PhysicsImpostor): void;
  58359. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  58360. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  58361. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  58362. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  58363. getRadius(impostor: PhysicsImpostor): number;
  58364. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  58365. dispose(): void;
  58366. /**
  58367. * Does a raycast in the physics world
  58368. * @param from when should the ray start?
  58369. * @param to when should the ray end?
  58370. * @returns PhysicsRaycastResult
  58371. */
  58372. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  58373. }
  58374. }
  58375. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  58376. import { Nullable } from "babylonjs/types";
  58377. import { Scene } from "babylonjs/scene";
  58378. import { Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  58379. import { Color4 } from "babylonjs/Maths/math.color";
  58380. import { Mesh } from "babylonjs/Meshes/mesh";
  58381. /**
  58382. * Class containing static functions to help procedurally build meshes
  58383. */
  58384. export class RibbonBuilder {
  58385. /**
  58386. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  58387. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  58388. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  58389. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  58390. * * 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
  58391. * * 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
  58392. * * 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
  58393. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58394. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58395. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  58396. * * 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
  58397. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  58398. * * 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
  58399. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  58400. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58401. * @param name defines the name of the mesh
  58402. * @param options defines the options used to create the mesh
  58403. * @param scene defines the hosting scene
  58404. * @returns the ribbon mesh
  58405. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  58406. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  58407. */
  58408. static CreateRibbon(name: string, options: {
  58409. pathArray: Vector3[][];
  58410. closeArray?: boolean;
  58411. closePath?: boolean;
  58412. offset?: number;
  58413. updatable?: boolean;
  58414. sideOrientation?: number;
  58415. frontUVs?: Vector4;
  58416. backUVs?: Vector4;
  58417. instance?: Mesh;
  58418. invertUV?: boolean;
  58419. uvs?: Vector2[];
  58420. colors?: Color4[];
  58421. }, scene?: Nullable<Scene>): Mesh;
  58422. }
  58423. }
  58424. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  58425. import { Nullable } from "babylonjs/types";
  58426. import { Scene } from "babylonjs/scene";
  58427. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  58428. import { Mesh } from "babylonjs/Meshes/mesh";
  58429. /**
  58430. * Class containing static functions to help procedurally build meshes
  58431. */
  58432. export class ShapeBuilder {
  58433. /**
  58434. * 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.
  58435. * * 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.
  58436. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  58437. * * 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.
  58438. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  58439. * * 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
  58440. * * 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
  58441. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  58442. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58443. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58444. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  58445. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  58446. * @param name defines the name of the mesh
  58447. * @param options defines the options used to create the mesh
  58448. * @param scene defines the hosting scene
  58449. * @returns the extruded shape mesh
  58450. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  58451. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  58452. */
  58453. static ExtrudeShape(name: string, options: {
  58454. shape: Vector3[];
  58455. path: Vector3[];
  58456. scale?: number;
  58457. rotation?: number;
  58458. cap?: number;
  58459. updatable?: boolean;
  58460. sideOrientation?: number;
  58461. frontUVs?: Vector4;
  58462. backUVs?: Vector4;
  58463. instance?: Mesh;
  58464. invertUV?: boolean;
  58465. }, scene?: Nullable<Scene>): Mesh;
  58466. /**
  58467. * Creates an custom extruded shape mesh.
  58468. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  58469. * * 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.
  58470. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  58471. * * 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
  58472. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  58473. * * 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
  58474. * * It must returns a float value that will be the scale value applied to the shape on each path point
  58475. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  58476. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  58477. * * 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
  58478. * * 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
  58479. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  58480. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58481. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58482. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  58483. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58484. * @param name defines the name of the mesh
  58485. * @param options defines the options used to create the mesh
  58486. * @param scene defines the hosting scene
  58487. * @returns the custom extruded shape mesh
  58488. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  58489. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  58490. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  58491. */
  58492. static ExtrudeShapeCustom(name: string, options: {
  58493. shape: Vector3[];
  58494. path: Vector3[];
  58495. scaleFunction?: any;
  58496. rotationFunction?: any;
  58497. ribbonCloseArray?: boolean;
  58498. ribbonClosePath?: boolean;
  58499. cap?: number;
  58500. updatable?: boolean;
  58501. sideOrientation?: number;
  58502. frontUVs?: Vector4;
  58503. backUVs?: Vector4;
  58504. instance?: Mesh;
  58505. invertUV?: boolean;
  58506. }, scene?: Nullable<Scene>): Mesh;
  58507. private static _ExtrudeShapeGeneric;
  58508. }
  58509. }
  58510. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  58511. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  58512. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  58513. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  58514. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  58515. import { Nullable } from "babylonjs/types";
  58516. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58517. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  58518. /**
  58519. * AmmoJS Physics plugin
  58520. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  58521. * @see https://github.com/kripken/ammo.js/
  58522. */
  58523. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  58524. private _useDeltaForWorldStep;
  58525. /**
  58526. * Reference to the Ammo library
  58527. */
  58528. bjsAMMO: any;
  58529. /**
  58530. * Created ammoJS world which physics bodies are added to
  58531. */
  58532. world: any;
  58533. /**
  58534. * Name of the plugin
  58535. */
  58536. name: string;
  58537. private _timeStep;
  58538. private _fixedTimeStep;
  58539. private _maxSteps;
  58540. private _tmpQuaternion;
  58541. private _tmpAmmoTransform;
  58542. private _tmpAmmoQuaternion;
  58543. private _tmpAmmoConcreteContactResultCallback;
  58544. private _collisionConfiguration;
  58545. private _dispatcher;
  58546. private _overlappingPairCache;
  58547. private _solver;
  58548. private _softBodySolver;
  58549. private _tmpAmmoVectorA;
  58550. private _tmpAmmoVectorB;
  58551. private _tmpAmmoVectorC;
  58552. private _tmpAmmoVectorD;
  58553. private _tmpContactCallbackResult;
  58554. private _tmpAmmoVectorRCA;
  58555. private _tmpAmmoVectorRCB;
  58556. private _raycastResult;
  58557. private static readonly DISABLE_COLLISION_FLAG;
  58558. private static readonly KINEMATIC_FLAG;
  58559. private static readonly DISABLE_DEACTIVATION_FLAG;
  58560. /**
  58561. * Initializes the ammoJS plugin
  58562. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  58563. * @param ammoInjection can be used to inject your own ammo reference
  58564. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  58565. */
  58566. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  58567. /**
  58568. * Sets the gravity of the physics world (m/(s^2))
  58569. * @param gravity Gravity to set
  58570. */
  58571. setGravity(gravity: Vector3): void;
  58572. /**
  58573. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  58574. * @param timeStep timestep to use in seconds
  58575. */
  58576. setTimeStep(timeStep: number): void;
  58577. /**
  58578. * 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)
  58579. * @param fixedTimeStep fixedTimeStep to use in seconds
  58580. */
  58581. setFixedTimeStep(fixedTimeStep: number): void;
  58582. /**
  58583. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  58584. * @param maxSteps the maximum number of steps by the physics engine per frame
  58585. */
  58586. setMaxSteps(maxSteps: number): void;
  58587. /**
  58588. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  58589. * @returns the current timestep in seconds
  58590. */
  58591. getTimeStep(): number;
  58592. /**
  58593. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  58594. */
  58595. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  58596. private _isImpostorInContact;
  58597. private _isImpostorPairInContact;
  58598. private _stepSimulation;
  58599. /**
  58600. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  58601. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  58602. * After the step the babylon meshes are set to the position of the physics imposters
  58603. * @param delta amount of time to step forward
  58604. * @param impostors array of imposters to update before/after the step
  58605. */
  58606. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  58607. /**
  58608. * Update babylon mesh to match physics world object
  58609. * @param impostor imposter to match
  58610. */
  58611. private _afterSoftStep;
  58612. /**
  58613. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  58614. * @param impostor imposter to match
  58615. */
  58616. private _ropeStep;
  58617. /**
  58618. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  58619. * @param impostor imposter to match
  58620. */
  58621. private _softbodyOrClothStep;
  58622. private _tmpMatrix;
  58623. /**
  58624. * Applies an impulse on the imposter
  58625. * @param impostor imposter to apply impulse to
  58626. * @param force amount of force to be applied to the imposter
  58627. * @param contactPoint the location to apply the impulse on the imposter
  58628. */
  58629. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  58630. /**
  58631. * Applies a force on the imposter
  58632. * @param impostor imposter to apply force
  58633. * @param force amount of force to be applied to the imposter
  58634. * @param contactPoint the location to apply the force on the imposter
  58635. */
  58636. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  58637. /**
  58638. * Creates a physics body using the plugin
  58639. * @param impostor the imposter to create the physics body on
  58640. */
  58641. generatePhysicsBody(impostor: PhysicsImpostor): void;
  58642. /**
  58643. * Removes the physics body from the imposter and disposes of the body's memory
  58644. * @param impostor imposter to remove the physics body from
  58645. */
  58646. removePhysicsBody(impostor: PhysicsImpostor): void;
  58647. /**
  58648. * Generates a joint
  58649. * @param impostorJoint the imposter joint to create the joint with
  58650. */
  58651. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  58652. /**
  58653. * Removes a joint
  58654. * @param impostorJoint the imposter joint to remove the joint from
  58655. */
  58656. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  58657. private _addMeshVerts;
  58658. /**
  58659. * Initialise the soft body vertices to match its object's (mesh) vertices
  58660. * Softbody vertices (nodes) are in world space and to match this
  58661. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  58662. * @param impostor to create the softbody for
  58663. */
  58664. private _softVertexData;
  58665. /**
  58666. * Create an impostor's soft body
  58667. * @param impostor to create the softbody for
  58668. */
  58669. private _createSoftbody;
  58670. /**
  58671. * Create cloth for an impostor
  58672. * @param impostor to create the softbody for
  58673. */
  58674. private _createCloth;
  58675. /**
  58676. * Create rope for an impostor
  58677. * @param impostor to create the softbody for
  58678. */
  58679. private _createRope;
  58680. /**
  58681. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  58682. * @param impostor to create the custom physics shape for
  58683. */
  58684. private _createCustom;
  58685. private _addHullVerts;
  58686. private _createShape;
  58687. /**
  58688. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  58689. * @param impostor imposter containing the physics body and babylon object
  58690. */
  58691. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  58692. /**
  58693. * Sets the babylon object's position/rotation from the physics body's position/rotation
  58694. * @param impostor imposter containing the physics body and babylon object
  58695. * @param newPosition new position
  58696. * @param newRotation new rotation
  58697. */
  58698. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  58699. /**
  58700. * If this plugin is supported
  58701. * @returns true if its supported
  58702. */
  58703. isSupported(): boolean;
  58704. /**
  58705. * Sets the linear velocity of the physics body
  58706. * @param impostor imposter to set the velocity on
  58707. * @param velocity velocity to set
  58708. */
  58709. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  58710. /**
  58711. * Sets the angular velocity of the physics body
  58712. * @param impostor imposter to set the velocity on
  58713. * @param velocity velocity to set
  58714. */
  58715. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  58716. /**
  58717. * gets the linear velocity
  58718. * @param impostor imposter to get linear velocity from
  58719. * @returns linear velocity
  58720. */
  58721. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  58722. /**
  58723. * gets the angular velocity
  58724. * @param impostor imposter to get angular velocity from
  58725. * @returns angular velocity
  58726. */
  58727. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  58728. /**
  58729. * Sets the mass of physics body
  58730. * @param impostor imposter to set the mass on
  58731. * @param mass mass to set
  58732. */
  58733. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  58734. /**
  58735. * Gets the mass of the physics body
  58736. * @param impostor imposter to get the mass from
  58737. * @returns mass
  58738. */
  58739. getBodyMass(impostor: PhysicsImpostor): number;
  58740. /**
  58741. * Gets friction of the impostor
  58742. * @param impostor impostor to get friction from
  58743. * @returns friction value
  58744. */
  58745. getBodyFriction(impostor: PhysicsImpostor): number;
  58746. /**
  58747. * Sets friction of the impostor
  58748. * @param impostor impostor to set friction on
  58749. * @param friction friction value
  58750. */
  58751. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  58752. /**
  58753. * Gets restitution of the impostor
  58754. * @param impostor impostor to get restitution from
  58755. * @returns restitution value
  58756. */
  58757. getBodyRestitution(impostor: PhysicsImpostor): number;
  58758. /**
  58759. * Sets resitution of the impostor
  58760. * @param impostor impostor to set resitution on
  58761. * @param restitution resitution value
  58762. */
  58763. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  58764. /**
  58765. * Gets pressure inside the impostor
  58766. * @param impostor impostor to get pressure from
  58767. * @returns pressure value
  58768. */
  58769. getBodyPressure(impostor: PhysicsImpostor): number;
  58770. /**
  58771. * Sets pressure inside a soft body impostor
  58772. * Cloth and rope must remain 0 pressure
  58773. * @param impostor impostor to set pressure on
  58774. * @param pressure pressure value
  58775. */
  58776. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  58777. /**
  58778. * Gets stiffness of the impostor
  58779. * @param impostor impostor to get stiffness from
  58780. * @returns pressure value
  58781. */
  58782. getBodyStiffness(impostor: PhysicsImpostor): number;
  58783. /**
  58784. * Sets stiffness of the impostor
  58785. * @param impostor impostor to set stiffness on
  58786. * @param stiffness stiffness value from 0 to 1
  58787. */
  58788. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  58789. /**
  58790. * Gets velocityIterations of the impostor
  58791. * @param impostor impostor to get velocity iterations from
  58792. * @returns velocityIterations value
  58793. */
  58794. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  58795. /**
  58796. * Sets velocityIterations of the impostor
  58797. * @param impostor impostor to set velocity iterations on
  58798. * @param velocityIterations velocityIterations value
  58799. */
  58800. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  58801. /**
  58802. * Gets positionIterations of the impostor
  58803. * @param impostor impostor to get position iterations from
  58804. * @returns positionIterations value
  58805. */
  58806. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  58807. /**
  58808. * Sets positionIterations of the impostor
  58809. * @param impostor impostor to set position on
  58810. * @param positionIterations positionIterations value
  58811. */
  58812. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  58813. /**
  58814. * Append an anchor to a cloth object
  58815. * @param impostor is the cloth impostor to add anchor to
  58816. * @param otherImpostor is the rigid impostor to anchor to
  58817. * @param width ratio across width from 0 to 1
  58818. * @param height ratio up height from 0 to 1
  58819. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  58820. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  58821. */
  58822. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  58823. /**
  58824. * Append an hook to a rope object
  58825. * @param impostor is the rope impostor to add hook to
  58826. * @param otherImpostor is the rigid impostor to hook to
  58827. * @param length ratio along the rope from 0 to 1
  58828. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  58829. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  58830. */
  58831. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  58832. /**
  58833. * Sleeps the physics body and stops it from being active
  58834. * @param impostor impostor to sleep
  58835. */
  58836. sleepBody(impostor: PhysicsImpostor): void;
  58837. /**
  58838. * Activates the physics body
  58839. * @param impostor impostor to activate
  58840. */
  58841. wakeUpBody(impostor: PhysicsImpostor): void;
  58842. /**
  58843. * Updates the distance parameters of the joint
  58844. * @param joint joint to update
  58845. * @param maxDistance maximum distance of the joint
  58846. * @param minDistance minimum distance of the joint
  58847. */
  58848. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  58849. /**
  58850. * Sets a motor on the joint
  58851. * @param joint joint to set motor on
  58852. * @param speed speed of the motor
  58853. * @param maxForce maximum force of the motor
  58854. * @param motorIndex index of the motor
  58855. */
  58856. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  58857. /**
  58858. * Sets the motors limit
  58859. * @param joint joint to set limit on
  58860. * @param upperLimit upper limit
  58861. * @param lowerLimit lower limit
  58862. */
  58863. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  58864. /**
  58865. * Syncs the position and rotation of a mesh with the impostor
  58866. * @param mesh mesh to sync
  58867. * @param impostor impostor to update the mesh with
  58868. */
  58869. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  58870. /**
  58871. * Gets the radius of the impostor
  58872. * @param impostor impostor to get radius from
  58873. * @returns the radius
  58874. */
  58875. getRadius(impostor: PhysicsImpostor): number;
  58876. /**
  58877. * Gets the box size of the impostor
  58878. * @param impostor impostor to get box size from
  58879. * @param result the resulting box size
  58880. */
  58881. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  58882. /**
  58883. * Disposes of the impostor
  58884. */
  58885. dispose(): void;
  58886. /**
  58887. * Does a raycast in the physics world
  58888. * @param from when should the ray start?
  58889. * @param to when should the ray end?
  58890. * @returns PhysicsRaycastResult
  58891. */
  58892. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  58893. }
  58894. }
  58895. declare module "babylonjs/Probes/reflectionProbe" {
  58896. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  58897. import { Vector3 } from "babylonjs/Maths/math.vector";
  58898. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58899. import { Nullable } from "babylonjs/types";
  58900. import { Scene } from "babylonjs/scene";
  58901. module "babylonjs/abstractScene" {
  58902. interface AbstractScene {
  58903. /**
  58904. * The list of reflection probes added to the scene
  58905. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  58906. */
  58907. reflectionProbes: Array<ReflectionProbe>;
  58908. /**
  58909. * Removes the given reflection probe from this scene.
  58910. * @param toRemove The reflection probe to remove
  58911. * @returns The index of the removed reflection probe
  58912. */
  58913. removeReflectionProbe(toRemove: ReflectionProbe): number;
  58914. /**
  58915. * Adds the given reflection probe to this scene.
  58916. * @param newReflectionProbe The reflection probe to add
  58917. */
  58918. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  58919. }
  58920. }
  58921. /**
  58922. * Class used to generate realtime reflection / refraction cube textures
  58923. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  58924. */
  58925. export class ReflectionProbe {
  58926. /** defines the name of the probe */
  58927. name: string;
  58928. private _scene;
  58929. private _renderTargetTexture;
  58930. private _projectionMatrix;
  58931. private _viewMatrix;
  58932. private _target;
  58933. private _add;
  58934. private _attachedMesh;
  58935. private _invertYAxis;
  58936. /** Gets or sets probe position (center of the cube map) */
  58937. position: Vector3;
  58938. /**
  58939. * Creates a new reflection probe
  58940. * @param name defines the name of the probe
  58941. * @param size defines the texture resolution (for each face)
  58942. * @param scene defines the hosting scene
  58943. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  58944. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  58945. */
  58946. constructor(
  58947. /** defines the name of the probe */
  58948. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  58949. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  58950. get samples(): number;
  58951. set samples(value: number);
  58952. /** Gets or sets the refresh rate to use (on every frame by default) */
  58953. get refreshRate(): number;
  58954. set refreshRate(value: number);
  58955. /**
  58956. * Gets the hosting scene
  58957. * @returns a Scene
  58958. */
  58959. getScene(): Scene;
  58960. /** Gets the internal CubeTexture used to render to */
  58961. get cubeTexture(): RenderTargetTexture;
  58962. /** Gets the list of meshes to render */
  58963. get renderList(): Nullable<AbstractMesh[]>;
  58964. /**
  58965. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  58966. * @param mesh defines the mesh to attach to
  58967. */
  58968. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  58969. /**
  58970. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  58971. * @param renderingGroupId The rendering group id corresponding to its index
  58972. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  58973. */
  58974. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  58975. /**
  58976. * Clean all associated resources
  58977. */
  58978. dispose(): void;
  58979. /**
  58980. * Converts the reflection probe information to a readable string for debug purpose.
  58981. * @param fullDetails Supports for multiple levels of logging within scene loading
  58982. * @returns the human readable reflection probe info
  58983. */
  58984. toString(fullDetails?: boolean): string;
  58985. /**
  58986. * Get the class name of the relfection probe.
  58987. * @returns "ReflectionProbe"
  58988. */
  58989. getClassName(): string;
  58990. /**
  58991. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  58992. * @returns The JSON representation of the texture
  58993. */
  58994. serialize(): any;
  58995. /**
  58996. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  58997. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  58998. * @param scene Define the scene the parsed reflection probe should be instantiated in
  58999. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  59000. * @returns The parsed reflection probe if successful
  59001. */
  59002. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  59003. }
  59004. }
  59005. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  59006. /** @hidden */
  59007. export var _BabylonLoaderRegistered: boolean;
  59008. /**
  59009. * Helps setting up some configuration for the babylon file loader.
  59010. */
  59011. export class BabylonFileLoaderConfiguration {
  59012. /**
  59013. * The loader does not allow injecting custom physix engine into the plugins.
  59014. * Unfortunately in ES6, we need to manually inject them into the plugin.
  59015. * So you could set this variable to your engine import to make it work.
  59016. */
  59017. static LoaderInjectedPhysicsEngine: any;
  59018. }
  59019. }
  59020. declare module "babylonjs/Loading/Plugins/index" {
  59021. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  59022. }
  59023. declare module "babylonjs/Loading/index" {
  59024. export * from "babylonjs/Loading/loadingScreen";
  59025. export * from "babylonjs/Loading/Plugins/index";
  59026. export * from "babylonjs/Loading/sceneLoader";
  59027. export * from "babylonjs/Loading/sceneLoaderFlags";
  59028. }
  59029. declare module "babylonjs/Materials/Background/index" {
  59030. export * from "babylonjs/Materials/Background/backgroundMaterial";
  59031. }
  59032. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  59033. import { Scene } from "babylonjs/scene";
  59034. import { Color3 } from "babylonjs/Maths/math.color";
  59035. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  59036. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  59037. /**
  59038. * The Physically based simple base material of BJS.
  59039. *
  59040. * This enables better naming and convention enforcements on top of the pbrMaterial.
  59041. * It is used as the base class for both the specGloss and metalRough conventions.
  59042. */
  59043. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  59044. /**
  59045. * Number of Simultaneous lights allowed on the material.
  59046. */
  59047. maxSimultaneousLights: number;
  59048. /**
  59049. * If sets to true, disables all the lights affecting the material.
  59050. */
  59051. disableLighting: boolean;
  59052. /**
  59053. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  59054. */
  59055. environmentTexture: BaseTexture;
  59056. /**
  59057. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  59058. */
  59059. invertNormalMapX: boolean;
  59060. /**
  59061. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  59062. */
  59063. invertNormalMapY: boolean;
  59064. /**
  59065. * Normal map used in the model.
  59066. */
  59067. normalTexture: BaseTexture;
  59068. /**
  59069. * Emissivie color used to self-illuminate the model.
  59070. */
  59071. emissiveColor: Color3;
  59072. /**
  59073. * Emissivie texture used to self-illuminate the model.
  59074. */
  59075. emissiveTexture: BaseTexture;
  59076. /**
  59077. * Occlusion Channel Strenght.
  59078. */
  59079. occlusionStrength: number;
  59080. /**
  59081. * Occlusion Texture of the material (adding extra occlusion effects).
  59082. */
  59083. occlusionTexture: BaseTexture;
  59084. /**
  59085. * Defines the alpha limits in alpha test mode.
  59086. */
  59087. alphaCutOff: number;
  59088. /**
  59089. * Gets the current double sided mode.
  59090. */
  59091. get doubleSided(): boolean;
  59092. /**
  59093. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  59094. */
  59095. set doubleSided(value: boolean);
  59096. /**
  59097. * Stores the pre-calculated light information of a mesh in a texture.
  59098. */
  59099. lightmapTexture: BaseTexture;
  59100. /**
  59101. * If true, the light map contains occlusion information instead of lighting info.
  59102. */
  59103. useLightmapAsShadowmap: boolean;
  59104. /**
  59105. * Instantiates a new PBRMaterial instance.
  59106. *
  59107. * @param name The material name
  59108. * @param scene The scene the material will be use in.
  59109. */
  59110. constructor(name: string, scene: Scene);
  59111. getClassName(): string;
  59112. }
  59113. }
  59114. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  59115. import { Scene } from "babylonjs/scene";
  59116. import { Color3 } from "babylonjs/Maths/math.color";
  59117. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  59118. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  59119. /**
  59120. * The PBR material of BJS following the metal roughness convention.
  59121. *
  59122. * This fits to the PBR convention in the GLTF definition:
  59123. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  59124. */
  59125. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  59126. /**
  59127. * The base color has two different interpretations depending on the value of metalness.
  59128. * When the material is a metal, the base color is the specific measured reflectance value
  59129. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  59130. * of the material.
  59131. */
  59132. baseColor: Color3;
  59133. /**
  59134. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  59135. * well as opacity information in the alpha channel.
  59136. */
  59137. baseTexture: BaseTexture;
  59138. /**
  59139. * Specifies the metallic scalar value of the material.
  59140. * Can also be used to scale the metalness values of the metallic texture.
  59141. */
  59142. metallic: number;
  59143. /**
  59144. * Specifies the roughness scalar value of the material.
  59145. * Can also be used to scale the roughness values of the metallic texture.
  59146. */
  59147. roughness: number;
  59148. /**
  59149. * Texture containing both the metallic value in the B channel and the
  59150. * roughness value in the G channel to keep better precision.
  59151. */
  59152. metallicRoughnessTexture: BaseTexture;
  59153. /**
  59154. * Instantiates a new PBRMetalRoughnessMaterial instance.
  59155. *
  59156. * @param name The material name
  59157. * @param scene The scene the material will be use in.
  59158. */
  59159. constructor(name: string, scene: Scene);
  59160. /**
  59161. * Return the currrent class name of the material.
  59162. */
  59163. getClassName(): string;
  59164. /**
  59165. * Makes a duplicate of the current material.
  59166. * @param name - name to use for the new material.
  59167. */
  59168. clone(name: string): PBRMetallicRoughnessMaterial;
  59169. /**
  59170. * Serialize the material to a parsable JSON object.
  59171. */
  59172. serialize(): any;
  59173. /**
  59174. * Parses a JSON object correponding to the serialize function.
  59175. */
  59176. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  59177. }
  59178. }
  59179. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  59180. import { Scene } from "babylonjs/scene";
  59181. import { Color3 } from "babylonjs/Maths/math.color";
  59182. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  59183. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  59184. /**
  59185. * The PBR material of BJS following the specular glossiness convention.
  59186. *
  59187. * This fits to the PBR convention in the GLTF definition:
  59188. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  59189. */
  59190. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  59191. /**
  59192. * Specifies the diffuse color of the material.
  59193. */
  59194. diffuseColor: Color3;
  59195. /**
  59196. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  59197. * channel.
  59198. */
  59199. diffuseTexture: BaseTexture;
  59200. /**
  59201. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  59202. */
  59203. specularColor: Color3;
  59204. /**
  59205. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  59206. */
  59207. glossiness: number;
  59208. /**
  59209. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  59210. */
  59211. specularGlossinessTexture: BaseTexture;
  59212. /**
  59213. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  59214. *
  59215. * @param name The material name
  59216. * @param scene The scene the material will be use in.
  59217. */
  59218. constructor(name: string, scene: Scene);
  59219. /**
  59220. * Return the currrent class name of the material.
  59221. */
  59222. getClassName(): string;
  59223. /**
  59224. * Makes a duplicate of the current material.
  59225. * @param name - name to use for the new material.
  59226. */
  59227. clone(name: string): PBRSpecularGlossinessMaterial;
  59228. /**
  59229. * Serialize the material to a parsable JSON object.
  59230. */
  59231. serialize(): any;
  59232. /**
  59233. * Parses a JSON object correponding to the serialize function.
  59234. */
  59235. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  59236. }
  59237. }
  59238. declare module "babylonjs/Materials/PBR/index" {
  59239. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  59240. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  59241. export * from "babylonjs/Materials/PBR/pbrMaterial";
  59242. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  59243. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  59244. }
  59245. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  59246. import { Nullable } from "babylonjs/types";
  59247. import { Scene } from "babylonjs/scene";
  59248. import { Matrix } from "babylonjs/Maths/math.vector";
  59249. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  59250. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  59251. import "babylonjs/Engines/Extensions/engine.rawTexture";
  59252. /**
  59253. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  59254. * It can help converting any input color in a desired output one. This can then be used to create effects
  59255. * from sepia, black and white to sixties or futuristic rendering...
  59256. *
  59257. * The only supported format is currently 3dl.
  59258. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  59259. */
  59260. export class ColorGradingTexture extends BaseTexture {
  59261. /**
  59262. * The texture URL.
  59263. */
  59264. url: string;
  59265. /**
  59266. * Empty line regex stored for GC.
  59267. */
  59268. private static _noneEmptyLineRegex;
  59269. private _textureMatrix;
  59270. private _onLoad;
  59271. /**
  59272. * Instantiates a ColorGradingTexture from the following parameters.
  59273. *
  59274. * @param url The location of the color gradind data (currently only supporting 3dl)
  59275. * @param sceneOrEngine The scene or engine the texture will be used in
  59276. * @param onLoad defines a callback triggered when the texture has been loaded
  59277. */
  59278. constructor(url: string, sceneOrEngine: Scene | ThinEngine, onLoad?: Nullable<() => void>);
  59279. /**
  59280. * Fires the onload event from the constructor if requested.
  59281. */
  59282. private _triggerOnLoad;
  59283. /**
  59284. * Returns the texture matrix used in most of the material.
  59285. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  59286. */
  59287. getTextureMatrix(): Matrix;
  59288. /**
  59289. * Occurs when the file being loaded is a .3dl LUT file.
  59290. */
  59291. private load3dlTexture;
  59292. /**
  59293. * Starts the loading process of the texture.
  59294. */
  59295. private loadTexture;
  59296. /**
  59297. * Clones the color gradind texture.
  59298. */
  59299. clone(): ColorGradingTexture;
  59300. /**
  59301. * Called during delayed load for textures.
  59302. */
  59303. delayLoad(): void;
  59304. /**
  59305. * Parses a color grading texture serialized by Babylon.
  59306. * @param parsedTexture The texture information being parsedTexture
  59307. * @param scene The scene to load the texture in
  59308. * @param rootUrl The root url of the data assets to load
  59309. * @return A color gradind texture
  59310. */
  59311. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  59312. /**
  59313. * Serializes the LUT texture to json format.
  59314. */
  59315. serialize(): any;
  59316. }
  59317. }
  59318. declare module "babylonjs/Materials/Textures/equiRectangularCubeTexture" {
  59319. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  59320. import { Scene } from "babylonjs/scene";
  59321. import { Nullable } from "babylonjs/types";
  59322. import "babylonjs/Engines/Extensions/engine.rawTexture";
  59323. /**
  59324. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  59325. */
  59326. export class EquiRectangularCubeTexture extends BaseTexture {
  59327. /** The six faces of the cube. */
  59328. private static _FacesMapping;
  59329. private _noMipmap;
  59330. private _onLoad;
  59331. private _onError;
  59332. /** The size of the cubemap. */
  59333. private _size;
  59334. /** The buffer of the image. */
  59335. private _buffer;
  59336. /** The width of the input image. */
  59337. private _width;
  59338. /** The height of the input image. */
  59339. private _height;
  59340. /** The URL to the image. */
  59341. url: string;
  59342. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  59343. coordinatesMode: number;
  59344. /**
  59345. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  59346. * @param url The location of the image
  59347. * @param scene The scene the texture will be used in
  59348. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  59349. * @param noMipmap Forces to not generate the mipmap if true
  59350. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  59351. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  59352. * @param onLoad — defines a callback called when texture is loaded
  59353. * @param onError — defines a callback called if there is an error
  59354. */
  59355. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  59356. /**
  59357. * Load the image data, by putting the image on a canvas and extracting its buffer.
  59358. */
  59359. private loadImage;
  59360. /**
  59361. * Convert the image buffer into a cubemap and create a CubeTexture.
  59362. */
  59363. private loadTexture;
  59364. /**
  59365. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  59366. * @param buffer The ArrayBuffer that should be converted.
  59367. * @returns The buffer as Float32Array.
  59368. */
  59369. private getFloat32ArrayFromArrayBuffer;
  59370. /**
  59371. * Get the current class name of the texture useful for serialization or dynamic coding.
  59372. * @returns "EquiRectangularCubeTexture"
  59373. */
  59374. getClassName(): string;
  59375. /**
  59376. * Create a clone of the current EquiRectangularCubeTexture and return it.
  59377. * @returns A clone of the current EquiRectangularCubeTexture.
  59378. */
  59379. clone(): EquiRectangularCubeTexture;
  59380. }
  59381. }
  59382. declare module "babylonjs/Misc/tga" {
  59383. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  59384. /**
  59385. * Based on jsTGALoader - Javascript loader for TGA file
  59386. * By Vincent Thibault
  59387. * @see http://blog.robrowser.com/javascript-tga-loader.html
  59388. */
  59389. export class TGATools {
  59390. private static _TYPE_INDEXED;
  59391. private static _TYPE_RGB;
  59392. private static _TYPE_GREY;
  59393. private static _TYPE_RLE_INDEXED;
  59394. private static _TYPE_RLE_RGB;
  59395. private static _TYPE_RLE_GREY;
  59396. private static _ORIGIN_MASK;
  59397. private static _ORIGIN_SHIFT;
  59398. private static _ORIGIN_BL;
  59399. private static _ORIGIN_BR;
  59400. private static _ORIGIN_UL;
  59401. private static _ORIGIN_UR;
  59402. /**
  59403. * Gets the header of a TGA file
  59404. * @param data defines the TGA data
  59405. * @returns the header
  59406. */
  59407. static GetTGAHeader(data: Uint8Array): any;
  59408. /**
  59409. * Uploads TGA content to a Babylon Texture
  59410. * @hidden
  59411. */
  59412. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  59413. /** @hidden */
  59414. 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;
  59415. /** @hidden */
  59416. 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;
  59417. /** @hidden */
  59418. 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;
  59419. /** @hidden */
  59420. 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;
  59421. /** @hidden */
  59422. 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;
  59423. /** @hidden */
  59424. 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;
  59425. }
  59426. }
  59427. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  59428. import { Nullable } from "babylonjs/types";
  59429. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  59430. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  59431. /**
  59432. * Implementation of the TGA Texture Loader.
  59433. * @hidden
  59434. */
  59435. export class _TGATextureLoader implements IInternalTextureLoader {
  59436. /**
  59437. * Defines wether the loader supports cascade loading the different faces.
  59438. */
  59439. readonly supportCascades: boolean;
  59440. /**
  59441. * This returns if the loader support the current file information.
  59442. * @param extension defines the file extension of the file being loaded
  59443. * @returns true if the loader can load the specified file
  59444. */
  59445. canLoad(extension: string): boolean;
  59446. /**
  59447. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  59448. * @param data contains the texture data
  59449. * @param texture defines the BabylonJS internal texture
  59450. * @param createPolynomials will be true if polynomials have been requested
  59451. * @param onLoad defines the callback to trigger once the texture is ready
  59452. * @param onError defines the callback to trigger in case of error
  59453. */
  59454. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  59455. /**
  59456. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  59457. * @param data contains the texture data
  59458. * @param texture defines the BabylonJS internal texture
  59459. * @param callback defines the method to call once ready to upload
  59460. */
  59461. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  59462. }
  59463. }
  59464. declare module "babylonjs/Misc/basis" {
  59465. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  59466. /**
  59467. * Info about the .basis files
  59468. */
  59469. class BasisFileInfo {
  59470. /**
  59471. * If the file has alpha
  59472. */
  59473. hasAlpha: boolean;
  59474. /**
  59475. * Info about each image of the basis file
  59476. */
  59477. images: Array<{
  59478. levels: Array<{
  59479. width: number;
  59480. height: number;
  59481. transcodedPixels: ArrayBufferView;
  59482. }>;
  59483. }>;
  59484. }
  59485. /**
  59486. * Result of transcoding a basis file
  59487. */
  59488. class TranscodeResult {
  59489. /**
  59490. * Info about the .basis file
  59491. */
  59492. fileInfo: BasisFileInfo;
  59493. /**
  59494. * Format to use when loading the file
  59495. */
  59496. format: number;
  59497. }
  59498. /**
  59499. * Configuration options for the Basis transcoder
  59500. */
  59501. export class BasisTranscodeConfiguration {
  59502. /**
  59503. * Supported compression formats used to determine the supported output format of the transcoder
  59504. */
  59505. supportedCompressionFormats?: {
  59506. /**
  59507. * etc1 compression format
  59508. */
  59509. etc1?: boolean;
  59510. /**
  59511. * s3tc compression format
  59512. */
  59513. s3tc?: boolean;
  59514. /**
  59515. * pvrtc compression format
  59516. */
  59517. pvrtc?: boolean;
  59518. /**
  59519. * etc2 compression format
  59520. */
  59521. etc2?: boolean;
  59522. };
  59523. /**
  59524. * If mipmap levels should be loaded for transcoded images (Default: true)
  59525. */
  59526. loadMipmapLevels?: boolean;
  59527. /**
  59528. * Index of a single image to load (Default: all images)
  59529. */
  59530. loadSingleImage?: number;
  59531. }
  59532. /**
  59533. * Used to load .Basis files
  59534. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  59535. */
  59536. export class BasisTools {
  59537. private static _IgnoreSupportedFormats;
  59538. /**
  59539. * URL to use when loading the basis transcoder
  59540. */
  59541. static JSModuleURL: string;
  59542. /**
  59543. * URL to use when loading the wasm module for the transcoder
  59544. */
  59545. static WasmModuleURL: string;
  59546. /**
  59547. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  59548. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  59549. * @returns internal format corresponding to the Basis format
  59550. */
  59551. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  59552. private static _WorkerPromise;
  59553. private static _Worker;
  59554. private static _actionId;
  59555. private static _CreateWorkerAsync;
  59556. /**
  59557. * Transcodes a loaded image file to compressed pixel data
  59558. * @param data image data to transcode
  59559. * @param config configuration options for the transcoding
  59560. * @returns a promise resulting in the transcoded image
  59561. */
  59562. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  59563. /**
  59564. * Loads a texture from the transcode result
  59565. * @param texture texture load to
  59566. * @param transcodeResult the result of transcoding the basis file to load from
  59567. */
  59568. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  59569. }
  59570. }
  59571. declare module "babylonjs/Materials/Textures/Loaders/basisTextureLoader" {
  59572. import { Nullable } from "babylonjs/types";
  59573. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  59574. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  59575. /**
  59576. * Loader for .basis file format
  59577. */
  59578. export class _BasisTextureLoader implements IInternalTextureLoader {
  59579. /**
  59580. * Defines whether the loader supports cascade loading the different faces.
  59581. */
  59582. readonly supportCascades: boolean;
  59583. /**
  59584. * This returns if the loader support the current file information.
  59585. * @param extension defines the file extension of the file being loaded
  59586. * @returns true if the loader can load the specified file
  59587. */
  59588. canLoad(extension: string): boolean;
  59589. /**
  59590. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  59591. * @param data contains the texture data
  59592. * @param texture defines the BabylonJS internal texture
  59593. * @param createPolynomials will be true if polynomials have been requested
  59594. * @param onLoad defines the callback to trigger once the texture is ready
  59595. * @param onError defines the callback to trigger in case of error
  59596. */
  59597. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  59598. /**
  59599. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  59600. * @param data contains the texture data
  59601. * @param texture defines the BabylonJS internal texture
  59602. * @param callback defines the method to call once ready to upload
  59603. */
  59604. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  59605. }
  59606. }
  59607. declare module "babylonjs/Materials/Textures/Loaders/index" {
  59608. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  59609. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  59610. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  59611. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  59612. export * from "babylonjs/Materials/Textures/Loaders/basisTextureLoader";
  59613. }
  59614. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  59615. import { Scene } from "babylonjs/scene";
  59616. import { Texture } from "babylonjs/Materials/Textures/texture";
  59617. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  59618. /**
  59619. * 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.
  59620. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  59621. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  59622. */
  59623. export class CustomProceduralTexture extends ProceduralTexture {
  59624. private _animate;
  59625. private _time;
  59626. private _config;
  59627. private _texturePath;
  59628. /**
  59629. * Instantiates a new Custom Procedural Texture.
  59630. * 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.
  59631. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  59632. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  59633. * @param name Define the name of the texture
  59634. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  59635. * @param size Define the size of the texture to create
  59636. * @param scene Define the scene the texture belongs to
  59637. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  59638. * @param generateMipMaps Define if the texture should creates mip maps or not
  59639. */
  59640. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  59641. private _loadJson;
  59642. /**
  59643. * Is the texture ready to be used ? (rendered at least once)
  59644. * @returns true if ready, otherwise, false.
  59645. */
  59646. isReady(): boolean;
  59647. /**
  59648. * Render the texture to its associated render target.
  59649. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  59650. */
  59651. render(useCameraPostProcess?: boolean): void;
  59652. /**
  59653. * Update the list of dependant textures samplers in the shader.
  59654. */
  59655. updateTextures(): void;
  59656. /**
  59657. * Update the uniform values of the procedural texture in the shader.
  59658. */
  59659. updateShaderUniforms(): void;
  59660. /**
  59661. * Define if the texture animates or not.
  59662. */
  59663. get animate(): boolean;
  59664. set animate(value: boolean);
  59665. }
  59666. }
  59667. declare module "babylonjs/Shaders/noise.fragment" {
  59668. /** @hidden */
  59669. export var noisePixelShader: {
  59670. name: string;
  59671. shader: string;
  59672. };
  59673. }
  59674. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  59675. import { Nullable } from "babylonjs/types";
  59676. import { Scene } from "babylonjs/scene";
  59677. import { Texture } from "babylonjs/Materials/Textures/texture";
  59678. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  59679. import "babylonjs/Shaders/noise.fragment";
  59680. /**
  59681. * Class used to generate noise procedural textures
  59682. */
  59683. export class NoiseProceduralTexture extends ProceduralTexture {
  59684. private _time;
  59685. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  59686. brightness: number;
  59687. /** Defines the number of octaves to process */
  59688. octaves: number;
  59689. /** Defines the level of persistence (0.8 by default) */
  59690. persistence: number;
  59691. /** Gets or sets animation speed factor (default is 1) */
  59692. animationSpeedFactor: number;
  59693. /**
  59694. * Creates a new NoiseProceduralTexture
  59695. * @param name defines the name fo the texture
  59696. * @param size defines the size of the texture (default is 256)
  59697. * @param scene defines the hosting scene
  59698. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  59699. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  59700. */
  59701. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  59702. private _updateShaderUniforms;
  59703. protected _getDefines(): string;
  59704. /** Generate the current state of the procedural texture */
  59705. render(useCameraPostProcess?: boolean): void;
  59706. /**
  59707. * Serializes this noise procedural texture
  59708. * @returns a serialized noise procedural texture object
  59709. */
  59710. serialize(): any;
  59711. /**
  59712. * Clone the texture.
  59713. * @returns the cloned texture
  59714. */
  59715. clone(): NoiseProceduralTexture;
  59716. /**
  59717. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  59718. * @param parsedTexture defines parsed texture data
  59719. * @param scene defines the current scene
  59720. * @param rootUrl defines the root URL containing noise procedural texture information
  59721. * @returns a parsed NoiseProceduralTexture
  59722. */
  59723. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  59724. }
  59725. }
  59726. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  59727. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  59728. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  59729. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  59730. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  59731. }
  59732. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  59733. import { Nullable } from "babylonjs/types";
  59734. import { Scene } from "babylonjs/scene";
  59735. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  59736. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  59737. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  59738. import "babylonjs/Engines/Extensions/engine.rawTexture";
  59739. /**
  59740. * Raw cube texture where the raw buffers are passed in
  59741. */
  59742. export class RawCubeTexture extends CubeTexture {
  59743. /**
  59744. * Creates a cube texture where the raw buffers are passed in.
  59745. * @param scene defines the scene the texture is attached to
  59746. * @param data defines the array of data to use to create each face
  59747. * @param size defines the size of the textures
  59748. * @param format defines the format of the data
  59749. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  59750. * @param generateMipMaps defines if the engine should generate the mip levels
  59751. * @param invertY defines if data must be stored with Y axis inverted
  59752. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  59753. * @param compression defines the compression used (null by default)
  59754. */
  59755. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  59756. /**
  59757. * Updates the raw cube texture.
  59758. * @param data defines the data to store
  59759. * @param format defines the data format
  59760. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  59761. * @param invertY defines if data must be stored with Y axis inverted
  59762. * @param compression defines the compression used (null by default)
  59763. * @param level defines which level of the texture to update
  59764. */
  59765. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  59766. /**
  59767. * Updates a raw cube texture with RGBD encoded data.
  59768. * @param data defines the array of data [mipmap][face] to use to create each face
  59769. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  59770. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  59771. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  59772. * @returns a promsie that resolves when the operation is complete
  59773. */
  59774. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  59775. /**
  59776. * Clones the raw cube texture.
  59777. * @return a new cube texture
  59778. */
  59779. clone(): CubeTexture;
  59780. /** @hidden */
  59781. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  59782. }
  59783. }
  59784. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  59785. import { Scene } from "babylonjs/scene";
  59786. import { Texture } from "babylonjs/Materials/Textures/texture";
  59787. import "babylonjs/Engines/Extensions/engine.rawTexture";
  59788. /**
  59789. * Class used to store 3D textures containing user data
  59790. */
  59791. export class RawTexture3D extends Texture {
  59792. /** Gets or sets the texture format to use */
  59793. format: number;
  59794. /**
  59795. * Create a new RawTexture3D
  59796. * @param data defines the data of the texture
  59797. * @param width defines the width of the texture
  59798. * @param height defines the height of the texture
  59799. * @param depth defines the depth of the texture
  59800. * @param format defines the texture format to use
  59801. * @param scene defines the hosting scene
  59802. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  59803. * @param invertY defines if texture must be stored with Y axis inverted
  59804. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  59805. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  59806. */
  59807. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  59808. /** Gets or sets the texture format to use */
  59809. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  59810. /**
  59811. * Update the texture with new data
  59812. * @param data defines the data to store in the texture
  59813. */
  59814. update(data: ArrayBufferView): void;
  59815. }
  59816. }
  59817. declare module "babylonjs/Materials/Textures/rawTexture2DArray" {
  59818. import { Scene } from "babylonjs/scene";
  59819. import { Texture } from "babylonjs/Materials/Textures/texture";
  59820. import "babylonjs/Engines/Extensions/engine.rawTexture";
  59821. /**
  59822. * Class used to store 2D array textures containing user data
  59823. */
  59824. export class RawTexture2DArray extends Texture {
  59825. /** Gets or sets the texture format to use */
  59826. format: number;
  59827. /**
  59828. * Create a new RawTexture2DArray
  59829. * @param data defines the data of the texture
  59830. * @param width defines the width of the texture
  59831. * @param height defines the height of the texture
  59832. * @param depth defines the number of layers of the texture
  59833. * @param format defines the texture format to use
  59834. * @param scene defines the hosting scene
  59835. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  59836. * @param invertY defines if texture must be stored with Y axis inverted
  59837. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  59838. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  59839. */
  59840. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  59841. /** Gets or sets the texture format to use */
  59842. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  59843. /**
  59844. * Update the texture with new data
  59845. * @param data defines the data to store in the texture
  59846. */
  59847. update(data: ArrayBufferView): void;
  59848. }
  59849. }
  59850. declare module "babylonjs/Materials/Textures/refractionTexture" {
  59851. import { Scene } from "babylonjs/scene";
  59852. import { Plane } from "babylonjs/Maths/math.plane";
  59853. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  59854. /**
  59855. * Creates a refraction texture used by refraction channel of the standard material.
  59856. * It is like a mirror but to see through a material.
  59857. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  59858. */
  59859. export class RefractionTexture extends RenderTargetTexture {
  59860. /**
  59861. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  59862. * 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.
  59863. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  59864. */
  59865. refractionPlane: Plane;
  59866. /**
  59867. * Define how deep under the surface we should see.
  59868. */
  59869. depth: number;
  59870. /**
  59871. * Creates a refraction texture used by refraction channel of the standard material.
  59872. * It is like a mirror but to see through a material.
  59873. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  59874. * @param name Define the texture name
  59875. * @param size Define the size of the underlying texture
  59876. * @param scene Define the scene the refraction belongs to
  59877. * @param generateMipMaps Define if we need to generate mips level for the refraction
  59878. */
  59879. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  59880. /**
  59881. * Clone the refraction texture.
  59882. * @returns the cloned texture
  59883. */
  59884. clone(): RefractionTexture;
  59885. /**
  59886. * Serialize the texture to a JSON representation you could use in Parse later on
  59887. * @returns the serialized JSON representation
  59888. */
  59889. serialize(): any;
  59890. }
  59891. }
  59892. declare module "babylonjs/Materials/Textures/htmlElementTexture" {
  59893. import { Nullable } from "babylonjs/types";
  59894. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  59895. import { Matrix } from "babylonjs/Maths/math.vector";
  59896. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  59897. import "babylonjs/Engines/Extensions/engine.videoTexture";
  59898. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  59899. import { Scene } from "babylonjs/scene";
  59900. /**
  59901. * Defines the options related to the creation of an HtmlElementTexture
  59902. */
  59903. export interface IHtmlElementTextureOptions {
  59904. /**
  59905. * Defines wether mip maps should be created or not.
  59906. */
  59907. generateMipMaps?: boolean;
  59908. /**
  59909. * Defines the sampling mode of the texture.
  59910. */
  59911. samplingMode?: number;
  59912. /**
  59913. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  59914. */
  59915. engine: Nullable<ThinEngine>;
  59916. /**
  59917. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  59918. */
  59919. scene: Nullable<Scene>;
  59920. }
  59921. /**
  59922. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  59923. * To be as efficient as possible depending on your constraints nothing aside the first upload
  59924. * is automatically managed.
  59925. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  59926. * in your application.
  59927. *
  59928. * As the update is not automatic, you need to call them manually.
  59929. */
  59930. export class HtmlElementTexture extends BaseTexture {
  59931. /**
  59932. * The texture URL.
  59933. */
  59934. element: HTMLVideoElement | HTMLCanvasElement;
  59935. private static readonly DefaultOptions;
  59936. private _textureMatrix;
  59937. private _isVideo;
  59938. private _generateMipMaps;
  59939. private _samplingMode;
  59940. /**
  59941. * Instantiates a HtmlElementTexture from the following parameters.
  59942. *
  59943. * @param name Defines the name of the texture
  59944. * @param element Defines the video or canvas the texture is filled with
  59945. * @param options Defines the other none mandatory texture creation options
  59946. */
  59947. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  59948. private _createInternalTexture;
  59949. /**
  59950. * Returns the texture matrix used in most of the material.
  59951. */
  59952. getTextureMatrix(): Matrix;
  59953. /**
  59954. * Updates the content of the texture.
  59955. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  59956. */
  59957. update(invertY?: Nullable<boolean>): void;
  59958. }
  59959. }
  59960. declare module "babylonjs/Materials/Textures/Packer/frame" {
  59961. import { Vector2 } from "babylonjs/Maths/math.vector";
  59962. /**
  59963. * Defines the basic options interface of a TexturePacker Frame
  59964. */
  59965. export interface ITexturePackerFrame {
  59966. /**
  59967. * The frame ID
  59968. */
  59969. id: number;
  59970. /**
  59971. * The frames Scale
  59972. */
  59973. scale: Vector2;
  59974. /**
  59975. * The Frames offset
  59976. */
  59977. offset: Vector2;
  59978. }
  59979. /**
  59980. * This is a support class for frame Data on texture packer sets.
  59981. */
  59982. export class TexturePackerFrame implements ITexturePackerFrame {
  59983. /**
  59984. * The frame ID
  59985. */
  59986. id: number;
  59987. /**
  59988. * The frames Scale
  59989. */
  59990. scale: Vector2;
  59991. /**
  59992. * The Frames offset
  59993. */
  59994. offset: Vector2;
  59995. /**
  59996. * Initializes a texture package frame.
  59997. * @param id The numerical frame identifier
  59998. * @param scale Scalar Vector2 for UV frame
  59999. * @param offset Vector2 for the frame position in UV units.
  60000. * @returns TexturePackerFrame
  60001. */
  60002. constructor(id: number, scale: Vector2, offset: Vector2);
  60003. }
  60004. }
  60005. declare module "babylonjs/Materials/Textures/Packer/packer" {
  60006. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60007. import { Scene } from "babylonjs/scene";
  60008. import { Nullable } from "babylonjs/types";
  60009. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  60010. import { TexturePackerFrame } from "babylonjs/Materials/Textures/Packer/frame";
  60011. /**
  60012. * Defines the basic options interface of a TexturePacker
  60013. */
  60014. export interface ITexturePackerOptions {
  60015. /**
  60016. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  60017. */
  60018. map?: string[];
  60019. /**
  60020. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  60021. */
  60022. uvsIn?: string;
  60023. /**
  60024. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  60025. */
  60026. uvsOut?: string;
  60027. /**
  60028. * number representing the layout style. Defaults to LAYOUT_STRIP
  60029. */
  60030. layout?: number;
  60031. /**
  60032. * number of columns if using custom column count layout(2). This defaults to 4.
  60033. */
  60034. colnum?: number;
  60035. /**
  60036. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  60037. */
  60038. updateInputMeshes?: boolean;
  60039. /**
  60040. * boolean flag to dispose all the source textures. Defaults to true.
  60041. */
  60042. disposeSources?: boolean;
  60043. /**
  60044. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  60045. */
  60046. fillBlanks?: boolean;
  60047. /**
  60048. * string value representing the context fill style color. Defaults to 'black'.
  60049. */
  60050. customFillColor?: string;
  60051. /**
  60052. * Width and Height Value of each Frame in the TexturePacker Sets
  60053. */
  60054. frameSize?: number;
  60055. /**
  60056. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  60057. */
  60058. paddingRatio?: number;
  60059. /**
  60060. * Number that declares the fill method for the padding gutter.
  60061. */
  60062. paddingMode?: number;
  60063. /**
  60064. * If in SUBUV_COLOR padding mode what color to use.
  60065. */
  60066. paddingColor?: Color3 | Color4;
  60067. }
  60068. /**
  60069. * Defines the basic interface of a TexturePacker JSON File
  60070. */
  60071. export interface ITexturePackerJSON {
  60072. /**
  60073. * The frame ID
  60074. */
  60075. name: string;
  60076. /**
  60077. * The base64 channel data
  60078. */
  60079. sets: any;
  60080. /**
  60081. * The options of the Packer
  60082. */
  60083. options: ITexturePackerOptions;
  60084. /**
  60085. * The frame data of the Packer
  60086. */
  60087. frames: Array<number>;
  60088. }
  60089. /**
  60090. * This is a support class that generates a series of packed texture sets.
  60091. * @see https://doc.babylonjs.com/babylon101/materials
  60092. */
  60093. export class TexturePacker {
  60094. /** Packer Layout Constant 0 */
  60095. static readonly LAYOUT_STRIP: number;
  60096. /** Packer Layout Constant 1 */
  60097. static readonly LAYOUT_POWER2: number;
  60098. /** Packer Layout Constant 2 */
  60099. static readonly LAYOUT_COLNUM: number;
  60100. /** Packer Layout Constant 0 */
  60101. static readonly SUBUV_WRAP: number;
  60102. /** Packer Layout Constant 1 */
  60103. static readonly SUBUV_EXTEND: number;
  60104. /** Packer Layout Constant 2 */
  60105. static readonly SUBUV_COLOR: number;
  60106. /** The Name of the Texture Package */
  60107. name: string;
  60108. /** The scene scope of the TexturePacker */
  60109. scene: Scene;
  60110. /** The Meshes to target */
  60111. meshes: AbstractMesh[];
  60112. /** Arguments passed with the Constructor */
  60113. options: ITexturePackerOptions;
  60114. /** The promise that is started upon initialization */
  60115. promise: Nullable<Promise<TexturePacker | string>>;
  60116. /** The Container object for the channel sets that are generated */
  60117. sets: object;
  60118. /** The Container array for the frames that are generated */
  60119. frames: TexturePackerFrame[];
  60120. /** The expected number of textures the system is parsing. */
  60121. private _expecting;
  60122. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  60123. private _paddingValue;
  60124. /**
  60125. * Initializes a texture package series from an array of meshes or a single mesh.
  60126. * @param name The name of the package
  60127. * @param meshes The target meshes to compose the package from
  60128. * @param options The arguments that texture packer should follow while building.
  60129. * @param scene The scene which the textures are scoped to.
  60130. * @returns TexturePacker
  60131. */
  60132. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  60133. /**
  60134. * Starts the package process
  60135. * @param resolve The promises resolution function
  60136. * @returns TexturePacker
  60137. */
  60138. private _createFrames;
  60139. /**
  60140. * Calculates the Size of the Channel Sets
  60141. * @returns Vector2
  60142. */
  60143. private _calculateSize;
  60144. /**
  60145. * Calculates the UV data for the frames.
  60146. * @param baseSize the base frameSize
  60147. * @param padding the base frame padding
  60148. * @param dtSize size of the Dynamic Texture for that channel
  60149. * @param dtUnits is 1/dtSize
  60150. * @param update flag to update the input meshes
  60151. */
  60152. private _calculateMeshUVFrames;
  60153. /**
  60154. * Calculates the frames Offset.
  60155. * @param index of the frame
  60156. * @returns Vector2
  60157. */
  60158. private _getFrameOffset;
  60159. /**
  60160. * Updates a Mesh to the frame data
  60161. * @param mesh that is the target
  60162. * @param frameID or the frame index
  60163. */
  60164. private _updateMeshUV;
  60165. /**
  60166. * Updates a Meshes materials to use the texture packer channels
  60167. * @param m is the mesh to target
  60168. * @param force all channels on the packer to be set.
  60169. */
  60170. private _updateTextureReferences;
  60171. /**
  60172. * Public method to set a Mesh to a frame
  60173. * @param m that is the target
  60174. * @param frameID or the frame index
  60175. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  60176. */
  60177. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  60178. /**
  60179. * Starts the async promise to compile the texture packer.
  60180. * @returns Promise<void>
  60181. */
  60182. processAsync(): Promise<void>;
  60183. /**
  60184. * Disposes all textures associated with this packer
  60185. */
  60186. dispose(): void;
  60187. /**
  60188. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  60189. * @param imageType is the image type to use.
  60190. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  60191. */
  60192. download(imageType?: string, quality?: number): void;
  60193. /**
  60194. * Public method to load a texturePacker JSON file.
  60195. * @param data of the JSON file in string format.
  60196. */
  60197. updateFromJSON(data: string): void;
  60198. }
  60199. }
  60200. declare module "babylonjs/Materials/Textures/Packer/index" {
  60201. export * from "babylonjs/Materials/Textures/Packer/packer";
  60202. export * from "babylonjs/Materials/Textures/Packer/frame";
  60203. }
  60204. declare module "babylonjs/Materials/Textures/index" {
  60205. export * from "babylonjs/Materials/Textures/baseTexture";
  60206. export * from "babylonjs/Materials/Textures/baseTexture.polynomial";
  60207. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  60208. export * from "babylonjs/Materials/Textures/cubeTexture";
  60209. export * from "babylonjs/Materials/Textures/dynamicTexture";
  60210. export * from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  60211. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  60212. export * from "babylonjs/Materials/Textures/internalTexture";
  60213. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  60214. export * from "babylonjs/Materials/Textures/Loaders/index";
  60215. export * from "babylonjs/Materials/Textures/mirrorTexture";
  60216. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  60217. export * from "babylonjs/Materials/Textures/Procedurals/index";
  60218. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  60219. export * from "babylonjs/Materials/Textures/rawTexture";
  60220. export * from "babylonjs/Materials/Textures/rawTexture3D";
  60221. export * from "babylonjs/Materials/Textures/rawTexture2DArray";
  60222. export * from "babylonjs/Materials/Textures/refractionTexture";
  60223. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  60224. export * from "babylonjs/Materials/Textures/texture";
  60225. export * from "babylonjs/Materials/Textures/videoTexture";
  60226. export * from "babylonjs/Materials/Textures/htmlElementTexture";
  60227. export * from "babylonjs/Materials/Textures/Packer/index";
  60228. }
  60229. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets" {
  60230. /**
  60231. * Enum used to define the target of a block
  60232. */
  60233. export enum NodeMaterialBlockTargets {
  60234. /** Vertex shader */
  60235. Vertex = 1,
  60236. /** Fragment shader */
  60237. Fragment = 2,
  60238. /** Neutral */
  60239. Neutral = 4,
  60240. /** Vertex and Fragment */
  60241. VertexAndFragment = 3
  60242. }
  60243. }
  60244. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes" {
  60245. /**
  60246. * Defines the kind of connection point for node based material
  60247. */
  60248. export enum NodeMaterialBlockConnectionPointTypes {
  60249. /** Float */
  60250. Float = 1,
  60251. /** Int */
  60252. Int = 2,
  60253. /** Vector2 */
  60254. Vector2 = 4,
  60255. /** Vector3 */
  60256. Vector3 = 8,
  60257. /** Vector4 */
  60258. Vector4 = 16,
  60259. /** Color3 */
  60260. Color3 = 32,
  60261. /** Color4 */
  60262. Color4 = 64,
  60263. /** Matrix */
  60264. Matrix = 128,
  60265. /** Custom object */
  60266. Object = 256,
  60267. /** Detect type based on connection */
  60268. AutoDetect = 1024,
  60269. /** Output type that will be defined by input type */
  60270. BasedOnInput = 2048
  60271. }
  60272. }
  60273. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode" {
  60274. /**
  60275. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  60276. */
  60277. export enum NodeMaterialBlockConnectionPointMode {
  60278. /** Value is an uniform */
  60279. Uniform = 0,
  60280. /** Value is a mesh attribute */
  60281. Attribute = 1,
  60282. /** Value is a varying between vertex and fragment shaders */
  60283. Varying = 2,
  60284. /** Mode is undefined */
  60285. Undefined = 3
  60286. }
  60287. }
  60288. declare module "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues" {
  60289. /**
  60290. * Enum used to define system values e.g. values automatically provided by the system
  60291. */
  60292. export enum NodeMaterialSystemValues {
  60293. /** World */
  60294. World = 1,
  60295. /** View */
  60296. View = 2,
  60297. /** Projection */
  60298. Projection = 3,
  60299. /** ViewProjection */
  60300. ViewProjection = 4,
  60301. /** WorldView */
  60302. WorldView = 5,
  60303. /** WorldViewProjection */
  60304. WorldViewProjection = 6,
  60305. /** CameraPosition */
  60306. CameraPosition = 7,
  60307. /** Fog Color */
  60308. FogColor = 8,
  60309. /** Delta time */
  60310. DeltaTime = 9
  60311. }
  60312. }
  60313. declare module "babylonjs/Materials/Node/Enums/nodeMaterialModes" {
  60314. /**
  60315. * Enum used to define the material modes
  60316. */
  60317. export enum NodeMaterialModes {
  60318. /** Regular material */
  60319. Material = 0,
  60320. /** For post process */
  60321. PostProcess = 1
  60322. }
  60323. }
  60324. declare module "babylonjs/Materials/Node/Enums/index" {
  60325. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  60326. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  60327. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode";
  60328. export * from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  60329. export * from "babylonjs/Materials/Node/Enums/nodeMaterialModes";
  60330. }
  60331. declare module "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer" {
  60332. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60333. /**
  60334. * Root class for all node material optimizers
  60335. */
  60336. export class NodeMaterialOptimizer {
  60337. /**
  60338. * Function used to optimize a NodeMaterial graph
  60339. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  60340. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  60341. */
  60342. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  60343. }
  60344. }
  60345. declare module "babylonjs/Materials/Node/Blocks/transformBlock" {
  60346. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60347. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60348. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60349. import { Scene } from "babylonjs/scene";
  60350. /**
  60351. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  60352. */
  60353. export class TransformBlock extends NodeMaterialBlock {
  60354. /**
  60355. * Defines the value to use to complement W value to transform it to a Vector4
  60356. */
  60357. complementW: number;
  60358. /**
  60359. * Defines the value to use to complement z value to transform it to a Vector4
  60360. */
  60361. complementZ: number;
  60362. /**
  60363. * Creates a new TransformBlock
  60364. * @param name defines the block name
  60365. */
  60366. constructor(name: string);
  60367. /**
  60368. * Gets the current class name
  60369. * @returns the class name
  60370. */
  60371. getClassName(): string;
  60372. /**
  60373. * Gets the vector input
  60374. */
  60375. get vector(): NodeMaterialConnectionPoint;
  60376. /**
  60377. * Gets the output component
  60378. */
  60379. get output(): NodeMaterialConnectionPoint;
  60380. /**
  60381. * Gets the xyz output component
  60382. */
  60383. get xyz(): NodeMaterialConnectionPoint;
  60384. /**
  60385. * Gets the matrix transform input
  60386. */
  60387. get transform(): NodeMaterialConnectionPoint;
  60388. protected _buildBlock(state: NodeMaterialBuildState): this;
  60389. serialize(): any;
  60390. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60391. protected _dumpPropertiesCode(): string;
  60392. }
  60393. }
  60394. declare module "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock" {
  60395. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60396. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60397. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60398. /**
  60399. * Block used to output the vertex position
  60400. */
  60401. export class VertexOutputBlock extends NodeMaterialBlock {
  60402. /**
  60403. * Creates a new VertexOutputBlock
  60404. * @param name defines the block name
  60405. */
  60406. constructor(name: string);
  60407. /**
  60408. * Gets the current class name
  60409. * @returns the class name
  60410. */
  60411. getClassName(): string;
  60412. /**
  60413. * Gets the vector input component
  60414. */
  60415. get vector(): NodeMaterialConnectionPoint;
  60416. protected _buildBlock(state: NodeMaterialBuildState): this;
  60417. }
  60418. }
  60419. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock" {
  60420. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60421. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60422. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60423. /**
  60424. * Block used to output the final color
  60425. */
  60426. export class FragmentOutputBlock extends NodeMaterialBlock {
  60427. /**
  60428. * Create a new FragmentOutputBlock
  60429. * @param name defines the block name
  60430. */
  60431. constructor(name: string);
  60432. /**
  60433. * Gets the current class name
  60434. * @returns the class name
  60435. */
  60436. getClassName(): string;
  60437. /**
  60438. * Gets the rgba input component
  60439. */
  60440. get rgba(): NodeMaterialConnectionPoint;
  60441. /**
  60442. * Gets the rgb input component
  60443. */
  60444. get rgb(): NodeMaterialConnectionPoint;
  60445. /**
  60446. * Gets the a input component
  60447. */
  60448. get a(): NodeMaterialConnectionPoint;
  60449. protected _buildBlock(state: NodeMaterialBuildState): this;
  60450. }
  60451. }
  60452. declare module "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock" {
  60453. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60454. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60455. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60456. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  60457. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60458. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  60459. import { Effect } from "babylonjs/Materials/effect";
  60460. import { Mesh } from "babylonjs/Meshes/mesh";
  60461. import { Nullable } from "babylonjs/types";
  60462. import { Scene } from "babylonjs/scene";
  60463. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  60464. /**
  60465. * Base block used to read a reflection texture from a sampler
  60466. */
  60467. export abstract class ReflectionTextureBaseBlock extends NodeMaterialBlock {
  60468. /** @hidden */
  60469. _define3DName: string;
  60470. /** @hidden */
  60471. _defineCubicName: string;
  60472. /** @hidden */
  60473. _defineExplicitName: string;
  60474. /** @hidden */
  60475. _defineProjectionName: string;
  60476. /** @hidden */
  60477. _defineLocalCubicName: string;
  60478. /** @hidden */
  60479. _defineSphericalName: string;
  60480. /** @hidden */
  60481. _definePlanarName: string;
  60482. /** @hidden */
  60483. _defineEquirectangularName: string;
  60484. /** @hidden */
  60485. _defineMirroredEquirectangularFixedName: string;
  60486. /** @hidden */
  60487. _defineEquirectangularFixedName: string;
  60488. /** @hidden */
  60489. _defineSkyboxName: string;
  60490. /** @hidden */
  60491. _defineOppositeZ: string;
  60492. /** @hidden */
  60493. _cubeSamplerName: string;
  60494. /** @hidden */
  60495. _2DSamplerName: string;
  60496. protected _positionUVWName: string;
  60497. protected _directionWName: string;
  60498. protected _reflectionVectorName: string;
  60499. /** @hidden */
  60500. _reflectionCoordsName: string;
  60501. /** @hidden */
  60502. _reflectionMatrixName: string;
  60503. protected _reflectionColorName: string;
  60504. /**
  60505. * Gets or sets the texture associated with the node
  60506. */
  60507. texture: Nullable<BaseTexture>;
  60508. /**
  60509. * Create a new ReflectionTextureBaseBlock
  60510. * @param name defines the block name
  60511. */
  60512. constructor(name: string);
  60513. /**
  60514. * Gets the current class name
  60515. * @returns the class name
  60516. */
  60517. getClassName(): string;
  60518. /**
  60519. * Gets the world position input component
  60520. */
  60521. abstract get position(): NodeMaterialConnectionPoint;
  60522. /**
  60523. * Gets the world position input component
  60524. */
  60525. abstract get worldPosition(): NodeMaterialConnectionPoint;
  60526. /**
  60527. * Gets the world normal input component
  60528. */
  60529. abstract get worldNormal(): NodeMaterialConnectionPoint;
  60530. /**
  60531. * Gets the world input component
  60532. */
  60533. abstract get world(): NodeMaterialConnectionPoint;
  60534. /**
  60535. * Gets the camera (or eye) position component
  60536. */
  60537. abstract get cameraPosition(): NodeMaterialConnectionPoint;
  60538. /**
  60539. * Gets the view input component
  60540. */
  60541. abstract get view(): NodeMaterialConnectionPoint;
  60542. protected _getTexture(): Nullable<BaseTexture>;
  60543. autoConfigure(material: NodeMaterial): void;
  60544. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  60545. isReady(): boolean;
  60546. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  60547. /**
  60548. * Gets the code to inject in the vertex shader
  60549. * @param state current state of the node material building
  60550. * @returns the shader code
  60551. */
  60552. handleVertexSide(state: NodeMaterialBuildState): string;
  60553. /**
  60554. * Handles the inits for the fragment code path
  60555. * @param state node material build state
  60556. */
  60557. handleFragmentSideInits(state: NodeMaterialBuildState): void;
  60558. /**
  60559. * Generates the reflection coords code for the fragment code path
  60560. * @param worldNormalVarName name of the world normal variable
  60561. * @param worldPos name of the world position variable. If not provided, will use the world position connected to this block
  60562. * @param onlyReflectionVector if true, generates code only for the reflection vector computation, not for the reflection coordinates
  60563. * @returns the shader code
  60564. */
  60565. handleFragmentSideCodeReflectionCoords(worldNormalVarName: string, worldPos?: string, onlyReflectionVector?: boolean): string;
  60566. /**
  60567. * Generates the reflection color code for the fragment code path
  60568. * @param lodVarName name of the lod variable
  60569. * @param swizzleLookupTexture swizzle to use for the final color variable
  60570. * @returns the shader code
  60571. */
  60572. handleFragmentSideCodeReflectionColor(lodVarName?: string, swizzleLookupTexture?: string): string;
  60573. /**
  60574. * Generates the code corresponding to the connected output points
  60575. * @param state node material build state
  60576. * @param varName name of the variable to output
  60577. * @returns the shader code
  60578. */
  60579. writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  60580. protected _buildBlock(state: NodeMaterialBuildState): this;
  60581. protected _dumpPropertiesCode(): string;
  60582. serialize(): any;
  60583. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60584. }
  60585. }
  60586. declare module "babylonjs/Materials/Node/nodeMaterialConnectionPointCustomObject" {
  60587. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60588. import { NodeMaterialConnectionPoint, NodeMaterialConnectionPointDirection, NodeMaterialConnectionPointCompatibilityStates } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60589. import { Nullable } from "babylonjs/types";
  60590. /**
  60591. * Defines a connection point to be used for points with a custom object type
  60592. */
  60593. export class NodeMaterialConnectionPointCustomObject<T extends NodeMaterialBlock> extends NodeMaterialConnectionPoint {
  60594. private _blockType;
  60595. private _blockName;
  60596. private _nameForCheking?;
  60597. /**
  60598. * Creates a new connection point
  60599. * @param name defines the connection point name
  60600. * @param ownerBlock defines the block hosting this connection point
  60601. * @param direction defines the direction of the connection point
  60602. */
  60603. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection, _blockType: new (...args: any[]) => T, _blockName: string, _nameForCheking?: string | undefined);
  60604. /**
  60605. * Gets a number indicating if the current point can be connected to another point
  60606. * @param connectionPoint defines the other connection point
  60607. * @returns a number defining the compatibility state
  60608. */
  60609. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  60610. /**
  60611. * Creates a block suitable to be used as an input for this input point.
  60612. * If null is returned, a block based on the point type will be created.
  60613. * @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
  60614. */
  60615. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  60616. }
  60617. }
  60618. declare module "babylonjs/Materials/Node/nodeMaterialDecorator" {
  60619. /**
  60620. * Enum defining the type of properties that can be edited in the property pages in the NME
  60621. */
  60622. export enum PropertyTypeForEdition {
  60623. /** property is a boolean */
  60624. Boolean = 0,
  60625. /** property is a float */
  60626. Float = 1,
  60627. /** property is a Vector2 */
  60628. Vector2 = 2,
  60629. /** property is a list of values */
  60630. List = 3
  60631. }
  60632. /**
  60633. * Interface that defines an option in a variable of type list
  60634. */
  60635. export interface IEditablePropertyListOption {
  60636. /** label of the option */
  60637. "label": string;
  60638. /** value of the option */
  60639. "value": number;
  60640. }
  60641. /**
  60642. * Interface that defines the options available for an editable property
  60643. */
  60644. export interface IEditablePropertyOption {
  60645. /** min value */
  60646. "min"?: number;
  60647. /** max value */
  60648. "max"?: number;
  60649. /** notifiers: indicates which actions to take when the property is changed */
  60650. "notifiers"?: {
  60651. /** the material should be rebuilt */
  60652. "rebuild"?: boolean;
  60653. /** the preview should be updated */
  60654. "update"?: boolean;
  60655. };
  60656. /** list of the options for a variable of type list */
  60657. "options"?: IEditablePropertyListOption[];
  60658. }
  60659. /**
  60660. * Interface that describes an editable property
  60661. */
  60662. export interface IPropertyDescriptionForEdition {
  60663. /** name of the property */
  60664. "propertyName": string;
  60665. /** display name of the property */
  60666. "displayName": string;
  60667. /** type of the property */
  60668. "type": PropertyTypeForEdition;
  60669. /** group of the property - all properties with the same group value will be displayed in a specific section */
  60670. "groupName": string;
  60671. /** options for the property */
  60672. "options": IEditablePropertyOption;
  60673. }
  60674. /**
  60675. * Decorator that flags a property in a node material block as being editable
  60676. */
  60677. export function editableInPropertyPage(displayName: string, propertyType?: PropertyTypeForEdition, groupName?: string, options?: IEditablePropertyOption): (target: any, propertyKey: string) => void;
  60678. }
  60679. declare module "babylonjs/Materials/Node/Blocks/PBR/refractionBlock" {
  60680. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60681. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60682. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  60683. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60684. import { Nullable } from "babylonjs/types";
  60685. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  60686. import { Mesh } from "babylonjs/Meshes/mesh";
  60687. import { SubMesh } from "babylonjs/Meshes/subMesh";
  60688. import { Effect } from "babylonjs/Materials/effect";
  60689. import { Scene } from "babylonjs/scene";
  60690. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60691. /**
  60692. * Block used to implement the refraction part of the sub surface module of the PBR material
  60693. */
  60694. export class RefractionBlock extends NodeMaterialBlock {
  60695. /** @hidden */
  60696. _define3DName: string;
  60697. /** @hidden */
  60698. _refractionMatrixName: string;
  60699. /** @hidden */
  60700. _defineLODRefractionAlpha: string;
  60701. /** @hidden */
  60702. _defineLinearSpecularRefraction: string;
  60703. /** @hidden */
  60704. _defineOppositeZ: string;
  60705. /** @hidden */
  60706. _cubeSamplerName: string;
  60707. /** @hidden */
  60708. _2DSamplerName: string;
  60709. /** @hidden */
  60710. _vRefractionMicrosurfaceInfosName: string;
  60711. /** @hidden */
  60712. _vRefractionInfosName: string;
  60713. private _scene;
  60714. /**
  60715. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  60716. * Materials half opaque for instance using refraction could benefit from this control.
  60717. */
  60718. linkRefractionWithTransparency: boolean;
  60719. /**
  60720. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  60721. */
  60722. invertRefractionY: boolean;
  60723. /**
  60724. * Gets or sets the texture associated with the node
  60725. */
  60726. texture: Nullable<BaseTexture>;
  60727. /**
  60728. * Create a new RefractionBlock
  60729. * @param name defines the block name
  60730. */
  60731. constructor(name: string);
  60732. /**
  60733. * Gets the current class name
  60734. * @returns the class name
  60735. */
  60736. getClassName(): string;
  60737. /**
  60738. * Gets the intensity input component
  60739. */
  60740. get intensity(): NodeMaterialConnectionPoint;
  60741. /**
  60742. * Gets the index of refraction input component
  60743. */
  60744. get indexOfRefraction(): NodeMaterialConnectionPoint;
  60745. /**
  60746. * Gets the tint at distance input component
  60747. */
  60748. get tintAtDistance(): NodeMaterialConnectionPoint;
  60749. /**
  60750. * Gets the view input component
  60751. */
  60752. get view(): NodeMaterialConnectionPoint;
  60753. /**
  60754. * Gets the refraction object output component
  60755. */
  60756. get refraction(): NodeMaterialConnectionPoint;
  60757. /**
  60758. * Returns true if the block has a texture
  60759. */
  60760. get hasTexture(): boolean;
  60761. protected _getTexture(): Nullable<BaseTexture>;
  60762. autoConfigure(material: NodeMaterial): void;
  60763. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  60764. isReady(): boolean;
  60765. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  60766. /**
  60767. * Gets the main code of the block (fragment side)
  60768. * @param state current state of the node material building
  60769. * @returns the shader code
  60770. */
  60771. getCode(state: NodeMaterialBuildState): string;
  60772. protected _buildBlock(state: NodeMaterialBuildState): this;
  60773. protected _dumpPropertiesCode(): string;
  60774. serialize(): any;
  60775. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60776. }
  60777. }
  60778. declare module "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock" {
  60779. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60780. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60781. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  60782. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60783. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60784. import { NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  60785. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  60786. import { Nullable } from "babylonjs/types";
  60787. import { Scene } from "babylonjs/scene";
  60788. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  60789. /**
  60790. * Base block used as input for post process
  60791. */
  60792. export class CurrentScreenBlock extends NodeMaterialBlock {
  60793. private _samplerName;
  60794. private _linearDefineName;
  60795. private _gammaDefineName;
  60796. private _mainUVName;
  60797. private _tempTextureRead;
  60798. /**
  60799. * Gets or sets the texture associated with the node
  60800. */
  60801. texture: Nullable<BaseTexture>;
  60802. /**
  60803. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  60804. */
  60805. convertToGammaSpace: boolean;
  60806. /**
  60807. * Gets or sets a boolean indicating if content needs to be converted to linear space
  60808. */
  60809. convertToLinearSpace: boolean;
  60810. /**
  60811. * Create a new CurrentScreenBlock
  60812. * @param name defines the block name
  60813. */
  60814. constructor(name: string);
  60815. /**
  60816. * Gets the current class name
  60817. * @returns the class name
  60818. */
  60819. getClassName(): string;
  60820. /**
  60821. * Gets the uv input component
  60822. */
  60823. get uv(): NodeMaterialConnectionPoint;
  60824. /**
  60825. * Gets the rgba output component
  60826. */
  60827. get rgba(): NodeMaterialConnectionPoint;
  60828. /**
  60829. * Gets the rgb output component
  60830. */
  60831. get rgb(): NodeMaterialConnectionPoint;
  60832. /**
  60833. * Gets the r output component
  60834. */
  60835. get r(): NodeMaterialConnectionPoint;
  60836. /**
  60837. * Gets the g output component
  60838. */
  60839. get g(): NodeMaterialConnectionPoint;
  60840. /**
  60841. * Gets the b output component
  60842. */
  60843. get b(): NodeMaterialConnectionPoint;
  60844. /**
  60845. * Gets the a output component
  60846. */
  60847. get a(): NodeMaterialConnectionPoint;
  60848. /**
  60849. * Initialize the block and prepare the context for build
  60850. * @param state defines the state that will be used for the build
  60851. */
  60852. initialize(state: NodeMaterialBuildState): void;
  60853. get target(): NodeMaterialBlockTargets;
  60854. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  60855. isReady(): boolean;
  60856. private _injectVertexCode;
  60857. private _writeTextureRead;
  60858. private _writeOutput;
  60859. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  60860. serialize(): any;
  60861. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60862. }
  60863. }
  60864. declare module "babylonjs/Materials/Node/Blocks/vectorMergerBlock" {
  60865. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60866. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60867. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60868. /**
  60869. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  60870. */
  60871. export class VectorMergerBlock extends NodeMaterialBlock {
  60872. /**
  60873. * Create a new VectorMergerBlock
  60874. * @param name defines the block name
  60875. */
  60876. constructor(name: string);
  60877. /**
  60878. * Gets the current class name
  60879. * @returns the class name
  60880. */
  60881. getClassName(): string;
  60882. /**
  60883. * Gets the xyz component (input)
  60884. */
  60885. get xyzIn(): NodeMaterialConnectionPoint;
  60886. /**
  60887. * Gets the xy component (input)
  60888. */
  60889. get xyIn(): NodeMaterialConnectionPoint;
  60890. /**
  60891. * Gets the x component (input)
  60892. */
  60893. get x(): NodeMaterialConnectionPoint;
  60894. /**
  60895. * Gets the y component (input)
  60896. */
  60897. get y(): NodeMaterialConnectionPoint;
  60898. /**
  60899. * Gets the z component (input)
  60900. */
  60901. get z(): NodeMaterialConnectionPoint;
  60902. /**
  60903. * Gets the w component (input)
  60904. */
  60905. get w(): NodeMaterialConnectionPoint;
  60906. /**
  60907. * Gets the xyzw component (output)
  60908. */
  60909. get xyzw(): NodeMaterialConnectionPoint;
  60910. /**
  60911. * Gets the xyz component (output)
  60912. */
  60913. get xyzOut(): NodeMaterialConnectionPoint;
  60914. /**
  60915. * Gets the xy component (output)
  60916. */
  60917. get xyOut(): NodeMaterialConnectionPoint;
  60918. /**
  60919. * Gets the xy component (output)
  60920. * @deprecated Please use xyOut instead.
  60921. */
  60922. get xy(): NodeMaterialConnectionPoint;
  60923. /**
  60924. * Gets the xyz component (output)
  60925. * @deprecated Please use xyzOut instead.
  60926. */
  60927. get xyz(): NodeMaterialConnectionPoint;
  60928. protected _buildBlock(state: NodeMaterialBuildState): this;
  60929. }
  60930. }
  60931. declare module "babylonjs/Materials/Node/Blocks/remapBlock" {
  60932. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60933. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60934. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60935. import { Vector2 } from "babylonjs/Maths/math.vector";
  60936. import { Scene } from "babylonjs/scene";
  60937. /**
  60938. * Block used to remap a float from a range to a new one
  60939. */
  60940. export class RemapBlock extends NodeMaterialBlock {
  60941. /**
  60942. * Gets or sets the source range
  60943. */
  60944. sourceRange: Vector2;
  60945. /**
  60946. * Gets or sets the target range
  60947. */
  60948. targetRange: Vector2;
  60949. /**
  60950. * Creates a new RemapBlock
  60951. * @param name defines the block name
  60952. */
  60953. constructor(name: string);
  60954. /**
  60955. * Gets the current class name
  60956. * @returns the class name
  60957. */
  60958. getClassName(): string;
  60959. /**
  60960. * Gets the input component
  60961. */
  60962. get input(): NodeMaterialConnectionPoint;
  60963. /**
  60964. * Gets the source min input component
  60965. */
  60966. get sourceMin(): NodeMaterialConnectionPoint;
  60967. /**
  60968. * Gets the source max input component
  60969. */
  60970. get sourceMax(): NodeMaterialConnectionPoint;
  60971. /**
  60972. * Gets the target min input component
  60973. */
  60974. get targetMin(): NodeMaterialConnectionPoint;
  60975. /**
  60976. * Gets the target max input component
  60977. */
  60978. get targetMax(): NodeMaterialConnectionPoint;
  60979. /**
  60980. * Gets the output component
  60981. */
  60982. get output(): NodeMaterialConnectionPoint;
  60983. protected _buildBlock(state: NodeMaterialBuildState): this;
  60984. protected _dumpPropertiesCode(): string;
  60985. serialize(): any;
  60986. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60987. }
  60988. }
  60989. declare module "babylonjs/Materials/Node/Blocks/multiplyBlock" {
  60990. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60991. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60992. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60993. /**
  60994. * Block used to multiply 2 values
  60995. */
  60996. export class MultiplyBlock extends NodeMaterialBlock {
  60997. /**
  60998. * Creates a new MultiplyBlock
  60999. * @param name defines the block name
  61000. */
  61001. constructor(name: string);
  61002. /**
  61003. * Gets the current class name
  61004. * @returns the class name
  61005. */
  61006. getClassName(): string;
  61007. /**
  61008. * Gets the left operand input component
  61009. */
  61010. get left(): NodeMaterialConnectionPoint;
  61011. /**
  61012. * Gets the right operand input component
  61013. */
  61014. get right(): NodeMaterialConnectionPoint;
  61015. /**
  61016. * Gets the output component
  61017. */
  61018. get output(): NodeMaterialConnectionPoint;
  61019. protected _buildBlock(state: NodeMaterialBuildState): this;
  61020. }
  61021. }
  61022. declare module "babylonjs/Materials/Node/nodeMaterial" {
  61023. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61024. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  61025. import { Scene } from "babylonjs/scene";
  61026. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61027. import { Matrix } from "babylonjs/Maths/math.vector";
  61028. import { Mesh } from "babylonjs/Meshes/mesh";
  61029. import { Engine } from "babylonjs/Engines/engine";
  61030. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  61031. import { Observable } from "babylonjs/Misc/observable";
  61032. import { SubMesh } from "babylonjs/Meshes/subMesh";
  61033. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  61034. import { NodeMaterialOptimizer } from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  61035. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  61036. import { Nullable } from "babylonjs/types";
  61037. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  61038. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  61039. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  61040. import { RefractionBlock } from "babylonjs/Materials/Node/Blocks/PBR/refractionBlock";
  61041. import { CurrentScreenBlock } from "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock";
  61042. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  61043. import { Camera } from "babylonjs/Cameras/camera";
  61044. import { NodeMaterialModes } from "babylonjs/Materials/Node/Enums/nodeMaterialModes";
  61045. /**
  61046. * Interface used to configure the node material editor
  61047. */
  61048. export interface INodeMaterialEditorOptions {
  61049. /** Define the URl to load node editor script */
  61050. editorURL?: string;
  61051. }
  61052. /** @hidden */
  61053. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  61054. NORMAL: boolean;
  61055. TANGENT: boolean;
  61056. UV1: boolean;
  61057. /** BONES */
  61058. NUM_BONE_INFLUENCERS: number;
  61059. BonesPerMesh: number;
  61060. BONETEXTURE: boolean;
  61061. /** MORPH TARGETS */
  61062. MORPHTARGETS: boolean;
  61063. MORPHTARGETS_NORMAL: boolean;
  61064. MORPHTARGETS_TANGENT: boolean;
  61065. MORPHTARGETS_UV: boolean;
  61066. NUM_MORPH_INFLUENCERS: number;
  61067. /** IMAGE PROCESSING */
  61068. IMAGEPROCESSING: boolean;
  61069. VIGNETTE: boolean;
  61070. VIGNETTEBLENDMODEMULTIPLY: boolean;
  61071. VIGNETTEBLENDMODEOPAQUE: boolean;
  61072. TONEMAPPING: boolean;
  61073. TONEMAPPING_ACES: boolean;
  61074. CONTRAST: boolean;
  61075. EXPOSURE: boolean;
  61076. COLORCURVES: boolean;
  61077. COLORGRADING: boolean;
  61078. COLORGRADING3D: boolean;
  61079. SAMPLER3DGREENDEPTH: boolean;
  61080. SAMPLER3DBGRMAP: boolean;
  61081. IMAGEPROCESSINGPOSTPROCESS: boolean;
  61082. /** MISC. */
  61083. BUMPDIRECTUV: number;
  61084. constructor();
  61085. setValue(name: string, value: any, markAsUnprocessedIfDirty?: boolean): void;
  61086. }
  61087. /**
  61088. * Class used to configure NodeMaterial
  61089. */
  61090. export interface INodeMaterialOptions {
  61091. /**
  61092. * Defines if blocks should emit comments
  61093. */
  61094. emitComments: boolean;
  61095. }
  61096. /**
  61097. * Class used to create a node based material built by assembling shader blocks
  61098. */
  61099. export class NodeMaterial extends PushMaterial {
  61100. private static _BuildIdGenerator;
  61101. private _options;
  61102. private _vertexCompilationState;
  61103. private _fragmentCompilationState;
  61104. private _sharedData;
  61105. private _buildId;
  61106. private _buildWasSuccessful;
  61107. private _cachedWorldViewMatrix;
  61108. private _cachedWorldViewProjectionMatrix;
  61109. private _optimizers;
  61110. private _animationFrame;
  61111. /** Define the Url to load node editor script */
  61112. static EditorURL: string;
  61113. /** Define the Url to load snippets */
  61114. static SnippetUrl: string;
  61115. /** Gets or sets a boolean indicating that node materials should not deserialize textures from json / snippet content */
  61116. static IgnoreTexturesAtLoadTime: boolean;
  61117. private BJSNODEMATERIALEDITOR;
  61118. /** Get the inspector from bundle or global */
  61119. private _getGlobalNodeMaterialEditor;
  61120. /**
  61121. * Snippet ID if the material was created from the snippet server
  61122. */
  61123. snippetId: string;
  61124. /**
  61125. * Gets or sets data used by visual editor
  61126. * @see https://nme.babylonjs.com
  61127. */
  61128. editorData: any;
  61129. /**
  61130. * 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)
  61131. */
  61132. ignoreAlpha: boolean;
  61133. /**
  61134. * Defines the maximum number of lights that can be used in the material
  61135. */
  61136. maxSimultaneousLights: number;
  61137. /**
  61138. * Observable raised when the material is built
  61139. */
  61140. onBuildObservable: Observable<NodeMaterial>;
  61141. /**
  61142. * Gets or sets the root nodes of the material vertex shader
  61143. */
  61144. _vertexOutputNodes: NodeMaterialBlock[];
  61145. /**
  61146. * Gets or sets the root nodes of the material fragment (pixel) shader
  61147. */
  61148. _fragmentOutputNodes: NodeMaterialBlock[];
  61149. /** Gets or sets options to control the node material overall behavior */
  61150. get options(): INodeMaterialOptions;
  61151. set options(options: INodeMaterialOptions);
  61152. /**
  61153. * Default configuration related to image processing available in the standard Material.
  61154. */
  61155. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  61156. /**
  61157. * Gets the image processing configuration used either in this material.
  61158. */
  61159. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  61160. /**
  61161. * Sets the Default image processing configuration used either in the this material.
  61162. *
  61163. * If sets to null, the scene one is in use.
  61164. */
  61165. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  61166. /**
  61167. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  61168. */
  61169. attachedBlocks: NodeMaterialBlock[];
  61170. /**
  61171. * Specifies the mode of the node material
  61172. * @hidden
  61173. */
  61174. _mode: NodeMaterialModes;
  61175. /**
  61176. * Gets the mode property
  61177. */
  61178. get mode(): NodeMaterialModes;
  61179. /**
  61180. * Create a new node based material
  61181. * @param name defines the material name
  61182. * @param scene defines the hosting scene
  61183. * @param options defines creation option
  61184. */
  61185. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  61186. /**
  61187. * Gets the current class name of the material e.g. "NodeMaterial"
  61188. * @returns the class name
  61189. */
  61190. getClassName(): string;
  61191. /**
  61192. * Keep track of the image processing observer to allow dispose and replace.
  61193. */
  61194. private _imageProcessingObserver;
  61195. /**
  61196. * Attaches a new image processing configuration to the Standard Material.
  61197. * @param configuration
  61198. */
  61199. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  61200. /**
  61201. * Get a block by its name
  61202. * @param name defines the name of the block to retrieve
  61203. * @returns the required block or null if not found
  61204. */
  61205. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  61206. /**
  61207. * Get a block by its name
  61208. * @param predicate defines the predicate used to find the good candidate
  61209. * @returns the required block or null if not found
  61210. */
  61211. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  61212. /**
  61213. * Get an input block by its name
  61214. * @param predicate defines the predicate used to find the good candidate
  61215. * @returns the required input block or null if not found
  61216. */
  61217. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  61218. /**
  61219. * Gets the list of input blocks attached to this material
  61220. * @returns an array of InputBlocks
  61221. */
  61222. getInputBlocks(): InputBlock[];
  61223. /**
  61224. * Adds a new optimizer to the list of optimizers
  61225. * @param optimizer defines the optimizers to add
  61226. * @returns the current material
  61227. */
  61228. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  61229. /**
  61230. * Remove an optimizer from the list of optimizers
  61231. * @param optimizer defines the optimizers to remove
  61232. * @returns the current material
  61233. */
  61234. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  61235. /**
  61236. * Add a new block to the list of output nodes
  61237. * @param node defines the node to add
  61238. * @returns the current material
  61239. */
  61240. addOutputNode(node: NodeMaterialBlock): this;
  61241. /**
  61242. * Remove a block from the list of root nodes
  61243. * @param node defines the node to remove
  61244. * @returns the current material
  61245. */
  61246. removeOutputNode(node: NodeMaterialBlock): this;
  61247. private _addVertexOutputNode;
  61248. private _removeVertexOutputNode;
  61249. private _addFragmentOutputNode;
  61250. private _removeFragmentOutputNode;
  61251. /**
  61252. * Specifies if the material will require alpha blending
  61253. * @returns a boolean specifying if alpha blending is needed
  61254. */
  61255. needAlphaBlending(): boolean;
  61256. /**
  61257. * Specifies if this material should be rendered in alpha test mode
  61258. * @returns a boolean specifying if an alpha test is needed.
  61259. */
  61260. needAlphaTesting(): boolean;
  61261. private _initializeBlock;
  61262. private _resetDualBlocks;
  61263. /**
  61264. * Remove a block from the current node material
  61265. * @param block defines the block to remove
  61266. */
  61267. removeBlock(block: NodeMaterialBlock): void;
  61268. /**
  61269. * Build the material and generates the inner effect
  61270. * @param verbose defines if the build should log activity
  61271. */
  61272. build(verbose?: boolean): void;
  61273. /**
  61274. * Runs an otpimization phase to try to improve the shader code
  61275. */
  61276. optimize(): void;
  61277. private _prepareDefinesForAttributes;
  61278. /**
  61279. * Create a post process from the material
  61280. * @param camera The camera to apply the render pass to.
  61281. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  61282. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61283. * @param engine The engine which the post process will be applied. (default: current engine)
  61284. * @param reusable If the post process can be reused on the same frame. (default: false)
  61285. * @param textureType Type of textures used when performing the post process. (default: 0)
  61286. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  61287. * @returns the post process created
  61288. */
  61289. createPostProcess(camera: Nullable<Camera>, options?: number | PostProcessOptions, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, textureFormat?: number): PostProcess;
  61290. private _processDefines;
  61291. /**
  61292. * Get if the submesh is ready to be used and all its information available.
  61293. * Child classes can use it to update shaders
  61294. * @param mesh defines the mesh to check
  61295. * @param subMesh defines which submesh to check
  61296. * @param useInstances specifies that instances should be used
  61297. * @returns a boolean indicating that the submesh is ready or not
  61298. */
  61299. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  61300. /**
  61301. * Get a string representing the shaders built by the current node graph
  61302. */
  61303. get compiledShaders(): string;
  61304. /**
  61305. * Binds the world matrix to the material
  61306. * @param world defines the world transformation matrix
  61307. */
  61308. bindOnlyWorldMatrix(world: Matrix): void;
  61309. /**
  61310. * Binds the submesh to this material by preparing the effect and shader to draw
  61311. * @param world defines the world transformation matrix
  61312. * @param mesh defines the mesh containing the submesh
  61313. * @param subMesh defines the submesh to bind the material to
  61314. */
  61315. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  61316. /**
  61317. * Gets the active textures from the material
  61318. * @returns an array of textures
  61319. */
  61320. getActiveTextures(): BaseTexture[];
  61321. /**
  61322. * Gets the list of texture blocks
  61323. * @returns an array of texture blocks
  61324. */
  61325. getTextureBlocks(): (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock)[];
  61326. /**
  61327. * Specifies if the material uses a texture
  61328. * @param texture defines the texture to check against the material
  61329. * @returns a boolean specifying if the material uses the texture
  61330. */
  61331. hasTexture(texture: BaseTexture): boolean;
  61332. /**
  61333. * Disposes the material
  61334. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  61335. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  61336. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  61337. */
  61338. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  61339. /** Creates the node editor window. */
  61340. private _createNodeEditor;
  61341. /**
  61342. * Launch the node material editor
  61343. * @param config Define the configuration of the editor
  61344. * @return a promise fulfilled when the node editor is visible
  61345. */
  61346. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  61347. /**
  61348. * Clear the current material
  61349. */
  61350. clear(): void;
  61351. /**
  61352. * Clear the current material and set it to a default state
  61353. */
  61354. setToDefault(): void;
  61355. /**
  61356. * Clear the current material and set it to a default state for post process
  61357. */
  61358. setToDefaultPostProcess(): void;
  61359. /**
  61360. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  61361. * @param url defines the url to load from
  61362. * @returns a promise that will fullfil when the material is fully loaded
  61363. */
  61364. loadAsync(url: string): Promise<void>;
  61365. private _gatherBlocks;
  61366. /**
  61367. * Generate a string containing the code declaration required to create an equivalent of this material
  61368. * @returns a string
  61369. */
  61370. generateCode(): string;
  61371. /**
  61372. * Serializes this material in a JSON representation
  61373. * @returns the serialized material object
  61374. */
  61375. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  61376. private _restoreConnections;
  61377. /**
  61378. * Clear the current graph and load a new one from a serialization object
  61379. * @param source defines the JSON representation of the material
  61380. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  61381. */
  61382. loadFromSerialization(source: any, rootUrl?: string): void;
  61383. /**
  61384. * Makes a duplicate of the current material.
  61385. * @param name - name to use for the new material.
  61386. */
  61387. clone(name: string): NodeMaterial;
  61388. /**
  61389. * Creates a node material from parsed material data
  61390. * @param source defines the JSON representation of the material
  61391. * @param scene defines the hosting scene
  61392. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  61393. * @returns a new node material
  61394. */
  61395. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  61396. /**
  61397. * Creates a node material from a snippet saved in a remote file
  61398. * @param name defines the name of the material to create
  61399. * @param url defines the url to load from
  61400. * @param scene defines the hosting scene
  61401. * @returns a promise that will resolve to the new node material
  61402. */
  61403. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  61404. /**
  61405. * Creates a node material from a snippet saved by the node material editor
  61406. * @param snippetId defines the snippet to load
  61407. * @param scene defines the hosting scene
  61408. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  61409. * @param nodeMaterial defines a node material to update (instead of creating a new one)
  61410. * @returns a promise that will resolve to the new node material
  61411. */
  61412. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string, nodeMaterial?: NodeMaterial): Promise<NodeMaterial>;
  61413. /**
  61414. * Creates a new node material set to default basic configuration
  61415. * @param name defines the name of the material
  61416. * @param scene defines the hosting scene
  61417. * @returns a new NodeMaterial
  61418. */
  61419. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  61420. }
  61421. }
  61422. declare module "babylonjs/Materials/Node/Blocks/Dual/textureBlock" {
  61423. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61424. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61425. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  61426. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61427. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61428. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  61429. import { Effect } from "babylonjs/Materials/effect";
  61430. import { Mesh } from "babylonjs/Meshes/mesh";
  61431. import { Nullable } from "babylonjs/types";
  61432. import { Texture } from "babylonjs/Materials/Textures/texture";
  61433. import { Scene } from "babylonjs/scene";
  61434. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  61435. /**
  61436. * Block used to read a texture from a sampler
  61437. */
  61438. export class TextureBlock extends NodeMaterialBlock {
  61439. private _defineName;
  61440. private _linearDefineName;
  61441. private _gammaDefineName;
  61442. private _tempTextureRead;
  61443. private _samplerName;
  61444. private _transformedUVName;
  61445. private _textureTransformName;
  61446. private _textureInfoName;
  61447. private _mainUVName;
  61448. private _mainUVDefineName;
  61449. /**
  61450. * Gets or sets the texture associated with the node
  61451. */
  61452. texture: Nullable<Texture>;
  61453. /**
  61454. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  61455. */
  61456. convertToGammaSpace: boolean;
  61457. /**
  61458. * Gets or sets a boolean indicating if content needs to be converted to linear space
  61459. */
  61460. convertToLinearSpace: boolean;
  61461. /**
  61462. * Create a new TextureBlock
  61463. * @param name defines the block name
  61464. */
  61465. constructor(name: string);
  61466. /**
  61467. * Gets the current class name
  61468. * @returns the class name
  61469. */
  61470. getClassName(): string;
  61471. /**
  61472. * Gets the uv input component
  61473. */
  61474. get uv(): NodeMaterialConnectionPoint;
  61475. /**
  61476. * Gets the rgba output component
  61477. */
  61478. get rgba(): NodeMaterialConnectionPoint;
  61479. /**
  61480. * Gets the rgb output component
  61481. */
  61482. get rgb(): NodeMaterialConnectionPoint;
  61483. /**
  61484. * Gets the r output component
  61485. */
  61486. get r(): NodeMaterialConnectionPoint;
  61487. /**
  61488. * Gets the g output component
  61489. */
  61490. get g(): NodeMaterialConnectionPoint;
  61491. /**
  61492. * Gets the b output component
  61493. */
  61494. get b(): NodeMaterialConnectionPoint;
  61495. /**
  61496. * Gets the a output component
  61497. */
  61498. get a(): NodeMaterialConnectionPoint;
  61499. get target(): NodeMaterialBlockTargets;
  61500. autoConfigure(material: NodeMaterial): void;
  61501. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  61502. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61503. isReady(): boolean;
  61504. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61505. private get _isMixed();
  61506. private _injectVertexCode;
  61507. private _writeTextureRead;
  61508. private _writeOutput;
  61509. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  61510. protected _dumpPropertiesCode(): string;
  61511. serialize(): any;
  61512. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61513. }
  61514. }
  61515. declare module "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData" {
  61516. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61517. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61518. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  61519. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  61520. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  61521. import { RefractionBlock } from "babylonjs/Materials/Node/Blocks/PBR/refractionBlock";
  61522. import { CurrentScreenBlock } from "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock";
  61523. import { Scene } from "babylonjs/scene";
  61524. /**
  61525. * Class used to store shared data between 2 NodeMaterialBuildState
  61526. */
  61527. export class NodeMaterialBuildStateSharedData {
  61528. /**
  61529. * Gets the list of emitted varyings
  61530. */
  61531. temps: string[];
  61532. /**
  61533. * Gets the list of emitted varyings
  61534. */
  61535. varyings: string[];
  61536. /**
  61537. * Gets the varying declaration string
  61538. */
  61539. varyingDeclaration: string;
  61540. /**
  61541. * Input blocks
  61542. */
  61543. inputBlocks: InputBlock[];
  61544. /**
  61545. * Input blocks
  61546. */
  61547. textureBlocks: (ReflectionTextureBaseBlock | TextureBlock | RefractionBlock | CurrentScreenBlock)[];
  61548. /**
  61549. * Bindable blocks (Blocks that need to set data to the effect)
  61550. */
  61551. bindableBlocks: NodeMaterialBlock[];
  61552. /**
  61553. * List of blocks that can provide a compilation fallback
  61554. */
  61555. blocksWithFallbacks: NodeMaterialBlock[];
  61556. /**
  61557. * List of blocks that can provide a define update
  61558. */
  61559. blocksWithDefines: NodeMaterialBlock[];
  61560. /**
  61561. * List of blocks that can provide a repeatable content
  61562. */
  61563. repeatableContentBlocks: NodeMaterialBlock[];
  61564. /**
  61565. * List of blocks that can provide a dynamic list of uniforms
  61566. */
  61567. dynamicUniformBlocks: NodeMaterialBlock[];
  61568. /**
  61569. * List of blocks that can block the isReady function for the material
  61570. */
  61571. blockingBlocks: NodeMaterialBlock[];
  61572. /**
  61573. * Gets the list of animated inputs
  61574. */
  61575. animatedInputs: InputBlock[];
  61576. /**
  61577. * Build Id used to avoid multiple recompilations
  61578. */
  61579. buildId: number;
  61580. /** List of emitted variables */
  61581. variableNames: {
  61582. [key: string]: number;
  61583. };
  61584. /** List of emitted defines */
  61585. defineNames: {
  61586. [key: string]: number;
  61587. };
  61588. /** Should emit comments? */
  61589. emitComments: boolean;
  61590. /** Emit build activity */
  61591. verbose: boolean;
  61592. /** Gets or sets the hosting scene */
  61593. scene: Scene;
  61594. /**
  61595. * Gets the compilation hints emitted at compilation time
  61596. */
  61597. hints: {
  61598. needWorldViewMatrix: boolean;
  61599. needWorldViewProjectionMatrix: boolean;
  61600. needAlphaBlending: boolean;
  61601. needAlphaTesting: boolean;
  61602. };
  61603. /**
  61604. * List of compilation checks
  61605. */
  61606. checks: {
  61607. emitVertex: boolean;
  61608. emitFragment: boolean;
  61609. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  61610. };
  61611. /** Creates a new shared data */
  61612. constructor();
  61613. /**
  61614. * Emits console errors and exceptions if there is a failing check
  61615. */
  61616. emitErrors(): void;
  61617. }
  61618. }
  61619. declare module "babylonjs/Materials/Node/nodeMaterialBuildState" {
  61620. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  61621. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  61622. import { NodeMaterialBuildStateSharedData } from "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData";
  61623. /**
  61624. * Class used to store node based material build state
  61625. */
  61626. export class NodeMaterialBuildState {
  61627. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  61628. supportUniformBuffers: boolean;
  61629. /**
  61630. * Gets the list of emitted attributes
  61631. */
  61632. attributes: string[];
  61633. /**
  61634. * Gets the list of emitted uniforms
  61635. */
  61636. uniforms: string[];
  61637. /**
  61638. * Gets the list of emitted constants
  61639. */
  61640. constants: string[];
  61641. /**
  61642. * Gets the list of emitted samplers
  61643. */
  61644. samplers: string[];
  61645. /**
  61646. * Gets the list of emitted functions
  61647. */
  61648. functions: {
  61649. [key: string]: string;
  61650. };
  61651. /**
  61652. * Gets the list of emitted extensions
  61653. */
  61654. extensions: {
  61655. [key: string]: string;
  61656. };
  61657. /**
  61658. * Gets the target of the compilation state
  61659. */
  61660. target: NodeMaterialBlockTargets;
  61661. /**
  61662. * Gets the list of emitted counters
  61663. */
  61664. counters: {
  61665. [key: string]: number;
  61666. };
  61667. /**
  61668. * Shared data between multiple NodeMaterialBuildState instances
  61669. */
  61670. sharedData: NodeMaterialBuildStateSharedData;
  61671. /** @hidden */
  61672. _vertexState: NodeMaterialBuildState;
  61673. /** @hidden */
  61674. _attributeDeclaration: string;
  61675. /** @hidden */
  61676. _uniformDeclaration: string;
  61677. /** @hidden */
  61678. _constantDeclaration: string;
  61679. /** @hidden */
  61680. _samplerDeclaration: string;
  61681. /** @hidden */
  61682. _varyingTransfer: string;
  61683. /** @hidden */
  61684. _injectAtEnd: string;
  61685. private _repeatableContentAnchorIndex;
  61686. /** @hidden */
  61687. _builtCompilationString: string;
  61688. /**
  61689. * Gets the emitted compilation strings
  61690. */
  61691. compilationString: string;
  61692. /**
  61693. * Finalize the compilation strings
  61694. * @param state defines the current compilation state
  61695. */
  61696. finalize(state: NodeMaterialBuildState): void;
  61697. /** @hidden */
  61698. get _repeatableContentAnchor(): string;
  61699. /** @hidden */
  61700. _getFreeVariableName(prefix: string): string;
  61701. /** @hidden */
  61702. _getFreeDefineName(prefix: string): string;
  61703. /** @hidden */
  61704. _excludeVariableName(name: string): void;
  61705. /** @hidden */
  61706. _emit2DSampler(name: string): void;
  61707. /** @hidden */
  61708. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  61709. /** @hidden */
  61710. _emitExtension(name: string, extension: string, define?: string): void;
  61711. /** @hidden */
  61712. _emitFunction(name: string, code: string, comments: string): void;
  61713. /** @hidden */
  61714. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  61715. replaceStrings?: {
  61716. search: RegExp;
  61717. replace: string;
  61718. }[];
  61719. repeatKey?: string;
  61720. }): string;
  61721. /** @hidden */
  61722. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  61723. repeatKey?: string;
  61724. removeAttributes?: boolean;
  61725. removeUniforms?: boolean;
  61726. removeVaryings?: boolean;
  61727. removeIfDef?: boolean;
  61728. replaceStrings?: {
  61729. search: RegExp;
  61730. replace: string;
  61731. }[];
  61732. }, storeKey?: string): void;
  61733. /** @hidden */
  61734. _registerTempVariable(name: string): boolean;
  61735. /** @hidden */
  61736. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  61737. /** @hidden */
  61738. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  61739. /** @hidden */
  61740. _emitFloat(value: number): string;
  61741. }
  61742. }
  61743. declare module "babylonjs/Materials/Node/nodeMaterialBlock" {
  61744. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  61745. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61746. import { Nullable } from "babylonjs/types";
  61747. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61748. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  61749. import { Effect } from "babylonjs/Materials/effect";
  61750. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61751. import { Mesh } from "babylonjs/Meshes/mesh";
  61752. import { SubMesh } from "babylonjs/Meshes/subMesh";
  61753. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  61754. import { Scene } from "babylonjs/scene";
  61755. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  61756. /**
  61757. * Defines a block that can be used inside a node based material
  61758. */
  61759. export class NodeMaterialBlock {
  61760. private _buildId;
  61761. private _buildTarget;
  61762. private _target;
  61763. private _isFinalMerger;
  61764. private _isInput;
  61765. protected _isUnique: boolean;
  61766. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  61767. inputsAreExclusive: boolean;
  61768. /** @hidden */
  61769. _codeVariableName: string;
  61770. /** @hidden */
  61771. _inputs: NodeMaterialConnectionPoint[];
  61772. /** @hidden */
  61773. _outputs: NodeMaterialConnectionPoint[];
  61774. /** @hidden */
  61775. _preparationId: number;
  61776. /**
  61777. * Gets or sets the name of the block
  61778. */
  61779. name: string;
  61780. /**
  61781. * Gets or sets the unique id of the node
  61782. */
  61783. uniqueId: number;
  61784. /**
  61785. * Gets or sets the comments associated with this block
  61786. */
  61787. comments: string;
  61788. /**
  61789. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  61790. */
  61791. get isUnique(): boolean;
  61792. /**
  61793. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  61794. */
  61795. get isFinalMerger(): boolean;
  61796. /**
  61797. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  61798. */
  61799. get isInput(): boolean;
  61800. /**
  61801. * Gets or sets the build Id
  61802. */
  61803. get buildId(): number;
  61804. set buildId(value: number);
  61805. /**
  61806. * Gets or sets the target of the block
  61807. */
  61808. get target(): NodeMaterialBlockTargets;
  61809. set target(value: NodeMaterialBlockTargets);
  61810. /**
  61811. * Gets the list of input points
  61812. */
  61813. get inputs(): NodeMaterialConnectionPoint[];
  61814. /** Gets the list of output points */
  61815. get outputs(): NodeMaterialConnectionPoint[];
  61816. /**
  61817. * Find an input by its name
  61818. * @param name defines the name of the input to look for
  61819. * @returns the input or null if not found
  61820. */
  61821. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  61822. /**
  61823. * Find an output by its name
  61824. * @param name defines the name of the outputto look for
  61825. * @returns the output or null if not found
  61826. */
  61827. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  61828. /**
  61829. * Creates a new NodeMaterialBlock
  61830. * @param name defines the block name
  61831. * @param target defines the target of that block (Vertex by default)
  61832. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  61833. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  61834. */
  61835. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  61836. /**
  61837. * Initialize the block and prepare the context for build
  61838. * @param state defines the state that will be used for the build
  61839. */
  61840. initialize(state: NodeMaterialBuildState): void;
  61841. /**
  61842. * Bind data to effect. Will only be called for blocks with isBindable === true
  61843. * @param effect defines the effect to bind data to
  61844. * @param nodeMaterial defines the hosting NodeMaterial
  61845. * @param mesh defines the mesh that will be rendered
  61846. * @param subMesh defines the submesh that will be rendered
  61847. */
  61848. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  61849. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  61850. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  61851. protected _writeFloat(value: number): string;
  61852. /**
  61853. * Gets the current class name e.g. "NodeMaterialBlock"
  61854. * @returns the class name
  61855. */
  61856. getClassName(): string;
  61857. /**
  61858. * Register a new input. Must be called inside a block constructor
  61859. * @param name defines the connection point name
  61860. * @param type defines the connection point type
  61861. * @param isOptional defines a boolean indicating that this input can be omitted
  61862. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  61863. * @param point an already created connection point. If not provided, create a new one
  61864. * @returns the current block
  61865. */
  61866. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  61867. /**
  61868. * Register a new output. Must be called inside a block constructor
  61869. * @param name defines the connection point name
  61870. * @param type defines the connection point type
  61871. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  61872. * @param point an already created connection point. If not provided, create a new one
  61873. * @returns the current block
  61874. */
  61875. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  61876. /**
  61877. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  61878. * @param forOutput defines an optional connection point to check compatibility with
  61879. * @returns the first available input or null
  61880. */
  61881. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  61882. /**
  61883. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  61884. * @param forBlock defines an optional block to check compatibility with
  61885. * @returns the first available input or null
  61886. */
  61887. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  61888. /**
  61889. * Gets the sibling of the given output
  61890. * @param current defines the current output
  61891. * @returns the next output in the list or null
  61892. */
  61893. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  61894. /**
  61895. * Connect current block with another block
  61896. * @param other defines the block to connect with
  61897. * @param options define the various options to help pick the right connections
  61898. * @returns the current block
  61899. */
  61900. connectTo(other: NodeMaterialBlock, options?: {
  61901. input?: string;
  61902. output?: string;
  61903. outputSwizzle?: string;
  61904. }): this | undefined;
  61905. protected _buildBlock(state: NodeMaterialBuildState): void;
  61906. /**
  61907. * Add uniforms, samplers and uniform buffers at compilation time
  61908. * @param state defines the state to update
  61909. * @param nodeMaterial defines the node material requesting the update
  61910. * @param defines defines the material defines to update
  61911. * @param uniformBuffers defines the list of uniform buffer names
  61912. */
  61913. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  61914. /**
  61915. * Add potential fallbacks if shader compilation fails
  61916. * @param mesh defines the mesh to be rendered
  61917. * @param fallbacks defines the current prioritized list of fallbacks
  61918. */
  61919. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  61920. /**
  61921. * Initialize defines for shader compilation
  61922. * @param mesh defines the mesh to be rendered
  61923. * @param nodeMaterial defines the node material requesting the update
  61924. * @param defines defines the material defines to update
  61925. * @param useInstances specifies that instances should be used
  61926. */
  61927. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  61928. /**
  61929. * Update defines for shader compilation
  61930. * @param mesh defines the mesh to be rendered
  61931. * @param nodeMaterial defines the node material requesting the update
  61932. * @param defines defines the material defines to update
  61933. * @param useInstances specifies that instances should be used
  61934. */
  61935. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  61936. /**
  61937. * Lets the block try to connect some inputs automatically
  61938. * @param material defines the hosting NodeMaterial
  61939. */
  61940. autoConfigure(material: NodeMaterial): void;
  61941. /**
  61942. * Function called when a block is declared as repeatable content generator
  61943. * @param vertexShaderState defines the current compilation state for the vertex shader
  61944. * @param fragmentShaderState defines the current compilation state for the fragment shader
  61945. * @param mesh defines the mesh to be rendered
  61946. * @param defines defines the material defines to update
  61947. */
  61948. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  61949. /**
  61950. * Checks if the block is ready
  61951. * @param mesh defines the mesh to be rendered
  61952. * @param nodeMaterial defines the node material requesting the update
  61953. * @param defines defines the material defines to update
  61954. * @param useInstances specifies that instances should be used
  61955. * @returns true if the block is ready
  61956. */
  61957. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  61958. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  61959. private _processBuild;
  61960. /**
  61961. * Compile the current node and generate the shader code
  61962. * @param state defines the current compilation state (uniforms, samplers, current string)
  61963. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  61964. * @returns true if already built
  61965. */
  61966. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  61967. protected _inputRename(name: string): string;
  61968. protected _outputRename(name: string): string;
  61969. protected _dumpPropertiesCode(): string;
  61970. /** @hidden */
  61971. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  61972. /** @hidden */
  61973. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  61974. /**
  61975. * Clone the current block to a new identical block
  61976. * @param scene defines the hosting scene
  61977. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  61978. * @returns a copy of the current block
  61979. */
  61980. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  61981. /**
  61982. * Serializes this block in a JSON representation
  61983. * @returns the serialized block object
  61984. */
  61985. serialize(): any;
  61986. /** @hidden */
  61987. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61988. private _deserializePortDisplayNames;
  61989. /**
  61990. * Release resources
  61991. */
  61992. dispose(): void;
  61993. }
  61994. }
  61995. declare module "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes" {
  61996. /**
  61997. * Enum defining the type of animations supported by InputBlock
  61998. */
  61999. export enum AnimatedInputBlockTypes {
  62000. /** No animation */
  62001. None = 0,
  62002. /** Time based animation. Will only work for floats */
  62003. Time = 1
  62004. }
  62005. }
  62006. declare module "babylonjs/Materials/Node/Blocks/Input/inputBlock" {
  62007. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62008. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  62009. import { NodeMaterialSystemValues } from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  62010. import { Nullable } from "babylonjs/types";
  62011. import { Effect } from "babylonjs/Materials/effect";
  62012. import { Matrix } from "babylonjs/Maths/math.vector";
  62013. import { Scene } from "babylonjs/scene";
  62014. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62015. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62016. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  62017. import { AnimatedInputBlockTypes } from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  62018. import { Observable } from "babylonjs/Misc/observable";
  62019. /**
  62020. * Block used to expose an input value
  62021. */
  62022. export class InputBlock extends NodeMaterialBlock {
  62023. private _mode;
  62024. private _associatedVariableName;
  62025. private _storedValue;
  62026. private _valueCallback;
  62027. private _type;
  62028. private _animationType;
  62029. /** Gets or set a value used to limit the range of float values */
  62030. min: number;
  62031. /** Gets or set a value used to limit the range of float values */
  62032. max: number;
  62033. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  62034. isBoolean: boolean;
  62035. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  62036. matrixMode: number;
  62037. /** @hidden */
  62038. _systemValue: Nullable<NodeMaterialSystemValues>;
  62039. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  62040. visibleInInspector: boolean;
  62041. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  62042. isConstant: boolean;
  62043. /** Gets or sets the group to use to display this block in the Inspector */
  62044. groupInInspector: string;
  62045. /** Gets an observable raised when the value is changed */
  62046. onValueChangedObservable: Observable<InputBlock>;
  62047. /**
  62048. * Gets or sets the connection point type (default is float)
  62049. */
  62050. get type(): NodeMaterialBlockConnectionPointTypes;
  62051. /**
  62052. * Creates a new InputBlock
  62053. * @param name defines the block name
  62054. * @param target defines the target of that block (Vertex by default)
  62055. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  62056. */
  62057. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  62058. /**
  62059. * Gets the output component
  62060. */
  62061. get output(): NodeMaterialConnectionPoint;
  62062. /**
  62063. * Set the source of this connection point to a vertex attribute
  62064. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  62065. * @returns the current connection point
  62066. */
  62067. setAsAttribute(attributeName?: string): InputBlock;
  62068. /**
  62069. * Set the source of this connection point to a system value
  62070. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  62071. * @returns the current connection point
  62072. */
  62073. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  62074. /**
  62075. * Gets or sets the value of that point.
  62076. * Please note that this value will be ignored if valueCallback is defined
  62077. */
  62078. get value(): any;
  62079. set value(value: any);
  62080. /**
  62081. * Gets or sets a callback used to get the value of that point.
  62082. * Please note that setting this value will force the connection point to ignore the value property
  62083. */
  62084. get valueCallback(): () => any;
  62085. set valueCallback(value: () => any);
  62086. /**
  62087. * Gets or sets the associated variable name in the shader
  62088. */
  62089. get associatedVariableName(): string;
  62090. set associatedVariableName(value: string);
  62091. /** Gets or sets the type of animation applied to the input */
  62092. get animationType(): AnimatedInputBlockTypes;
  62093. set animationType(value: AnimatedInputBlockTypes);
  62094. /**
  62095. * Gets a boolean indicating that this connection point not defined yet
  62096. */
  62097. get isUndefined(): boolean;
  62098. /**
  62099. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  62100. * In this case the connection point name must be the name of the uniform to use.
  62101. * Can only be set on inputs
  62102. */
  62103. get isUniform(): boolean;
  62104. set isUniform(value: boolean);
  62105. /**
  62106. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  62107. * In this case the connection point name must be the name of the attribute to use
  62108. * Can only be set on inputs
  62109. */
  62110. get isAttribute(): boolean;
  62111. set isAttribute(value: boolean);
  62112. /**
  62113. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  62114. * Can only be set on exit points
  62115. */
  62116. get isVarying(): boolean;
  62117. set isVarying(value: boolean);
  62118. /**
  62119. * Gets a boolean indicating that the current connection point is a system value
  62120. */
  62121. get isSystemValue(): boolean;
  62122. /**
  62123. * Gets or sets the current well known value or null if not defined as a system value
  62124. */
  62125. get systemValue(): Nullable<NodeMaterialSystemValues>;
  62126. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  62127. /**
  62128. * Gets the current class name
  62129. * @returns the class name
  62130. */
  62131. getClassName(): string;
  62132. /**
  62133. * Animate the input if animationType !== None
  62134. * @param scene defines the rendering scene
  62135. */
  62136. animate(scene: Scene): void;
  62137. private _emitDefine;
  62138. initialize(state: NodeMaterialBuildState): void;
  62139. /**
  62140. * Set the input block to its default value (based on its type)
  62141. */
  62142. setDefaultValue(): void;
  62143. private _emitConstant;
  62144. private _emit;
  62145. /** @hidden */
  62146. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  62147. /** @hidden */
  62148. _transmit(effect: Effect, scene: Scene): void;
  62149. protected _buildBlock(state: NodeMaterialBuildState): void;
  62150. protected _dumpPropertiesCode(): string;
  62151. dispose(): void;
  62152. serialize(): any;
  62153. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62154. }
  62155. }
  62156. declare module "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint" {
  62157. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  62158. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  62159. import { Nullable } from "babylonjs/types";
  62160. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  62161. import { Observable } from "babylonjs/Misc/observable";
  62162. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62163. /**
  62164. * Enum used to define the compatibility state between two connection points
  62165. */
  62166. export enum NodeMaterialConnectionPointCompatibilityStates {
  62167. /** Points are compatibles */
  62168. Compatible = 0,
  62169. /** Points are incompatible because of their types */
  62170. TypeIncompatible = 1,
  62171. /** Points are incompatible because of their targets (vertex vs fragment) */
  62172. TargetIncompatible = 2
  62173. }
  62174. /**
  62175. * Defines the direction of a connection point
  62176. */
  62177. export enum NodeMaterialConnectionPointDirection {
  62178. /** Input */
  62179. Input = 0,
  62180. /** Output */
  62181. Output = 1
  62182. }
  62183. /**
  62184. * Defines a connection point for a block
  62185. */
  62186. export class NodeMaterialConnectionPoint {
  62187. /** @hidden */
  62188. _ownerBlock: NodeMaterialBlock;
  62189. /** @hidden */
  62190. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  62191. private _endpoints;
  62192. private _associatedVariableName;
  62193. private _direction;
  62194. /** @hidden */
  62195. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  62196. /** @hidden */
  62197. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  62198. private _type;
  62199. /** @hidden */
  62200. _enforceAssociatedVariableName: boolean;
  62201. /** Gets the direction of the point */
  62202. get direction(): NodeMaterialConnectionPointDirection;
  62203. /** Indicates that this connection point needs dual validation before being connected to another point */
  62204. needDualDirectionValidation: boolean;
  62205. /**
  62206. * Gets or sets the additional types supported by this connection point
  62207. */
  62208. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  62209. /**
  62210. * Gets or sets the additional types excluded by this connection point
  62211. */
  62212. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  62213. /**
  62214. * Observable triggered when this point is connected
  62215. */
  62216. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  62217. /**
  62218. * Gets or sets the associated variable name in the shader
  62219. */
  62220. get associatedVariableName(): string;
  62221. set associatedVariableName(value: string);
  62222. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  62223. get innerType(): NodeMaterialBlockConnectionPointTypes;
  62224. /**
  62225. * Gets or sets the connection point type (default is float)
  62226. */
  62227. get type(): NodeMaterialBlockConnectionPointTypes;
  62228. set type(value: NodeMaterialBlockConnectionPointTypes);
  62229. /**
  62230. * Gets or sets the connection point name
  62231. */
  62232. name: string;
  62233. /**
  62234. * Gets or sets the connection point name
  62235. */
  62236. displayName: string;
  62237. /**
  62238. * Gets or sets a boolean indicating that this connection point can be omitted
  62239. */
  62240. isOptional: boolean;
  62241. /**
  62242. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  62243. */
  62244. define: string;
  62245. /** @hidden */
  62246. _prioritizeVertex: boolean;
  62247. private _target;
  62248. /** Gets or sets the target of that connection point */
  62249. get target(): NodeMaterialBlockTargets;
  62250. set target(value: NodeMaterialBlockTargets);
  62251. /**
  62252. * Gets a boolean indicating that the current point is connected to another NodeMaterialBlock
  62253. */
  62254. get isConnected(): boolean;
  62255. /**
  62256. * Gets a boolean indicating that the current point is connected to an input block
  62257. */
  62258. get isConnectedToInputBlock(): boolean;
  62259. /**
  62260. * Gets a the connected input block (if any)
  62261. */
  62262. get connectInputBlock(): Nullable<InputBlock>;
  62263. /** Get the other side of the connection (if any) */
  62264. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  62265. /** Get the block that owns this connection point */
  62266. get ownerBlock(): NodeMaterialBlock;
  62267. /** Get the block connected on the other side of this connection (if any) */
  62268. get sourceBlock(): Nullable<NodeMaterialBlock>;
  62269. /** Get the block connected on the endpoints of this connection (if any) */
  62270. get connectedBlocks(): Array<NodeMaterialBlock>;
  62271. /** Gets the list of connected endpoints */
  62272. get endpoints(): NodeMaterialConnectionPoint[];
  62273. /** Gets a boolean indicating if that output point is connected to at least one input */
  62274. get hasEndpoints(): boolean;
  62275. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  62276. get isConnectedInVertexShader(): boolean;
  62277. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  62278. get isConnectedInFragmentShader(): boolean;
  62279. /**
  62280. * Creates a block suitable to be used as an input for this input point.
  62281. * If null is returned, a block based on the point type will be created.
  62282. * @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
  62283. */
  62284. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  62285. /**
  62286. * Creates a new connection point
  62287. * @param name defines the connection point name
  62288. * @param ownerBlock defines the block hosting this connection point
  62289. * @param direction defines the direction of the connection point
  62290. */
  62291. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  62292. /**
  62293. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  62294. * @returns the class name
  62295. */
  62296. getClassName(): string;
  62297. /**
  62298. * Gets a boolean indicating if the current point can be connected to another point
  62299. * @param connectionPoint defines the other connection point
  62300. * @returns a boolean
  62301. */
  62302. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  62303. /**
  62304. * Gets a number indicating if the current point can be connected to another point
  62305. * @param connectionPoint defines the other connection point
  62306. * @returns a number defining the compatibility state
  62307. */
  62308. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  62309. /**
  62310. * Connect this point to another connection point
  62311. * @param connectionPoint defines the other connection point
  62312. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  62313. * @returns the current connection point
  62314. */
  62315. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  62316. /**
  62317. * Disconnect this point from one of his endpoint
  62318. * @param endpoint defines the other connection point
  62319. * @returns the current connection point
  62320. */
  62321. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  62322. /**
  62323. * Serializes this point in a JSON representation
  62324. * @param isInput defines if the connection point is an input (default is true)
  62325. * @returns the serialized point object
  62326. */
  62327. serialize(isInput?: boolean): any;
  62328. /**
  62329. * Release resources
  62330. */
  62331. dispose(): void;
  62332. }
  62333. }
  62334. declare module "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock" {
  62335. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62336. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62337. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62338. import { Mesh } from "babylonjs/Meshes/mesh";
  62339. import { Effect } from "babylonjs/Materials/effect";
  62340. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62341. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  62342. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  62343. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  62344. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  62345. /**
  62346. * Block used to add support for vertex skinning (bones)
  62347. */
  62348. export class BonesBlock extends NodeMaterialBlock {
  62349. /**
  62350. * Creates a new BonesBlock
  62351. * @param name defines the block name
  62352. */
  62353. constructor(name: string);
  62354. /**
  62355. * Initialize the block and prepare the context for build
  62356. * @param state defines the state that will be used for the build
  62357. */
  62358. initialize(state: NodeMaterialBuildState): void;
  62359. /**
  62360. * Gets the current class name
  62361. * @returns the class name
  62362. */
  62363. getClassName(): string;
  62364. /**
  62365. * Gets the matrix indices input component
  62366. */
  62367. get matricesIndices(): NodeMaterialConnectionPoint;
  62368. /**
  62369. * Gets the matrix weights input component
  62370. */
  62371. get matricesWeights(): NodeMaterialConnectionPoint;
  62372. /**
  62373. * Gets the extra matrix indices input component
  62374. */
  62375. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  62376. /**
  62377. * Gets the extra matrix weights input component
  62378. */
  62379. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  62380. /**
  62381. * Gets the world input component
  62382. */
  62383. get world(): NodeMaterialConnectionPoint;
  62384. /**
  62385. * Gets the output component
  62386. */
  62387. get output(): NodeMaterialConnectionPoint;
  62388. autoConfigure(material: NodeMaterial): void;
  62389. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  62390. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  62391. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62392. protected _buildBlock(state: NodeMaterialBuildState): this;
  62393. }
  62394. }
  62395. declare module "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock" {
  62396. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62397. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62398. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62399. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62400. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  62401. /**
  62402. * Block used to add support for instances
  62403. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  62404. */
  62405. export class InstancesBlock extends NodeMaterialBlock {
  62406. /**
  62407. * Creates a new InstancesBlock
  62408. * @param name defines the block name
  62409. */
  62410. constructor(name: string);
  62411. /**
  62412. * Gets the current class name
  62413. * @returns the class name
  62414. */
  62415. getClassName(): string;
  62416. /**
  62417. * Gets the first world row input component
  62418. */
  62419. get world0(): NodeMaterialConnectionPoint;
  62420. /**
  62421. * Gets the second world row input component
  62422. */
  62423. get world1(): NodeMaterialConnectionPoint;
  62424. /**
  62425. * Gets the third world row input component
  62426. */
  62427. get world2(): NodeMaterialConnectionPoint;
  62428. /**
  62429. * Gets the forth world row input component
  62430. */
  62431. get world3(): NodeMaterialConnectionPoint;
  62432. /**
  62433. * Gets the world input component
  62434. */
  62435. get world(): NodeMaterialConnectionPoint;
  62436. /**
  62437. * Gets the output component
  62438. */
  62439. get output(): NodeMaterialConnectionPoint;
  62440. /**
  62441. * Gets the isntanceID component
  62442. */
  62443. get instanceID(): NodeMaterialConnectionPoint;
  62444. autoConfigure(material: NodeMaterial): void;
  62445. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  62446. protected _buildBlock(state: NodeMaterialBuildState): this;
  62447. }
  62448. }
  62449. declare module "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock" {
  62450. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62451. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62452. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62453. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62454. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  62455. import { Effect } from "babylonjs/Materials/effect";
  62456. import { Mesh } from "babylonjs/Meshes/mesh";
  62457. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  62458. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  62459. /**
  62460. * Block used to add morph targets support to vertex shader
  62461. */
  62462. export class MorphTargetsBlock extends NodeMaterialBlock {
  62463. private _repeatableContentAnchor;
  62464. /**
  62465. * Create a new MorphTargetsBlock
  62466. * @param name defines the block name
  62467. */
  62468. constructor(name: string);
  62469. /**
  62470. * Gets the current class name
  62471. * @returns the class name
  62472. */
  62473. getClassName(): string;
  62474. /**
  62475. * Gets the position input component
  62476. */
  62477. get position(): NodeMaterialConnectionPoint;
  62478. /**
  62479. * Gets the normal input component
  62480. */
  62481. get normal(): NodeMaterialConnectionPoint;
  62482. /**
  62483. * Gets the tangent input component
  62484. */
  62485. get tangent(): NodeMaterialConnectionPoint;
  62486. /**
  62487. * Gets the tangent input component
  62488. */
  62489. get uv(): NodeMaterialConnectionPoint;
  62490. /**
  62491. * Gets the position output component
  62492. */
  62493. get positionOutput(): NodeMaterialConnectionPoint;
  62494. /**
  62495. * Gets the normal output component
  62496. */
  62497. get normalOutput(): NodeMaterialConnectionPoint;
  62498. /**
  62499. * Gets the tangent output component
  62500. */
  62501. get tangentOutput(): NodeMaterialConnectionPoint;
  62502. /**
  62503. * Gets the tangent output component
  62504. */
  62505. get uvOutput(): NodeMaterialConnectionPoint;
  62506. initialize(state: NodeMaterialBuildState): void;
  62507. autoConfigure(material: NodeMaterial): void;
  62508. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62509. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  62510. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  62511. protected _buildBlock(state: NodeMaterialBuildState): this;
  62512. }
  62513. }
  62514. declare module "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock" {
  62515. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62516. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62517. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62518. import { Nullable } from "babylonjs/types";
  62519. import { Scene } from "babylonjs/scene";
  62520. import { Effect } from "babylonjs/Materials/effect";
  62521. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  62522. import { Mesh } from "babylonjs/Meshes/mesh";
  62523. import { Light } from "babylonjs/Lights/light";
  62524. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62525. /**
  62526. * Block used to get data information from a light
  62527. */
  62528. export class LightInformationBlock extends NodeMaterialBlock {
  62529. private _lightDataUniformName;
  62530. private _lightColorUniformName;
  62531. private _lightTypeDefineName;
  62532. /**
  62533. * Gets or sets the light associated with this block
  62534. */
  62535. light: Nullable<Light>;
  62536. /**
  62537. * Creates a new LightInformationBlock
  62538. * @param name defines the block name
  62539. */
  62540. constructor(name: string);
  62541. /**
  62542. * Gets the current class name
  62543. * @returns the class name
  62544. */
  62545. getClassName(): string;
  62546. /**
  62547. * Gets the world position input component
  62548. */
  62549. get worldPosition(): NodeMaterialConnectionPoint;
  62550. /**
  62551. * Gets the direction output component
  62552. */
  62553. get direction(): NodeMaterialConnectionPoint;
  62554. /**
  62555. * Gets the direction output component
  62556. */
  62557. get color(): NodeMaterialConnectionPoint;
  62558. /**
  62559. * Gets the direction output component
  62560. */
  62561. get intensity(): NodeMaterialConnectionPoint;
  62562. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  62563. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62564. protected _buildBlock(state: NodeMaterialBuildState): this;
  62565. serialize(): any;
  62566. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62567. }
  62568. }
  62569. declare module "babylonjs/Materials/Node/Blocks/Vertex/index" {
  62570. export * from "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock";
  62571. export * from "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock";
  62572. export * from "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock";
  62573. export * from "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock";
  62574. export * from "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock";
  62575. }
  62576. declare module "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock" {
  62577. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62578. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62579. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62580. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62581. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  62582. import { Effect } from "babylonjs/Materials/effect";
  62583. import { Mesh } from "babylonjs/Meshes/mesh";
  62584. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  62585. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  62586. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  62587. /**
  62588. * Block used to add image processing support to fragment shader
  62589. */
  62590. export class ImageProcessingBlock extends NodeMaterialBlock {
  62591. /**
  62592. * Create a new ImageProcessingBlock
  62593. * @param name defines the block name
  62594. */
  62595. constructor(name: string);
  62596. /**
  62597. * Gets the current class name
  62598. * @returns the class name
  62599. */
  62600. getClassName(): string;
  62601. /**
  62602. * Gets the color input component
  62603. */
  62604. get color(): NodeMaterialConnectionPoint;
  62605. /**
  62606. * Gets the output component
  62607. */
  62608. get output(): NodeMaterialConnectionPoint;
  62609. /**
  62610. * Initialize the block and prepare the context for build
  62611. * @param state defines the state that will be used for the build
  62612. */
  62613. initialize(state: NodeMaterialBuildState): void;
  62614. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  62615. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62616. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  62617. protected _buildBlock(state: NodeMaterialBuildState): this;
  62618. }
  62619. }
  62620. declare module "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock" {
  62621. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62622. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62623. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62624. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  62625. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62626. import { Effect } from "babylonjs/Materials/effect";
  62627. import { Mesh } from "babylonjs/Meshes/mesh";
  62628. import { Scene } from "babylonjs/scene";
  62629. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  62630. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  62631. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  62632. /**
  62633. * Block used to pertub normals based on a normal map
  62634. */
  62635. export class PerturbNormalBlock extends NodeMaterialBlock {
  62636. private _tangentSpaceParameterName;
  62637. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  62638. invertX: boolean;
  62639. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  62640. invertY: boolean;
  62641. /**
  62642. * Create a new PerturbNormalBlock
  62643. * @param name defines the block name
  62644. */
  62645. constructor(name: string);
  62646. /**
  62647. * Gets the current class name
  62648. * @returns the class name
  62649. */
  62650. getClassName(): string;
  62651. /**
  62652. * Gets the world position input component
  62653. */
  62654. get worldPosition(): NodeMaterialConnectionPoint;
  62655. /**
  62656. * Gets the world normal input component
  62657. */
  62658. get worldNormal(): NodeMaterialConnectionPoint;
  62659. /**
  62660. * Gets the world tangent input component
  62661. */
  62662. get worldTangent(): NodeMaterialConnectionPoint;
  62663. /**
  62664. * Gets the uv input component
  62665. */
  62666. get uv(): NodeMaterialConnectionPoint;
  62667. /**
  62668. * Gets the normal map color input component
  62669. */
  62670. get normalMapColor(): NodeMaterialConnectionPoint;
  62671. /**
  62672. * Gets the strength input component
  62673. */
  62674. get strength(): NodeMaterialConnectionPoint;
  62675. /**
  62676. * Gets the output component
  62677. */
  62678. get output(): NodeMaterialConnectionPoint;
  62679. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62680. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  62681. autoConfigure(material: NodeMaterial): void;
  62682. protected _buildBlock(state: NodeMaterialBuildState): this;
  62683. protected _dumpPropertiesCode(): string;
  62684. serialize(): any;
  62685. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62686. }
  62687. }
  62688. declare module "babylonjs/Materials/Node/Blocks/Fragment/discardBlock" {
  62689. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62690. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62691. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62692. /**
  62693. * Block used to discard a pixel if a value is smaller than a cutoff
  62694. */
  62695. export class DiscardBlock extends NodeMaterialBlock {
  62696. /**
  62697. * Create a new DiscardBlock
  62698. * @param name defines the block name
  62699. */
  62700. constructor(name: string);
  62701. /**
  62702. * Gets the current class name
  62703. * @returns the class name
  62704. */
  62705. getClassName(): string;
  62706. /**
  62707. * Gets the color input component
  62708. */
  62709. get value(): NodeMaterialConnectionPoint;
  62710. /**
  62711. * Gets the cutoff input component
  62712. */
  62713. get cutoff(): NodeMaterialConnectionPoint;
  62714. protected _buildBlock(state: NodeMaterialBuildState): this;
  62715. }
  62716. }
  62717. declare module "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock" {
  62718. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62719. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62720. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62721. /**
  62722. * Block used to test if the fragment shader is front facing
  62723. */
  62724. export class FrontFacingBlock extends NodeMaterialBlock {
  62725. /**
  62726. * Creates a new FrontFacingBlock
  62727. * @param name defines the block name
  62728. */
  62729. constructor(name: string);
  62730. /**
  62731. * Gets the current class name
  62732. * @returns the class name
  62733. */
  62734. getClassName(): string;
  62735. /**
  62736. * Gets the output component
  62737. */
  62738. get output(): NodeMaterialConnectionPoint;
  62739. protected _buildBlock(state: NodeMaterialBuildState): this;
  62740. }
  62741. }
  62742. declare module "babylonjs/Materials/Node/Blocks/Fragment/derivativeBlock" {
  62743. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62744. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62745. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62746. /**
  62747. * Block used to get the derivative value on x and y of a given input
  62748. */
  62749. export class DerivativeBlock extends NodeMaterialBlock {
  62750. /**
  62751. * Create a new DerivativeBlock
  62752. * @param name defines the block name
  62753. */
  62754. constructor(name: string);
  62755. /**
  62756. * Gets the current class name
  62757. * @returns the class name
  62758. */
  62759. getClassName(): string;
  62760. /**
  62761. * Gets the input component
  62762. */
  62763. get input(): NodeMaterialConnectionPoint;
  62764. /**
  62765. * Gets the derivative output on x
  62766. */
  62767. get dx(): NodeMaterialConnectionPoint;
  62768. /**
  62769. * Gets the derivative output on y
  62770. */
  62771. get dy(): NodeMaterialConnectionPoint;
  62772. protected _buildBlock(state: NodeMaterialBuildState): this;
  62773. }
  62774. }
  62775. declare module "babylonjs/Materials/Node/Blocks/Fragment/index" {
  62776. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock";
  62777. export * from "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock";
  62778. export * from "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock";
  62779. export * from "babylonjs/Materials/Node/Blocks/Fragment/discardBlock";
  62780. export * from "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock";
  62781. export * from "babylonjs/Materials/Node/Blocks/Fragment/derivativeBlock";
  62782. }
  62783. declare module "babylonjs/Materials/Node/Blocks/Dual/fogBlock" {
  62784. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62785. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62786. import { Mesh } from "babylonjs/Meshes/mesh";
  62787. import { Effect } from "babylonjs/Materials/effect";
  62788. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62789. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62790. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  62791. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  62792. /**
  62793. * Block used to add support for scene fog
  62794. */
  62795. export class FogBlock extends NodeMaterialBlock {
  62796. private _fogDistanceName;
  62797. private _fogParameters;
  62798. /**
  62799. * Create a new FogBlock
  62800. * @param name defines the block name
  62801. */
  62802. constructor(name: string);
  62803. /**
  62804. * Gets the current class name
  62805. * @returns the class name
  62806. */
  62807. getClassName(): string;
  62808. /**
  62809. * Gets the world position input component
  62810. */
  62811. get worldPosition(): NodeMaterialConnectionPoint;
  62812. /**
  62813. * Gets the view input component
  62814. */
  62815. get view(): NodeMaterialConnectionPoint;
  62816. /**
  62817. * Gets the color input component
  62818. */
  62819. get input(): NodeMaterialConnectionPoint;
  62820. /**
  62821. * Gets the fog color input component
  62822. */
  62823. get fogColor(): NodeMaterialConnectionPoint;
  62824. /**
  62825. * Gets the output component
  62826. */
  62827. get output(): NodeMaterialConnectionPoint;
  62828. autoConfigure(material: NodeMaterial): void;
  62829. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62830. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  62831. protected _buildBlock(state: NodeMaterialBuildState): this;
  62832. }
  62833. }
  62834. declare module "babylonjs/Materials/Node/Blocks/Dual/lightBlock" {
  62835. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62836. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62837. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62838. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62839. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  62840. import { Effect } from "babylonjs/Materials/effect";
  62841. import { Mesh } from "babylonjs/Meshes/mesh";
  62842. import { Light } from "babylonjs/Lights/light";
  62843. import { Nullable } from "babylonjs/types";
  62844. import { Scene } from "babylonjs/scene";
  62845. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  62846. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  62847. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  62848. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  62849. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  62850. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  62851. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  62852. /**
  62853. * Block used to add light in the fragment shader
  62854. */
  62855. export class LightBlock extends NodeMaterialBlock {
  62856. private _lightId;
  62857. /**
  62858. * Gets or sets the light associated with this block
  62859. */
  62860. light: Nullable<Light>;
  62861. /**
  62862. * Create a new LightBlock
  62863. * @param name defines the block name
  62864. */
  62865. constructor(name: string);
  62866. /**
  62867. * Gets the current class name
  62868. * @returns the class name
  62869. */
  62870. getClassName(): string;
  62871. /**
  62872. * Gets the world position input component
  62873. */
  62874. get worldPosition(): NodeMaterialConnectionPoint;
  62875. /**
  62876. * Gets the world normal input component
  62877. */
  62878. get worldNormal(): NodeMaterialConnectionPoint;
  62879. /**
  62880. * Gets the camera (or eye) position component
  62881. */
  62882. get cameraPosition(): NodeMaterialConnectionPoint;
  62883. /**
  62884. * Gets the glossiness component
  62885. */
  62886. get glossiness(): NodeMaterialConnectionPoint;
  62887. /**
  62888. * Gets the glossinness power component
  62889. */
  62890. get glossPower(): NodeMaterialConnectionPoint;
  62891. /**
  62892. * Gets the diffuse color component
  62893. */
  62894. get diffuseColor(): NodeMaterialConnectionPoint;
  62895. /**
  62896. * Gets the specular color component
  62897. */
  62898. get specularColor(): NodeMaterialConnectionPoint;
  62899. /**
  62900. * Gets the diffuse output component
  62901. */
  62902. get diffuseOutput(): NodeMaterialConnectionPoint;
  62903. /**
  62904. * Gets the specular output component
  62905. */
  62906. get specularOutput(): NodeMaterialConnectionPoint;
  62907. /**
  62908. * Gets the shadow output component
  62909. */
  62910. get shadow(): NodeMaterialConnectionPoint;
  62911. autoConfigure(material: NodeMaterial): void;
  62912. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62913. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  62914. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  62915. private _injectVertexCode;
  62916. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  62917. serialize(): any;
  62918. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62919. }
  62920. }
  62921. declare module "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock" {
  62922. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62923. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62924. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  62925. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  62926. /**
  62927. * Block used to read a reflection texture from a sampler
  62928. */
  62929. export class ReflectionTextureBlock extends ReflectionTextureBaseBlock {
  62930. /**
  62931. * Create a new ReflectionTextureBlock
  62932. * @param name defines the block name
  62933. */
  62934. constructor(name: string);
  62935. /**
  62936. * Gets the current class name
  62937. * @returns the class name
  62938. */
  62939. getClassName(): string;
  62940. /**
  62941. * Gets the world position input component
  62942. */
  62943. get position(): NodeMaterialConnectionPoint;
  62944. /**
  62945. * Gets the world position input component
  62946. */
  62947. get worldPosition(): NodeMaterialConnectionPoint;
  62948. /**
  62949. * Gets the world normal input component
  62950. */
  62951. get worldNormal(): NodeMaterialConnectionPoint;
  62952. /**
  62953. * Gets the world input component
  62954. */
  62955. get world(): NodeMaterialConnectionPoint;
  62956. /**
  62957. * Gets the camera (or eye) position component
  62958. */
  62959. get cameraPosition(): NodeMaterialConnectionPoint;
  62960. /**
  62961. * Gets the view input component
  62962. */
  62963. get view(): NodeMaterialConnectionPoint;
  62964. /**
  62965. * Gets the rgb output component
  62966. */
  62967. get rgb(): NodeMaterialConnectionPoint;
  62968. /**
  62969. * Gets the r output component
  62970. */
  62971. get r(): NodeMaterialConnectionPoint;
  62972. /**
  62973. * Gets the g output component
  62974. */
  62975. get g(): NodeMaterialConnectionPoint;
  62976. /**
  62977. * Gets the b output component
  62978. */
  62979. get b(): NodeMaterialConnectionPoint;
  62980. autoConfigure(material: NodeMaterial): void;
  62981. protected _buildBlock(state: NodeMaterialBuildState): this;
  62982. }
  62983. }
  62984. declare module "babylonjs/Materials/Node/Blocks/Dual/index" {
  62985. export * from "babylonjs/Materials/Node/Blocks/Dual/fogBlock";
  62986. export * from "babylonjs/Materials/Node/Blocks/Dual/lightBlock";
  62987. export * from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  62988. export * from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  62989. export * from "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock";
  62990. }
  62991. declare module "babylonjs/Materials/Node/Blocks/Input/index" {
  62992. export * from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  62993. export * from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  62994. }
  62995. declare module "babylonjs/Materials/Node/Blocks/addBlock" {
  62996. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62997. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62998. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62999. /**
  63000. * Block used to add 2 vectors
  63001. */
  63002. export class AddBlock extends NodeMaterialBlock {
  63003. /**
  63004. * Creates a new AddBlock
  63005. * @param name defines the block name
  63006. */
  63007. constructor(name: string);
  63008. /**
  63009. * Gets the current class name
  63010. * @returns the class name
  63011. */
  63012. getClassName(): string;
  63013. /**
  63014. * Gets the left operand input component
  63015. */
  63016. get left(): NodeMaterialConnectionPoint;
  63017. /**
  63018. * Gets the right operand input component
  63019. */
  63020. get right(): NodeMaterialConnectionPoint;
  63021. /**
  63022. * Gets the output component
  63023. */
  63024. get output(): NodeMaterialConnectionPoint;
  63025. protected _buildBlock(state: NodeMaterialBuildState): this;
  63026. }
  63027. }
  63028. declare module "babylonjs/Materials/Node/Blocks/scaleBlock" {
  63029. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63030. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63031. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63032. /**
  63033. * Block used to scale a vector by a float
  63034. */
  63035. export class ScaleBlock extends NodeMaterialBlock {
  63036. /**
  63037. * Creates a new ScaleBlock
  63038. * @param name defines the block name
  63039. */
  63040. constructor(name: string);
  63041. /**
  63042. * Gets the current class name
  63043. * @returns the class name
  63044. */
  63045. getClassName(): string;
  63046. /**
  63047. * Gets the input component
  63048. */
  63049. get input(): NodeMaterialConnectionPoint;
  63050. /**
  63051. * Gets the factor input component
  63052. */
  63053. get factor(): NodeMaterialConnectionPoint;
  63054. /**
  63055. * Gets the output component
  63056. */
  63057. get output(): NodeMaterialConnectionPoint;
  63058. protected _buildBlock(state: NodeMaterialBuildState): this;
  63059. }
  63060. }
  63061. declare module "babylonjs/Materials/Node/Blocks/clampBlock" {
  63062. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63063. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63064. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63065. import { Scene } from "babylonjs/scene";
  63066. /**
  63067. * Block used to clamp a float
  63068. */
  63069. export class ClampBlock extends NodeMaterialBlock {
  63070. /** Gets or sets the minimum range */
  63071. minimum: number;
  63072. /** Gets or sets the maximum range */
  63073. maximum: number;
  63074. /**
  63075. * Creates a new ClampBlock
  63076. * @param name defines the block name
  63077. */
  63078. constructor(name: string);
  63079. /**
  63080. * Gets the current class name
  63081. * @returns the class name
  63082. */
  63083. getClassName(): string;
  63084. /**
  63085. * Gets the value input component
  63086. */
  63087. get value(): NodeMaterialConnectionPoint;
  63088. /**
  63089. * Gets the output component
  63090. */
  63091. get output(): NodeMaterialConnectionPoint;
  63092. protected _buildBlock(state: NodeMaterialBuildState): this;
  63093. protected _dumpPropertiesCode(): string;
  63094. serialize(): any;
  63095. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63096. }
  63097. }
  63098. declare module "babylonjs/Materials/Node/Blocks/crossBlock" {
  63099. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63100. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63101. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63102. /**
  63103. * Block used to apply a cross product between 2 vectors
  63104. */
  63105. export class CrossBlock extends NodeMaterialBlock {
  63106. /**
  63107. * Creates a new CrossBlock
  63108. * @param name defines the block name
  63109. */
  63110. constructor(name: string);
  63111. /**
  63112. * Gets the current class name
  63113. * @returns the class name
  63114. */
  63115. getClassName(): string;
  63116. /**
  63117. * Gets the left operand input component
  63118. */
  63119. get left(): NodeMaterialConnectionPoint;
  63120. /**
  63121. * Gets the right operand input component
  63122. */
  63123. get right(): NodeMaterialConnectionPoint;
  63124. /**
  63125. * Gets the output component
  63126. */
  63127. get output(): NodeMaterialConnectionPoint;
  63128. protected _buildBlock(state: NodeMaterialBuildState): this;
  63129. }
  63130. }
  63131. declare module "babylonjs/Materials/Node/Blocks/dotBlock" {
  63132. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63133. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63134. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63135. /**
  63136. * Block used to apply a dot product between 2 vectors
  63137. */
  63138. export class DotBlock extends NodeMaterialBlock {
  63139. /**
  63140. * Creates a new DotBlock
  63141. * @param name defines the block name
  63142. */
  63143. constructor(name: string);
  63144. /**
  63145. * Gets the current class name
  63146. * @returns the class name
  63147. */
  63148. getClassName(): string;
  63149. /**
  63150. * Gets the left operand input component
  63151. */
  63152. get left(): NodeMaterialConnectionPoint;
  63153. /**
  63154. * Gets the right operand input component
  63155. */
  63156. get right(): NodeMaterialConnectionPoint;
  63157. /**
  63158. * Gets the output component
  63159. */
  63160. get output(): NodeMaterialConnectionPoint;
  63161. protected _buildBlock(state: NodeMaterialBuildState): this;
  63162. }
  63163. }
  63164. declare module "babylonjs/Materials/Node/Blocks/normalizeBlock" {
  63165. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63166. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63167. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63168. /**
  63169. * Block used to normalize a vector
  63170. */
  63171. export class NormalizeBlock extends NodeMaterialBlock {
  63172. /**
  63173. * Creates a new NormalizeBlock
  63174. * @param name defines the block name
  63175. */
  63176. constructor(name: string);
  63177. /**
  63178. * Gets the current class name
  63179. * @returns the class name
  63180. */
  63181. getClassName(): string;
  63182. /**
  63183. * Gets the input component
  63184. */
  63185. get input(): NodeMaterialConnectionPoint;
  63186. /**
  63187. * Gets the output component
  63188. */
  63189. get output(): NodeMaterialConnectionPoint;
  63190. protected _buildBlock(state: NodeMaterialBuildState): this;
  63191. }
  63192. }
  63193. declare module "babylonjs/Materials/Node/Blocks/trigonometryBlock" {
  63194. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63195. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63196. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63197. import { Scene } from "babylonjs/scene";
  63198. /**
  63199. * Operations supported by the Trigonometry block
  63200. */
  63201. export enum TrigonometryBlockOperations {
  63202. /** Cos */
  63203. Cos = 0,
  63204. /** Sin */
  63205. Sin = 1,
  63206. /** Abs */
  63207. Abs = 2,
  63208. /** Exp */
  63209. Exp = 3,
  63210. /** Exp2 */
  63211. Exp2 = 4,
  63212. /** Round */
  63213. Round = 5,
  63214. /** Floor */
  63215. Floor = 6,
  63216. /** Ceiling */
  63217. Ceiling = 7,
  63218. /** Square root */
  63219. Sqrt = 8,
  63220. /** Log */
  63221. Log = 9,
  63222. /** Tangent */
  63223. Tan = 10,
  63224. /** Arc tangent */
  63225. ArcTan = 11,
  63226. /** Arc cosinus */
  63227. ArcCos = 12,
  63228. /** Arc sinus */
  63229. ArcSin = 13,
  63230. /** Fraction */
  63231. Fract = 14,
  63232. /** Sign */
  63233. Sign = 15,
  63234. /** To radians (from degrees) */
  63235. Radians = 16,
  63236. /** To degrees (from radians) */
  63237. Degrees = 17
  63238. }
  63239. /**
  63240. * Block used to apply trigonometry operation to floats
  63241. */
  63242. export class TrigonometryBlock extends NodeMaterialBlock {
  63243. /**
  63244. * Gets or sets the operation applied by the block
  63245. */
  63246. operation: TrigonometryBlockOperations;
  63247. /**
  63248. * Creates a new TrigonometryBlock
  63249. * @param name defines the block name
  63250. */
  63251. constructor(name: string);
  63252. /**
  63253. * Gets the current class name
  63254. * @returns the class name
  63255. */
  63256. getClassName(): string;
  63257. /**
  63258. * Gets the input component
  63259. */
  63260. get input(): NodeMaterialConnectionPoint;
  63261. /**
  63262. * Gets the output component
  63263. */
  63264. get output(): NodeMaterialConnectionPoint;
  63265. protected _buildBlock(state: NodeMaterialBuildState): this;
  63266. serialize(): any;
  63267. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63268. protected _dumpPropertiesCode(): string;
  63269. }
  63270. }
  63271. declare module "babylonjs/Materials/Node/Blocks/colorMergerBlock" {
  63272. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63273. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63274. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63275. /**
  63276. * Block used to create a Color3/4 out of individual inputs (one for each component)
  63277. */
  63278. export class ColorMergerBlock extends NodeMaterialBlock {
  63279. /**
  63280. * Create a new ColorMergerBlock
  63281. * @param name defines the block name
  63282. */
  63283. constructor(name: string);
  63284. /**
  63285. * Gets the current class name
  63286. * @returns the class name
  63287. */
  63288. getClassName(): string;
  63289. /**
  63290. * Gets the rgb component (input)
  63291. */
  63292. get rgbIn(): NodeMaterialConnectionPoint;
  63293. /**
  63294. * Gets the r component (input)
  63295. */
  63296. get r(): NodeMaterialConnectionPoint;
  63297. /**
  63298. * Gets the g component (input)
  63299. */
  63300. get g(): NodeMaterialConnectionPoint;
  63301. /**
  63302. * Gets the b component (input)
  63303. */
  63304. get b(): NodeMaterialConnectionPoint;
  63305. /**
  63306. * Gets the a component (input)
  63307. */
  63308. get a(): NodeMaterialConnectionPoint;
  63309. /**
  63310. * Gets the rgba component (output)
  63311. */
  63312. get rgba(): NodeMaterialConnectionPoint;
  63313. /**
  63314. * Gets the rgb component (output)
  63315. */
  63316. get rgbOut(): NodeMaterialConnectionPoint;
  63317. /**
  63318. * Gets the rgb component (output)
  63319. * @deprecated Please use rgbOut instead.
  63320. */
  63321. get rgb(): NodeMaterialConnectionPoint;
  63322. protected _buildBlock(state: NodeMaterialBuildState): this;
  63323. }
  63324. }
  63325. declare module "babylonjs/Materials/Node/Blocks/colorSplitterBlock" {
  63326. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63327. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63328. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63329. /**
  63330. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  63331. */
  63332. export class ColorSplitterBlock extends NodeMaterialBlock {
  63333. /**
  63334. * Create a new ColorSplitterBlock
  63335. * @param name defines the block name
  63336. */
  63337. constructor(name: string);
  63338. /**
  63339. * Gets the current class name
  63340. * @returns the class name
  63341. */
  63342. getClassName(): string;
  63343. /**
  63344. * Gets the rgba component (input)
  63345. */
  63346. get rgba(): NodeMaterialConnectionPoint;
  63347. /**
  63348. * Gets the rgb component (input)
  63349. */
  63350. get rgbIn(): NodeMaterialConnectionPoint;
  63351. /**
  63352. * Gets the rgb component (output)
  63353. */
  63354. get rgbOut(): NodeMaterialConnectionPoint;
  63355. /**
  63356. * Gets the r component (output)
  63357. */
  63358. get r(): NodeMaterialConnectionPoint;
  63359. /**
  63360. * Gets the g component (output)
  63361. */
  63362. get g(): NodeMaterialConnectionPoint;
  63363. /**
  63364. * Gets the b component (output)
  63365. */
  63366. get b(): NodeMaterialConnectionPoint;
  63367. /**
  63368. * Gets the a component (output)
  63369. */
  63370. get a(): NodeMaterialConnectionPoint;
  63371. protected _inputRename(name: string): string;
  63372. protected _outputRename(name: string): string;
  63373. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  63374. }
  63375. }
  63376. declare module "babylonjs/Materials/Node/Blocks/vectorSplitterBlock" {
  63377. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63378. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63379. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63380. /**
  63381. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  63382. */
  63383. export class VectorSplitterBlock extends NodeMaterialBlock {
  63384. /**
  63385. * Create a new VectorSplitterBlock
  63386. * @param name defines the block name
  63387. */
  63388. constructor(name: string);
  63389. /**
  63390. * Gets the current class name
  63391. * @returns the class name
  63392. */
  63393. getClassName(): string;
  63394. /**
  63395. * Gets the xyzw component (input)
  63396. */
  63397. get xyzw(): NodeMaterialConnectionPoint;
  63398. /**
  63399. * Gets the xyz component (input)
  63400. */
  63401. get xyzIn(): NodeMaterialConnectionPoint;
  63402. /**
  63403. * Gets the xy component (input)
  63404. */
  63405. get xyIn(): NodeMaterialConnectionPoint;
  63406. /**
  63407. * Gets the xyz component (output)
  63408. */
  63409. get xyzOut(): NodeMaterialConnectionPoint;
  63410. /**
  63411. * Gets the xy component (output)
  63412. */
  63413. get xyOut(): NodeMaterialConnectionPoint;
  63414. /**
  63415. * Gets the x component (output)
  63416. */
  63417. get x(): NodeMaterialConnectionPoint;
  63418. /**
  63419. * Gets the y component (output)
  63420. */
  63421. get y(): NodeMaterialConnectionPoint;
  63422. /**
  63423. * Gets the z component (output)
  63424. */
  63425. get z(): NodeMaterialConnectionPoint;
  63426. /**
  63427. * Gets the w component (output)
  63428. */
  63429. get w(): NodeMaterialConnectionPoint;
  63430. protected _inputRename(name: string): string;
  63431. protected _outputRename(name: string): string;
  63432. protected _buildBlock(state: NodeMaterialBuildState): this;
  63433. }
  63434. }
  63435. declare module "babylonjs/Materials/Node/Blocks/lerpBlock" {
  63436. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63437. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63438. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63439. /**
  63440. * Block used to lerp between 2 values
  63441. */
  63442. export class LerpBlock extends NodeMaterialBlock {
  63443. /**
  63444. * Creates a new LerpBlock
  63445. * @param name defines the block name
  63446. */
  63447. constructor(name: string);
  63448. /**
  63449. * Gets the current class name
  63450. * @returns the class name
  63451. */
  63452. getClassName(): string;
  63453. /**
  63454. * Gets the left operand input component
  63455. */
  63456. get left(): NodeMaterialConnectionPoint;
  63457. /**
  63458. * Gets the right operand input component
  63459. */
  63460. get right(): NodeMaterialConnectionPoint;
  63461. /**
  63462. * Gets the gradient operand input component
  63463. */
  63464. get gradient(): NodeMaterialConnectionPoint;
  63465. /**
  63466. * Gets the output component
  63467. */
  63468. get output(): NodeMaterialConnectionPoint;
  63469. protected _buildBlock(state: NodeMaterialBuildState): this;
  63470. }
  63471. }
  63472. declare module "babylonjs/Materials/Node/Blocks/divideBlock" {
  63473. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63474. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63475. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63476. /**
  63477. * Block used to divide 2 vectors
  63478. */
  63479. export class DivideBlock extends NodeMaterialBlock {
  63480. /**
  63481. * Creates a new DivideBlock
  63482. * @param name defines the block name
  63483. */
  63484. constructor(name: string);
  63485. /**
  63486. * Gets the current class name
  63487. * @returns the class name
  63488. */
  63489. getClassName(): string;
  63490. /**
  63491. * Gets the left operand input component
  63492. */
  63493. get left(): NodeMaterialConnectionPoint;
  63494. /**
  63495. * Gets the right operand input component
  63496. */
  63497. get right(): NodeMaterialConnectionPoint;
  63498. /**
  63499. * Gets the output component
  63500. */
  63501. get output(): NodeMaterialConnectionPoint;
  63502. protected _buildBlock(state: NodeMaterialBuildState): this;
  63503. }
  63504. }
  63505. declare module "babylonjs/Materials/Node/Blocks/subtractBlock" {
  63506. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63507. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63508. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63509. /**
  63510. * Block used to subtract 2 vectors
  63511. */
  63512. export class SubtractBlock extends NodeMaterialBlock {
  63513. /**
  63514. * Creates a new SubtractBlock
  63515. * @param name defines the block name
  63516. */
  63517. constructor(name: string);
  63518. /**
  63519. * Gets the current class name
  63520. * @returns the class name
  63521. */
  63522. getClassName(): string;
  63523. /**
  63524. * Gets the left operand input component
  63525. */
  63526. get left(): NodeMaterialConnectionPoint;
  63527. /**
  63528. * Gets the right operand input component
  63529. */
  63530. get right(): NodeMaterialConnectionPoint;
  63531. /**
  63532. * Gets the output component
  63533. */
  63534. get output(): NodeMaterialConnectionPoint;
  63535. protected _buildBlock(state: NodeMaterialBuildState): this;
  63536. }
  63537. }
  63538. declare module "babylonjs/Materials/Node/Blocks/stepBlock" {
  63539. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63540. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63541. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63542. /**
  63543. * Block used to step a value
  63544. */
  63545. export class StepBlock extends NodeMaterialBlock {
  63546. /**
  63547. * Creates a new StepBlock
  63548. * @param name defines the block name
  63549. */
  63550. constructor(name: string);
  63551. /**
  63552. * Gets the current class name
  63553. * @returns the class name
  63554. */
  63555. getClassName(): string;
  63556. /**
  63557. * Gets the value operand input component
  63558. */
  63559. get value(): NodeMaterialConnectionPoint;
  63560. /**
  63561. * Gets the edge operand input component
  63562. */
  63563. get edge(): NodeMaterialConnectionPoint;
  63564. /**
  63565. * Gets the output component
  63566. */
  63567. get output(): NodeMaterialConnectionPoint;
  63568. protected _buildBlock(state: NodeMaterialBuildState): this;
  63569. }
  63570. }
  63571. declare module "babylonjs/Materials/Node/Blocks/oneMinusBlock" {
  63572. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63573. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63574. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63575. /**
  63576. * Block used to get the opposite (1 - x) of a value
  63577. */
  63578. export class OneMinusBlock extends NodeMaterialBlock {
  63579. /**
  63580. * Creates a new OneMinusBlock
  63581. * @param name defines the block name
  63582. */
  63583. constructor(name: string);
  63584. /**
  63585. * Gets the current class name
  63586. * @returns the class name
  63587. */
  63588. getClassName(): string;
  63589. /**
  63590. * Gets the input component
  63591. */
  63592. get input(): NodeMaterialConnectionPoint;
  63593. /**
  63594. * Gets the output component
  63595. */
  63596. get output(): NodeMaterialConnectionPoint;
  63597. protected _buildBlock(state: NodeMaterialBuildState): this;
  63598. }
  63599. }
  63600. declare module "babylonjs/Materials/Node/Blocks/viewDirectionBlock" {
  63601. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63602. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63603. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63604. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  63605. /**
  63606. * Block used to get the view direction
  63607. */
  63608. export class ViewDirectionBlock extends NodeMaterialBlock {
  63609. /**
  63610. * Creates a new ViewDirectionBlock
  63611. * @param name defines the block name
  63612. */
  63613. constructor(name: string);
  63614. /**
  63615. * Gets the current class name
  63616. * @returns the class name
  63617. */
  63618. getClassName(): string;
  63619. /**
  63620. * Gets the world position component
  63621. */
  63622. get worldPosition(): NodeMaterialConnectionPoint;
  63623. /**
  63624. * Gets the camera position component
  63625. */
  63626. get cameraPosition(): NodeMaterialConnectionPoint;
  63627. /**
  63628. * Gets the output component
  63629. */
  63630. get output(): NodeMaterialConnectionPoint;
  63631. autoConfigure(material: NodeMaterial): void;
  63632. protected _buildBlock(state: NodeMaterialBuildState): this;
  63633. }
  63634. }
  63635. declare module "babylonjs/Materials/Node/Blocks/fresnelBlock" {
  63636. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63637. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63638. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63639. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  63640. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  63641. /**
  63642. * Block used to compute fresnel value
  63643. */
  63644. export class FresnelBlock extends NodeMaterialBlock {
  63645. /**
  63646. * Create a new FresnelBlock
  63647. * @param name defines the block name
  63648. */
  63649. constructor(name: string);
  63650. /**
  63651. * Gets the current class name
  63652. * @returns the class name
  63653. */
  63654. getClassName(): string;
  63655. /**
  63656. * Gets the world normal input component
  63657. */
  63658. get worldNormal(): NodeMaterialConnectionPoint;
  63659. /**
  63660. * Gets the view direction input component
  63661. */
  63662. get viewDirection(): NodeMaterialConnectionPoint;
  63663. /**
  63664. * Gets the bias input component
  63665. */
  63666. get bias(): NodeMaterialConnectionPoint;
  63667. /**
  63668. * Gets the camera (or eye) position component
  63669. */
  63670. get power(): NodeMaterialConnectionPoint;
  63671. /**
  63672. * Gets the fresnel output component
  63673. */
  63674. get fresnel(): NodeMaterialConnectionPoint;
  63675. autoConfigure(material: NodeMaterial): void;
  63676. protected _buildBlock(state: NodeMaterialBuildState): this;
  63677. }
  63678. }
  63679. declare module "babylonjs/Materials/Node/Blocks/maxBlock" {
  63680. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63681. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63682. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63683. /**
  63684. * Block used to get the max of 2 values
  63685. */
  63686. export class MaxBlock extends NodeMaterialBlock {
  63687. /**
  63688. * Creates a new MaxBlock
  63689. * @param name defines the block name
  63690. */
  63691. constructor(name: string);
  63692. /**
  63693. * Gets the current class name
  63694. * @returns the class name
  63695. */
  63696. getClassName(): string;
  63697. /**
  63698. * Gets the left operand input component
  63699. */
  63700. get left(): NodeMaterialConnectionPoint;
  63701. /**
  63702. * Gets the right operand input component
  63703. */
  63704. get right(): NodeMaterialConnectionPoint;
  63705. /**
  63706. * Gets the output component
  63707. */
  63708. get output(): NodeMaterialConnectionPoint;
  63709. protected _buildBlock(state: NodeMaterialBuildState): this;
  63710. }
  63711. }
  63712. declare module "babylonjs/Materials/Node/Blocks/minBlock" {
  63713. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63714. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63715. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63716. /**
  63717. * Block used to get the min of 2 values
  63718. */
  63719. export class MinBlock extends NodeMaterialBlock {
  63720. /**
  63721. * Creates a new MinBlock
  63722. * @param name defines the block name
  63723. */
  63724. constructor(name: string);
  63725. /**
  63726. * Gets the current class name
  63727. * @returns the class name
  63728. */
  63729. getClassName(): string;
  63730. /**
  63731. * Gets the left operand input component
  63732. */
  63733. get left(): NodeMaterialConnectionPoint;
  63734. /**
  63735. * Gets the right operand input component
  63736. */
  63737. get right(): NodeMaterialConnectionPoint;
  63738. /**
  63739. * Gets the output component
  63740. */
  63741. get output(): NodeMaterialConnectionPoint;
  63742. protected _buildBlock(state: NodeMaterialBuildState): this;
  63743. }
  63744. }
  63745. declare module "babylonjs/Materials/Node/Blocks/distanceBlock" {
  63746. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63747. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63748. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63749. /**
  63750. * Block used to get the distance between 2 values
  63751. */
  63752. export class DistanceBlock extends NodeMaterialBlock {
  63753. /**
  63754. * Creates a new DistanceBlock
  63755. * @param name defines the block name
  63756. */
  63757. constructor(name: string);
  63758. /**
  63759. * Gets the current class name
  63760. * @returns the class name
  63761. */
  63762. getClassName(): string;
  63763. /**
  63764. * Gets the left operand input component
  63765. */
  63766. get left(): NodeMaterialConnectionPoint;
  63767. /**
  63768. * Gets the right operand input component
  63769. */
  63770. get right(): NodeMaterialConnectionPoint;
  63771. /**
  63772. * Gets the output component
  63773. */
  63774. get output(): NodeMaterialConnectionPoint;
  63775. protected _buildBlock(state: NodeMaterialBuildState): this;
  63776. }
  63777. }
  63778. declare module "babylonjs/Materials/Node/Blocks/lengthBlock" {
  63779. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63780. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63781. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63782. /**
  63783. * Block used to get the length of a vector
  63784. */
  63785. export class LengthBlock extends NodeMaterialBlock {
  63786. /**
  63787. * Creates a new LengthBlock
  63788. * @param name defines the block name
  63789. */
  63790. constructor(name: string);
  63791. /**
  63792. * Gets the current class name
  63793. * @returns the class name
  63794. */
  63795. getClassName(): string;
  63796. /**
  63797. * Gets the value input component
  63798. */
  63799. get value(): NodeMaterialConnectionPoint;
  63800. /**
  63801. * Gets the output component
  63802. */
  63803. get output(): NodeMaterialConnectionPoint;
  63804. protected _buildBlock(state: NodeMaterialBuildState): this;
  63805. }
  63806. }
  63807. declare module "babylonjs/Materials/Node/Blocks/negateBlock" {
  63808. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63809. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63810. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63811. /**
  63812. * Block used to get negative version of a value (i.e. x * -1)
  63813. */
  63814. export class NegateBlock extends NodeMaterialBlock {
  63815. /**
  63816. * Creates a new NegateBlock
  63817. * @param name defines the block name
  63818. */
  63819. constructor(name: string);
  63820. /**
  63821. * Gets the current class name
  63822. * @returns the class name
  63823. */
  63824. getClassName(): string;
  63825. /**
  63826. * Gets the value input component
  63827. */
  63828. get value(): NodeMaterialConnectionPoint;
  63829. /**
  63830. * Gets the output component
  63831. */
  63832. get output(): NodeMaterialConnectionPoint;
  63833. protected _buildBlock(state: NodeMaterialBuildState): this;
  63834. }
  63835. }
  63836. declare module "babylonjs/Materials/Node/Blocks/powBlock" {
  63837. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63838. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63839. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63840. /**
  63841. * Block used to get the value of the first parameter raised to the power of the second
  63842. */
  63843. export class PowBlock extends NodeMaterialBlock {
  63844. /**
  63845. * Creates a new PowBlock
  63846. * @param name defines the block name
  63847. */
  63848. constructor(name: string);
  63849. /**
  63850. * Gets the current class name
  63851. * @returns the class name
  63852. */
  63853. getClassName(): string;
  63854. /**
  63855. * Gets the value operand input component
  63856. */
  63857. get value(): NodeMaterialConnectionPoint;
  63858. /**
  63859. * Gets the power operand input component
  63860. */
  63861. get power(): NodeMaterialConnectionPoint;
  63862. /**
  63863. * Gets the output component
  63864. */
  63865. get output(): NodeMaterialConnectionPoint;
  63866. protected _buildBlock(state: NodeMaterialBuildState): this;
  63867. }
  63868. }
  63869. declare module "babylonjs/Materials/Node/Blocks/randomNumberBlock" {
  63870. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63871. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63872. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63873. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  63874. /**
  63875. * Block used to get a random number
  63876. */
  63877. export class RandomNumberBlock extends NodeMaterialBlock {
  63878. /**
  63879. * Creates a new RandomNumberBlock
  63880. * @param name defines the block name
  63881. */
  63882. constructor(name: string);
  63883. /**
  63884. * Gets the current class name
  63885. * @returns the class name
  63886. */
  63887. getClassName(): string;
  63888. /**
  63889. * Gets the seed input component
  63890. */
  63891. get seed(): NodeMaterialConnectionPoint;
  63892. /**
  63893. * Gets the output component
  63894. */
  63895. get output(): NodeMaterialConnectionPoint;
  63896. protected _buildBlock(state: NodeMaterialBuildState): this;
  63897. }
  63898. }
  63899. declare module "babylonjs/Materials/Node/Blocks/arcTan2Block" {
  63900. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63901. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63902. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63903. /**
  63904. * Block used to compute arc tangent of 2 values
  63905. */
  63906. export class ArcTan2Block extends NodeMaterialBlock {
  63907. /**
  63908. * Creates a new ArcTan2Block
  63909. * @param name defines the block name
  63910. */
  63911. constructor(name: string);
  63912. /**
  63913. * Gets the current class name
  63914. * @returns the class name
  63915. */
  63916. getClassName(): string;
  63917. /**
  63918. * Gets the x operand input component
  63919. */
  63920. get x(): NodeMaterialConnectionPoint;
  63921. /**
  63922. * Gets the y operand input component
  63923. */
  63924. get y(): NodeMaterialConnectionPoint;
  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/smoothStepBlock" {
  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 smooth step a value
  63938. */
  63939. export class SmoothStepBlock extends NodeMaterialBlock {
  63940. /**
  63941. * Creates a new SmoothStepBlock
  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 value operand input component
  63952. */
  63953. get value(): NodeMaterialConnectionPoint;
  63954. /**
  63955. * Gets the first edge operand input component
  63956. */
  63957. get edge0(): NodeMaterialConnectionPoint;
  63958. /**
  63959. * Gets the second edge operand input component
  63960. */
  63961. get edge1(): NodeMaterialConnectionPoint;
  63962. /**
  63963. * Gets the output component
  63964. */
  63965. get output(): NodeMaterialConnectionPoint;
  63966. protected _buildBlock(state: NodeMaterialBuildState): this;
  63967. }
  63968. }
  63969. declare module "babylonjs/Materials/Node/Blocks/reciprocalBlock" {
  63970. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63971. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63972. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63973. /**
  63974. * Block used to get the reciprocal (1 / x) of a value
  63975. */
  63976. export class ReciprocalBlock extends NodeMaterialBlock {
  63977. /**
  63978. * Creates a new ReciprocalBlock
  63979. * @param name defines the block name
  63980. */
  63981. constructor(name: string);
  63982. /**
  63983. * Gets the current class name
  63984. * @returns the class name
  63985. */
  63986. getClassName(): string;
  63987. /**
  63988. * Gets the input component
  63989. */
  63990. get input(): NodeMaterialConnectionPoint;
  63991. /**
  63992. * Gets the output component
  63993. */
  63994. get output(): NodeMaterialConnectionPoint;
  63995. protected _buildBlock(state: NodeMaterialBuildState): this;
  63996. }
  63997. }
  63998. declare module "babylonjs/Materials/Node/Blocks/replaceColorBlock" {
  63999. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64000. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64001. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64002. /**
  64003. * Block used to replace a color by another one
  64004. */
  64005. export class ReplaceColorBlock extends NodeMaterialBlock {
  64006. /**
  64007. * Creates a new ReplaceColorBlock
  64008. * @param name defines the block name
  64009. */
  64010. constructor(name: string);
  64011. /**
  64012. * Gets the current class name
  64013. * @returns the class name
  64014. */
  64015. getClassName(): string;
  64016. /**
  64017. * Gets the value input component
  64018. */
  64019. get value(): NodeMaterialConnectionPoint;
  64020. /**
  64021. * Gets the reference input component
  64022. */
  64023. get reference(): NodeMaterialConnectionPoint;
  64024. /**
  64025. * Gets the distance input component
  64026. */
  64027. get distance(): NodeMaterialConnectionPoint;
  64028. /**
  64029. * Gets the replacement input component
  64030. */
  64031. get replacement(): NodeMaterialConnectionPoint;
  64032. /**
  64033. * Gets the output component
  64034. */
  64035. get output(): NodeMaterialConnectionPoint;
  64036. protected _buildBlock(state: NodeMaterialBuildState): this;
  64037. }
  64038. }
  64039. declare module "babylonjs/Materials/Node/Blocks/posterizeBlock" {
  64040. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64041. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64042. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64043. /**
  64044. * Block used to posterize a value
  64045. * @see https://en.wikipedia.org/wiki/Posterization
  64046. */
  64047. export class PosterizeBlock extends NodeMaterialBlock {
  64048. /**
  64049. * Creates a new PosterizeBlock
  64050. * @param name defines the block name
  64051. */
  64052. constructor(name: string);
  64053. /**
  64054. * Gets the current class name
  64055. * @returns the class name
  64056. */
  64057. getClassName(): string;
  64058. /**
  64059. * Gets the value input component
  64060. */
  64061. get value(): NodeMaterialConnectionPoint;
  64062. /**
  64063. * Gets the steps input component
  64064. */
  64065. get steps(): NodeMaterialConnectionPoint;
  64066. /**
  64067. * Gets the output component
  64068. */
  64069. get output(): NodeMaterialConnectionPoint;
  64070. protected _buildBlock(state: NodeMaterialBuildState): this;
  64071. }
  64072. }
  64073. declare module "babylonjs/Materials/Node/Blocks/waveBlock" {
  64074. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64075. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64076. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64077. import { Scene } from "babylonjs/scene";
  64078. /**
  64079. * Operations supported by the Wave block
  64080. */
  64081. export enum WaveBlockKind {
  64082. /** SawTooth */
  64083. SawTooth = 0,
  64084. /** Square */
  64085. Square = 1,
  64086. /** Triangle */
  64087. Triangle = 2
  64088. }
  64089. /**
  64090. * Block used to apply wave operation to floats
  64091. */
  64092. export class WaveBlock extends NodeMaterialBlock {
  64093. /**
  64094. * Gets or sets the kibnd of wave to be applied by the block
  64095. */
  64096. kind: WaveBlockKind;
  64097. /**
  64098. * Creates a new WaveBlock
  64099. * @param name defines the block name
  64100. */
  64101. constructor(name: string);
  64102. /**
  64103. * Gets the current class name
  64104. * @returns the class name
  64105. */
  64106. getClassName(): string;
  64107. /**
  64108. * Gets the input component
  64109. */
  64110. get input(): NodeMaterialConnectionPoint;
  64111. /**
  64112. * Gets the output component
  64113. */
  64114. get output(): NodeMaterialConnectionPoint;
  64115. protected _buildBlock(state: NodeMaterialBuildState): this;
  64116. serialize(): any;
  64117. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64118. }
  64119. }
  64120. declare module "babylonjs/Materials/Node/Blocks/gradientBlock" {
  64121. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64122. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64123. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64124. import { Color3 } from "babylonjs/Maths/math.color";
  64125. import { Scene } from "babylonjs/scene";
  64126. /**
  64127. * Class used to store a color step for the GradientBlock
  64128. */
  64129. export class GradientBlockColorStep {
  64130. /**
  64131. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  64132. */
  64133. step: number;
  64134. /**
  64135. * Gets or sets the color associated with this step
  64136. */
  64137. color: Color3;
  64138. /**
  64139. * Creates a new GradientBlockColorStep
  64140. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  64141. * @param color defines the color associated with this step
  64142. */
  64143. constructor(
  64144. /**
  64145. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  64146. */
  64147. step: number,
  64148. /**
  64149. * Gets or sets the color associated with this step
  64150. */
  64151. color: Color3);
  64152. }
  64153. /**
  64154. * Block used to return a color from a gradient based on an input value between 0 and 1
  64155. */
  64156. export class GradientBlock extends NodeMaterialBlock {
  64157. /**
  64158. * Gets or sets the list of color steps
  64159. */
  64160. colorSteps: GradientBlockColorStep[];
  64161. /**
  64162. * Creates a new GradientBlock
  64163. * @param name defines the block name
  64164. */
  64165. constructor(name: string);
  64166. /**
  64167. * Gets the current class name
  64168. * @returns the class name
  64169. */
  64170. getClassName(): string;
  64171. /**
  64172. * Gets the gradient input component
  64173. */
  64174. get gradient(): NodeMaterialConnectionPoint;
  64175. /**
  64176. * Gets the output component
  64177. */
  64178. get output(): NodeMaterialConnectionPoint;
  64179. private _writeColorConstant;
  64180. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  64181. serialize(): any;
  64182. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64183. protected _dumpPropertiesCode(): string;
  64184. }
  64185. }
  64186. declare module "babylonjs/Materials/Node/Blocks/nLerpBlock" {
  64187. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64188. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64189. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64190. /**
  64191. * Block used to normalize lerp between 2 values
  64192. */
  64193. export class NLerpBlock extends NodeMaterialBlock {
  64194. /**
  64195. * Creates a new NLerpBlock
  64196. * @param name defines the block name
  64197. */
  64198. constructor(name: string);
  64199. /**
  64200. * Gets the current class name
  64201. * @returns the class name
  64202. */
  64203. getClassName(): string;
  64204. /**
  64205. * Gets the left operand input component
  64206. */
  64207. get left(): NodeMaterialConnectionPoint;
  64208. /**
  64209. * Gets the right operand input component
  64210. */
  64211. get right(): NodeMaterialConnectionPoint;
  64212. /**
  64213. * Gets the gradient operand input component
  64214. */
  64215. get gradient(): NodeMaterialConnectionPoint;
  64216. /**
  64217. * Gets the output component
  64218. */
  64219. get output(): NodeMaterialConnectionPoint;
  64220. protected _buildBlock(state: NodeMaterialBuildState): this;
  64221. }
  64222. }
  64223. declare module "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock" {
  64224. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64225. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64226. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64227. import { Scene } from "babylonjs/scene";
  64228. /**
  64229. * block used to Generate a Worley Noise 3D Noise Pattern
  64230. */
  64231. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  64232. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  64233. manhattanDistance: boolean;
  64234. /**
  64235. * Creates a new WorleyNoise3DBlock
  64236. * @param name defines the block name
  64237. */
  64238. constructor(name: string);
  64239. /**
  64240. * Gets the current class name
  64241. * @returns the class name
  64242. */
  64243. getClassName(): string;
  64244. /**
  64245. * Gets the seed input component
  64246. */
  64247. get seed(): NodeMaterialConnectionPoint;
  64248. /**
  64249. * Gets the jitter input component
  64250. */
  64251. get jitter(): NodeMaterialConnectionPoint;
  64252. /**
  64253. * Gets the output component
  64254. */
  64255. get output(): NodeMaterialConnectionPoint;
  64256. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  64257. /**
  64258. * Exposes the properties to the UI?
  64259. */
  64260. protected _dumpPropertiesCode(): string;
  64261. /**
  64262. * Exposes the properties to the Seralize?
  64263. */
  64264. serialize(): any;
  64265. /**
  64266. * Exposes the properties to the deseralize?
  64267. */
  64268. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64269. }
  64270. }
  64271. declare module "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock" {
  64272. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64273. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64274. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64275. /**
  64276. * block used to Generate a Simplex Perlin 3d Noise Pattern
  64277. */
  64278. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  64279. /**
  64280. * Creates a new SimplexPerlin3DBlock
  64281. * @param name defines the block name
  64282. */
  64283. constructor(name: string);
  64284. /**
  64285. * Gets the current class name
  64286. * @returns the class name
  64287. */
  64288. getClassName(): string;
  64289. /**
  64290. * Gets the seed operand input component
  64291. */
  64292. get seed(): NodeMaterialConnectionPoint;
  64293. /**
  64294. * Gets the output component
  64295. */
  64296. get output(): NodeMaterialConnectionPoint;
  64297. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  64298. }
  64299. }
  64300. declare module "babylonjs/Materials/Node/Blocks/normalBlendBlock" {
  64301. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64302. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64303. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64304. /**
  64305. * Block used to blend normals
  64306. */
  64307. export class NormalBlendBlock extends NodeMaterialBlock {
  64308. /**
  64309. * Creates a new NormalBlendBlock
  64310. * @param name defines the block name
  64311. */
  64312. constructor(name: string);
  64313. /**
  64314. * Gets the current class name
  64315. * @returns the class name
  64316. */
  64317. getClassName(): string;
  64318. /**
  64319. * Gets the first input component
  64320. */
  64321. get normalMap0(): NodeMaterialConnectionPoint;
  64322. /**
  64323. * Gets the second input component
  64324. */
  64325. get normalMap1(): NodeMaterialConnectionPoint;
  64326. /**
  64327. * Gets the output component
  64328. */
  64329. get output(): NodeMaterialConnectionPoint;
  64330. protected _buildBlock(state: NodeMaterialBuildState): this;
  64331. }
  64332. }
  64333. declare module "babylonjs/Materials/Node/Blocks/rotate2dBlock" {
  64334. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64335. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64336. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64337. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  64338. /**
  64339. * Block used to rotate a 2d vector by a given angle
  64340. */
  64341. export class Rotate2dBlock extends NodeMaterialBlock {
  64342. /**
  64343. * Creates a new Rotate2dBlock
  64344. * @param name defines the block name
  64345. */
  64346. constructor(name: string);
  64347. /**
  64348. * Gets the current class name
  64349. * @returns the class name
  64350. */
  64351. getClassName(): string;
  64352. /**
  64353. * Gets the input vector
  64354. */
  64355. get input(): NodeMaterialConnectionPoint;
  64356. /**
  64357. * Gets the input angle
  64358. */
  64359. get angle(): NodeMaterialConnectionPoint;
  64360. /**
  64361. * Gets the output component
  64362. */
  64363. get output(): NodeMaterialConnectionPoint;
  64364. autoConfigure(material: NodeMaterial): void;
  64365. protected _buildBlock(state: NodeMaterialBuildState): this;
  64366. }
  64367. }
  64368. declare module "babylonjs/Materials/Node/Blocks/reflectBlock" {
  64369. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64370. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64371. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64372. /**
  64373. * Block used to get the reflected vector from a direction and a normal
  64374. */
  64375. export class ReflectBlock extends NodeMaterialBlock {
  64376. /**
  64377. * Creates a new ReflectBlock
  64378. * @param name defines the block name
  64379. */
  64380. constructor(name: string);
  64381. /**
  64382. * Gets the current class name
  64383. * @returns the class name
  64384. */
  64385. getClassName(): string;
  64386. /**
  64387. * Gets the incident component
  64388. */
  64389. get incident(): NodeMaterialConnectionPoint;
  64390. /**
  64391. * Gets the normal component
  64392. */
  64393. get normal(): NodeMaterialConnectionPoint;
  64394. /**
  64395. * Gets the output component
  64396. */
  64397. get output(): NodeMaterialConnectionPoint;
  64398. protected _buildBlock(state: NodeMaterialBuildState): this;
  64399. }
  64400. }
  64401. declare module "babylonjs/Materials/Node/Blocks/refractBlock" {
  64402. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64403. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64404. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64405. /**
  64406. * Block used to get the refracted vector from a direction and a normal
  64407. */
  64408. export class RefractBlock extends NodeMaterialBlock {
  64409. /**
  64410. * Creates a new RefractBlock
  64411. * @param name defines the block name
  64412. */
  64413. constructor(name: string);
  64414. /**
  64415. * Gets the current class name
  64416. * @returns the class name
  64417. */
  64418. getClassName(): string;
  64419. /**
  64420. * Gets the incident component
  64421. */
  64422. get incident(): NodeMaterialConnectionPoint;
  64423. /**
  64424. * Gets the normal component
  64425. */
  64426. get normal(): NodeMaterialConnectionPoint;
  64427. /**
  64428. * Gets the index of refraction component
  64429. */
  64430. get ior(): NodeMaterialConnectionPoint;
  64431. /**
  64432. * Gets the output component
  64433. */
  64434. get output(): NodeMaterialConnectionPoint;
  64435. protected _buildBlock(state: NodeMaterialBuildState): this;
  64436. }
  64437. }
  64438. declare module "babylonjs/Materials/Node/Blocks/desaturateBlock" {
  64439. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64440. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64441. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64442. /**
  64443. * Block used to desaturate a color
  64444. */
  64445. export class DesaturateBlock extends NodeMaterialBlock {
  64446. /**
  64447. * Creates a new DesaturateBlock
  64448. * @param name defines the block name
  64449. */
  64450. constructor(name: string);
  64451. /**
  64452. * Gets the current class name
  64453. * @returns the class name
  64454. */
  64455. getClassName(): string;
  64456. /**
  64457. * Gets the color operand input component
  64458. */
  64459. get color(): NodeMaterialConnectionPoint;
  64460. /**
  64461. * Gets the level operand input component
  64462. */
  64463. get level(): NodeMaterialConnectionPoint;
  64464. /**
  64465. * Gets the output component
  64466. */
  64467. get output(): NodeMaterialConnectionPoint;
  64468. protected _buildBlock(state: NodeMaterialBuildState): this;
  64469. }
  64470. }
  64471. declare module "babylonjs/Materials/Node/Blocks/PBR/ambientOcclusionBlock" {
  64472. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64473. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64474. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64475. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  64476. import { Nullable } from "babylonjs/types";
  64477. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64478. import { Scene } from "babylonjs/scene";
  64479. /**
  64480. * Block used to implement the ambient occlusion module of the PBR material
  64481. */
  64482. export class AmbientOcclusionBlock extends NodeMaterialBlock {
  64483. /**
  64484. * Create a new AmbientOcclusionBlock
  64485. * @param name defines the block name
  64486. */
  64487. constructor(name: string);
  64488. /**
  64489. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  64490. */
  64491. useAmbientInGrayScale: boolean;
  64492. /**
  64493. * Initialize the block and prepare the context for build
  64494. * @param state defines the state that will be used for the build
  64495. */
  64496. initialize(state: NodeMaterialBuildState): void;
  64497. /**
  64498. * Gets the current class name
  64499. * @returns the class name
  64500. */
  64501. getClassName(): string;
  64502. /**
  64503. * Gets the texture input component
  64504. */
  64505. get texture(): NodeMaterialConnectionPoint;
  64506. /**
  64507. * Gets the texture intensity component
  64508. */
  64509. get intensity(): NodeMaterialConnectionPoint;
  64510. /**
  64511. * Gets the direct light intensity input component
  64512. */
  64513. get directLightIntensity(): NodeMaterialConnectionPoint;
  64514. /**
  64515. * Gets the ambient occlusion object output component
  64516. */
  64517. get ambientOcclusion(): NodeMaterialConnectionPoint;
  64518. /**
  64519. * Gets the main code of the block (fragment side)
  64520. * @param block instance of an AmbientOcclusionBlock or null if the code must be generated without an active ambient occlusion module
  64521. * @returns the shader code
  64522. */
  64523. static GetCode(block: Nullable<AmbientOcclusionBlock>): string;
  64524. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64525. protected _buildBlock(state: NodeMaterialBuildState): this;
  64526. protected _dumpPropertiesCode(): string;
  64527. serialize(): any;
  64528. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64529. }
  64530. }
  64531. declare module "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock" {
  64532. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64533. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64534. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  64535. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  64536. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64537. import { Nullable } from "babylonjs/types";
  64538. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  64539. import { Mesh } from "babylonjs/Meshes/mesh";
  64540. import { SubMesh } from "babylonjs/Meshes/subMesh";
  64541. import { Effect } from "babylonjs/Materials/effect";
  64542. import { Scene } from "babylonjs/scene";
  64543. /**
  64544. * Block used to implement the reflection module of the PBR material
  64545. */
  64546. export class ReflectionBlock extends ReflectionTextureBaseBlock {
  64547. /** @hidden */
  64548. _defineLODReflectionAlpha: string;
  64549. /** @hidden */
  64550. _defineLinearSpecularReflection: string;
  64551. private _vEnvironmentIrradianceName;
  64552. /** @hidden */
  64553. _vReflectionMicrosurfaceInfosName: string;
  64554. /** @hidden */
  64555. _vReflectionInfosName: string;
  64556. private _scene;
  64557. /**
  64558. * The three properties below are set by the main PBR block prior to calling methods of this class.
  64559. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  64560. * It's less burden on the user side in the editor part.
  64561. */
  64562. /** @hidden */
  64563. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  64564. /** @hidden */
  64565. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  64566. /** @hidden */
  64567. cameraPositionConnectionPoint: NodeMaterialConnectionPoint;
  64568. /**
  64569. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  64570. * diffuse part of the IBL.
  64571. */
  64572. useSphericalHarmonics: boolean;
  64573. /**
  64574. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  64575. */
  64576. forceIrradianceInFragment: boolean;
  64577. /**
  64578. * Create a new ReflectionBlock
  64579. * @param name defines the block name
  64580. */
  64581. constructor(name: string);
  64582. /**
  64583. * Gets the current class name
  64584. * @returns the class name
  64585. */
  64586. getClassName(): string;
  64587. /**
  64588. * Gets the position input component
  64589. */
  64590. get position(): NodeMaterialConnectionPoint;
  64591. /**
  64592. * Gets the world position input component
  64593. */
  64594. get worldPosition(): NodeMaterialConnectionPoint;
  64595. /**
  64596. * Gets the world normal input component
  64597. */
  64598. get worldNormal(): NodeMaterialConnectionPoint;
  64599. /**
  64600. * Gets the world input component
  64601. */
  64602. get world(): NodeMaterialConnectionPoint;
  64603. /**
  64604. * Gets the camera (or eye) position component
  64605. */
  64606. get cameraPosition(): NodeMaterialConnectionPoint;
  64607. /**
  64608. * Gets the view input component
  64609. */
  64610. get view(): NodeMaterialConnectionPoint;
  64611. /**
  64612. * Gets the color input component
  64613. */
  64614. get color(): NodeMaterialConnectionPoint;
  64615. /**
  64616. * Gets the reflection object output component
  64617. */
  64618. get reflection(): NodeMaterialConnectionPoint;
  64619. /**
  64620. * Returns true if the block has a texture (either its own texture or the environment texture from the scene, if set)
  64621. */
  64622. get hasTexture(): boolean;
  64623. /**
  64624. * Gets the reflection color (either the name of the variable if the color input is connected, else a default value)
  64625. */
  64626. get reflectionColor(): string;
  64627. protected _getTexture(): Nullable<BaseTexture>;
  64628. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64629. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  64630. /**
  64631. * Gets the code to inject in the vertex shader
  64632. * @param state current state of the node material building
  64633. * @returns the shader code
  64634. */
  64635. handleVertexSide(state: NodeMaterialBuildState): string;
  64636. /**
  64637. * Gets the main code of the block (fragment side)
  64638. * @param state current state of the node material building
  64639. * @param normalVarName name of the existing variable corresponding to the normal
  64640. * @returns the shader code
  64641. */
  64642. getCode(state: NodeMaterialBuildState, normalVarName: string): string;
  64643. protected _buildBlock(state: NodeMaterialBuildState): this;
  64644. protected _dumpPropertiesCode(): string;
  64645. serialize(): any;
  64646. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64647. }
  64648. }
  64649. declare module "babylonjs/Materials/Node/Blocks/PBR/sheenBlock" {
  64650. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64651. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64652. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64653. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  64654. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64655. import { ReflectionBlock } from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  64656. import { Scene } from "babylonjs/scene";
  64657. import { Nullable } from "babylonjs/types";
  64658. /**
  64659. * Block used to implement the sheen module of the PBR material
  64660. */
  64661. export class SheenBlock extends NodeMaterialBlock {
  64662. /**
  64663. * Create a new SheenBlock
  64664. * @param name defines the block name
  64665. */
  64666. constructor(name: string);
  64667. /**
  64668. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  64669. * It allows the strength of the sheen effect to not depend on the base color of the material,
  64670. * making it easier to setup and tweak the effect
  64671. */
  64672. albedoScaling: boolean;
  64673. /**
  64674. * Defines if the sheen is linked to the sheen color.
  64675. */
  64676. linkSheenWithAlbedo: boolean;
  64677. /**
  64678. * Initialize the block and prepare the context for build
  64679. * @param state defines the state that will be used for the build
  64680. */
  64681. initialize(state: NodeMaterialBuildState): void;
  64682. /**
  64683. * Gets the current class name
  64684. * @returns the class name
  64685. */
  64686. getClassName(): string;
  64687. /**
  64688. * Gets the intensity input component
  64689. */
  64690. get intensity(): NodeMaterialConnectionPoint;
  64691. /**
  64692. * Gets the color input component
  64693. */
  64694. get color(): NodeMaterialConnectionPoint;
  64695. /**
  64696. * Gets the roughness input component
  64697. */
  64698. get roughness(): NodeMaterialConnectionPoint;
  64699. /**
  64700. * Gets the texture input component
  64701. */
  64702. get texture(): NodeMaterialConnectionPoint;
  64703. /**
  64704. * Gets the sheen object output component
  64705. */
  64706. get sheen(): NodeMaterialConnectionPoint;
  64707. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64708. /**
  64709. * Gets the main code of the block (fragment side)
  64710. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  64711. * @returns the shader code
  64712. */
  64713. getCode(reflectionBlock: Nullable<ReflectionBlock>): string;
  64714. protected _buildBlock(state: NodeMaterialBuildState): this;
  64715. protected _dumpPropertiesCode(): string;
  64716. serialize(): any;
  64717. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64718. }
  64719. }
  64720. declare module "babylonjs/Materials/Node/Blocks/PBR/reflectivityBlock" {
  64721. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  64722. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64723. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64724. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64725. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64726. import { Scene } from "babylonjs/scene";
  64727. /**
  64728. * Block used to implement the reflectivity module of the PBR material
  64729. */
  64730. export class ReflectivityBlock extends NodeMaterialBlock {
  64731. /**
  64732. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  64733. */
  64734. useAmbientOcclusionFromMetallicTextureRed: boolean;
  64735. /**
  64736. * Specifies if the metallic texture contains the metallness information in its blue channel.
  64737. */
  64738. useMetallnessFromMetallicTextureBlue: boolean;
  64739. /**
  64740. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  64741. */
  64742. useRoughnessFromMetallicTextureAlpha: boolean;
  64743. /**
  64744. * Specifies if the metallic texture contains the roughness information in its green channel.
  64745. */
  64746. useRoughnessFromMetallicTextureGreen: boolean;
  64747. /**
  64748. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  64749. */
  64750. useMetallicF0FactorFromMetallicTexture: boolean;
  64751. /**
  64752. * Create a new ReflectivityBlock
  64753. * @param name defines the block name
  64754. */
  64755. constructor(name: string);
  64756. /**
  64757. * Initialize the block and prepare the context for build
  64758. * @param state defines the state that will be used for the build
  64759. */
  64760. initialize(state: NodeMaterialBuildState): void;
  64761. /**
  64762. * Gets the current class name
  64763. * @returns the class name
  64764. */
  64765. getClassName(): string;
  64766. /**
  64767. * Gets the metallic input component
  64768. */
  64769. get metallic(): NodeMaterialConnectionPoint;
  64770. /**
  64771. * Gets the roughness input component
  64772. */
  64773. get roughness(): NodeMaterialConnectionPoint;
  64774. /**
  64775. * Gets the texture input component
  64776. */
  64777. get texture(): NodeMaterialConnectionPoint;
  64778. /**
  64779. * Gets the reflectivity object output component
  64780. */
  64781. get reflectivity(): NodeMaterialConnectionPoint;
  64782. /**
  64783. * Gets the main code of the block (fragment side)
  64784. * @param aoIntensityVarName name of the variable with the ambient occlusion intensity
  64785. * @returns the shader code
  64786. */
  64787. getCode(aoIntensityVarName: string): string;
  64788. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64789. protected _buildBlock(state: NodeMaterialBuildState): this;
  64790. protected _dumpPropertiesCode(): string;
  64791. serialize(): any;
  64792. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64793. }
  64794. }
  64795. declare module "babylonjs/Materials/Node/Blocks/PBR/anisotropyBlock" {
  64796. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  64797. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64798. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64799. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64800. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64801. /**
  64802. * Block used to implement the anisotropy module of the PBR material
  64803. */
  64804. export class AnisotropyBlock extends NodeMaterialBlock {
  64805. /**
  64806. * The two properties below are set by the main PBR block prior to calling methods of this class.
  64807. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  64808. * It's less burden on the user side in the editor part.
  64809. */
  64810. /** @hidden */
  64811. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  64812. /** @hidden */
  64813. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  64814. /**
  64815. * Create a new AnisotropyBlock
  64816. * @param name defines the block name
  64817. */
  64818. constructor(name: string);
  64819. /**
  64820. * Initialize the block and prepare the context for build
  64821. * @param state defines the state that will be used for the build
  64822. */
  64823. initialize(state: NodeMaterialBuildState): void;
  64824. /**
  64825. * Gets the current class name
  64826. * @returns the class name
  64827. */
  64828. getClassName(): string;
  64829. /**
  64830. * Gets the intensity input component
  64831. */
  64832. get intensity(): NodeMaterialConnectionPoint;
  64833. /**
  64834. * Gets the direction input component
  64835. */
  64836. get direction(): NodeMaterialConnectionPoint;
  64837. /**
  64838. * Gets the texture input component
  64839. */
  64840. get texture(): NodeMaterialConnectionPoint;
  64841. /**
  64842. * Gets the uv input component
  64843. */
  64844. get uv(): NodeMaterialConnectionPoint;
  64845. /**
  64846. * Gets the worldTangent input component
  64847. */
  64848. get worldTangent(): NodeMaterialConnectionPoint;
  64849. /**
  64850. * Gets the anisotropy object output component
  64851. */
  64852. get anisotropy(): NodeMaterialConnectionPoint;
  64853. private _generateTBNSpace;
  64854. /**
  64855. * Gets the main code of the block (fragment side)
  64856. * @param state current state of the node material building
  64857. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  64858. * @returns the shader code
  64859. */
  64860. getCode(state: NodeMaterialBuildState, generateTBNSpace?: boolean): string;
  64861. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64862. protected _buildBlock(state: NodeMaterialBuildState): this;
  64863. }
  64864. }
  64865. declare module "babylonjs/Materials/Node/Blocks/PBR/clearCoatBlock" {
  64866. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64867. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64868. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64869. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  64870. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64871. import { ReflectionBlock } from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  64872. import { Nullable } from "babylonjs/types";
  64873. import { Mesh } from "babylonjs/Meshes/mesh";
  64874. import { SubMesh } from "babylonjs/Meshes/subMesh";
  64875. import { Effect } from "babylonjs/Materials/effect";
  64876. /**
  64877. * Block used to implement the clear coat module of the PBR material
  64878. */
  64879. export class ClearCoatBlock extends NodeMaterialBlock {
  64880. private _scene;
  64881. /**
  64882. * Create a new ClearCoatBlock
  64883. * @param name defines the block name
  64884. */
  64885. constructor(name: string);
  64886. /**
  64887. * Initialize the block and prepare the context for build
  64888. * @param state defines the state that will be used for the build
  64889. */
  64890. initialize(state: NodeMaterialBuildState): void;
  64891. /**
  64892. * Gets the current class name
  64893. * @returns the class name
  64894. */
  64895. getClassName(): string;
  64896. /**
  64897. * Gets the intensity input component
  64898. */
  64899. get intensity(): NodeMaterialConnectionPoint;
  64900. /**
  64901. * Gets the roughness input component
  64902. */
  64903. get roughness(): NodeMaterialConnectionPoint;
  64904. /**
  64905. * Gets the ior input component
  64906. */
  64907. get ior(): NodeMaterialConnectionPoint;
  64908. /**
  64909. * Gets the texture input component
  64910. */
  64911. get texture(): NodeMaterialConnectionPoint;
  64912. /**
  64913. * Gets the bump texture input component
  64914. */
  64915. get bumpTexture(): NodeMaterialConnectionPoint;
  64916. /**
  64917. * Gets the uv input component
  64918. */
  64919. get uv(): NodeMaterialConnectionPoint;
  64920. /**
  64921. * Gets the tint color input component
  64922. */
  64923. get tintColor(): NodeMaterialConnectionPoint;
  64924. /**
  64925. * Gets the tint "at distance" input component
  64926. */
  64927. get tintAtDistance(): NodeMaterialConnectionPoint;
  64928. /**
  64929. * Gets the tint thickness input component
  64930. */
  64931. get tintThickness(): NodeMaterialConnectionPoint;
  64932. /**
  64933. * Gets the tint texture input component
  64934. */
  64935. get tintTexture(): NodeMaterialConnectionPoint;
  64936. /**
  64937. * Gets the world tangent input component
  64938. */
  64939. get worldTangent(): NodeMaterialConnectionPoint;
  64940. /**
  64941. * Gets the clear coat object output component
  64942. */
  64943. get clearcoat(): NodeMaterialConnectionPoint;
  64944. autoConfigure(material: NodeMaterial): void;
  64945. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64946. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  64947. private _generateTBNSpace;
  64948. /**
  64949. * Gets the main code of the block (fragment side)
  64950. * @param state current state of the node material building
  64951. * @param ccBlock instance of a ClearCoatBlock or null if the code must be generated without an active clear coat module
  64952. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  64953. * @param worldPosVarName name of the variable holding the world position
  64954. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  64955. * @param vTBNAvailable indicate that the vTBN variable is already existing because it has already been generated by another block (PerturbNormal or Anisotropy)
  64956. * @param worldNormalVarName name of the variable holding the world normal
  64957. * @returns the shader code
  64958. */
  64959. static GetCode(state: NodeMaterialBuildState, ccBlock: Nullable<ClearCoatBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string, generateTBNSpace: boolean, vTBNAvailable: boolean, worldNormalVarName: string): string;
  64960. protected _buildBlock(state: NodeMaterialBuildState): this;
  64961. }
  64962. }
  64963. declare module "babylonjs/Materials/Node/Blocks/PBR/subSurfaceBlock" {
  64964. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64965. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64966. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64967. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  64968. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64969. import { ReflectionBlock } from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  64970. import { Nullable } from "babylonjs/types";
  64971. /**
  64972. * Block used to implement the sub surface module of the PBR material
  64973. */
  64974. export class SubSurfaceBlock extends NodeMaterialBlock {
  64975. /**
  64976. * Create a new SubSurfaceBlock
  64977. * @param name defines the block name
  64978. */
  64979. constructor(name: string);
  64980. /**
  64981. * Stores the intensity of the different subsurface effects in the thickness texture.
  64982. * * the green channel is the translucency intensity.
  64983. * * the blue channel is the scattering intensity.
  64984. * * the alpha channel is the refraction intensity.
  64985. */
  64986. useMaskFromThicknessTexture: boolean;
  64987. /**
  64988. * Initialize the block and prepare the context for build
  64989. * @param state defines the state that will be used for the build
  64990. */
  64991. initialize(state: NodeMaterialBuildState): void;
  64992. /**
  64993. * Gets the current class name
  64994. * @returns the class name
  64995. */
  64996. getClassName(): string;
  64997. /**
  64998. * Gets the min thickness input component
  64999. */
  65000. get minThickness(): NodeMaterialConnectionPoint;
  65001. /**
  65002. * Gets the max thickness input component
  65003. */
  65004. get maxThickness(): NodeMaterialConnectionPoint;
  65005. /**
  65006. * Gets the thickness texture component
  65007. */
  65008. get thicknessTexture(): NodeMaterialConnectionPoint;
  65009. /**
  65010. * Gets the tint color input component
  65011. */
  65012. get tintColor(): NodeMaterialConnectionPoint;
  65013. /**
  65014. * Gets the translucency intensity input component
  65015. */
  65016. get translucencyIntensity(): NodeMaterialConnectionPoint;
  65017. /**
  65018. * Gets the translucency diffusion distance input component
  65019. */
  65020. get translucencyDiffusionDistance(): NodeMaterialConnectionPoint;
  65021. /**
  65022. * Gets the refraction object parameters
  65023. */
  65024. get refraction(): NodeMaterialConnectionPoint;
  65025. /**
  65026. * Gets the sub surface object output component
  65027. */
  65028. get subsurface(): NodeMaterialConnectionPoint;
  65029. autoConfigure(material: NodeMaterial): void;
  65030. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65031. /**
  65032. * Gets the main code of the block (fragment side)
  65033. * @param state current state of the node material building
  65034. * @param ssBlock instance of a SubSurfaceBlock or null if the code must be generated without an active sub surface module
  65035. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  65036. * @param worldPosVarName name of the variable holding the world position
  65037. * @returns the shader code
  65038. */
  65039. static GetCode(state: NodeMaterialBuildState, ssBlock: Nullable<SubSurfaceBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string): string;
  65040. protected _buildBlock(state: NodeMaterialBuildState): this;
  65041. }
  65042. }
  65043. declare module "babylonjs/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock" {
  65044. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65045. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65046. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65047. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  65048. import { Light } from "babylonjs/Lights/light";
  65049. import { Nullable } from "babylonjs/types";
  65050. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65051. import { Effect } from "babylonjs/Materials/effect";
  65052. import { Mesh } from "babylonjs/Meshes/mesh";
  65053. import { Scene } from "babylonjs/scene";
  65054. /**
  65055. * Block used to implement the PBR metallic/roughness model
  65056. */
  65057. export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
  65058. /**
  65059. * Gets or sets the light associated with this block
  65060. */
  65061. light: Nullable<Light>;
  65062. private _lightId;
  65063. private _scene;
  65064. private _environmentBRDFTexture;
  65065. private _environmentBrdfSamplerName;
  65066. private _vNormalWName;
  65067. private _invertNormalName;
  65068. /**
  65069. * Create a new ReflectionBlock
  65070. * @param name defines the block name
  65071. */
  65072. constructor(name: string);
  65073. /**
  65074. * Intensity of the direct lights e.g. the four lights available in your scene.
  65075. * This impacts both the direct diffuse and specular highlights.
  65076. */
  65077. directIntensity: number;
  65078. /**
  65079. * Intensity of the environment e.g. how much the environment will light the object
  65080. * either through harmonics for rough material or through the refelction for shiny ones.
  65081. */
  65082. environmentIntensity: number;
  65083. /**
  65084. * This is a special control allowing the reduction of the specular highlights coming from the
  65085. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  65086. */
  65087. specularIntensity: number;
  65088. /**
  65089. * Defines the falloff type used in this material.
  65090. * It by default is Physical.
  65091. */
  65092. lightFalloff: number;
  65093. /**
  65094. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  65095. */
  65096. useAlphaFromAlbedoTexture: boolean;
  65097. /**
  65098. * Specifies that alpha test should be used
  65099. */
  65100. useAlphaTest: boolean;
  65101. /**
  65102. * Defines the alpha limits in alpha test mode.
  65103. */
  65104. alphaTestCutoff: number;
  65105. /**
  65106. * Specifies that alpha blending should be used
  65107. */
  65108. useAlphaBlending: boolean;
  65109. /**
  65110. * Defines if the alpha value should be determined via the rgb values.
  65111. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  65112. */
  65113. opacityRGB: boolean;
  65114. /**
  65115. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  65116. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  65117. */
  65118. useRadianceOverAlpha: boolean;
  65119. /**
  65120. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
  65121. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  65122. */
  65123. useSpecularOverAlpha: boolean;
  65124. /**
  65125. * Enables specular anti aliasing in the PBR shader.
  65126. * It will both interacts on the Geometry for analytical and IBL lighting.
  65127. * It also prefilter the roughness map based on the bump values.
  65128. */
  65129. enableSpecularAntiAliasing: boolean;
  65130. /**
  65131. * Defines if the material uses energy conservation.
  65132. */
  65133. useEnergyConservation: boolean;
  65134. /**
  65135. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  65136. * too much the area relying on ambient texture to define their ambient occlusion.
  65137. */
  65138. useRadianceOcclusion: boolean;
  65139. /**
  65140. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  65141. * makes the reflect vector face the model (under horizon).
  65142. */
  65143. useHorizonOcclusion: boolean;
  65144. /**
  65145. * If set to true, no lighting calculations will be applied.
  65146. */
  65147. unlit: boolean;
  65148. /**
  65149. * Force normal to face away from face.
  65150. */
  65151. forceNormalForward: boolean;
  65152. /**
  65153. * Defines the material debug mode.
  65154. * It helps seeing only some components of the material while troubleshooting.
  65155. */
  65156. debugMode: number;
  65157. /**
  65158. * Specify from where on screen the debug mode should start.
  65159. * The value goes from -1 (full screen) to 1 (not visible)
  65160. * It helps with side by side comparison against the final render
  65161. * This defaults to 0
  65162. */
  65163. debugLimit: number;
  65164. /**
  65165. * As the default viewing range might not be enough (if the ambient is really small for instance)
  65166. * You can use the factor to better multiply the final value.
  65167. */
  65168. debugFactor: number;
  65169. /**
  65170. * Initialize the block and prepare the context for build
  65171. * @param state defines the state that will be used for the build
  65172. */
  65173. initialize(state: NodeMaterialBuildState): void;
  65174. /**
  65175. * Gets the current class name
  65176. * @returns the class name
  65177. */
  65178. getClassName(): string;
  65179. /**
  65180. * Gets the world position input component
  65181. */
  65182. get worldPosition(): NodeMaterialConnectionPoint;
  65183. /**
  65184. * Gets the world normal input component
  65185. */
  65186. get worldNormal(): NodeMaterialConnectionPoint;
  65187. /**
  65188. * Gets the perturbed normal input component
  65189. */
  65190. get perturbedNormal(): NodeMaterialConnectionPoint;
  65191. /**
  65192. * Gets the camera position input component
  65193. */
  65194. get cameraPosition(): NodeMaterialConnectionPoint;
  65195. /**
  65196. * Gets the base color input component
  65197. */
  65198. get baseColor(): NodeMaterialConnectionPoint;
  65199. /**
  65200. * Gets the base texture input component
  65201. */
  65202. get baseTexture(): NodeMaterialConnectionPoint;
  65203. /**
  65204. * Gets the opacity texture input component
  65205. */
  65206. get opacityTexture(): NodeMaterialConnectionPoint;
  65207. /**
  65208. * Gets the ambient color input component
  65209. */
  65210. get ambientColor(): NodeMaterialConnectionPoint;
  65211. /**
  65212. * Gets the reflectivity object parameters
  65213. */
  65214. get reflectivity(): NodeMaterialConnectionPoint;
  65215. /**
  65216. * Gets the ambient occlusion object parameters
  65217. */
  65218. get ambientOcclusion(): NodeMaterialConnectionPoint;
  65219. /**
  65220. * Gets the reflection object parameters
  65221. */
  65222. get reflection(): NodeMaterialConnectionPoint;
  65223. /**
  65224. * Gets the sheen object parameters
  65225. */
  65226. get sheen(): NodeMaterialConnectionPoint;
  65227. /**
  65228. * Gets the clear coat object parameters
  65229. */
  65230. get clearcoat(): NodeMaterialConnectionPoint;
  65231. /**
  65232. * Gets the sub surface object parameters
  65233. */
  65234. get subsurface(): NodeMaterialConnectionPoint;
  65235. /**
  65236. * Gets the anisotropy object parameters
  65237. */
  65238. get anisotropy(): NodeMaterialConnectionPoint;
  65239. /**
  65240. * Gets the ambient output component
  65241. */
  65242. get ambient(): NodeMaterialConnectionPoint;
  65243. /**
  65244. * Gets the diffuse output component
  65245. */
  65246. get diffuse(): NodeMaterialConnectionPoint;
  65247. /**
  65248. * Gets the specular output component
  65249. */
  65250. get specular(): NodeMaterialConnectionPoint;
  65251. /**
  65252. * Gets the sheen output component
  65253. */
  65254. get sheenDir(): NodeMaterialConnectionPoint;
  65255. /**
  65256. * Gets the clear coat output component
  65257. */
  65258. get clearcoatDir(): NodeMaterialConnectionPoint;
  65259. /**
  65260. * Gets the indirect diffuse output component
  65261. */
  65262. get diffuseIndirect(): NodeMaterialConnectionPoint;
  65263. /**
  65264. * Gets the indirect specular output component
  65265. */
  65266. get specularIndirect(): NodeMaterialConnectionPoint;
  65267. /**
  65268. * Gets the indirect sheen output component
  65269. */
  65270. get sheenIndirect(): NodeMaterialConnectionPoint;
  65271. /**
  65272. * Gets the indirect clear coat output component
  65273. */
  65274. get clearcoatIndirect(): NodeMaterialConnectionPoint;
  65275. /**
  65276. * Gets the refraction output component
  65277. */
  65278. get refraction(): NodeMaterialConnectionPoint;
  65279. /**
  65280. * Gets the global lighting output component
  65281. */
  65282. get lighting(): NodeMaterialConnectionPoint;
  65283. /**
  65284. * Gets the shadow output component
  65285. */
  65286. get shadow(): NodeMaterialConnectionPoint;
  65287. /**
  65288. * Gets the alpha output component
  65289. */
  65290. get alpha(): NodeMaterialConnectionPoint;
  65291. autoConfigure(material: NodeMaterial): void;
  65292. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65293. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  65294. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  65295. private _injectVertexCode;
  65296. /**
  65297. * Gets the code corresponding to the albedo/opacity module
  65298. * @returns the shader code
  65299. */
  65300. getAlbedoOpacityCode(): string;
  65301. protected _buildBlock(state: NodeMaterialBuildState): this;
  65302. protected _dumpPropertiesCode(): string;
  65303. serialize(): any;
  65304. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65305. }
  65306. }
  65307. declare module "babylonjs/Materials/Node/Blocks/PBR/index" {
  65308. export * from "babylonjs/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock";
  65309. export * from "babylonjs/Materials/Node/Blocks/PBR/sheenBlock";
  65310. export * from "babylonjs/Materials/Node/Blocks/PBR/ambientOcclusionBlock";
  65311. export * from "babylonjs/Materials/Node/Blocks/PBR/reflectivityBlock";
  65312. export * from "babylonjs/Materials/Node/Blocks/PBR/anisotropyBlock";
  65313. export * from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  65314. export * from "babylonjs/Materials/Node/Blocks/PBR/clearCoatBlock";
  65315. export * from "babylonjs/Materials/Node/Blocks/PBR/refractionBlock";
  65316. export * from "babylonjs/Materials/Node/Blocks/PBR/subSurfaceBlock";
  65317. }
  65318. declare module "babylonjs/Materials/Node/Blocks/index" {
  65319. export * from "babylonjs/Materials/Node/Blocks/Vertex/index";
  65320. export * from "babylonjs/Materials/Node/Blocks/Fragment/index";
  65321. export * from "babylonjs/Materials/Node/Blocks/Dual/index";
  65322. export * from "babylonjs/Materials/Node/Blocks/Input/index";
  65323. export * from "babylonjs/Materials/Node/Blocks/multiplyBlock";
  65324. export * from "babylonjs/Materials/Node/Blocks/addBlock";
  65325. export * from "babylonjs/Materials/Node/Blocks/scaleBlock";
  65326. export * from "babylonjs/Materials/Node/Blocks/clampBlock";
  65327. export * from "babylonjs/Materials/Node/Blocks/crossBlock";
  65328. export * from "babylonjs/Materials/Node/Blocks/dotBlock";
  65329. export * from "babylonjs/Materials/Node/Blocks/transformBlock";
  65330. export * from "babylonjs/Materials/Node/Blocks/remapBlock";
  65331. export * from "babylonjs/Materials/Node/Blocks/normalizeBlock";
  65332. export * from "babylonjs/Materials/Node/Blocks/trigonometryBlock";
  65333. export * from "babylonjs/Materials/Node/Blocks/colorMergerBlock";
  65334. export * from "babylonjs/Materials/Node/Blocks/vectorMergerBlock";
  65335. export * from "babylonjs/Materials/Node/Blocks/colorSplitterBlock";
  65336. export * from "babylonjs/Materials/Node/Blocks/vectorSplitterBlock";
  65337. export * from "babylonjs/Materials/Node/Blocks/lerpBlock";
  65338. export * from "babylonjs/Materials/Node/Blocks/divideBlock";
  65339. export * from "babylonjs/Materials/Node/Blocks/subtractBlock";
  65340. export * from "babylonjs/Materials/Node/Blocks/stepBlock";
  65341. export * from "babylonjs/Materials/Node/Blocks/oneMinusBlock";
  65342. export * from "babylonjs/Materials/Node/Blocks/viewDirectionBlock";
  65343. export * from "babylonjs/Materials/Node/Blocks/fresnelBlock";
  65344. export * from "babylonjs/Materials/Node/Blocks/maxBlock";
  65345. export * from "babylonjs/Materials/Node/Blocks/minBlock";
  65346. export * from "babylonjs/Materials/Node/Blocks/distanceBlock";
  65347. export * from "babylonjs/Materials/Node/Blocks/lengthBlock";
  65348. export * from "babylonjs/Materials/Node/Blocks/negateBlock";
  65349. export * from "babylonjs/Materials/Node/Blocks/powBlock";
  65350. export * from "babylonjs/Materials/Node/Blocks/randomNumberBlock";
  65351. export * from "babylonjs/Materials/Node/Blocks/arcTan2Block";
  65352. export * from "babylonjs/Materials/Node/Blocks/smoothStepBlock";
  65353. export * from "babylonjs/Materials/Node/Blocks/reciprocalBlock";
  65354. export * from "babylonjs/Materials/Node/Blocks/replaceColorBlock";
  65355. export * from "babylonjs/Materials/Node/Blocks/posterizeBlock";
  65356. export * from "babylonjs/Materials/Node/Blocks/waveBlock";
  65357. export * from "babylonjs/Materials/Node/Blocks/gradientBlock";
  65358. export * from "babylonjs/Materials/Node/Blocks/nLerpBlock";
  65359. export * from "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock";
  65360. export * from "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock";
  65361. export * from "babylonjs/Materials/Node/Blocks/normalBlendBlock";
  65362. export * from "babylonjs/Materials/Node/Blocks/rotate2dBlock";
  65363. export * from "babylonjs/Materials/Node/Blocks/reflectBlock";
  65364. export * from "babylonjs/Materials/Node/Blocks/refractBlock";
  65365. export * from "babylonjs/Materials/Node/Blocks/desaturateBlock";
  65366. export * from "babylonjs/Materials/Node/Blocks/PBR/index";
  65367. }
  65368. declare module "babylonjs/Materials/Node/Optimizers/index" {
  65369. export * from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  65370. }
  65371. declare module "babylonjs/Materials/Node/index" {
  65372. export * from "babylonjs/Materials/Node/Enums/index";
  65373. export * from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65374. export * from "babylonjs/Materials/Node/nodeMaterialBlock";
  65375. export * from "babylonjs/Materials/Node/nodeMaterial";
  65376. export * from "babylonjs/Materials/Node/Blocks/index";
  65377. export * from "babylonjs/Materials/Node/Optimizers/index";
  65378. export * from "babylonjs/Materials/Node/nodeMaterialDecorator";
  65379. }
  65380. declare module "babylonjs/Materials/effectRenderer" {
  65381. import { Nullable } from "babylonjs/types";
  65382. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  65383. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  65384. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  65385. import { Viewport } from "babylonjs/Maths/math.viewport";
  65386. import { Observable } from "babylonjs/Misc/observable";
  65387. import { Effect } from "babylonjs/Materials/effect";
  65388. import "babylonjs/Shaders/postprocess.vertex";
  65389. /**
  65390. * Effect Render Options
  65391. */
  65392. export interface IEffectRendererOptions {
  65393. /**
  65394. * Defines the vertices positions.
  65395. */
  65396. positions?: number[];
  65397. /**
  65398. * Defines the indices.
  65399. */
  65400. indices?: number[];
  65401. }
  65402. /**
  65403. * Helper class to render one or more effects.
  65404. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  65405. */
  65406. export class EffectRenderer {
  65407. private engine;
  65408. private static _DefaultOptions;
  65409. private _vertexBuffers;
  65410. private _indexBuffer;
  65411. private _fullscreenViewport;
  65412. /**
  65413. * Creates an effect renderer
  65414. * @param engine the engine to use for rendering
  65415. * @param options defines the options of the effect renderer
  65416. */
  65417. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  65418. /**
  65419. * Sets the current viewport in normalized coordinates 0-1
  65420. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  65421. */
  65422. setViewport(viewport?: Viewport): void;
  65423. /**
  65424. * Binds the embedded attributes buffer to the effect.
  65425. * @param effect Defines the effect to bind the attributes for
  65426. */
  65427. bindBuffers(effect: Effect): void;
  65428. /**
  65429. * Sets the current effect wrapper to use during draw.
  65430. * The effect needs to be ready before calling this api.
  65431. * This also sets the default full screen position attribute.
  65432. * @param effectWrapper Defines the effect to draw with
  65433. */
  65434. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  65435. /**
  65436. * Draws a full screen quad.
  65437. */
  65438. draw(): void;
  65439. private isRenderTargetTexture;
  65440. /**
  65441. * renders one or more effects to a specified texture
  65442. * @param effectWrapper the effect to renderer
  65443. * @param outputTexture texture to draw to, if null it will render to the screen.
  65444. */
  65445. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  65446. /**
  65447. * Disposes of the effect renderer
  65448. */
  65449. dispose(): void;
  65450. }
  65451. /**
  65452. * Options to create an EffectWrapper
  65453. */
  65454. interface EffectWrapperCreationOptions {
  65455. /**
  65456. * Engine to use to create the effect
  65457. */
  65458. engine: ThinEngine;
  65459. /**
  65460. * Fragment shader for the effect
  65461. */
  65462. fragmentShader: string;
  65463. /**
  65464. * Vertex shader for the effect
  65465. */
  65466. vertexShader?: string;
  65467. /**
  65468. * Attributes to use in the shader
  65469. */
  65470. attributeNames?: Array<string>;
  65471. /**
  65472. * Uniforms to use in the shader
  65473. */
  65474. uniformNames?: Array<string>;
  65475. /**
  65476. * Texture sampler names to use in the shader
  65477. */
  65478. samplerNames?: Array<string>;
  65479. /**
  65480. * The friendly name of the effect displayed in Spector.
  65481. */
  65482. name?: string;
  65483. }
  65484. /**
  65485. * Wraps an effect to be used for rendering
  65486. */
  65487. export class EffectWrapper {
  65488. /**
  65489. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  65490. */
  65491. onApplyObservable: Observable<{}>;
  65492. /**
  65493. * The underlying effect
  65494. */
  65495. effect: Effect;
  65496. /**
  65497. * Creates an effect to be renderer
  65498. * @param creationOptions options to create the effect
  65499. */
  65500. constructor(creationOptions: EffectWrapperCreationOptions);
  65501. /**
  65502. * Disposes of the effect wrapper
  65503. */
  65504. dispose(): void;
  65505. }
  65506. }
  65507. declare module "babylonjs/Materials/index" {
  65508. export * from "babylonjs/Materials/Background/index";
  65509. export * from "babylonjs/Materials/colorCurves";
  65510. export * from "babylonjs/Materials/iEffectFallbacks";
  65511. export * from "babylonjs/Materials/effectFallbacks";
  65512. export * from "babylonjs/Materials/effect";
  65513. export * from "babylonjs/Materials/fresnelParameters";
  65514. export * from "babylonjs/Materials/imageProcessingConfiguration";
  65515. export * from "babylonjs/Materials/material";
  65516. export * from "babylonjs/Materials/materialDefines";
  65517. export * from "babylonjs/Materials/materialHelper";
  65518. export * from "babylonjs/Materials/multiMaterial";
  65519. export * from "babylonjs/Materials/PBR/index";
  65520. export * from "babylonjs/Materials/pushMaterial";
  65521. export * from "babylonjs/Materials/shaderMaterial";
  65522. export * from "babylonjs/Materials/standardMaterial";
  65523. export * from "babylonjs/Materials/Textures/index";
  65524. export * from "babylonjs/Materials/uniformBuffer";
  65525. export * from "babylonjs/Materials/materialFlags";
  65526. export * from "babylonjs/Materials/Node/index";
  65527. export * from "babylonjs/Materials/effectRenderer";
  65528. export * from "babylonjs/Materials/shadowDepthWrapper";
  65529. }
  65530. declare module "babylonjs/Maths/index" {
  65531. export * from "babylonjs/Maths/math.scalar";
  65532. export * from "babylonjs/Maths/math";
  65533. export * from "babylonjs/Maths/sphericalPolynomial";
  65534. }
  65535. declare module "babylonjs/Misc/workerPool" {
  65536. import { IDisposable } from "babylonjs/scene";
  65537. /**
  65538. * Helper class to push actions to a pool of workers.
  65539. */
  65540. export class WorkerPool implements IDisposable {
  65541. private _workerInfos;
  65542. private _pendingActions;
  65543. /**
  65544. * Constructor
  65545. * @param workers Array of workers to use for actions
  65546. */
  65547. constructor(workers: Array<Worker>);
  65548. /**
  65549. * Terminates all workers and clears any pending actions.
  65550. */
  65551. dispose(): void;
  65552. /**
  65553. * Pushes an action to the worker pool. If all the workers are active, the action will be
  65554. * pended until a worker has completed its action.
  65555. * @param action The action to perform. Call onComplete when the action is complete.
  65556. */
  65557. push(action: (worker: Worker, onComplete: () => void) => void): void;
  65558. private _execute;
  65559. }
  65560. }
  65561. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  65562. import { IDisposable } from "babylonjs/scene";
  65563. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  65564. /**
  65565. * Configuration for Draco compression
  65566. */
  65567. export interface IDracoCompressionConfiguration {
  65568. /**
  65569. * Configuration for the decoder.
  65570. */
  65571. decoder: {
  65572. /**
  65573. * The url to the WebAssembly module.
  65574. */
  65575. wasmUrl?: string;
  65576. /**
  65577. * The url to the WebAssembly binary.
  65578. */
  65579. wasmBinaryUrl?: string;
  65580. /**
  65581. * The url to the fallback JavaScript module.
  65582. */
  65583. fallbackUrl?: string;
  65584. };
  65585. }
  65586. /**
  65587. * Draco compression (https://google.github.io/draco/)
  65588. *
  65589. * This class wraps the Draco module.
  65590. *
  65591. * **Encoder**
  65592. *
  65593. * The encoder is not currently implemented.
  65594. *
  65595. * **Decoder**
  65596. *
  65597. * 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.
  65598. *
  65599. * To update the configuration, use the following code:
  65600. * ```javascript
  65601. * DracoCompression.Configuration = {
  65602. * decoder: {
  65603. * wasmUrl: "<url to the WebAssembly library>",
  65604. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  65605. * fallbackUrl: "<url to the fallback JavaScript library>",
  65606. * }
  65607. * };
  65608. * ```
  65609. *
  65610. * 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.
  65611. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  65612. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  65613. *
  65614. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  65615. * ```javascript
  65616. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  65617. * ```
  65618. *
  65619. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  65620. */
  65621. export class DracoCompression implements IDisposable {
  65622. private _workerPoolPromise?;
  65623. private _decoderModulePromise?;
  65624. /**
  65625. * The configuration. Defaults to the following urls:
  65626. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  65627. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  65628. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  65629. */
  65630. static Configuration: IDracoCompressionConfiguration;
  65631. /**
  65632. * Returns true if the decoder configuration is available.
  65633. */
  65634. static get DecoderAvailable(): boolean;
  65635. /**
  65636. * Default number of workers to create when creating the draco compression object.
  65637. */
  65638. static DefaultNumWorkers: number;
  65639. private static GetDefaultNumWorkers;
  65640. private static _Default;
  65641. /**
  65642. * Default instance for the draco compression object.
  65643. */
  65644. static get Default(): DracoCompression;
  65645. /**
  65646. * Constructor
  65647. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  65648. */
  65649. constructor(numWorkers?: number);
  65650. /**
  65651. * Stop all async operations and release resources.
  65652. */
  65653. dispose(): void;
  65654. /**
  65655. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  65656. * @returns a promise that resolves when ready
  65657. */
  65658. whenReadyAsync(): Promise<void>;
  65659. /**
  65660. * Decode Draco compressed mesh data to vertex data.
  65661. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  65662. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  65663. * @returns A promise that resolves with the decoded vertex data
  65664. */
  65665. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  65666. [kind: string]: number;
  65667. }): Promise<VertexData>;
  65668. }
  65669. }
  65670. declare module "babylonjs/Meshes/Compression/index" {
  65671. export * from "babylonjs/Meshes/Compression/dracoCompression";
  65672. }
  65673. declare module "babylonjs/Meshes/csg" {
  65674. import { Nullable } from "babylonjs/types";
  65675. import { Scene } from "babylonjs/scene";
  65676. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  65677. import { Mesh } from "babylonjs/Meshes/mesh";
  65678. import { Material } from "babylonjs/Materials/material";
  65679. /**
  65680. * Class for building Constructive Solid Geometry
  65681. */
  65682. export class CSG {
  65683. private polygons;
  65684. /**
  65685. * The world matrix
  65686. */
  65687. matrix: Matrix;
  65688. /**
  65689. * Stores the position
  65690. */
  65691. position: Vector3;
  65692. /**
  65693. * Stores the rotation
  65694. */
  65695. rotation: Vector3;
  65696. /**
  65697. * Stores the rotation quaternion
  65698. */
  65699. rotationQuaternion: Nullable<Quaternion>;
  65700. /**
  65701. * Stores the scaling vector
  65702. */
  65703. scaling: Vector3;
  65704. /**
  65705. * Convert the Mesh to CSG
  65706. * @param mesh The Mesh to convert to CSG
  65707. * @returns A new CSG from the Mesh
  65708. */
  65709. static FromMesh(mesh: Mesh): CSG;
  65710. /**
  65711. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  65712. * @param polygons Polygons used to construct a CSG solid
  65713. */
  65714. private static FromPolygons;
  65715. /**
  65716. * Clones, or makes a deep copy, of the CSG
  65717. * @returns A new CSG
  65718. */
  65719. clone(): CSG;
  65720. /**
  65721. * Unions this CSG with another CSG
  65722. * @param csg The CSG to union against this CSG
  65723. * @returns The unioned CSG
  65724. */
  65725. union(csg: CSG): CSG;
  65726. /**
  65727. * Unions this CSG with another CSG in place
  65728. * @param csg The CSG to union against this CSG
  65729. */
  65730. unionInPlace(csg: CSG): void;
  65731. /**
  65732. * Subtracts this CSG with another CSG
  65733. * @param csg The CSG to subtract against this CSG
  65734. * @returns A new CSG
  65735. */
  65736. subtract(csg: CSG): CSG;
  65737. /**
  65738. * Subtracts this CSG with another CSG in place
  65739. * @param csg The CSG to subtact against this CSG
  65740. */
  65741. subtractInPlace(csg: CSG): void;
  65742. /**
  65743. * Intersect this CSG with another CSG
  65744. * @param csg The CSG to intersect against this CSG
  65745. * @returns A new CSG
  65746. */
  65747. intersect(csg: CSG): CSG;
  65748. /**
  65749. * Intersects this CSG with another CSG in place
  65750. * @param csg The CSG to intersect against this CSG
  65751. */
  65752. intersectInPlace(csg: CSG): void;
  65753. /**
  65754. * Return a new CSG solid with solid and empty space switched. This solid is
  65755. * not modified.
  65756. * @returns A new CSG solid with solid and empty space switched
  65757. */
  65758. inverse(): CSG;
  65759. /**
  65760. * Inverses the CSG in place
  65761. */
  65762. inverseInPlace(): void;
  65763. /**
  65764. * This is used to keep meshes transformations so they can be restored
  65765. * when we build back a Babylon Mesh
  65766. * NB : All CSG operations are performed in world coordinates
  65767. * @param csg The CSG to copy the transform attributes from
  65768. * @returns This CSG
  65769. */
  65770. copyTransformAttributes(csg: CSG): CSG;
  65771. /**
  65772. * Build Raw mesh from CSG
  65773. * Coordinates here are in world space
  65774. * @param name The name of the mesh geometry
  65775. * @param scene The Scene
  65776. * @param keepSubMeshes Specifies if the submeshes should be kept
  65777. * @returns A new Mesh
  65778. */
  65779. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  65780. /**
  65781. * Build Mesh from CSG taking material and transforms into account
  65782. * @param name The name of the Mesh
  65783. * @param material The material of the Mesh
  65784. * @param scene The Scene
  65785. * @param keepSubMeshes Specifies if submeshes should be kept
  65786. * @returns The new Mesh
  65787. */
  65788. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  65789. }
  65790. }
  65791. declare module "babylonjs/Meshes/trailMesh" {
  65792. import { Mesh } from "babylonjs/Meshes/mesh";
  65793. import { Scene } from "babylonjs/scene";
  65794. import { TransformNode } from "babylonjs/Meshes/transformNode";
  65795. /**
  65796. * Class used to create a trail following a mesh
  65797. */
  65798. export class TrailMesh extends Mesh {
  65799. private _generator;
  65800. private _autoStart;
  65801. private _running;
  65802. private _diameter;
  65803. private _length;
  65804. private _sectionPolygonPointsCount;
  65805. private _sectionVectors;
  65806. private _sectionNormalVectors;
  65807. private _beforeRenderObserver;
  65808. /**
  65809. * @constructor
  65810. * @param name The value used by scene.getMeshByName() to do a lookup.
  65811. * @param generator The mesh or transform node to generate a trail.
  65812. * @param scene The scene to add this mesh to.
  65813. * @param diameter Diameter of trailing mesh. Default is 1.
  65814. * @param length Length of trailing mesh. Default is 60.
  65815. * @param autoStart Automatically start trailing mesh. Default true.
  65816. */
  65817. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  65818. /**
  65819. * "TrailMesh"
  65820. * @returns "TrailMesh"
  65821. */
  65822. getClassName(): string;
  65823. private _createMesh;
  65824. /**
  65825. * Start trailing mesh.
  65826. */
  65827. start(): void;
  65828. /**
  65829. * Stop trailing mesh.
  65830. */
  65831. stop(): void;
  65832. /**
  65833. * Update trailing mesh geometry.
  65834. */
  65835. update(): void;
  65836. /**
  65837. * Returns a new TrailMesh object.
  65838. * @param name is a string, the name given to the new mesh
  65839. * @param newGenerator use new generator object for cloned trail mesh
  65840. * @returns a new mesh
  65841. */
  65842. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  65843. /**
  65844. * Serializes this trail mesh
  65845. * @param serializationObject object to write serialization to
  65846. */
  65847. serialize(serializationObject: any): void;
  65848. /**
  65849. * Parses a serialized trail mesh
  65850. * @param parsedMesh the serialized mesh
  65851. * @param scene the scene to create the trail mesh in
  65852. * @returns the created trail mesh
  65853. */
  65854. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  65855. }
  65856. }
  65857. declare module "babylonjs/Meshes/Builders/tiledBoxBuilder" {
  65858. import { Nullable } from "babylonjs/types";
  65859. import { Scene } from "babylonjs/scene";
  65860. import { Vector4 } from "babylonjs/Maths/math.vector";
  65861. import { Color4 } from "babylonjs/Maths/math.color";
  65862. import { Mesh } from "babylonjs/Meshes/mesh";
  65863. /**
  65864. * Class containing static functions to help procedurally build meshes
  65865. */
  65866. export class TiledBoxBuilder {
  65867. /**
  65868. * Creates a box mesh
  65869. * 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)
  65870. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  65871. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65872. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  65873. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65874. * @param name defines the name of the mesh
  65875. * @param options defines the options used to create the mesh
  65876. * @param scene defines the hosting scene
  65877. * @returns the box mesh
  65878. */
  65879. static CreateTiledBox(name: string, options: {
  65880. pattern?: number;
  65881. width?: number;
  65882. height?: number;
  65883. depth?: number;
  65884. tileSize?: number;
  65885. tileWidth?: number;
  65886. tileHeight?: number;
  65887. alignHorizontal?: number;
  65888. alignVertical?: number;
  65889. faceUV?: Vector4[];
  65890. faceColors?: Color4[];
  65891. sideOrientation?: number;
  65892. updatable?: boolean;
  65893. }, scene?: Nullable<Scene>): Mesh;
  65894. }
  65895. }
  65896. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  65897. import { Vector4 } from "babylonjs/Maths/math.vector";
  65898. import { Mesh } from "babylonjs/Meshes/mesh";
  65899. /**
  65900. * Class containing static functions to help procedurally build meshes
  65901. */
  65902. export class TorusKnotBuilder {
  65903. /**
  65904. * Creates a torus knot mesh
  65905. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  65906. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  65907. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  65908. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  65909. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65910. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  65911. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  65912. * @param name defines the name of the mesh
  65913. * @param options defines the options used to create the mesh
  65914. * @param scene defines the hosting scene
  65915. * @returns the torus knot mesh
  65916. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  65917. */
  65918. static CreateTorusKnot(name: string, options: {
  65919. radius?: number;
  65920. tube?: number;
  65921. radialSegments?: number;
  65922. tubularSegments?: number;
  65923. p?: number;
  65924. q?: number;
  65925. updatable?: boolean;
  65926. sideOrientation?: number;
  65927. frontUVs?: Vector4;
  65928. backUVs?: Vector4;
  65929. }, scene: any): Mesh;
  65930. }
  65931. }
  65932. declare module "babylonjs/Meshes/polygonMesh" {
  65933. import { Scene } from "babylonjs/scene";
  65934. import { Vector2 } from "babylonjs/Maths/math.vector";
  65935. import { Mesh } from "babylonjs/Meshes/mesh";
  65936. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  65937. import { Path2 } from "babylonjs/Maths/math.path";
  65938. /**
  65939. * Polygon
  65940. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  65941. */
  65942. export class Polygon {
  65943. /**
  65944. * Creates a rectangle
  65945. * @param xmin bottom X coord
  65946. * @param ymin bottom Y coord
  65947. * @param xmax top X coord
  65948. * @param ymax top Y coord
  65949. * @returns points that make the resulting rectation
  65950. */
  65951. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  65952. /**
  65953. * Creates a circle
  65954. * @param radius radius of circle
  65955. * @param cx scale in x
  65956. * @param cy scale in y
  65957. * @param numberOfSides number of sides that make up the circle
  65958. * @returns points that make the resulting circle
  65959. */
  65960. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  65961. /**
  65962. * Creates a polygon from input string
  65963. * @param input Input polygon data
  65964. * @returns the parsed points
  65965. */
  65966. static Parse(input: string): Vector2[];
  65967. /**
  65968. * Starts building a polygon from x and y coordinates
  65969. * @param x x coordinate
  65970. * @param y y coordinate
  65971. * @returns the started path2
  65972. */
  65973. static StartingAt(x: number, y: number): Path2;
  65974. }
  65975. /**
  65976. * Builds a polygon
  65977. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  65978. */
  65979. export class PolygonMeshBuilder {
  65980. private _points;
  65981. private _outlinepoints;
  65982. private _holes;
  65983. private _name;
  65984. private _scene;
  65985. private _epoints;
  65986. private _eholes;
  65987. private _addToepoint;
  65988. /**
  65989. * Babylon reference to the earcut plugin.
  65990. */
  65991. bjsEarcut: any;
  65992. /**
  65993. * Creates a PolygonMeshBuilder
  65994. * @param name name of the builder
  65995. * @param contours Path of the polygon
  65996. * @param scene scene to add to when creating the mesh
  65997. * @param earcutInjection can be used to inject your own earcut reference
  65998. */
  65999. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  66000. /**
  66001. * Adds a whole within the polygon
  66002. * @param hole Array of points defining the hole
  66003. * @returns this
  66004. */
  66005. addHole(hole: Vector2[]): PolygonMeshBuilder;
  66006. /**
  66007. * Creates the polygon
  66008. * @param updatable If the mesh should be updatable
  66009. * @param depth The depth of the mesh created
  66010. * @returns the created mesh
  66011. */
  66012. build(updatable?: boolean, depth?: number): Mesh;
  66013. /**
  66014. * Creates the polygon
  66015. * @param depth The depth of the mesh created
  66016. * @returns the created VertexData
  66017. */
  66018. buildVertexData(depth?: number): VertexData;
  66019. /**
  66020. * Adds a side to the polygon
  66021. * @param positions points that make the polygon
  66022. * @param normals normals of the polygon
  66023. * @param uvs uvs of the polygon
  66024. * @param indices indices of the polygon
  66025. * @param bounds bounds of the polygon
  66026. * @param points points of the polygon
  66027. * @param depth depth of the polygon
  66028. * @param flip flip of the polygon
  66029. */
  66030. private addSide;
  66031. }
  66032. }
  66033. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  66034. import { Scene } from "babylonjs/scene";
  66035. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  66036. import { Color4 } from "babylonjs/Maths/math.color";
  66037. import { Mesh } from "babylonjs/Meshes/mesh";
  66038. import { Nullable } from "babylonjs/types";
  66039. /**
  66040. * Class containing static functions to help procedurally build meshes
  66041. */
  66042. export class PolygonBuilder {
  66043. /**
  66044. * Creates a polygon mesh
  66045. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  66046. * * 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
  66047. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  66048. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66049. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  66050. * * Remember you can only change the shape positions, not their number when updating a polygon
  66051. * @param name defines the name of the mesh
  66052. * @param options defines the options used to create the mesh
  66053. * @param scene defines the hosting scene
  66054. * @param earcutInjection can be used to inject your own earcut reference
  66055. * @returns the polygon mesh
  66056. */
  66057. static CreatePolygon(name: string, options: {
  66058. shape: Vector3[];
  66059. holes?: Vector3[][];
  66060. depth?: number;
  66061. faceUV?: Vector4[];
  66062. faceColors?: Color4[];
  66063. updatable?: boolean;
  66064. sideOrientation?: number;
  66065. frontUVs?: Vector4;
  66066. backUVs?: Vector4;
  66067. wrap?: boolean;
  66068. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  66069. /**
  66070. * Creates an extruded polygon mesh, with depth in the Y direction.
  66071. * * 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)
  66072. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  66073. * @param name defines the name of the mesh
  66074. * @param options defines the options used to create the mesh
  66075. * @param scene defines the hosting scene
  66076. * @param earcutInjection can be used to inject your own earcut reference
  66077. * @returns the polygon mesh
  66078. */
  66079. static ExtrudePolygon(name: string, options: {
  66080. shape: Vector3[];
  66081. holes?: Vector3[][];
  66082. depth?: number;
  66083. faceUV?: Vector4[];
  66084. faceColors?: Color4[];
  66085. updatable?: boolean;
  66086. sideOrientation?: number;
  66087. frontUVs?: Vector4;
  66088. backUVs?: Vector4;
  66089. wrap?: boolean;
  66090. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  66091. }
  66092. }
  66093. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  66094. import { Scene } from "babylonjs/scene";
  66095. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  66096. import { Mesh } from "babylonjs/Meshes/mesh";
  66097. import { Nullable } from "babylonjs/types";
  66098. /**
  66099. * Class containing static functions to help procedurally build meshes
  66100. */
  66101. export class LatheBuilder {
  66102. /**
  66103. * Creates lathe mesh.
  66104. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  66105. * * 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
  66106. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  66107. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  66108. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  66109. * * 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
  66110. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  66111. * * 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
  66112. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66113. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  66114. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  66115. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66116. * @param name defines the name of the mesh
  66117. * @param options defines the options used to create the mesh
  66118. * @param scene defines the hosting scene
  66119. * @returns the lathe mesh
  66120. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  66121. */
  66122. static CreateLathe(name: string, options: {
  66123. shape: Vector3[];
  66124. radius?: number;
  66125. tessellation?: number;
  66126. clip?: number;
  66127. arc?: number;
  66128. closed?: boolean;
  66129. updatable?: boolean;
  66130. sideOrientation?: number;
  66131. frontUVs?: Vector4;
  66132. backUVs?: Vector4;
  66133. cap?: number;
  66134. invertUV?: boolean;
  66135. }, scene?: Nullable<Scene>): Mesh;
  66136. }
  66137. }
  66138. declare module "babylonjs/Meshes/Builders/tiledPlaneBuilder" {
  66139. import { Nullable } from "babylonjs/types";
  66140. import { Scene } from "babylonjs/scene";
  66141. import { Vector4 } from "babylonjs/Maths/math.vector";
  66142. import { Mesh } from "babylonjs/Meshes/mesh";
  66143. /**
  66144. * Class containing static functions to help procedurally build meshes
  66145. */
  66146. export class TiledPlaneBuilder {
  66147. /**
  66148. * Creates a tiled plane mesh
  66149. * * The parameter `pattern` will, depending on value, do nothing or
  66150. * * * flip (reflect about central vertical) alternate tiles across and up
  66151. * * * flip every tile on alternate rows
  66152. * * * rotate (180 degs) alternate tiles across and up
  66153. * * * rotate every tile on alternate rows
  66154. * * * flip and rotate alternate tiles across and up
  66155. * * * flip and rotate every tile on alternate rows
  66156. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  66157. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  66158. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  66159. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  66160. * * 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)
  66161. * * 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)
  66162. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  66163. * @param name defines the name of the mesh
  66164. * @param options defines the options used to create the mesh
  66165. * @param scene defines the hosting scene
  66166. * @returns the box mesh
  66167. */
  66168. static CreateTiledPlane(name: string, options: {
  66169. pattern?: number;
  66170. tileSize?: number;
  66171. tileWidth?: number;
  66172. tileHeight?: number;
  66173. size?: number;
  66174. width?: number;
  66175. height?: number;
  66176. alignHorizontal?: number;
  66177. alignVertical?: number;
  66178. sideOrientation?: number;
  66179. frontUVs?: Vector4;
  66180. backUVs?: Vector4;
  66181. updatable?: boolean;
  66182. }, scene?: Nullable<Scene>): Mesh;
  66183. }
  66184. }
  66185. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  66186. import { Nullable } from "babylonjs/types";
  66187. import { Scene } from "babylonjs/scene";
  66188. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  66189. import { Mesh } from "babylonjs/Meshes/mesh";
  66190. /**
  66191. * Class containing static functions to help procedurally build meshes
  66192. */
  66193. export class TubeBuilder {
  66194. /**
  66195. * Creates a tube mesh.
  66196. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  66197. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  66198. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  66199. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  66200. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  66201. * * 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)
  66202. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  66203. * * 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
  66204. * * 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
  66205. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66206. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  66207. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  66208. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66209. * @param name defines the name of the mesh
  66210. * @param options defines the options used to create the mesh
  66211. * @param scene defines the hosting scene
  66212. * @returns the tube mesh
  66213. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  66214. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  66215. */
  66216. static CreateTube(name: string, options: {
  66217. path: Vector3[];
  66218. radius?: number;
  66219. tessellation?: number;
  66220. radiusFunction?: {
  66221. (i: number, distance: number): number;
  66222. };
  66223. cap?: number;
  66224. arc?: number;
  66225. updatable?: boolean;
  66226. sideOrientation?: number;
  66227. frontUVs?: Vector4;
  66228. backUVs?: Vector4;
  66229. instance?: Mesh;
  66230. invertUV?: boolean;
  66231. }, scene?: Nullable<Scene>): Mesh;
  66232. }
  66233. }
  66234. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  66235. import { Scene } from "babylonjs/scene";
  66236. import { Vector4 } from "babylonjs/Maths/math.vector";
  66237. import { Mesh } from "babylonjs/Meshes/mesh";
  66238. import { Nullable } from "babylonjs/types";
  66239. /**
  66240. * Class containing static functions to help procedurally build meshes
  66241. */
  66242. export class IcoSphereBuilder {
  66243. /**
  66244. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  66245. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  66246. * * 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`)
  66247. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  66248. * * 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
  66249. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66250. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  66251. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66252. * @param name defines the name of the mesh
  66253. * @param options defines the options used to create the mesh
  66254. * @param scene defines the hosting scene
  66255. * @returns the icosahedron mesh
  66256. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  66257. */
  66258. static CreateIcoSphere(name: string, options: {
  66259. radius?: number;
  66260. radiusX?: number;
  66261. radiusY?: number;
  66262. radiusZ?: number;
  66263. flat?: boolean;
  66264. subdivisions?: number;
  66265. sideOrientation?: number;
  66266. frontUVs?: Vector4;
  66267. backUVs?: Vector4;
  66268. updatable?: boolean;
  66269. }, scene?: Nullable<Scene>): Mesh;
  66270. }
  66271. }
  66272. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  66273. import { Vector3 } from "babylonjs/Maths/math.vector";
  66274. import { Mesh } from "babylonjs/Meshes/mesh";
  66275. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66276. /**
  66277. * Class containing static functions to help procedurally build meshes
  66278. */
  66279. export class DecalBuilder {
  66280. /**
  66281. * Creates a decal mesh.
  66282. * 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
  66283. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  66284. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  66285. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  66286. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  66287. * @param name defines the name of the mesh
  66288. * @param sourceMesh defines the mesh where the decal must be applied
  66289. * @param options defines the options used to create the mesh
  66290. * @param scene defines the hosting scene
  66291. * @returns the decal mesh
  66292. * @see https://doc.babylonjs.com/how_to/decals
  66293. */
  66294. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  66295. position?: Vector3;
  66296. normal?: Vector3;
  66297. size?: Vector3;
  66298. angle?: number;
  66299. }): Mesh;
  66300. }
  66301. }
  66302. declare module "babylonjs/Meshes/meshBuilder" {
  66303. import { Vector4, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  66304. import { Nullable } from "babylonjs/types";
  66305. import { Scene } from "babylonjs/scene";
  66306. import { Mesh } from "babylonjs/Meshes/mesh";
  66307. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  66308. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  66309. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66310. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  66311. import { Plane } from "babylonjs/Maths/math.plane";
  66312. /**
  66313. * Class containing static functions to help procedurally build meshes
  66314. */
  66315. export class MeshBuilder {
  66316. /**
  66317. * Creates a box mesh
  66318. * * The parameter `size` sets the size (float) of each box side (default 1)
  66319. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  66320. * * 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)
  66321. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  66322. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66323. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  66324. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66325. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  66326. * @param name defines the name of the mesh
  66327. * @param options defines the options used to create the mesh
  66328. * @param scene defines the hosting scene
  66329. * @returns the box mesh
  66330. */
  66331. static CreateBox(name: string, options: {
  66332. size?: number;
  66333. width?: number;
  66334. height?: number;
  66335. depth?: number;
  66336. faceUV?: Vector4[];
  66337. faceColors?: Color4[];
  66338. sideOrientation?: number;
  66339. frontUVs?: Vector4;
  66340. backUVs?: Vector4;
  66341. wrap?: boolean;
  66342. topBaseAt?: number;
  66343. bottomBaseAt?: number;
  66344. updatable?: boolean;
  66345. }, scene?: Nullable<Scene>): Mesh;
  66346. /**
  66347. * Creates a tiled box mesh
  66348. * * faceTiles sets the pattern, tile size and number of tiles for a face
  66349. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66350. * @param name defines the name of the mesh
  66351. * @param options defines the options used to create the mesh
  66352. * @param scene defines the hosting scene
  66353. * @returns the tiled box mesh
  66354. */
  66355. static CreateTiledBox(name: string, options: {
  66356. pattern?: number;
  66357. size?: number;
  66358. width?: number;
  66359. height?: number;
  66360. depth: number;
  66361. tileSize?: number;
  66362. tileWidth?: number;
  66363. tileHeight?: number;
  66364. faceUV?: Vector4[];
  66365. faceColors?: Color4[];
  66366. alignHorizontal?: number;
  66367. alignVertical?: number;
  66368. sideOrientation?: number;
  66369. updatable?: boolean;
  66370. }, scene?: Nullable<Scene>): Mesh;
  66371. /**
  66372. * Creates a sphere mesh
  66373. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  66374. * * 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`)
  66375. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  66376. * * 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
  66377. * * 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)
  66378. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66379. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  66380. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66381. * @param name defines the name of the mesh
  66382. * @param options defines the options used to create the mesh
  66383. * @param scene defines the hosting scene
  66384. * @returns the sphere mesh
  66385. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  66386. */
  66387. static CreateSphere(name: string, options: {
  66388. segments?: number;
  66389. diameter?: number;
  66390. diameterX?: number;
  66391. diameterY?: number;
  66392. diameterZ?: number;
  66393. arc?: number;
  66394. slice?: number;
  66395. sideOrientation?: number;
  66396. frontUVs?: Vector4;
  66397. backUVs?: Vector4;
  66398. updatable?: boolean;
  66399. }, scene?: Nullable<Scene>): Mesh;
  66400. /**
  66401. * Creates a plane polygonal mesh. By default, this is a disc
  66402. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  66403. * * 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
  66404. * * 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
  66405. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66406. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  66407. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66408. * @param name defines the name of the mesh
  66409. * @param options defines the options used to create the mesh
  66410. * @param scene defines the hosting scene
  66411. * @returns the plane polygonal mesh
  66412. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  66413. */
  66414. static CreateDisc(name: string, options: {
  66415. radius?: number;
  66416. tessellation?: number;
  66417. arc?: number;
  66418. updatable?: boolean;
  66419. sideOrientation?: number;
  66420. frontUVs?: Vector4;
  66421. backUVs?: Vector4;
  66422. }, scene?: Nullable<Scene>): Mesh;
  66423. /**
  66424. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  66425. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  66426. * * 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`)
  66427. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  66428. * * 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
  66429. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66430. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  66431. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66432. * @param name defines the name of the mesh
  66433. * @param options defines the options used to create the mesh
  66434. * @param scene defines the hosting scene
  66435. * @returns the icosahedron mesh
  66436. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  66437. */
  66438. static CreateIcoSphere(name: string, options: {
  66439. radius?: number;
  66440. radiusX?: number;
  66441. radiusY?: number;
  66442. radiusZ?: number;
  66443. flat?: boolean;
  66444. subdivisions?: number;
  66445. sideOrientation?: number;
  66446. frontUVs?: Vector4;
  66447. backUVs?: Vector4;
  66448. updatable?: boolean;
  66449. }, scene?: Nullable<Scene>): Mesh;
  66450. /**
  66451. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  66452. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  66453. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  66454. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  66455. * * 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
  66456. * * 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
  66457. * * 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
  66458. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66459. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  66460. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  66461. * * 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
  66462. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  66463. * * 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
  66464. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  66465. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66466. * @param name defines the name of the mesh
  66467. * @param options defines the options used to create the mesh
  66468. * @param scene defines the hosting scene
  66469. * @returns the ribbon mesh
  66470. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  66471. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  66472. */
  66473. static CreateRibbon(name: string, options: {
  66474. pathArray: Vector3[][];
  66475. closeArray?: boolean;
  66476. closePath?: boolean;
  66477. offset?: number;
  66478. updatable?: boolean;
  66479. sideOrientation?: number;
  66480. frontUVs?: Vector4;
  66481. backUVs?: Vector4;
  66482. instance?: Mesh;
  66483. invertUV?: boolean;
  66484. uvs?: Vector2[];
  66485. colors?: Color4[];
  66486. }, scene?: Nullable<Scene>): Mesh;
  66487. /**
  66488. * Creates a cylinder or a cone mesh
  66489. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  66490. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  66491. * * 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.
  66492. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  66493. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  66494. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  66495. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  66496. * * 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).
  66497. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  66498. * * 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).
  66499. * * 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
  66500. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  66501. * * 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
  66502. * * 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.
  66503. * * If `enclose` is false, a ring surface is one element.
  66504. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  66505. * * 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
  66506. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66507. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  66508. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  66509. * @param name defines the name of the mesh
  66510. * @param options defines the options used to create the mesh
  66511. * @param scene defines the hosting scene
  66512. * @returns the cylinder mesh
  66513. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  66514. */
  66515. static CreateCylinder(name: string, options: {
  66516. height?: number;
  66517. diameterTop?: number;
  66518. diameterBottom?: number;
  66519. diameter?: number;
  66520. tessellation?: number;
  66521. subdivisions?: number;
  66522. arc?: number;
  66523. faceColors?: Color4[];
  66524. faceUV?: Vector4[];
  66525. updatable?: boolean;
  66526. hasRings?: boolean;
  66527. enclose?: boolean;
  66528. cap?: number;
  66529. sideOrientation?: number;
  66530. frontUVs?: Vector4;
  66531. backUVs?: Vector4;
  66532. }, scene?: Nullable<Scene>): Mesh;
  66533. /**
  66534. * Creates a torus mesh
  66535. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  66536. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  66537. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  66538. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66539. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  66540. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  66541. * @param name defines the name of the mesh
  66542. * @param options defines the options used to create the mesh
  66543. * @param scene defines the hosting scene
  66544. * @returns the torus mesh
  66545. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  66546. */
  66547. static CreateTorus(name: string, options: {
  66548. diameter?: number;
  66549. thickness?: number;
  66550. tessellation?: number;
  66551. updatable?: boolean;
  66552. sideOrientation?: number;
  66553. frontUVs?: Vector4;
  66554. backUVs?: Vector4;
  66555. }, scene?: Nullable<Scene>): Mesh;
  66556. /**
  66557. * Creates a torus knot mesh
  66558. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  66559. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  66560. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  66561. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  66562. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66563. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  66564. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  66565. * @param name defines the name of the mesh
  66566. * @param options defines the options used to create the mesh
  66567. * @param scene defines the hosting scene
  66568. * @returns the torus knot mesh
  66569. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  66570. */
  66571. static CreateTorusKnot(name: string, options: {
  66572. radius?: number;
  66573. tube?: number;
  66574. radialSegments?: number;
  66575. tubularSegments?: number;
  66576. p?: number;
  66577. q?: number;
  66578. updatable?: boolean;
  66579. sideOrientation?: number;
  66580. frontUVs?: Vector4;
  66581. backUVs?: Vector4;
  66582. }, scene?: Nullable<Scene>): Mesh;
  66583. /**
  66584. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  66585. * * 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
  66586. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  66587. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  66588. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  66589. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  66590. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  66591. * * 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
  66592. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  66593. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66594. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  66595. * @param name defines the name of the new line system
  66596. * @param options defines the options used to create the line system
  66597. * @param scene defines the hosting scene
  66598. * @returns a new line system mesh
  66599. */
  66600. static CreateLineSystem(name: string, options: {
  66601. lines: Vector3[][];
  66602. updatable?: boolean;
  66603. instance?: Nullable<LinesMesh>;
  66604. colors?: Nullable<Color4[][]>;
  66605. useVertexAlpha?: boolean;
  66606. }, scene: Nullable<Scene>): LinesMesh;
  66607. /**
  66608. * Creates a line mesh
  66609. * 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
  66610. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  66611. * * The parameter `points` is an array successive Vector3
  66612. * * 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
  66613. * * The optional parameter `colors` is an array of successive Color4, one per line point
  66614. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  66615. * * When updating an instance, remember that only point positions can change, not the number of points
  66616. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66617. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  66618. * @param name defines the name of the new line system
  66619. * @param options defines the options used to create the line system
  66620. * @param scene defines the hosting scene
  66621. * @returns a new line mesh
  66622. */
  66623. static CreateLines(name: string, options: {
  66624. points: Vector3[];
  66625. updatable?: boolean;
  66626. instance?: Nullable<LinesMesh>;
  66627. colors?: Color4[];
  66628. useVertexAlpha?: boolean;
  66629. }, scene?: Nullable<Scene>): LinesMesh;
  66630. /**
  66631. * Creates a dashed line mesh
  66632. * * 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
  66633. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  66634. * * The parameter `points` is an array successive Vector3
  66635. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  66636. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  66637. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  66638. * * 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
  66639. * * When updating an instance, remember that only point positions can change, not the number of points
  66640. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66641. * @param name defines the name of the mesh
  66642. * @param options defines the options used to create the mesh
  66643. * @param scene defines the hosting scene
  66644. * @returns the dashed line mesh
  66645. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  66646. */
  66647. static CreateDashedLines(name: string, options: {
  66648. points: Vector3[];
  66649. dashSize?: number;
  66650. gapSize?: number;
  66651. dashNb?: number;
  66652. updatable?: boolean;
  66653. instance?: LinesMesh;
  66654. }, scene?: Nullable<Scene>): LinesMesh;
  66655. /**
  66656. * 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.
  66657. * * 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.
  66658. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  66659. * * 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.
  66660. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  66661. * * 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
  66662. * * 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
  66663. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  66664. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66665. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  66666. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  66667. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  66668. * @param name defines the name of the mesh
  66669. * @param options defines the options used to create the mesh
  66670. * @param scene defines the hosting scene
  66671. * @returns the extruded shape mesh
  66672. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  66673. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  66674. */
  66675. static ExtrudeShape(name: string, options: {
  66676. shape: Vector3[];
  66677. path: Vector3[];
  66678. scale?: number;
  66679. rotation?: number;
  66680. cap?: number;
  66681. updatable?: boolean;
  66682. sideOrientation?: number;
  66683. frontUVs?: Vector4;
  66684. backUVs?: Vector4;
  66685. instance?: Mesh;
  66686. invertUV?: boolean;
  66687. }, scene?: Nullable<Scene>): Mesh;
  66688. /**
  66689. * Creates an custom extruded shape mesh.
  66690. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  66691. * * 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.
  66692. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  66693. * * 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
  66694. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  66695. * * 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
  66696. * * It must returns a float value that will be the scale value applied to the shape on each path point
  66697. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  66698. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  66699. * * 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
  66700. * * 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
  66701. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  66702. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66703. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  66704. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  66705. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66706. * @param name defines the name of the mesh
  66707. * @param options defines the options used to create the mesh
  66708. * @param scene defines the hosting scene
  66709. * @returns the custom extruded shape mesh
  66710. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  66711. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  66712. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  66713. */
  66714. static ExtrudeShapeCustom(name: string, options: {
  66715. shape: Vector3[];
  66716. path: Vector3[];
  66717. scaleFunction?: any;
  66718. rotationFunction?: any;
  66719. ribbonCloseArray?: boolean;
  66720. ribbonClosePath?: boolean;
  66721. cap?: number;
  66722. updatable?: boolean;
  66723. sideOrientation?: number;
  66724. frontUVs?: Vector4;
  66725. backUVs?: Vector4;
  66726. instance?: Mesh;
  66727. invertUV?: boolean;
  66728. }, scene?: Nullable<Scene>): Mesh;
  66729. /**
  66730. * Creates lathe mesh.
  66731. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  66732. * * 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
  66733. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  66734. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  66735. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  66736. * * 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
  66737. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  66738. * * 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
  66739. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66740. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  66741. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  66742. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66743. * @param name defines the name of the mesh
  66744. * @param options defines the options used to create the mesh
  66745. * @param scene defines the hosting scene
  66746. * @returns the lathe mesh
  66747. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  66748. */
  66749. static CreateLathe(name: string, options: {
  66750. shape: Vector3[];
  66751. radius?: number;
  66752. tessellation?: number;
  66753. clip?: number;
  66754. arc?: number;
  66755. closed?: boolean;
  66756. updatable?: boolean;
  66757. sideOrientation?: number;
  66758. frontUVs?: Vector4;
  66759. backUVs?: Vector4;
  66760. cap?: number;
  66761. invertUV?: boolean;
  66762. }, scene?: Nullable<Scene>): Mesh;
  66763. /**
  66764. * Creates a tiled plane mesh
  66765. * * You can set a limited pattern arrangement with the tiles
  66766. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66767. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  66768. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66769. * @param name defines the name of the mesh
  66770. * @param options defines the options used to create the mesh
  66771. * @param scene defines the hosting scene
  66772. * @returns the plane mesh
  66773. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  66774. */
  66775. static CreateTiledPlane(name: string, options: {
  66776. pattern?: number;
  66777. tileSize?: number;
  66778. tileWidth?: number;
  66779. tileHeight?: number;
  66780. size?: number;
  66781. width?: number;
  66782. height?: number;
  66783. alignHorizontal?: number;
  66784. alignVertical?: number;
  66785. sideOrientation?: number;
  66786. frontUVs?: Vector4;
  66787. backUVs?: Vector4;
  66788. updatable?: boolean;
  66789. }, scene?: Nullable<Scene>): Mesh;
  66790. /**
  66791. * Creates a plane mesh
  66792. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  66793. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  66794. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  66795. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66796. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  66797. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66798. * @param name defines the name of the mesh
  66799. * @param options defines the options used to create the mesh
  66800. * @param scene defines the hosting scene
  66801. * @returns the plane mesh
  66802. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  66803. */
  66804. static CreatePlane(name: string, options: {
  66805. size?: number;
  66806. width?: number;
  66807. height?: number;
  66808. sideOrientation?: number;
  66809. frontUVs?: Vector4;
  66810. backUVs?: Vector4;
  66811. updatable?: boolean;
  66812. sourcePlane?: Plane;
  66813. }, scene?: Nullable<Scene>): Mesh;
  66814. /**
  66815. * Creates a ground mesh
  66816. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  66817. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  66818. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66819. * @param name defines the name of the mesh
  66820. * @param options defines the options used to create the mesh
  66821. * @param scene defines the hosting scene
  66822. * @returns the ground mesh
  66823. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  66824. */
  66825. static CreateGround(name: string, options: {
  66826. width?: number;
  66827. height?: number;
  66828. subdivisions?: number;
  66829. subdivisionsX?: number;
  66830. subdivisionsY?: number;
  66831. updatable?: boolean;
  66832. }, scene?: Nullable<Scene>): Mesh;
  66833. /**
  66834. * Creates a tiled ground mesh
  66835. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  66836. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  66837. * * 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
  66838. * * 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
  66839. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  66840. * @param name defines the name of the mesh
  66841. * @param options defines the options used to create the mesh
  66842. * @param scene defines the hosting scene
  66843. * @returns the tiled ground mesh
  66844. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  66845. */
  66846. static CreateTiledGround(name: string, options: {
  66847. xmin: number;
  66848. zmin: number;
  66849. xmax: number;
  66850. zmax: number;
  66851. subdivisions?: {
  66852. w: number;
  66853. h: number;
  66854. };
  66855. precision?: {
  66856. w: number;
  66857. h: number;
  66858. };
  66859. updatable?: boolean;
  66860. }, scene?: Nullable<Scene>): Mesh;
  66861. /**
  66862. * Creates a ground mesh from a height map
  66863. * * The parameter `url` sets the URL of the height map image resource.
  66864. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  66865. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  66866. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  66867. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  66868. * * 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.
  66869. * * 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).
  66870. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  66871. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  66872. * @param name defines the name of the mesh
  66873. * @param url defines the url to the height map
  66874. * @param options defines the options used to create the mesh
  66875. * @param scene defines the hosting scene
  66876. * @returns the ground mesh
  66877. * @see https://doc.babylonjs.com/babylon101/height_map
  66878. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  66879. */
  66880. static CreateGroundFromHeightMap(name: string, url: string, options: {
  66881. width?: number;
  66882. height?: number;
  66883. subdivisions?: number;
  66884. minHeight?: number;
  66885. maxHeight?: number;
  66886. colorFilter?: Color3;
  66887. alphaFilter?: number;
  66888. updatable?: boolean;
  66889. onReady?: (mesh: GroundMesh) => void;
  66890. }, scene?: Nullable<Scene>): GroundMesh;
  66891. /**
  66892. * Creates a polygon mesh
  66893. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  66894. * * 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
  66895. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  66896. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66897. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  66898. * * Remember you can only change the shape positions, not their number when updating a polygon
  66899. * @param name defines the name of the mesh
  66900. * @param options defines the options used to create the mesh
  66901. * @param scene defines the hosting scene
  66902. * @param earcutInjection can be used to inject your own earcut reference
  66903. * @returns the polygon mesh
  66904. */
  66905. static CreatePolygon(name: string, options: {
  66906. shape: Vector3[];
  66907. holes?: Vector3[][];
  66908. depth?: number;
  66909. faceUV?: Vector4[];
  66910. faceColors?: Color4[];
  66911. updatable?: boolean;
  66912. sideOrientation?: number;
  66913. frontUVs?: Vector4;
  66914. backUVs?: Vector4;
  66915. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  66916. /**
  66917. * Creates an extruded polygon mesh, with depth in the Y direction.
  66918. * * 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)
  66919. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  66920. * @param name defines the name of the mesh
  66921. * @param options defines the options used to create the mesh
  66922. * @param scene defines the hosting scene
  66923. * @param earcutInjection can be used to inject your own earcut reference
  66924. * @returns the polygon mesh
  66925. */
  66926. static ExtrudePolygon(name: string, options: {
  66927. shape: Vector3[];
  66928. holes?: Vector3[][];
  66929. depth?: number;
  66930. faceUV?: Vector4[];
  66931. faceColors?: Color4[];
  66932. updatable?: boolean;
  66933. sideOrientation?: number;
  66934. frontUVs?: Vector4;
  66935. backUVs?: Vector4;
  66936. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  66937. /**
  66938. * Creates a tube mesh.
  66939. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  66940. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  66941. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  66942. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  66943. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  66944. * * 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)
  66945. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  66946. * * 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
  66947. * * 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
  66948. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66949. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  66950. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  66951. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66952. * @param name defines the name of the mesh
  66953. * @param options defines the options used to create the mesh
  66954. * @param scene defines the hosting scene
  66955. * @returns the tube mesh
  66956. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  66957. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  66958. */
  66959. static CreateTube(name: string, options: {
  66960. path: Vector3[];
  66961. radius?: number;
  66962. tessellation?: number;
  66963. radiusFunction?: {
  66964. (i: number, distance: number): number;
  66965. };
  66966. cap?: number;
  66967. arc?: number;
  66968. updatable?: boolean;
  66969. sideOrientation?: number;
  66970. frontUVs?: Vector4;
  66971. backUVs?: Vector4;
  66972. instance?: Mesh;
  66973. invertUV?: boolean;
  66974. }, scene?: Nullable<Scene>): Mesh;
  66975. /**
  66976. * Creates a polyhedron mesh
  66977. * * 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
  66978. * * The parameter `size` (positive float, default 1) sets the polygon size
  66979. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  66980. * * 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`
  66981. * * 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
  66982. * * 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)`)
  66983. * * 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
  66984. * * 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
  66985. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66986. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  66987. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66988. * @param name defines the name of the mesh
  66989. * @param options defines the options used to create the mesh
  66990. * @param scene defines the hosting scene
  66991. * @returns the polyhedron mesh
  66992. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  66993. */
  66994. static CreatePolyhedron(name: string, options: {
  66995. type?: number;
  66996. size?: number;
  66997. sizeX?: number;
  66998. sizeY?: number;
  66999. sizeZ?: number;
  67000. custom?: any;
  67001. faceUV?: Vector4[];
  67002. faceColors?: Color4[];
  67003. flat?: boolean;
  67004. updatable?: boolean;
  67005. sideOrientation?: number;
  67006. frontUVs?: Vector4;
  67007. backUVs?: Vector4;
  67008. }, scene?: Nullable<Scene>): Mesh;
  67009. /**
  67010. * Creates a decal mesh.
  67011. * 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
  67012. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  67013. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  67014. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  67015. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  67016. * @param name defines the name of the mesh
  67017. * @param sourceMesh defines the mesh where the decal must be applied
  67018. * @param options defines the options used to create the mesh
  67019. * @param scene defines the hosting scene
  67020. * @returns the decal mesh
  67021. * @see https://doc.babylonjs.com/how_to/decals
  67022. */
  67023. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  67024. position?: Vector3;
  67025. normal?: Vector3;
  67026. size?: Vector3;
  67027. angle?: number;
  67028. }): Mesh;
  67029. }
  67030. }
  67031. declare module "babylonjs/Meshes/meshSimplification" {
  67032. import { Mesh } from "babylonjs/Meshes/mesh";
  67033. /**
  67034. * A simplifier interface for future simplification implementations
  67035. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  67036. */
  67037. export interface ISimplifier {
  67038. /**
  67039. * Simplification of a given mesh according to the given settings.
  67040. * Since this requires computation, it is assumed that the function runs async.
  67041. * @param settings The settings of the simplification, including quality and distance
  67042. * @param successCallback A callback that will be called after the mesh was simplified.
  67043. * @param errorCallback in case of an error, this callback will be called. optional.
  67044. */
  67045. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  67046. }
  67047. /**
  67048. * Expected simplification settings.
  67049. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  67050. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  67051. */
  67052. export interface ISimplificationSettings {
  67053. /**
  67054. * Gets or sets the expected quality
  67055. */
  67056. quality: number;
  67057. /**
  67058. * Gets or sets the distance when this optimized version should be used
  67059. */
  67060. distance: number;
  67061. /**
  67062. * Gets an already optimized mesh
  67063. */
  67064. optimizeMesh?: boolean;
  67065. }
  67066. /**
  67067. * Class used to specify simplification options
  67068. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  67069. */
  67070. export class SimplificationSettings implements ISimplificationSettings {
  67071. /** expected quality */
  67072. quality: number;
  67073. /** distance when this optimized version should be used */
  67074. distance: number;
  67075. /** already optimized mesh */
  67076. optimizeMesh?: boolean | undefined;
  67077. /**
  67078. * Creates a SimplificationSettings
  67079. * @param quality expected quality
  67080. * @param distance distance when this optimized version should be used
  67081. * @param optimizeMesh already optimized mesh
  67082. */
  67083. constructor(
  67084. /** expected quality */
  67085. quality: number,
  67086. /** distance when this optimized version should be used */
  67087. distance: number,
  67088. /** already optimized mesh */
  67089. optimizeMesh?: boolean | undefined);
  67090. }
  67091. /**
  67092. * Interface used to define a simplification task
  67093. */
  67094. export interface ISimplificationTask {
  67095. /**
  67096. * Array of settings
  67097. */
  67098. settings: Array<ISimplificationSettings>;
  67099. /**
  67100. * Simplification type
  67101. */
  67102. simplificationType: SimplificationType;
  67103. /**
  67104. * Mesh to simplify
  67105. */
  67106. mesh: Mesh;
  67107. /**
  67108. * Callback called on success
  67109. */
  67110. successCallback?: () => void;
  67111. /**
  67112. * Defines if parallel processing can be used
  67113. */
  67114. parallelProcessing: boolean;
  67115. }
  67116. /**
  67117. * Queue used to order the simplification tasks
  67118. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  67119. */
  67120. export class SimplificationQueue {
  67121. private _simplificationArray;
  67122. /**
  67123. * Gets a boolean indicating that the process is still running
  67124. */
  67125. running: boolean;
  67126. /**
  67127. * Creates a new queue
  67128. */
  67129. constructor();
  67130. /**
  67131. * Adds a new simplification task
  67132. * @param task defines a task to add
  67133. */
  67134. addTask(task: ISimplificationTask): void;
  67135. /**
  67136. * Execute next task
  67137. */
  67138. executeNext(): void;
  67139. /**
  67140. * Execute a simplification task
  67141. * @param task defines the task to run
  67142. */
  67143. runSimplification(task: ISimplificationTask): void;
  67144. private getSimplifier;
  67145. }
  67146. /**
  67147. * The implemented types of simplification
  67148. * At the moment only Quadratic Error Decimation is implemented
  67149. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  67150. */
  67151. export enum SimplificationType {
  67152. /** Quadratic error decimation */
  67153. QUADRATIC = 0
  67154. }
  67155. /**
  67156. * An implementation of the Quadratic Error simplification algorithm.
  67157. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  67158. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  67159. * @author RaananW
  67160. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  67161. */
  67162. export class QuadraticErrorSimplification implements ISimplifier {
  67163. private _mesh;
  67164. private triangles;
  67165. private vertices;
  67166. private references;
  67167. private _reconstructedMesh;
  67168. /** Gets or sets the number pf sync interations */
  67169. syncIterations: number;
  67170. /** Gets or sets the aggressiveness of the simplifier */
  67171. aggressiveness: number;
  67172. /** Gets or sets the number of allowed iterations for decimation */
  67173. decimationIterations: number;
  67174. /** Gets or sets the espilon to use for bounding box computation */
  67175. boundingBoxEpsilon: number;
  67176. /**
  67177. * Creates a new QuadraticErrorSimplification
  67178. * @param _mesh defines the target mesh
  67179. */
  67180. constructor(_mesh: Mesh);
  67181. /**
  67182. * Simplification of a given mesh according to the given settings.
  67183. * Since this requires computation, it is assumed that the function runs async.
  67184. * @param settings The settings of the simplification, including quality and distance
  67185. * @param successCallback A callback that will be called after the mesh was simplified.
  67186. */
  67187. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  67188. private runDecimation;
  67189. private initWithMesh;
  67190. private init;
  67191. private reconstructMesh;
  67192. private initDecimatedMesh;
  67193. private isFlipped;
  67194. private updateTriangles;
  67195. private identifyBorder;
  67196. private updateMesh;
  67197. private vertexError;
  67198. private calculateError;
  67199. }
  67200. }
  67201. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  67202. import { Scene } from "babylonjs/scene";
  67203. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  67204. import { ISceneComponent } from "babylonjs/sceneComponent";
  67205. module "babylonjs/scene" {
  67206. interface Scene {
  67207. /** @hidden (Backing field) */
  67208. _simplificationQueue: SimplificationQueue;
  67209. /**
  67210. * Gets or sets the simplification queue attached to the scene
  67211. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  67212. */
  67213. simplificationQueue: SimplificationQueue;
  67214. }
  67215. }
  67216. module "babylonjs/Meshes/mesh" {
  67217. interface Mesh {
  67218. /**
  67219. * Simplify the mesh according to the given array of settings.
  67220. * Function will return immediately and will simplify async
  67221. * @param settings a collection of simplification settings
  67222. * @param parallelProcessing should all levels calculate parallel or one after the other
  67223. * @param simplificationType the type of simplification to run
  67224. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  67225. * @returns the current mesh
  67226. */
  67227. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  67228. }
  67229. }
  67230. /**
  67231. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  67232. * created in a scene
  67233. */
  67234. export class SimplicationQueueSceneComponent implements ISceneComponent {
  67235. /**
  67236. * The component name helpfull to identify the component in the list of scene components.
  67237. */
  67238. readonly name: string;
  67239. /**
  67240. * The scene the component belongs to.
  67241. */
  67242. scene: Scene;
  67243. /**
  67244. * Creates a new instance of the component for the given scene
  67245. * @param scene Defines the scene to register the component in
  67246. */
  67247. constructor(scene: Scene);
  67248. /**
  67249. * Registers the component in a given scene
  67250. */
  67251. register(): void;
  67252. /**
  67253. * Rebuilds the elements related to this component in case of
  67254. * context lost for instance.
  67255. */
  67256. rebuild(): void;
  67257. /**
  67258. * Disposes the component and the associated ressources
  67259. */
  67260. dispose(): void;
  67261. private _beforeCameraUpdate;
  67262. }
  67263. }
  67264. declare module "babylonjs/Meshes/Builders/index" {
  67265. export * from "babylonjs/Meshes/Builders/boxBuilder";
  67266. export * from "babylonjs/Meshes/Builders/tiledBoxBuilder";
  67267. export * from "babylonjs/Meshes/Builders/discBuilder";
  67268. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  67269. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  67270. export * from "babylonjs/Meshes/Builders/hemisphereBuilder";
  67271. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  67272. export * from "babylonjs/Meshes/Builders/torusBuilder";
  67273. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  67274. export * from "babylonjs/Meshes/Builders/linesBuilder";
  67275. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  67276. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  67277. export * from "babylonjs/Meshes/Builders/latheBuilder";
  67278. export * from "babylonjs/Meshes/Builders/planeBuilder";
  67279. export * from "babylonjs/Meshes/Builders/tiledPlaneBuilder";
  67280. export * from "babylonjs/Meshes/Builders/groundBuilder";
  67281. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  67282. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  67283. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  67284. export * from "babylonjs/Meshes/Builders/decalBuilder";
  67285. }
  67286. declare module "babylonjs/Meshes/index" {
  67287. export * from "babylonjs/Meshes/abstractMesh";
  67288. export * from "babylonjs/Meshes/buffer";
  67289. export * from "babylonjs/Meshes/Compression/index";
  67290. export * from "babylonjs/Meshes/csg";
  67291. export * from "babylonjs/Meshes/geometry";
  67292. export * from "babylonjs/Meshes/groundMesh";
  67293. export * from "babylonjs/Meshes/trailMesh";
  67294. export * from "babylonjs/Meshes/instancedMesh";
  67295. export * from "babylonjs/Meshes/linesMesh";
  67296. export * from "babylonjs/Meshes/mesh";
  67297. export * from "babylonjs/Meshes/mesh.vertexData";
  67298. export * from "babylonjs/Meshes/meshBuilder";
  67299. export * from "babylonjs/Meshes/meshSimplification";
  67300. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  67301. export * from "babylonjs/Meshes/polygonMesh";
  67302. export * from "babylonjs/Meshes/subMesh";
  67303. export * from "babylonjs/Meshes/meshLODLevel";
  67304. export * from "babylonjs/Meshes/transformNode";
  67305. export * from "babylonjs/Meshes/Builders/index";
  67306. export * from "babylonjs/Meshes/dataBuffer";
  67307. export * from "babylonjs/Meshes/WebGL/webGLDataBuffer";
  67308. }
  67309. declare module "babylonjs/Morph/index" {
  67310. export * from "babylonjs/Morph/morphTarget";
  67311. export * from "babylonjs/Morph/morphTargetManager";
  67312. }
  67313. declare module "babylonjs/Navigation/INavigationEngine" {
  67314. import { TransformNode } from "babylonjs/Meshes/transformNode";
  67315. import { Vector3 } from "babylonjs/Maths/math";
  67316. import { Mesh } from "babylonjs/Meshes/mesh";
  67317. import { Scene } from "babylonjs/scene";
  67318. /**
  67319. * Navigation plugin interface to add navigation constrained by a navigation mesh
  67320. */
  67321. export interface INavigationEnginePlugin {
  67322. /**
  67323. * plugin name
  67324. */
  67325. name: string;
  67326. /**
  67327. * Creates a navigation mesh
  67328. * @param meshes array of all the geometry used to compute the navigatio mesh
  67329. * @param parameters bunch of parameters used to filter geometry
  67330. */
  67331. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  67332. /**
  67333. * Create a navigation mesh debug mesh
  67334. * @param scene is where the mesh will be added
  67335. * @returns debug display mesh
  67336. */
  67337. createDebugNavMesh(scene: Scene): Mesh;
  67338. /**
  67339. * Get a navigation mesh constrained position, closest to the parameter position
  67340. * @param position world position
  67341. * @returns the closest point to position constrained by the navigation mesh
  67342. */
  67343. getClosestPoint(position: Vector3): Vector3;
  67344. /**
  67345. * Get a navigation mesh constrained position, closest to the parameter position
  67346. * @param position world position
  67347. * @param result output the closest point to position constrained by the navigation mesh
  67348. */
  67349. getClosestPointToRef(position: Vector3, result: Vector3): void;
  67350. /**
  67351. * Get a navigation mesh constrained position, within a particular radius
  67352. * @param position world position
  67353. * @param maxRadius the maximum distance to the constrained world position
  67354. * @returns the closest point to position constrained by the navigation mesh
  67355. */
  67356. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  67357. /**
  67358. * Get a navigation mesh constrained position, within a particular radius
  67359. * @param position world position
  67360. * @param maxRadius the maximum distance to the constrained world position
  67361. * @param result output the closest point to position constrained by the navigation mesh
  67362. */
  67363. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  67364. /**
  67365. * Compute the final position from a segment made of destination-position
  67366. * @param position world position
  67367. * @param destination world position
  67368. * @returns the resulting point along the navmesh
  67369. */
  67370. moveAlong(position: Vector3, destination: Vector3): Vector3;
  67371. /**
  67372. * Compute the final position from a segment made of destination-position
  67373. * @param position world position
  67374. * @param destination world position
  67375. * @param result output the resulting point along the navmesh
  67376. */
  67377. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  67378. /**
  67379. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  67380. * @param start world position
  67381. * @param end world position
  67382. * @returns array containing world position composing the path
  67383. */
  67384. computePath(start: Vector3, end: Vector3): Vector3[];
  67385. /**
  67386. * If this plugin is supported
  67387. * @returns true if plugin is supported
  67388. */
  67389. isSupported(): boolean;
  67390. /**
  67391. * Create a new Crowd so you can add agents
  67392. * @param maxAgents the maximum agent count in the crowd
  67393. * @param maxAgentRadius the maximum radius an agent can have
  67394. * @param scene to attach the crowd to
  67395. * @returns the crowd you can add agents to
  67396. */
  67397. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  67398. /**
  67399. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  67400. * The queries will try to find a solution within those bounds
  67401. * default is (1,1,1)
  67402. * @param extent x,y,z value that define the extent around the queries point of reference
  67403. */
  67404. setDefaultQueryExtent(extent: Vector3): void;
  67405. /**
  67406. * Get the Bounding box extent specified by setDefaultQueryExtent
  67407. * @returns the box extent values
  67408. */
  67409. getDefaultQueryExtent(): Vector3;
  67410. /**
  67411. * build the navmesh from a previously saved state using getNavmeshData
  67412. * @param data the Uint8Array returned by getNavmeshData
  67413. */
  67414. buildFromNavmeshData(data: Uint8Array): void;
  67415. /**
  67416. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  67417. * @returns data the Uint8Array that can be saved and reused
  67418. */
  67419. getNavmeshData(): Uint8Array;
  67420. /**
  67421. * Get the Bounding box extent result specified by setDefaultQueryExtent
  67422. * @param result output the box extent values
  67423. */
  67424. getDefaultQueryExtentToRef(result: Vector3): void;
  67425. /**
  67426. * Release all resources
  67427. */
  67428. dispose(): void;
  67429. }
  67430. /**
  67431. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  67432. */
  67433. export interface ICrowd {
  67434. /**
  67435. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  67436. * You can attach anything to that node. The node position is updated in the scene update tick.
  67437. * @param pos world position that will be constrained by the navigation mesh
  67438. * @param parameters agent parameters
  67439. * @param transform hooked to the agent that will be update by the scene
  67440. * @returns agent index
  67441. */
  67442. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  67443. /**
  67444. * Returns the agent position in world space
  67445. * @param index agent index returned by addAgent
  67446. * @returns world space position
  67447. */
  67448. getAgentPosition(index: number): Vector3;
  67449. /**
  67450. * Gets the agent position result in world space
  67451. * @param index agent index returned by addAgent
  67452. * @param result output world space position
  67453. */
  67454. getAgentPositionToRef(index: number, result: Vector3): void;
  67455. /**
  67456. * Gets the agent velocity in world space
  67457. * @param index agent index returned by addAgent
  67458. * @returns world space velocity
  67459. */
  67460. getAgentVelocity(index: number): Vector3;
  67461. /**
  67462. * Gets the agent velocity result in world space
  67463. * @param index agent index returned by addAgent
  67464. * @param result output world space velocity
  67465. */
  67466. getAgentVelocityToRef(index: number, result: Vector3): void;
  67467. /**
  67468. * remove a particular agent previously created
  67469. * @param index agent index returned by addAgent
  67470. */
  67471. removeAgent(index: number): void;
  67472. /**
  67473. * get the list of all agents attached to this crowd
  67474. * @returns list of agent indices
  67475. */
  67476. getAgents(): number[];
  67477. /**
  67478. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  67479. * @param deltaTime in seconds
  67480. */
  67481. update(deltaTime: number): void;
  67482. /**
  67483. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  67484. * @param index agent index returned by addAgent
  67485. * @param destination targeted world position
  67486. */
  67487. agentGoto(index: number, destination: Vector3): void;
  67488. /**
  67489. * Teleport the agent to a new position
  67490. * @param index agent index returned by addAgent
  67491. * @param destination targeted world position
  67492. */
  67493. agentTeleport(index: number, destination: Vector3): void;
  67494. /**
  67495. * Update agent parameters
  67496. * @param index agent index returned by addAgent
  67497. * @param parameters agent parameters
  67498. */
  67499. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  67500. /**
  67501. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  67502. * The queries will try to find a solution within those bounds
  67503. * default is (1,1,1)
  67504. * @param extent x,y,z value that define the extent around the queries point of reference
  67505. */
  67506. setDefaultQueryExtent(extent: Vector3): void;
  67507. /**
  67508. * Get the Bounding box extent specified by setDefaultQueryExtent
  67509. * @returns the box extent values
  67510. */
  67511. getDefaultQueryExtent(): Vector3;
  67512. /**
  67513. * Get the Bounding box extent result specified by setDefaultQueryExtent
  67514. * @param result output the box extent values
  67515. */
  67516. getDefaultQueryExtentToRef(result: Vector3): void;
  67517. /**
  67518. * Release all resources
  67519. */
  67520. dispose(): void;
  67521. }
  67522. /**
  67523. * Configures an agent
  67524. */
  67525. export interface IAgentParameters {
  67526. /**
  67527. * Agent radius. [Limit: >= 0]
  67528. */
  67529. radius: number;
  67530. /**
  67531. * Agent height. [Limit: > 0]
  67532. */
  67533. height: number;
  67534. /**
  67535. * Maximum allowed acceleration. [Limit: >= 0]
  67536. */
  67537. maxAcceleration: number;
  67538. /**
  67539. * Maximum allowed speed. [Limit: >= 0]
  67540. */
  67541. maxSpeed: number;
  67542. /**
  67543. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  67544. */
  67545. collisionQueryRange: number;
  67546. /**
  67547. * The path visibility optimization range. [Limit: > 0]
  67548. */
  67549. pathOptimizationRange: number;
  67550. /**
  67551. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  67552. */
  67553. separationWeight: number;
  67554. }
  67555. /**
  67556. * Configures the navigation mesh creation
  67557. */
  67558. export interface INavMeshParameters {
  67559. /**
  67560. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  67561. */
  67562. cs: number;
  67563. /**
  67564. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  67565. */
  67566. ch: number;
  67567. /**
  67568. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  67569. */
  67570. walkableSlopeAngle: number;
  67571. /**
  67572. * Minimum floor to 'ceiling' height that will still allow the floor area to
  67573. * be considered walkable. [Limit: >= 3] [Units: vx]
  67574. */
  67575. walkableHeight: number;
  67576. /**
  67577. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  67578. */
  67579. walkableClimb: number;
  67580. /**
  67581. * The distance to erode/shrink the walkable area of the heightfield away from
  67582. * obstructions. [Limit: >=0] [Units: vx]
  67583. */
  67584. walkableRadius: number;
  67585. /**
  67586. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  67587. */
  67588. maxEdgeLen: number;
  67589. /**
  67590. * The maximum distance a simplfied contour's border edges should deviate
  67591. * the original raw contour. [Limit: >=0] [Units: vx]
  67592. */
  67593. maxSimplificationError: number;
  67594. /**
  67595. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  67596. */
  67597. minRegionArea: number;
  67598. /**
  67599. * Any regions with a span count smaller than this value will, if possible,
  67600. * be merged with larger regions. [Limit: >=0] [Units: vx]
  67601. */
  67602. mergeRegionArea: number;
  67603. /**
  67604. * The maximum number of vertices allowed for polygons generated during the
  67605. * contour to polygon conversion process. [Limit: >= 3]
  67606. */
  67607. maxVertsPerPoly: number;
  67608. /**
  67609. * Sets the sampling distance to use when generating the detail mesh.
  67610. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  67611. */
  67612. detailSampleDist: number;
  67613. /**
  67614. * The maximum distance the detail mesh surface should deviate from heightfield
  67615. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  67616. */
  67617. detailSampleMaxError: number;
  67618. }
  67619. }
  67620. declare module "babylonjs/Navigation/Plugins/recastJSPlugin" {
  67621. import { INavigationEnginePlugin, ICrowd, IAgentParameters, INavMeshParameters } from "babylonjs/Navigation/INavigationEngine";
  67622. import { Mesh } from "babylonjs/Meshes/mesh";
  67623. import { Scene } from "babylonjs/scene";
  67624. import { Vector3 } from "babylonjs/Maths/math";
  67625. import { TransformNode } from "babylonjs/Meshes/transformNode";
  67626. /**
  67627. * RecastJS navigation plugin
  67628. */
  67629. export class RecastJSPlugin implements INavigationEnginePlugin {
  67630. /**
  67631. * Reference to the Recast library
  67632. */
  67633. bjsRECAST: any;
  67634. /**
  67635. * plugin name
  67636. */
  67637. name: string;
  67638. /**
  67639. * the first navmesh created. We might extend this to support multiple navmeshes
  67640. */
  67641. navMesh: any;
  67642. /**
  67643. * Initializes the recastJS plugin
  67644. * @param recastInjection can be used to inject your own recast reference
  67645. */
  67646. constructor(recastInjection?: any);
  67647. /**
  67648. * Creates a navigation mesh
  67649. * @param meshes array of all the geometry used to compute the navigatio mesh
  67650. * @param parameters bunch of parameters used to filter geometry
  67651. */
  67652. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  67653. /**
  67654. * Create a navigation mesh debug mesh
  67655. * @param scene is where the mesh will be added
  67656. * @returns debug display mesh
  67657. */
  67658. createDebugNavMesh(scene: Scene): Mesh;
  67659. /**
  67660. * Get a navigation mesh constrained position, closest to the parameter position
  67661. * @param position world position
  67662. * @returns the closest point to position constrained by the navigation mesh
  67663. */
  67664. getClosestPoint(position: Vector3): Vector3;
  67665. /**
  67666. * Get a navigation mesh constrained position, closest to the parameter position
  67667. * @param position world position
  67668. * @param result output the closest point to position constrained by the navigation mesh
  67669. */
  67670. getClosestPointToRef(position: Vector3, result: Vector3): void;
  67671. /**
  67672. * Get a navigation mesh constrained position, within a particular radius
  67673. * @param position world position
  67674. * @param maxRadius the maximum distance to the constrained world position
  67675. * @returns the closest point to position constrained by the navigation mesh
  67676. */
  67677. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  67678. /**
  67679. * Get a navigation mesh constrained position, within a particular radius
  67680. * @param position world position
  67681. * @param maxRadius the maximum distance to the constrained world position
  67682. * @param result output the closest point to position constrained by the navigation mesh
  67683. */
  67684. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  67685. /**
  67686. * Compute the final position from a segment made of destination-position
  67687. * @param position world position
  67688. * @param destination world position
  67689. * @returns the resulting point along the navmesh
  67690. */
  67691. moveAlong(position: Vector3, destination: Vector3): Vector3;
  67692. /**
  67693. * Compute the final position from a segment made of destination-position
  67694. * @param position world position
  67695. * @param destination world position
  67696. * @param result output the resulting point along the navmesh
  67697. */
  67698. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  67699. /**
  67700. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  67701. * @param start world position
  67702. * @param end world position
  67703. * @returns array containing world position composing the path
  67704. */
  67705. computePath(start: Vector3, end: Vector3): Vector3[];
  67706. /**
  67707. * Create a new Crowd so you can add agents
  67708. * @param maxAgents the maximum agent count in the crowd
  67709. * @param maxAgentRadius the maximum radius an agent can have
  67710. * @param scene to attach the crowd to
  67711. * @returns the crowd you can add agents to
  67712. */
  67713. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  67714. /**
  67715. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  67716. * The queries will try to find a solution within those bounds
  67717. * default is (1,1,1)
  67718. * @param extent x,y,z value that define the extent around the queries point of reference
  67719. */
  67720. setDefaultQueryExtent(extent: Vector3): void;
  67721. /**
  67722. * Get the Bounding box extent specified by setDefaultQueryExtent
  67723. * @returns the box extent values
  67724. */
  67725. getDefaultQueryExtent(): Vector3;
  67726. /**
  67727. * build the navmesh from a previously saved state using getNavmeshData
  67728. * @param data the Uint8Array returned by getNavmeshData
  67729. */
  67730. buildFromNavmeshData(data: Uint8Array): void;
  67731. /**
  67732. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  67733. * @returns data the Uint8Array that can be saved and reused
  67734. */
  67735. getNavmeshData(): Uint8Array;
  67736. /**
  67737. * Get the Bounding box extent result specified by setDefaultQueryExtent
  67738. * @param result output the box extent values
  67739. */
  67740. getDefaultQueryExtentToRef(result: Vector3): void;
  67741. /**
  67742. * Disposes
  67743. */
  67744. dispose(): void;
  67745. /**
  67746. * If this plugin is supported
  67747. * @returns true if plugin is supported
  67748. */
  67749. isSupported(): boolean;
  67750. }
  67751. /**
  67752. * Recast detour crowd implementation
  67753. */
  67754. export class RecastJSCrowd implements ICrowd {
  67755. /**
  67756. * Recast/detour plugin
  67757. */
  67758. bjsRECASTPlugin: RecastJSPlugin;
  67759. /**
  67760. * Link to the detour crowd
  67761. */
  67762. recastCrowd: any;
  67763. /**
  67764. * One transform per agent
  67765. */
  67766. transforms: TransformNode[];
  67767. /**
  67768. * All agents created
  67769. */
  67770. agents: number[];
  67771. /**
  67772. * Link to the scene is kept to unregister the crowd from the scene
  67773. */
  67774. private _scene;
  67775. /**
  67776. * Observer for crowd updates
  67777. */
  67778. private _onBeforeAnimationsObserver;
  67779. /**
  67780. * Constructor
  67781. * @param plugin recastJS plugin
  67782. * @param maxAgents the maximum agent count in the crowd
  67783. * @param maxAgentRadius the maximum radius an agent can have
  67784. * @param scene to attach the crowd to
  67785. * @returns the crowd you can add agents to
  67786. */
  67787. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  67788. /**
  67789. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  67790. * You can attach anything to that node. The node position is updated in the scene update tick.
  67791. * @param pos world position that will be constrained by the navigation mesh
  67792. * @param parameters agent parameters
  67793. * @param transform hooked to the agent that will be update by the scene
  67794. * @returns agent index
  67795. */
  67796. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  67797. /**
  67798. * Returns the agent position in world space
  67799. * @param index agent index returned by addAgent
  67800. * @returns world space position
  67801. */
  67802. getAgentPosition(index: number): Vector3;
  67803. /**
  67804. * Returns the agent position result in world space
  67805. * @param index agent index returned by addAgent
  67806. * @param result output world space position
  67807. */
  67808. getAgentPositionToRef(index: number, result: Vector3): void;
  67809. /**
  67810. * Returns the agent velocity in world space
  67811. * @param index agent index returned by addAgent
  67812. * @returns world space velocity
  67813. */
  67814. getAgentVelocity(index: number): Vector3;
  67815. /**
  67816. * Returns the agent velocity result in world space
  67817. * @param index agent index returned by addAgent
  67818. * @param result output world space velocity
  67819. */
  67820. getAgentVelocityToRef(index: number, result: Vector3): void;
  67821. /**
  67822. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  67823. * @param index agent index returned by addAgent
  67824. * @param destination targeted world position
  67825. */
  67826. agentGoto(index: number, destination: Vector3): void;
  67827. /**
  67828. * Teleport the agent to a new position
  67829. * @param index agent index returned by addAgent
  67830. * @param destination targeted world position
  67831. */
  67832. agentTeleport(index: number, destination: Vector3): void;
  67833. /**
  67834. * Update agent parameters
  67835. * @param index agent index returned by addAgent
  67836. * @param parameters agent parameters
  67837. */
  67838. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  67839. /**
  67840. * remove a particular agent previously created
  67841. * @param index agent index returned by addAgent
  67842. */
  67843. removeAgent(index: number): void;
  67844. /**
  67845. * get the list of all agents attached to this crowd
  67846. * @returns list of agent indices
  67847. */
  67848. getAgents(): number[];
  67849. /**
  67850. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  67851. * @param deltaTime in seconds
  67852. */
  67853. update(deltaTime: number): void;
  67854. /**
  67855. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  67856. * The queries will try to find a solution within those bounds
  67857. * default is (1,1,1)
  67858. * @param extent x,y,z value that define the extent around the queries point of reference
  67859. */
  67860. setDefaultQueryExtent(extent: Vector3): void;
  67861. /**
  67862. * Get the Bounding box extent specified by setDefaultQueryExtent
  67863. * @returns the box extent values
  67864. */
  67865. getDefaultQueryExtent(): Vector3;
  67866. /**
  67867. * Get the Bounding box extent result specified by setDefaultQueryExtent
  67868. * @param result output the box extent values
  67869. */
  67870. getDefaultQueryExtentToRef(result: Vector3): void;
  67871. /**
  67872. * Release all resources
  67873. */
  67874. dispose(): void;
  67875. }
  67876. }
  67877. declare module "babylonjs/Navigation/Plugins/index" {
  67878. export * from "babylonjs/Navigation/Plugins/recastJSPlugin";
  67879. }
  67880. declare module "babylonjs/Navigation/index" {
  67881. export * from "babylonjs/Navigation/INavigationEngine";
  67882. export * from "babylonjs/Navigation/Plugins/index";
  67883. }
  67884. declare module "babylonjs/Offline/database" {
  67885. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  67886. /**
  67887. * Class used to enable access to IndexedDB
  67888. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  67889. */
  67890. export class Database implements IOfflineProvider {
  67891. private _callbackManifestChecked;
  67892. private _currentSceneUrl;
  67893. private _db;
  67894. private _enableSceneOffline;
  67895. private _enableTexturesOffline;
  67896. private _manifestVersionFound;
  67897. private _mustUpdateRessources;
  67898. private _hasReachedQuota;
  67899. private _isSupported;
  67900. private _idbFactory;
  67901. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  67902. private static IsUASupportingBlobStorage;
  67903. /**
  67904. * Gets a boolean indicating if Database storate is enabled (off by default)
  67905. */
  67906. static IDBStorageEnabled: boolean;
  67907. /**
  67908. * Gets a boolean indicating if scene must be saved in the database
  67909. */
  67910. get enableSceneOffline(): boolean;
  67911. /**
  67912. * Gets a boolean indicating if textures must be saved in the database
  67913. */
  67914. get enableTexturesOffline(): boolean;
  67915. /**
  67916. * Creates a new Database
  67917. * @param urlToScene defines the url to load the scene
  67918. * @param callbackManifestChecked defines the callback to use when manifest is checked
  67919. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  67920. */
  67921. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  67922. private static _ParseURL;
  67923. private static _ReturnFullUrlLocation;
  67924. private _checkManifestFile;
  67925. /**
  67926. * Open the database and make it available
  67927. * @param successCallback defines the callback to call on success
  67928. * @param errorCallback defines the callback to call on error
  67929. */
  67930. open(successCallback: () => void, errorCallback: () => void): void;
  67931. /**
  67932. * Loads an image from the database
  67933. * @param url defines the url to load from
  67934. * @param image defines the target DOM image
  67935. */
  67936. loadImage(url: string, image: HTMLImageElement): void;
  67937. private _loadImageFromDBAsync;
  67938. private _saveImageIntoDBAsync;
  67939. private _checkVersionFromDB;
  67940. private _loadVersionFromDBAsync;
  67941. private _saveVersionIntoDBAsync;
  67942. /**
  67943. * Loads a file from database
  67944. * @param url defines the URL to load from
  67945. * @param sceneLoaded defines a callback to call on success
  67946. * @param progressCallBack defines a callback to call when progress changed
  67947. * @param errorCallback defines a callback to call on error
  67948. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  67949. */
  67950. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  67951. private _loadFileAsync;
  67952. private _saveFileAsync;
  67953. /**
  67954. * Validates if xhr data is correct
  67955. * @param xhr defines the request to validate
  67956. * @param dataType defines the expected data type
  67957. * @returns true if data is correct
  67958. */
  67959. private static _ValidateXHRData;
  67960. }
  67961. }
  67962. declare module "babylonjs/Offline/index" {
  67963. export * from "babylonjs/Offline/database";
  67964. export * from "babylonjs/Offline/IOfflineProvider";
  67965. }
  67966. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  67967. /** @hidden */
  67968. export var gpuUpdateParticlesPixelShader: {
  67969. name: string;
  67970. shader: string;
  67971. };
  67972. }
  67973. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  67974. /** @hidden */
  67975. export var gpuUpdateParticlesVertexShader: {
  67976. name: string;
  67977. shader: string;
  67978. };
  67979. }
  67980. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  67981. /** @hidden */
  67982. export var clipPlaneFragmentDeclaration2: {
  67983. name: string;
  67984. shader: string;
  67985. };
  67986. }
  67987. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  67988. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  67989. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  67990. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  67991. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  67992. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  67993. /** @hidden */
  67994. export var gpuRenderParticlesPixelShader: {
  67995. name: string;
  67996. shader: string;
  67997. };
  67998. }
  67999. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  68000. /** @hidden */
  68001. export var clipPlaneVertexDeclaration2: {
  68002. name: string;
  68003. shader: string;
  68004. };
  68005. }
  68006. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  68007. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  68008. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  68009. /** @hidden */
  68010. export var gpuRenderParticlesVertexShader: {
  68011. name: string;
  68012. shader: string;
  68013. };
  68014. }
  68015. declare module "babylonjs/Particles/gpuParticleSystem" {
  68016. import { Nullable } from "babylonjs/types";
  68017. import { Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  68018. import { Observable } from "babylonjs/Misc/observable";
  68019. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  68020. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  68021. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  68022. import { Scene, IDisposable } from "babylonjs/scene";
  68023. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  68024. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  68025. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  68026. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  68027. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  68028. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  68029. /**
  68030. * This represents a GPU particle system in Babylon
  68031. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  68032. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  68033. */
  68034. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  68035. /**
  68036. * The layer mask we are rendering the particles through.
  68037. */
  68038. layerMask: number;
  68039. private _capacity;
  68040. private _activeCount;
  68041. private _currentActiveCount;
  68042. private _accumulatedCount;
  68043. private _renderEffect;
  68044. private _updateEffect;
  68045. private _buffer0;
  68046. private _buffer1;
  68047. private _spriteBuffer;
  68048. private _updateVAO;
  68049. private _renderVAO;
  68050. private _targetIndex;
  68051. private _sourceBuffer;
  68052. private _targetBuffer;
  68053. private _engine;
  68054. private _currentRenderId;
  68055. private _started;
  68056. private _stopped;
  68057. private _timeDelta;
  68058. private _randomTexture;
  68059. private _randomTexture2;
  68060. private _attributesStrideSize;
  68061. private _updateEffectOptions;
  68062. private _randomTextureSize;
  68063. private _actualFrame;
  68064. private readonly _rawTextureWidth;
  68065. /**
  68066. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  68067. */
  68068. static get IsSupported(): boolean;
  68069. /**
  68070. * An event triggered when the system is disposed.
  68071. */
  68072. onDisposeObservable: Observable<GPUParticleSystem>;
  68073. /**
  68074. * Gets the maximum number of particles active at the same time.
  68075. * @returns The max number of active particles.
  68076. */
  68077. getCapacity(): number;
  68078. /**
  68079. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  68080. * to override the particles.
  68081. */
  68082. forceDepthWrite: boolean;
  68083. /**
  68084. * Gets or set the number of active particles
  68085. */
  68086. get activeParticleCount(): number;
  68087. set activeParticleCount(value: number);
  68088. private _preWarmDone;
  68089. /**
  68090. * Specifies if the particles are updated in emitter local space or world space.
  68091. */
  68092. isLocal: boolean;
  68093. /**
  68094. * Is this system ready to be used/rendered
  68095. * @return true if the system is ready
  68096. */
  68097. isReady(): boolean;
  68098. /**
  68099. * Gets if the system has been started. (Note: this will still be true after stop is called)
  68100. * @returns True if it has been started, otherwise false.
  68101. */
  68102. isStarted(): boolean;
  68103. /**
  68104. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  68105. * @returns True if it has been stopped, otherwise false.
  68106. */
  68107. isStopped(): boolean;
  68108. /**
  68109. * Gets a boolean indicating that the system is stopping
  68110. * @returns true if the system is currently stopping
  68111. */
  68112. isStopping(): boolean;
  68113. /**
  68114. * Gets the number of particles active at the same time.
  68115. * @returns The number of active particles.
  68116. */
  68117. getActiveCount(): number;
  68118. /**
  68119. * Starts the particle system and begins to emit
  68120. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  68121. */
  68122. start(delay?: number): void;
  68123. /**
  68124. * Stops the particle system.
  68125. */
  68126. stop(): void;
  68127. /**
  68128. * Remove all active particles
  68129. */
  68130. reset(): void;
  68131. /**
  68132. * Returns the string "GPUParticleSystem"
  68133. * @returns a string containing the class name
  68134. */
  68135. getClassName(): string;
  68136. private _colorGradientsTexture;
  68137. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  68138. /**
  68139. * Adds a new color gradient
  68140. * @param gradient defines the gradient to use (between 0 and 1)
  68141. * @param color1 defines the color to affect to the specified gradient
  68142. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  68143. * @returns the current particle system
  68144. */
  68145. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  68146. private _refreshColorGradient;
  68147. /** Force the system to rebuild all gradients that need to be resync */
  68148. forceRefreshGradients(): void;
  68149. /**
  68150. * Remove a specific color gradient
  68151. * @param gradient defines the gradient to remove
  68152. * @returns the current particle system
  68153. */
  68154. removeColorGradient(gradient: number): GPUParticleSystem;
  68155. private _angularSpeedGradientsTexture;
  68156. private _sizeGradientsTexture;
  68157. private _velocityGradientsTexture;
  68158. private _limitVelocityGradientsTexture;
  68159. private _dragGradientsTexture;
  68160. private _addFactorGradient;
  68161. /**
  68162. * Adds a new size gradient
  68163. * @param gradient defines the gradient to use (between 0 and 1)
  68164. * @param factor defines the size factor to affect to the specified gradient
  68165. * @returns the current particle system
  68166. */
  68167. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  68168. /**
  68169. * Remove a specific size gradient
  68170. * @param gradient defines the gradient to remove
  68171. * @returns the current particle system
  68172. */
  68173. removeSizeGradient(gradient: number): GPUParticleSystem;
  68174. private _refreshFactorGradient;
  68175. /**
  68176. * Adds a new angular speed gradient
  68177. * @param gradient defines the gradient to use (between 0 and 1)
  68178. * @param factor defines the angular speed to affect to the specified gradient
  68179. * @returns the current particle system
  68180. */
  68181. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  68182. /**
  68183. * Remove a specific angular speed gradient
  68184. * @param gradient defines the gradient to remove
  68185. * @returns the current particle system
  68186. */
  68187. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  68188. /**
  68189. * Adds a new velocity gradient
  68190. * @param gradient defines the gradient to use (between 0 and 1)
  68191. * @param factor defines the velocity to affect to the specified gradient
  68192. * @returns the current particle system
  68193. */
  68194. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  68195. /**
  68196. * Remove a specific velocity gradient
  68197. * @param gradient defines the gradient to remove
  68198. * @returns the current particle system
  68199. */
  68200. removeVelocityGradient(gradient: number): GPUParticleSystem;
  68201. /**
  68202. * Adds a new limit velocity gradient
  68203. * @param gradient defines the gradient to use (between 0 and 1)
  68204. * @param factor defines the limit velocity value to affect to the specified gradient
  68205. * @returns the current particle system
  68206. */
  68207. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  68208. /**
  68209. * Remove a specific limit velocity gradient
  68210. * @param gradient defines the gradient to remove
  68211. * @returns the current particle system
  68212. */
  68213. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  68214. /**
  68215. * Adds a new drag gradient
  68216. * @param gradient defines the gradient to use (between 0 and 1)
  68217. * @param factor defines the drag value to affect to the specified gradient
  68218. * @returns the current particle system
  68219. */
  68220. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  68221. /**
  68222. * Remove a specific drag gradient
  68223. * @param gradient defines the gradient to remove
  68224. * @returns the current particle system
  68225. */
  68226. removeDragGradient(gradient: number): GPUParticleSystem;
  68227. /**
  68228. * Not supported by GPUParticleSystem
  68229. * @param gradient defines the gradient to use (between 0 and 1)
  68230. * @param factor defines the emit rate value to affect to the specified gradient
  68231. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  68232. * @returns the current particle system
  68233. */
  68234. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  68235. /**
  68236. * Not supported by GPUParticleSystem
  68237. * @param gradient defines the gradient to remove
  68238. * @returns the current particle system
  68239. */
  68240. removeEmitRateGradient(gradient: number): IParticleSystem;
  68241. /**
  68242. * Not supported by GPUParticleSystem
  68243. * @param gradient defines the gradient to use (between 0 and 1)
  68244. * @param factor defines the start size value to affect to the specified gradient
  68245. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  68246. * @returns the current particle system
  68247. */
  68248. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  68249. /**
  68250. * Not supported by GPUParticleSystem
  68251. * @param gradient defines the gradient to remove
  68252. * @returns the current particle system
  68253. */
  68254. removeStartSizeGradient(gradient: number): IParticleSystem;
  68255. /**
  68256. * Not supported by GPUParticleSystem
  68257. * @param gradient defines the gradient to use (between 0 and 1)
  68258. * @param min defines the color remap minimal range
  68259. * @param max defines the color remap maximal range
  68260. * @returns the current particle system
  68261. */
  68262. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  68263. /**
  68264. * Not supported by GPUParticleSystem
  68265. * @param gradient defines the gradient to remove
  68266. * @returns the current particle system
  68267. */
  68268. removeColorRemapGradient(): IParticleSystem;
  68269. /**
  68270. * Not supported by GPUParticleSystem
  68271. * @param gradient defines the gradient to use (between 0 and 1)
  68272. * @param min defines the alpha remap minimal range
  68273. * @param max defines the alpha remap maximal range
  68274. * @returns the current particle system
  68275. */
  68276. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  68277. /**
  68278. * Not supported by GPUParticleSystem
  68279. * @param gradient defines the gradient to remove
  68280. * @returns the current particle system
  68281. */
  68282. removeAlphaRemapGradient(): IParticleSystem;
  68283. /**
  68284. * Not supported by GPUParticleSystem
  68285. * @param gradient defines the gradient to use (between 0 and 1)
  68286. * @param color defines the color to affect to the specified gradient
  68287. * @returns the current particle system
  68288. */
  68289. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  68290. /**
  68291. * Not supported by GPUParticleSystem
  68292. * @param gradient defines the gradient to remove
  68293. * @returns the current particle system
  68294. */
  68295. removeRampGradient(): IParticleSystem;
  68296. /**
  68297. * Not supported by GPUParticleSystem
  68298. * @returns the list of ramp gradients
  68299. */
  68300. getRampGradients(): Nullable<Array<Color3Gradient>>;
  68301. /**
  68302. * Not supported by GPUParticleSystem
  68303. * Gets or sets a boolean indicating that ramp gradients must be used
  68304. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  68305. */
  68306. get useRampGradients(): boolean;
  68307. set useRampGradients(value: boolean);
  68308. /**
  68309. * Not supported by GPUParticleSystem
  68310. * @param gradient defines the gradient to use (between 0 and 1)
  68311. * @param factor defines the life time factor to affect to the specified gradient
  68312. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  68313. * @returns the current particle system
  68314. */
  68315. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  68316. /**
  68317. * Not supported by GPUParticleSystem
  68318. * @param gradient defines the gradient to remove
  68319. * @returns the current particle system
  68320. */
  68321. removeLifeTimeGradient(gradient: number): IParticleSystem;
  68322. /**
  68323. * Instantiates a GPU particle system.
  68324. * 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.
  68325. * @param name The name of the particle system
  68326. * @param options The options used to create the system
  68327. * @param scene The scene the particle system belongs to
  68328. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  68329. */
  68330. constructor(name: string, options: Partial<{
  68331. capacity: number;
  68332. randomTextureSize: number;
  68333. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  68334. protected _reset(): void;
  68335. private _createUpdateVAO;
  68336. private _createRenderVAO;
  68337. private _initialize;
  68338. /** @hidden */
  68339. _recreateUpdateEffect(): void;
  68340. /** @hidden */
  68341. _recreateRenderEffect(): void;
  68342. /**
  68343. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  68344. * @param preWarm defines if we are in the pre-warmimg phase
  68345. */
  68346. animate(preWarm?: boolean): void;
  68347. private _createFactorGradientTexture;
  68348. private _createSizeGradientTexture;
  68349. private _createAngularSpeedGradientTexture;
  68350. private _createVelocityGradientTexture;
  68351. private _createLimitVelocityGradientTexture;
  68352. private _createDragGradientTexture;
  68353. private _createColorGradientTexture;
  68354. /**
  68355. * Renders the particle system in its current state
  68356. * @param preWarm defines if the system should only update the particles but not render them
  68357. * @returns the current number of particles
  68358. */
  68359. render(preWarm?: boolean): number;
  68360. /**
  68361. * Rebuilds the particle system
  68362. */
  68363. rebuild(): void;
  68364. private _releaseBuffers;
  68365. private _releaseVAOs;
  68366. /**
  68367. * Disposes the particle system and free the associated resources
  68368. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  68369. */
  68370. dispose(disposeTexture?: boolean): void;
  68371. /**
  68372. * Clones the particle system.
  68373. * @param name The name of the cloned object
  68374. * @param newEmitter The new emitter to use
  68375. * @returns the cloned particle system
  68376. */
  68377. clone(name: string, newEmitter: any): GPUParticleSystem;
  68378. /**
  68379. * Serializes the particle system to a JSON object
  68380. * @param serializeTexture defines if the texture must be serialized as well
  68381. * @returns the JSON object
  68382. */
  68383. serialize(serializeTexture?: boolean): any;
  68384. /**
  68385. * Parses a JSON object to create a GPU particle system.
  68386. * @param parsedParticleSystem The JSON object to parse
  68387. * @param scene The scene to create the particle system in
  68388. * @param rootUrl The root url to use to load external dependencies like texture
  68389. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  68390. * @returns the parsed GPU particle system
  68391. */
  68392. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  68393. }
  68394. }
  68395. declare module "babylonjs/Particles/particleSystemSet" {
  68396. import { Nullable } from "babylonjs/types";
  68397. import { Color3 } from "babylonjs/Maths/math.color";
  68398. import { TransformNode } from "babylonjs/Meshes/transformNode";
  68399. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68400. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  68401. import { Scene, IDisposable } from "babylonjs/scene";
  68402. /**
  68403. * Represents a set of particle systems working together to create a specific effect
  68404. */
  68405. export class ParticleSystemSet implements IDisposable {
  68406. /**
  68407. * Gets or sets base Assets URL
  68408. */
  68409. static BaseAssetsUrl: string;
  68410. private _emitterCreationOptions;
  68411. private _emitterNode;
  68412. /**
  68413. * Gets the particle system list
  68414. */
  68415. systems: IParticleSystem[];
  68416. /**
  68417. * Gets the emitter node used with this set
  68418. */
  68419. get emitterNode(): Nullable<TransformNode>;
  68420. /**
  68421. * Creates a new emitter mesh as a sphere
  68422. * @param options defines the options used to create the sphere
  68423. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  68424. * @param scene defines the hosting scene
  68425. */
  68426. setEmitterAsSphere(options: {
  68427. diameter: number;
  68428. segments: number;
  68429. color: Color3;
  68430. }, renderingGroupId: number, scene: Scene): void;
  68431. /**
  68432. * Starts all particle systems of the set
  68433. * @param emitter defines an optional mesh to use as emitter for the particle systems
  68434. */
  68435. start(emitter?: AbstractMesh): void;
  68436. /**
  68437. * Release all associated resources
  68438. */
  68439. dispose(): void;
  68440. /**
  68441. * Serialize the set into a JSON compatible object
  68442. * @param serializeTexture defines if the texture must be serialized as well
  68443. * @returns a JSON compatible representation of the set
  68444. */
  68445. serialize(serializeTexture?: boolean): any;
  68446. /**
  68447. * Parse a new ParticleSystemSet from a serialized source
  68448. * @param data defines a JSON compatible representation of the set
  68449. * @param scene defines the hosting scene
  68450. * @param gpu defines if we want GPU particles or CPU particles
  68451. * @returns a new ParticleSystemSet
  68452. */
  68453. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  68454. }
  68455. }
  68456. declare module "babylonjs/Particles/particleHelper" {
  68457. import { Nullable } from "babylonjs/types";
  68458. import { Scene } from "babylonjs/scene";
  68459. import { Vector3 } from "babylonjs/Maths/math.vector";
  68460. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68461. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  68462. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  68463. /**
  68464. * This class is made for on one-liner static method to help creating particle system set.
  68465. */
  68466. export class ParticleHelper {
  68467. /**
  68468. * Gets or sets base Assets URL
  68469. */
  68470. static BaseAssetsUrl: string;
  68471. /** Define the Url to load snippets */
  68472. static SnippetUrl: string;
  68473. /**
  68474. * Create a default particle system that you can tweak
  68475. * @param emitter defines the emitter to use
  68476. * @param capacity defines the system capacity (default is 500 particles)
  68477. * @param scene defines the hosting scene
  68478. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  68479. * @returns the new Particle system
  68480. */
  68481. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  68482. /**
  68483. * This is the main static method (one-liner) of this helper to create different particle systems
  68484. * @param type This string represents the type to the particle system to create
  68485. * @param scene The scene where the particle system should live
  68486. * @param gpu If the system will use gpu
  68487. * @returns the ParticleSystemSet created
  68488. */
  68489. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  68490. /**
  68491. * Static function used to export a particle system to a ParticleSystemSet variable.
  68492. * Please note that the emitter shape is not exported
  68493. * @param systems defines the particle systems to export
  68494. * @returns the created particle system set
  68495. */
  68496. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  68497. /**
  68498. * Creates a particle system from a snippet saved in a remote file
  68499. * @param name defines the name of the particle system to create
  68500. * @param url defines the url to load from
  68501. * @param scene defines the hosting scene
  68502. * @param gpu If the system will use gpu
  68503. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  68504. * @returns a promise that will resolve to the new particle system
  68505. */
  68506. static ParseFromFileAsync(name: string, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  68507. /**
  68508. * Creates a particle system from a snippet saved by the particle system editor
  68509. * @param snippetId defines the snippet to load
  68510. * @param scene defines the hosting scene
  68511. * @param gpu If the system will use gpu
  68512. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  68513. * @returns a promise that will resolve to the new particle system
  68514. */
  68515. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  68516. }
  68517. }
  68518. declare module "babylonjs/Particles/particleSystemComponent" {
  68519. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  68520. import { Effect } from "babylonjs/Materials/effect";
  68521. import "babylonjs/Shaders/particles.vertex";
  68522. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  68523. module "babylonjs/Engines/engine" {
  68524. interface Engine {
  68525. /**
  68526. * Create an effect to use with particle systems.
  68527. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  68528. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  68529. * @param uniformsNames defines a list of attribute names
  68530. * @param samplers defines an array of string used to represent textures
  68531. * @param defines defines the string containing the defines to use to compile the shaders
  68532. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  68533. * @param onCompiled defines a function to call when the effect creation is successful
  68534. * @param onError defines a function to call when the effect creation has failed
  68535. * @returns the new Effect
  68536. */
  68537. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  68538. }
  68539. }
  68540. module "babylonjs/Meshes/mesh" {
  68541. interface Mesh {
  68542. /**
  68543. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  68544. * @returns an array of IParticleSystem
  68545. */
  68546. getEmittedParticleSystems(): IParticleSystem[];
  68547. /**
  68548. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  68549. * @returns an array of IParticleSystem
  68550. */
  68551. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  68552. }
  68553. }
  68554. /**
  68555. * @hidden
  68556. */
  68557. export var _IDoNeedToBeInTheBuild: number;
  68558. }
  68559. declare module "babylonjs/Particles/pointsCloudSystem" {
  68560. import { Color4 } from "babylonjs/Maths/math";
  68561. import { Mesh } from "babylonjs/Meshes/mesh";
  68562. import { Scene, IDisposable } from "babylonjs/scene";
  68563. import { CloudPoint } from "babylonjs/Particles/cloudPoint";
  68564. /** Defines the 4 color options */
  68565. export enum PointColor {
  68566. /** color value */
  68567. Color = 2,
  68568. /** uv value */
  68569. UV = 1,
  68570. /** random value */
  68571. Random = 0,
  68572. /** stated value */
  68573. Stated = 3
  68574. }
  68575. /**
  68576. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  68577. * 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.
  68578. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  68579. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  68580. *
  68581. * Full documentation here : TO BE ENTERED
  68582. */
  68583. export class PointsCloudSystem implements IDisposable {
  68584. /**
  68585. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  68586. * Example : var p = SPS.particles[i];
  68587. */
  68588. particles: CloudPoint[];
  68589. /**
  68590. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  68591. */
  68592. nbParticles: number;
  68593. /**
  68594. * This a counter for your own usage. It's not set by any SPS functions.
  68595. */
  68596. counter: number;
  68597. /**
  68598. * The PCS name. This name is also given to the underlying mesh.
  68599. */
  68600. name: string;
  68601. /**
  68602. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  68603. */
  68604. mesh: Mesh;
  68605. /**
  68606. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  68607. * Please read :
  68608. */
  68609. vars: any;
  68610. /**
  68611. * @hidden
  68612. */
  68613. _size: number;
  68614. private _scene;
  68615. private _promises;
  68616. private _positions;
  68617. private _indices;
  68618. private _normals;
  68619. private _colors;
  68620. private _uvs;
  68621. private _indices32;
  68622. private _positions32;
  68623. private _colors32;
  68624. private _uvs32;
  68625. private _updatable;
  68626. private _isVisibilityBoxLocked;
  68627. private _alwaysVisible;
  68628. private _groups;
  68629. private _groupCounter;
  68630. private _computeParticleColor;
  68631. private _computeParticleTexture;
  68632. private _computeParticleRotation;
  68633. private _computeBoundingBox;
  68634. private _isReady;
  68635. /**
  68636. * Creates a PCS (Points Cloud System) object
  68637. * @param name (String) is the PCS name, this will be the underlying mesh name
  68638. * @param pointSize (number) is the size for each point
  68639. * @param scene (Scene) is the scene in which the PCS is added
  68640. * @param options defines the options of the PCS e.g.
  68641. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  68642. */
  68643. constructor(name: string, pointSize: number, scene: Scene, options?: {
  68644. updatable?: boolean;
  68645. });
  68646. /**
  68647. * Builds the PCS underlying mesh. Returns a standard Mesh.
  68648. * If no points were added to the PCS, the returned mesh is just a single point.
  68649. * @returns a promise for the created mesh
  68650. */
  68651. buildMeshAsync(): Promise<Mesh>;
  68652. /**
  68653. * @hidden
  68654. */
  68655. private _buildMesh;
  68656. private _addParticle;
  68657. private _randomUnitVector;
  68658. private _getColorIndicesForCoord;
  68659. private _setPointsColorOrUV;
  68660. private _colorFromTexture;
  68661. private _calculateDensity;
  68662. /**
  68663. * Adds points to the PCS in random positions within a unit sphere
  68664. * @param nb (positive integer) the number of particles to be created from this model
  68665. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  68666. * @returns the number of groups in the system
  68667. */
  68668. addPoints(nb: number, pointFunction?: any): number;
  68669. /**
  68670. * Adds points to the PCS from the surface of the model shape
  68671. * @param mesh is any Mesh object that will be used as a surface model for the points
  68672. * @param nb (positive integer) the number of particles to be created from this model
  68673. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  68674. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  68675. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  68676. * @returns the number of groups in the system
  68677. */
  68678. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  68679. /**
  68680. * Adds points to the PCS inside the model shape
  68681. * @param mesh is any Mesh object that will be used as a surface model for the points
  68682. * @param nb (positive integer) the number of particles to be created from this model
  68683. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  68684. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  68685. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  68686. * @returns the number of groups in the system
  68687. */
  68688. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  68689. /**
  68690. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  68691. * This method calls `updateParticle()` for each particle of the SPS.
  68692. * For an animated SPS, it is usually called within the render loop.
  68693. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  68694. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  68695. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  68696. * @returns the PCS.
  68697. */
  68698. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  68699. /**
  68700. * Disposes the PCS.
  68701. */
  68702. dispose(): void;
  68703. /**
  68704. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  68705. * doc :
  68706. * @returns the PCS.
  68707. */
  68708. refreshVisibleSize(): PointsCloudSystem;
  68709. /**
  68710. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  68711. * @param size the size (float) of the visibility box
  68712. * note : this doesn't lock the PCS mesh bounding box.
  68713. * doc :
  68714. */
  68715. setVisibilityBox(size: number): void;
  68716. /**
  68717. * Gets whether the PCS is always visible or not
  68718. * doc :
  68719. */
  68720. get isAlwaysVisible(): boolean;
  68721. /**
  68722. * Sets the PCS as always visible or not
  68723. * doc :
  68724. */
  68725. set isAlwaysVisible(val: boolean);
  68726. /**
  68727. * Tells to `setParticles()` to compute the particle rotations or not
  68728. * Default value : false. The PCS is faster when it's set to false
  68729. * Note : particle rotations are only applied to parent particles
  68730. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  68731. */
  68732. set computeParticleRotation(val: boolean);
  68733. /**
  68734. * Tells to `setParticles()` to compute the particle colors or not.
  68735. * Default value : true. The PCS is faster when it's set to false.
  68736. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  68737. */
  68738. set computeParticleColor(val: boolean);
  68739. set computeParticleTexture(val: boolean);
  68740. /**
  68741. * Gets if `setParticles()` computes the particle colors or not.
  68742. * Default value : false. The PCS is faster when it's set to false.
  68743. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  68744. */
  68745. get computeParticleColor(): boolean;
  68746. /**
  68747. * Gets if `setParticles()` computes the particle textures or not.
  68748. * Default value : false. The PCS is faster when it's set to false.
  68749. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  68750. */
  68751. get computeParticleTexture(): boolean;
  68752. /**
  68753. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  68754. */
  68755. set computeBoundingBox(val: boolean);
  68756. /**
  68757. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  68758. */
  68759. get computeBoundingBox(): boolean;
  68760. /**
  68761. * This function does nothing. It may be overwritten to set all the particle first values.
  68762. * The PCS doesn't call this function, you may have to call it by your own.
  68763. * doc :
  68764. */
  68765. initParticles(): void;
  68766. /**
  68767. * This function does nothing. It may be overwritten to recycle a particle
  68768. * The PCS doesn't call this function, you can to call it
  68769. * doc :
  68770. * @param particle The particle to recycle
  68771. * @returns the recycled particle
  68772. */
  68773. recycleParticle(particle: CloudPoint): CloudPoint;
  68774. /**
  68775. * Updates a particle : this function should be overwritten by the user.
  68776. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  68777. * doc :
  68778. * @example : just set a particle position or velocity and recycle conditions
  68779. * @param particle The particle to update
  68780. * @returns the updated particle
  68781. */
  68782. updateParticle(particle: CloudPoint): CloudPoint;
  68783. /**
  68784. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  68785. * This does nothing and may be overwritten by the user.
  68786. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  68787. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  68788. * @param update the boolean update value actually passed to setParticles()
  68789. */
  68790. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  68791. /**
  68792. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  68793. * This will be passed three parameters.
  68794. * This does nothing and may be overwritten by the user.
  68795. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  68796. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  68797. * @param update the boolean update value actually passed to setParticles()
  68798. */
  68799. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  68800. }
  68801. }
  68802. declare module "babylonjs/Particles/cloudPoint" {
  68803. import { Nullable } from "babylonjs/types";
  68804. import { Color4, Vector2, Vector3, Matrix, Quaternion } from "babylonjs/Maths/math";
  68805. import { Mesh } from "babylonjs/Meshes/mesh";
  68806. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  68807. import { PointsCloudSystem } from "babylonjs/Particles/pointsCloudSystem";
  68808. /**
  68809. * Represents one particle of a points cloud system.
  68810. */
  68811. export class CloudPoint {
  68812. /**
  68813. * particle global index
  68814. */
  68815. idx: number;
  68816. /**
  68817. * The color of the particle
  68818. */
  68819. color: Nullable<Color4>;
  68820. /**
  68821. * The world space position of the particle.
  68822. */
  68823. position: Vector3;
  68824. /**
  68825. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  68826. */
  68827. rotation: Vector3;
  68828. /**
  68829. * The world space rotation quaternion of the particle.
  68830. */
  68831. rotationQuaternion: Nullable<Quaternion>;
  68832. /**
  68833. * The uv of the particle.
  68834. */
  68835. uv: Nullable<Vector2>;
  68836. /**
  68837. * The current speed of the particle.
  68838. */
  68839. velocity: Vector3;
  68840. /**
  68841. * The pivot point in the particle local space.
  68842. */
  68843. pivot: Vector3;
  68844. /**
  68845. * Must the particle be translated from its pivot point in its local space ?
  68846. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  68847. * Default : false
  68848. */
  68849. translateFromPivot: boolean;
  68850. /**
  68851. * Index of this particle in the global "positions" array (Internal use)
  68852. * @hidden
  68853. */
  68854. _pos: number;
  68855. /**
  68856. * @hidden Index of this particle in the global "indices" array (Internal use)
  68857. */
  68858. _ind: number;
  68859. /**
  68860. * Group this particle belongs to
  68861. */
  68862. _group: PointsGroup;
  68863. /**
  68864. * Group id of this particle
  68865. */
  68866. groupId: number;
  68867. /**
  68868. * Index of the particle in its group id (Internal use)
  68869. */
  68870. idxInGroup: number;
  68871. /**
  68872. * @hidden Particle BoundingInfo object (Internal use)
  68873. */
  68874. _boundingInfo: BoundingInfo;
  68875. /**
  68876. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  68877. */
  68878. _pcs: PointsCloudSystem;
  68879. /**
  68880. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  68881. */
  68882. _stillInvisible: boolean;
  68883. /**
  68884. * @hidden Last computed particle rotation matrix
  68885. */
  68886. _rotationMatrix: number[];
  68887. /**
  68888. * Parent particle Id, if any.
  68889. * Default null.
  68890. */
  68891. parentId: Nullable<number>;
  68892. /**
  68893. * @hidden Internal global position in the PCS.
  68894. */
  68895. _globalPosition: Vector3;
  68896. /**
  68897. * Creates a Point Cloud object.
  68898. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  68899. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  68900. * @param group (PointsGroup) is the group the particle belongs to
  68901. * @param groupId (integer) is the group identifier in the PCS.
  68902. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  68903. * @param pcs defines the PCS it is associated to
  68904. */
  68905. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  68906. /**
  68907. * get point size
  68908. */
  68909. get size(): Vector3;
  68910. /**
  68911. * Set point size
  68912. */
  68913. set size(scale: Vector3);
  68914. /**
  68915. * Legacy support, changed quaternion to rotationQuaternion
  68916. */
  68917. get quaternion(): Nullable<Quaternion>;
  68918. /**
  68919. * Legacy support, changed quaternion to rotationQuaternion
  68920. */
  68921. set quaternion(q: Nullable<Quaternion>);
  68922. /**
  68923. * Returns a boolean. True if the particle intersects a mesh, else false
  68924. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  68925. * @param target is the object (point or mesh) what the intersection is computed against
  68926. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  68927. * @returns true if it intersects
  68928. */
  68929. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  68930. /**
  68931. * get the rotation matrix of the particle
  68932. * @hidden
  68933. */
  68934. getRotationMatrix(m: Matrix): void;
  68935. }
  68936. /**
  68937. * Represents a group of points in a points cloud system
  68938. * * PCS internal tool, don't use it manually.
  68939. */
  68940. export class PointsGroup {
  68941. /**
  68942. * The group id
  68943. * @hidden
  68944. */
  68945. groupID: number;
  68946. /**
  68947. * image data for group (internal use)
  68948. * @hidden
  68949. */
  68950. _groupImageData: Nullable<ArrayBufferView>;
  68951. /**
  68952. * Image Width (internal use)
  68953. * @hidden
  68954. */
  68955. _groupImgWidth: number;
  68956. /**
  68957. * Image Height (internal use)
  68958. * @hidden
  68959. */
  68960. _groupImgHeight: number;
  68961. /**
  68962. * Custom position function (internal use)
  68963. * @hidden
  68964. */
  68965. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  68966. /**
  68967. * density per facet for surface points
  68968. * @hidden
  68969. */
  68970. _groupDensity: number[];
  68971. /**
  68972. * Only when points are colored by texture carries pointer to texture list array
  68973. * @hidden
  68974. */
  68975. _textureNb: number;
  68976. /**
  68977. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  68978. * PCS internal tool, don't use it manually.
  68979. * @hidden
  68980. */
  68981. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  68982. }
  68983. }
  68984. declare module "babylonjs/Particles/index" {
  68985. export * from "babylonjs/Particles/baseParticleSystem";
  68986. export * from "babylonjs/Particles/EmitterTypes/index";
  68987. export * from "babylonjs/Particles/gpuParticleSystem";
  68988. export * from "babylonjs/Particles/IParticleSystem";
  68989. export * from "babylonjs/Particles/particle";
  68990. export * from "babylonjs/Particles/particleHelper";
  68991. export * from "babylonjs/Particles/particleSystem";
  68992. export * from "babylonjs/Particles/particleSystemComponent";
  68993. export * from "babylonjs/Particles/particleSystemSet";
  68994. export * from "babylonjs/Particles/solidParticle";
  68995. export * from "babylonjs/Particles/solidParticleSystem";
  68996. export * from "babylonjs/Particles/cloudPoint";
  68997. export * from "babylonjs/Particles/pointsCloudSystem";
  68998. export * from "babylonjs/Particles/subEmitter";
  68999. }
  69000. declare module "babylonjs/Physics/physicsEngineComponent" {
  69001. import { Nullable } from "babylonjs/types";
  69002. import { Observable, Observer } from "babylonjs/Misc/observable";
  69003. import { Vector3 } from "babylonjs/Maths/math.vector";
  69004. import { Mesh } from "babylonjs/Meshes/mesh";
  69005. import { ISceneComponent } from "babylonjs/sceneComponent";
  69006. import { Scene } from "babylonjs/scene";
  69007. import { Node } from "babylonjs/node";
  69008. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  69009. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  69010. module "babylonjs/scene" {
  69011. interface Scene {
  69012. /** @hidden (Backing field) */
  69013. _physicsEngine: Nullable<IPhysicsEngine>;
  69014. /** @hidden */
  69015. _physicsTimeAccumulator: number;
  69016. /**
  69017. * Gets the current physics engine
  69018. * @returns a IPhysicsEngine or null if none attached
  69019. */
  69020. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  69021. /**
  69022. * Enables physics to the current scene
  69023. * @param gravity defines the scene's gravity for the physics engine
  69024. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  69025. * @return a boolean indicating if the physics engine was initialized
  69026. */
  69027. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  69028. /**
  69029. * Disables and disposes the physics engine associated with the scene
  69030. */
  69031. disablePhysicsEngine(): void;
  69032. /**
  69033. * Gets a boolean indicating if there is an active physics engine
  69034. * @returns a boolean indicating if there is an active physics engine
  69035. */
  69036. isPhysicsEnabled(): boolean;
  69037. /**
  69038. * Deletes a physics compound impostor
  69039. * @param compound defines the compound to delete
  69040. */
  69041. deleteCompoundImpostor(compound: any): void;
  69042. /**
  69043. * An event triggered when physic simulation is about to be run
  69044. */
  69045. onBeforePhysicsObservable: Observable<Scene>;
  69046. /**
  69047. * An event triggered when physic simulation has been done
  69048. */
  69049. onAfterPhysicsObservable: Observable<Scene>;
  69050. }
  69051. }
  69052. module "babylonjs/Meshes/abstractMesh" {
  69053. interface AbstractMesh {
  69054. /** @hidden */
  69055. _physicsImpostor: Nullable<PhysicsImpostor>;
  69056. /**
  69057. * Gets or sets impostor used for physic simulation
  69058. * @see http://doc.babylonjs.com/features/physics_engine
  69059. */
  69060. physicsImpostor: Nullable<PhysicsImpostor>;
  69061. /**
  69062. * Gets the current physics impostor
  69063. * @see http://doc.babylonjs.com/features/physics_engine
  69064. * @returns a physics impostor or null
  69065. */
  69066. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  69067. /** Apply a physic impulse to the mesh
  69068. * @param force defines the force to apply
  69069. * @param contactPoint defines where to apply the force
  69070. * @returns the current mesh
  69071. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  69072. */
  69073. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  69074. /**
  69075. * Creates a physic joint between two meshes
  69076. * @param otherMesh defines the other mesh to use
  69077. * @param pivot1 defines the pivot to use on this mesh
  69078. * @param pivot2 defines the pivot to use on the other mesh
  69079. * @param options defines additional options (can be plugin dependent)
  69080. * @returns the current mesh
  69081. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  69082. */
  69083. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  69084. /** @hidden */
  69085. _disposePhysicsObserver: Nullable<Observer<Node>>;
  69086. }
  69087. }
  69088. /**
  69089. * Defines the physics engine scene component responsible to manage a physics engine
  69090. */
  69091. export class PhysicsEngineSceneComponent implements ISceneComponent {
  69092. /**
  69093. * The component name helpful to identify the component in the list of scene components.
  69094. */
  69095. readonly name: string;
  69096. /**
  69097. * The scene the component belongs to.
  69098. */
  69099. scene: Scene;
  69100. /**
  69101. * Creates a new instance of the component for the given scene
  69102. * @param scene Defines the scene to register the component in
  69103. */
  69104. constructor(scene: Scene);
  69105. /**
  69106. * Registers the component in a given scene
  69107. */
  69108. register(): void;
  69109. /**
  69110. * Rebuilds the elements related to this component in case of
  69111. * context lost for instance.
  69112. */
  69113. rebuild(): void;
  69114. /**
  69115. * Disposes the component and the associated ressources
  69116. */
  69117. dispose(): void;
  69118. }
  69119. }
  69120. declare module "babylonjs/Physics/physicsHelper" {
  69121. import { Nullable } from "babylonjs/types";
  69122. import { Vector3 } from "babylonjs/Maths/math.vector";
  69123. import { Mesh } from "babylonjs/Meshes/mesh";
  69124. import { Scene } from "babylonjs/scene";
  69125. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  69126. /**
  69127. * A helper for physics simulations
  69128. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  69129. */
  69130. export class PhysicsHelper {
  69131. private _scene;
  69132. private _physicsEngine;
  69133. /**
  69134. * Initializes the Physics helper
  69135. * @param scene Babylon.js scene
  69136. */
  69137. constructor(scene: Scene);
  69138. /**
  69139. * Applies a radial explosion impulse
  69140. * @param origin the origin of the explosion
  69141. * @param radiusOrEventOptions the radius or the options of radial explosion
  69142. * @param strength the explosion strength
  69143. * @param falloff possible options: Constant & Linear. Defaults to Constant
  69144. * @returns A physics radial explosion event, or null
  69145. */
  69146. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  69147. /**
  69148. * Applies a radial explosion force
  69149. * @param origin the origin of the explosion
  69150. * @param radiusOrEventOptions the radius or the options of radial explosion
  69151. * @param strength the explosion strength
  69152. * @param falloff possible options: Constant & Linear. Defaults to Constant
  69153. * @returns A physics radial explosion event, or null
  69154. */
  69155. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  69156. /**
  69157. * Creates a gravitational field
  69158. * @param origin the origin of the explosion
  69159. * @param radiusOrEventOptions the radius or the options of radial explosion
  69160. * @param strength the explosion strength
  69161. * @param falloff possible options: Constant & Linear. Defaults to Constant
  69162. * @returns A physics gravitational field event, or null
  69163. */
  69164. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  69165. /**
  69166. * Creates a physics updraft event
  69167. * @param origin the origin of the updraft
  69168. * @param radiusOrEventOptions the radius or the options of the updraft
  69169. * @param strength the strength of the updraft
  69170. * @param height the height of the updraft
  69171. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  69172. * @returns A physics updraft event, or null
  69173. */
  69174. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  69175. /**
  69176. * Creates a physics vortex event
  69177. * @param origin the of the vortex
  69178. * @param radiusOrEventOptions the radius or the options of the vortex
  69179. * @param strength the strength of the vortex
  69180. * @param height the height of the vortex
  69181. * @returns a Physics vortex event, or null
  69182. * A physics vortex event or null
  69183. */
  69184. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  69185. }
  69186. /**
  69187. * Represents a physics radial explosion event
  69188. */
  69189. class PhysicsRadialExplosionEvent {
  69190. private _scene;
  69191. private _options;
  69192. private _sphere;
  69193. private _dataFetched;
  69194. /**
  69195. * Initializes a radial explosioin event
  69196. * @param _scene BabylonJS scene
  69197. * @param _options The options for the vortex event
  69198. */
  69199. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  69200. /**
  69201. * Returns the data related to the radial explosion event (sphere).
  69202. * @returns The radial explosion event data
  69203. */
  69204. getData(): PhysicsRadialExplosionEventData;
  69205. /**
  69206. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  69207. * @param impostor A physics imposter
  69208. * @param origin the origin of the explosion
  69209. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  69210. */
  69211. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  69212. /**
  69213. * Triggers affecterd impostors callbacks
  69214. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  69215. */
  69216. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  69217. /**
  69218. * Disposes the sphere.
  69219. * @param force Specifies if the sphere should be disposed by force
  69220. */
  69221. dispose(force?: boolean): void;
  69222. /*** Helpers ***/
  69223. private _prepareSphere;
  69224. private _intersectsWithSphere;
  69225. }
  69226. /**
  69227. * Represents a gravitational field event
  69228. */
  69229. class PhysicsGravitationalFieldEvent {
  69230. private _physicsHelper;
  69231. private _scene;
  69232. private _origin;
  69233. private _options;
  69234. private _tickCallback;
  69235. private _sphere;
  69236. private _dataFetched;
  69237. /**
  69238. * Initializes the physics gravitational field event
  69239. * @param _physicsHelper A physics helper
  69240. * @param _scene BabylonJS scene
  69241. * @param _origin The origin position of the gravitational field event
  69242. * @param _options The options for the vortex event
  69243. */
  69244. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  69245. /**
  69246. * Returns the data related to the gravitational field event (sphere).
  69247. * @returns A gravitational field event
  69248. */
  69249. getData(): PhysicsGravitationalFieldEventData;
  69250. /**
  69251. * Enables the gravitational field.
  69252. */
  69253. enable(): void;
  69254. /**
  69255. * Disables the gravitational field.
  69256. */
  69257. disable(): void;
  69258. /**
  69259. * Disposes the sphere.
  69260. * @param force The force to dispose from the gravitational field event
  69261. */
  69262. dispose(force?: boolean): void;
  69263. private _tick;
  69264. }
  69265. /**
  69266. * Represents a physics updraft event
  69267. */
  69268. class PhysicsUpdraftEvent {
  69269. private _scene;
  69270. private _origin;
  69271. private _options;
  69272. private _physicsEngine;
  69273. private _originTop;
  69274. private _originDirection;
  69275. private _tickCallback;
  69276. private _cylinder;
  69277. private _cylinderPosition;
  69278. private _dataFetched;
  69279. /**
  69280. * Initializes the physics updraft event
  69281. * @param _scene BabylonJS scene
  69282. * @param _origin The origin position of the updraft
  69283. * @param _options The options for the updraft event
  69284. */
  69285. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  69286. /**
  69287. * Returns the data related to the updraft event (cylinder).
  69288. * @returns A physics updraft event
  69289. */
  69290. getData(): PhysicsUpdraftEventData;
  69291. /**
  69292. * Enables the updraft.
  69293. */
  69294. enable(): void;
  69295. /**
  69296. * Disables the updraft.
  69297. */
  69298. disable(): void;
  69299. /**
  69300. * Disposes the cylinder.
  69301. * @param force Specifies if the updraft should be disposed by force
  69302. */
  69303. dispose(force?: boolean): void;
  69304. private getImpostorHitData;
  69305. private _tick;
  69306. /*** Helpers ***/
  69307. private _prepareCylinder;
  69308. private _intersectsWithCylinder;
  69309. }
  69310. /**
  69311. * Represents a physics vortex event
  69312. */
  69313. class PhysicsVortexEvent {
  69314. private _scene;
  69315. private _origin;
  69316. private _options;
  69317. private _physicsEngine;
  69318. private _originTop;
  69319. private _tickCallback;
  69320. private _cylinder;
  69321. private _cylinderPosition;
  69322. private _dataFetched;
  69323. /**
  69324. * Initializes the physics vortex event
  69325. * @param _scene The BabylonJS scene
  69326. * @param _origin The origin position of the vortex
  69327. * @param _options The options for the vortex event
  69328. */
  69329. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  69330. /**
  69331. * Returns the data related to the vortex event (cylinder).
  69332. * @returns The physics vortex event data
  69333. */
  69334. getData(): PhysicsVortexEventData;
  69335. /**
  69336. * Enables the vortex.
  69337. */
  69338. enable(): void;
  69339. /**
  69340. * Disables the cortex.
  69341. */
  69342. disable(): void;
  69343. /**
  69344. * Disposes the sphere.
  69345. * @param force
  69346. */
  69347. dispose(force?: boolean): void;
  69348. private getImpostorHitData;
  69349. private _tick;
  69350. /*** Helpers ***/
  69351. private _prepareCylinder;
  69352. private _intersectsWithCylinder;
  69353. }
  69354. /**
  69355. * Options fot the radial explosion event
  69356. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  69357. */
  69358. export class PhysicsRadialExplosionEventOptions {
  69359. /**
  69360. * The radius of the sphere for the radial explosion.
  69361. */
  69362. radius: number;
  69363. /**
  69364. * The strenth of the explosion.
  69365. */
  69366. strength: number;
  69367. /**
  69368. * The strenght of the force in correspondence to the distance of the affected object
  69369. */
  69370. falloff: PhysicsRadialImpulseFalloff;
  69371. /**
  69372. * Sphere options for the radial explosion.
  69373. */
  69374. sphere: {
  69375. segments: number;
  69376. diameter: number;
  69377. };
  69378. /**
  69379. * Sphere options for the radial explosion.
  69380. */
  69381. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  69382. }
  69383. /**
  69384. * Options fot the updraft event
  69385. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  69386. */
  69387. export class PhysicsUpdraftEventOptions {
  69388. /**
  69389. * The radius of the cylinder for the vortex
  69390. */
  69391. radius: number;
  69392. /**
  69393. * The strenth of the updraft.
  69394. */
  69395. strength: number;
  69396. /**
  69397. * The height of the cylinder for the updraft.
  69398. */
  69399. height: number;
  69400. /**
  69401. * The mode for the the updraft.
  69402. */
  69403. updraftMode: PhysicsUpdraftMode;
  69404. }
  69405. /**
  69406. * Options fot the vortex event
  69407. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  69408. */
  69409. export class PhysicsVortexEventOptions {
  69410. /**
  69411. * The radius of the cylinder for the vortex
  69412. */
  69413. radius: number;
  69414. /**
  69415. * The strenth of the vortex.
  69416. */
  69417. strength: number;
  69418. /**
  69419. * The height of the cylinder for the vortex.
  69420. */
  69421. height: number;
  69422. /**
  69423. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  69424. */
  69425. centripetalForceThreshold: number;
  69426. /**
  69427. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  69428. */
  69429. centripetalForceMultiplier: number;
  69430. /**
  69431. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  69432. */
  69433. centrifugalForceMultiplier: number;
  69434. /**
  69435. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  69436. */
  69437. updraftForceMultiplier: number;
  69438. }
  69439. /**
  69440. * The strenght of the force in correspondence to the distance of the affected object
  69441. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  69442. */
  69443. export enum PhysicsRadialImpulseFalloff {
  69444. /** Defines that impulse is constant in strength across it's whole radius */
  69445. Constant = 0,
  69446. /** Defines that impulse gets weaker if it's further from the origin */
  69447. Linear = 1
  69448. }
  69449. /**
  69450. * The strength of the force in correspondence to the distance of the affected object
  69451. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  69452. */
  69453. export enum PhysicsUpdraftMode {
  69454. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  69455. Center = 0,
  69456. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  69457. Perpendicular = 1
  69458. }
  69459. /**
  69460. * Interface for a physics hit data
  69461. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  69462. */
  69463. export interface PhysicsHitData {
  69464. /**
  69465. * The force applied at the contact point
  69466. */
  69467. force: Vector3;
  69468. /**
  69469. * The contact point
  69470. */
  69471. contactPoint: Vector3;
  69472. /**
  69473. * The distance from the origin to the contact point
  69474. */
  69475. distanceFromOrigin: number;
  69476. }
  69477. /**
  69478. * Interface for radial explosion event data
  69479. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  69480. */
  69481. export interface PhysicsRadialExplosionEventData {
  69482. /**
  69483. * A sphere used for the radial explosion event
  69484. */
  69485. sphere: Mesh;
  69486. }
  69487. /**
  69488. * Interface for gravitational field event data
  69489. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  69490. */
  69491. export interface PhysicsGravitationalFieldEventData {
  69492. /**
  69493. * A sphere mesh used for the gravitational field event
  69494. */
  69495. sphere: Mesh;
  69496. }
  69497. /**
  69498. * Interface for updraft event data
  69499. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  69500. */
  69501. export interface PhysicsUpdraftEventData {
  69502. /**
  69503. * A cylinder used for the updraft event
  69504. */
  69505. cylinder: Mesh;
  69506. }
  69507. /**
  69508. * Interface for vortex event data
  69509. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  69510. */
  69511. export interface PhysicsVortexEventData {
  69512. /**
  69513. * A cylinder used for the vortex event
  69514. */
  69515. cylinder: Mesh;
  69516. }
  69517. /**
  69518. * Interface for an affected physics impostor
  69519. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  69520. */
  69521. export interface PhysicsAffectedImpostorWithData {
  69522. /**
  69523. * The impostor affected by the effect
  69524. */
  69525. impostor: PhysicsImpostor;
  69526. /**
  69527. * The data about the hit/horce from the explosion
  69528. */
  69529. hitData: PhysicsHitData;
  69530. }
  69531. }
  69532. declare module "babylonjs/Physics/Plugins/index" {
  69533. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  69534. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  69535. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  69536. }
  69537. declare module "babylonjs/Physics/index" {
  69538. export * from "babylonjs/Physics/IPhysicsEngine";
  69539. export * from "babylonjs/Physics/physicsEngine";
  69540. export * from "babylonjs/Physics/physicsEngineComponent";
  69541. export * from "babylonjs/Physics/physicsHelper";
  69542. export * from "babylonjs/Physics/physicsImpostor";
  69543. export * from "babylonjs/Physics/physicsJoint";
  69544. export * from "babylonjs/Physics/Plugins/index";
  69545. }
  69546. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  69547. /** @hidden */
  69548. export var blackAndWhitePixelShader: {
  69549. name: string;
  69550. shader: string;
  69551. };
  69552. }
  69553. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  69554. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  69555. import { Camera } from "babylonjs/Cameras/camera";
  69556. import { Engine } from "babylonjs/Engines/engine";
  69557. import "babylonjs/Shaders/blackAndWhite.fragment";
  69558. /**
  69559. * Post process used to render in black and white
  69560. */
  69561. export class BlackAndWhitePostProcess extends PostProcess {
  69562. /**
  69563. * Linear about to convert he result to black and white (default: 1)
  69564. */
  69565. degree: number;
  69566. /**
  69567. * Creates a black and white post process
  69568. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  69569. * @param name The name of the effect.
  69570. * @param options The required width/height ratio to downsize to before computing the render pass.
  69571. * @param camera The camera to apply the render pass to.
  69572. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69573. * @param engine The engine which the post process will be applied. (default: current engine)
  69574. * @param reusable If the post process can be reused on the same frame. (default: false)
  69575. */
  69576. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  69577. }
  69578. }
  69579. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  69580. import { Nullable } from "babylonjs/types";
  69581. import { Camera } from "babylonjs/Cameras/camera";
  69582. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  69583. import { Engine } from "babylonjs/Engines/engine";
  69584. /**
  69585. * This represents a set of one or more post processes in Babylon.
  69586. * A post process can be used to apply a shader to a texture after it is rendered.
  69587. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  69588. */
  69589. export class PostProcessRenderEffect {
  69590. private _postProcesses;
  69591. private _getPostProcesses;
  69592. private _singleInstance;
  69593. private _cameras;
  69594. private _indicesForCamera;
  69595. /**
  69596. * Name of the effect
  69597. * @hidden
  69598. */
  69599. _name: string;
  69600. /**
  69601. * Instantiates a post process render effect.
  69602. * A post process can be used to apply a shader to a texture after it is rendered.
  69603. * @param engine The engine the effect is tied to
  69604. * @param name The name of the effect
  69605. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  69606. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  69607. */
  69608. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  69609. /**
  69610. * Checks if all the post processes in the effect are supported.
  69611. */
  69612. get isSupported(): boolean;
  69613. /**
  69614. * Updates the current state of the effect
  69615. * @hidden
  69616. */
  69617. _update(): void;
  69618. /**
  69619. * Attaches the effect on cameras
  69620. * @param cameras The camera to attach to.
  69621. * @hidden
  69622. */
  69623. _attachCameras(cameras: Camera): void;
  69624. /**
  69625. * Attaches the effect on cameras
  69626. * @param cameras The camera to attach to.
  69627. * @hidden
  69628. */
  69629. _attachCameras(cameras: Camera[]): void;
  69630. /**
  69631. * Detaches the effect on cameras
  69632. * @param cameras The camera to detatch from.
  69633. * @hidden
  69634. */
  69635. _detachCameras(cameras: Camera): void;
  69636. /**
  69637. * Detatches the effect on cameras
  69638. * @param cameras The camera to detatch from.
  69639. * @hidden
  69640. */
  69641. _detachCameras(cameras: Camera[]): void;
  69642. /**
  69643. * Enables the effect on given cameras
  69644. * @param cameras The camera to enable.
  69645. * @hidden
  69646. */
  69647. _enable(cameras: Camera): void;
  69648. /**
  69649. * Enables the effect on given cameras
  69650. * @param cameras The camera to enable.
  69651. * @hidden
  69652. */
  69653. _enable(cameras: Nullable<Camera[]>): void;
  69654. /**
  69655. * Disables the effect on the given cameras
  69656. * @param cameras The camera to disable.
  69657. * @hidden
  69658. */
  69659. _disable(cameras: Camera): void;
  69660. /**
  69661. * Disables the effect on the given cameras
  69662. * @param cameras The camera to disable.
  69663. * @hidden
  69664. */
  69665. _disable(cameras: Nullable<Camera[]>): void;
  69666. /**
  69667. * Gets a list of the post processes contained in the effect.
  69668. * @param camera The camera to get the post processes on.
  69669. * @returns The list of the post processes in the effect.
  69670. */
  69671. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  69672. }
  69673. }
  69674. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  69675. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  69676. /** @hidden */
  69677. export var extractHighlightsPixelShader: {
  69678. name: string;
  69679. shader: string;
  69680. };
  69681. }
  69682. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  69683. import { Nullable } from "babylonjs/types";
  69684. import { Camera } from "babylonjs/Cameras/camera";
  69685. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  69686. import { Engine } from "babylonjs/Engines/engine";
  69687. import "babylonjs/Shaders/extractHighlights.fragment";
  69688. /**
  69689. * 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.
  69690. */
  69691. export class ExtractHighlightsPostProcess extends PostProcess {
  69692. /**
  69693. * The luminance threshold, pixels below this value will be set to black.
  69694. */
  69695. threshold: number;
  69696. /** @hidden */
  69697. _exposure: number;
  69698. /**
  69699. * Post process which has the input texture to be used when performing highlight extraction
  69700. * @hidden
  69701. */
  69702. _inputPostProcess: Nullable<PostProcess>;
  69703. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  69704. }
  69705. }
  69706. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  69707. /** @hidden */
  69708. export var bloomMergePixelShader: {
  69709. name: string;
  69710. shader: string;
  69711. };
  69712. }
  69713. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  69714. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  69715. import { Nullable } from "babylonjs/types";
  69716. import { Engine } from "babylonjs/Engines/engine";
  69717. import { Camera } from "babylonjs/Cameras/camera";
  69718. import "babylonjs/Shaders/bloomMerge.fragment";
  69719. /**
  69720. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  69721. */
  69722. export class BloomMergePostProcess extends PostProcess {
  69723. /** Weight of the bloom to be added to the original input. */
  69724. weight: number;
  69725. /**
  69726. * Creates a new instance of @see BloomMergePostProcess
  69727. * @param name The name of the effect.
  69728. * @param originalFromInput Post process which's input will be used for the merge.
  69729. * @param blurred Blurred highlights post process which's output will be used.
  69730. * @param weight Weight of the bloom to be added to the original input.
  69731. * @param options The required width/height ratio to downsize to before computing the render pass.
  69732. * @param camera The camera to apply the render pass to.
  69733. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69734. * @param engine The engine which the post process will be applied. (default: current engine)
  69735. * @param reusable If the post process can be reused on the same frame. (default: false)
  69736. * @param textureType Type of textures used when performing the post process. (default: 0)
  69737. * @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)
  69738. */
  69739. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  69740. /** Weight of the bloom to be added to the original input. */
  69741. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  69742. }
  69743. }
  69744. declare module "babylonjs/PostProcesses/bloomEffect" {
  69745. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  69746. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  69747. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  69748. import { Camera } from "babylonjs/Cameras/camera";
  69749. import { Scene } from "babylonjs/scene";
  69750. /**
  69751. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  69752. */
  69753. export class BloomEffect extends PostProcessRenderEffect {
  69754. private bloomScale;
  69755. /**
  69756. * @hidden Internal
  69757. */
  69758. _effects: Array<PostProcess>;
  69759. /**
  69760. * @hidden Internal
  69761. */
  69762. _downscale: ExtractHighlightsPostProcess;
  69763. private _blurX;
  69764. private _blurY;
  69765. private _merge;
  69766. /**
  69767. * The luminance threshold to find bright areas of the image to bloom.
  69768. */
  69769. get threshold(): number;
  69770. set threshold(value: number);
  69771. /**
  69772. * The strength of the bloom.
  69773. */
  69774. get weight(): number;
  69775. set weight(value: number);
  69776. /**
  69777. * Specifies the size of the bloom blur kernel, relative to the final output size
  69778. */
  69779. get kernel(): number;
  69780. set kernel(value: number);
  69781. /**
  69782. * Creates a new instance of @see BloomEffect
  69783. * @param scene The scene the effect belongs to.
  69784. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  69785. * @param bloomKernel The size of the kernel to be used when applying the blur.
  69786. * @param bloomWeight The the strength of bloom.
  69787. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  69788. * @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)
  69789. */
  69790. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  69791. /**
  69792. * Disposes each of the internal effects for a given camera.
  69793. * @param camera The camera to dispose the effect on.
  69794. */
  69795. disposeEffects(camera: Camera): void;
  69796. /**
  69797. * @hidden Internal
  69798. */
  69799. _updateEffects(): void;
  69800. /**
  69801. * Internal
  69802. * @returns if all the contained post processes are ready.
  69803. * @hidden
  69804. */
  69805. _isReady(): boolean;
  69806. }
  69807. }
  69808. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  69809. /** @hidden */
  69810. export var chromaticAberrationPixelShader: {
  69811. name: string;
  69812. shader: string;
  69813. };
  69814. }
  69815. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  69816. import { Vector2 } from "babylonjs/Maths/math.vector";
  69817. import { Nullable } from "babylonjs/types";
  69818. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  69819. import { Camera } from "babylonjs/Cameras/camera";
  69820. import { Engine } from "babylonjs/Engines/engine";
  69821. import "babylonjs/Shaders/chromaticAberration.fragment";
  69822. /**
  69823. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  69824. */
  69825. export class ChromaticAberrationPostProcess extends PostProcess {
  69826. /**
  69827. * The amount of seperation of rgb channels (default: 30)
  69828. */
  69829. aberrationAmount: number;
  69830. /**
  69831. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  69832. */
  69833. radialIntensity: number;
  69834. /**
  69835. * 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))
  69836. */
  69837. direction: Vector2;
  69838. /**
  69839. * 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))
  69840. */
  69841. centerPosition: Vector2;
  69842. /**
  69843. * Creates a new instance ChromaticAberrationPostProcess
  69844. * @param name The name of the effect.
  69845. * @param screenWidth The width of the screen to apply the effect on.
  69846. * @param screenHeight The height of the screen to apply the effect on.
  69847. * @param options The required width/height ratio to downsize to before computing the render pass.
  69848. * @param camera The camera to apply the render pass to.
  69849. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69850. * @param engine The engine which the post process will be applied. (default: current engine)
  69851. * @param reusable If the post process can be reused on the same frame. (default: false)
  69852. * @param textureType Type of textures used when performing the post process. (default: 0)
  69853. * @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)
  69854. */
  69855. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  69856. }
  69857. }
  69858. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  69859. /** @hidden */
  69860. export var circleOfConfusionPixelShader: {
  69861. name: string;
  69862. shader: string;
  69863. };
  69864. }
  69865. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  69866. import { Nullable } from "babylonjs/types";
  69867. import { Engine } from "babylonjs/Engines/engine";
  69868. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  69869. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  69870. import { Camera } from "babylonjs/Cameras/camera";
  69871. import "babylonjs/Shaders/circleOfConfusion.fragment";
  69872. /**
  69873. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  69874. */
  69875. export class CircleOfConfusionPostProcess extends PostProcess {
  69876. /**
  69877. * 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.
  69878. */
  69879. lensSize: number;
  69880. /**
  69881. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  69882. */
  69883. fStop: number;
  69884. /**
  69885. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  69886. */
  69887. focusDistance: number;
  69888. /**
  69889. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  69890. */
  69891. focalLength: number;
  69892. private _depthTexture;
  69893. /**
  69894. * Creates a new instance CircleOfConfusionPostProcess
  69895. * @param name The name of the effect.
  69896. * @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.
  69897. * @param options The required width/height ratio to downsize to before computing the render pass.
  69898. * @param camera The camera to apply the render pass to.
  69899. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69900. * @param engine The engine which the post process will be applied. (default: current engine)
  69901. * @param reusable If the post process can be reused on the same frame. (default: false)
  69902. * @param textureType Type of textures used when performing the post process. (default: 0)
  69903. * @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)
  69904. */
  69905. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  69906. /**
  69907. * 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.
  69908. */
  69909. set depthTexture(value: RenderTargetTexture);
  69910. }
  69911. }
  69912. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  69913. /** @hidden */
  69914. export var colorCorrectionPixelShader: {
  69915. name: string;
  69916. shader: string;
  69917. };
  69918. }
  69919. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  69920. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  69921. import { Engine } from "babylonjs/Engines/engine";
  69922. import { Camera } from "babylonjs/Cameras/camera";
  69923. import "babylonjs/Shaders/colorCorrection.fragment";
  69924. /**
  69925. *
  69926. * This post-process allows the modification of rendered colors by using
  69927. * a 'look-up table' (LUT). This effect is also called Color Grading.
  69928. *
  69929. * The object needs to be provided an url to a texture containing the color
  69930. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  69931. * Use an image editing software to tweak the LUT to match your needs.
  69932. *
  69933. * For an example of a color LUT, see here:
  69934. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  69935. * For explanations on color grading, see here:
  69936. * @see http://udn.epicgames.com/Three/ColorGrading.html
  69937. *
  69938. */
  69939. export class ColorCorrectionPostProcess extends PostProcess {
  69940. private _colorTableTexture;
  69941. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  69942. }
  69943. }
  69944. declare module "babylonjs/Shaders/convolution.fragment" {
  69945. /** @hidden */
  69946. export var convolutionPixelShader: {
  69947. name: string;
  69948. shader: string;
  69949. };
  69950. }
  69951. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  69952. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  69953. import { Nullable } from "babylonjs/types";
  69954. import { Camera } from "babylonjs/Cameras/camera";
  69955. import { Engine } from "babylonjs/Engines/engine";
  69956. import "babylonjs/Shaders/convolution.fragment";
  69957. /**
  69958. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  69959. * input texture to perform effects such as edge detection or sharpening
  69960. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  69961. */
  69962. export class ConvolutionPostProcess extends PostProcess {
  69963. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  69964. kernel: number[];
  69965. /**
  69966. * Creates a new instance ConvolutionPostProcess
  69967. * @param name The name of the effect.
  69968. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  69969. * @param options The required width/height ratio to downsize to before computing the render pass.
  69970. * @param camera The camera to apply the render pass to.
  69971. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69972. * @param engine The engine which the post process will be applied. (default: current engine)
  69973. * @param reusable If the post process can be reused on the same frame. (default: false)
  69974. * @param textureType Type of textures used when performing the post process. (default: 0)
  69975. */
  69976. constructor(name: string,
  69977. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  69978. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  69979. /**
  69980. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  69981. */
  69982. static EdgeDetect0Kernel: number[];
  69983. /**
  69984. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  69985. */
  69986. static EdgeDetect1Kernel: number[];
  69987. /**
  69988. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  69989. */
  69990. static EdgeDetect2Kernel: number[];
  69991. /**
  69992. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  69993. */
  69994. static SharpenKernel: number[];
  69995. /**
  69996. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  69997. */
  69998. static EmbossKernel: number[];
  69999. /**
  70000. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  70001. */
  70002. static GaussianKernel: number[];
  70003. }
  70004. }
  70005. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  70006. import { Nullable } from "babylonjs/types";
  70007. import { Vector2 } from "babylonjs/Maths/math.vector";
  70008. import { Camera } from "babylonjs/Cameras/camera";
  70009. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  70010. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  70011. import { Engine } from "babylonjs/Engines/engine";
  70012. import { Scene } from "babylonjs/scene";
  70013. /**
  70014. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  70015. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  70016. * based on samples that have a large difference in distance than the center pixel.
  70017. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  70018. */
  70019. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  70020. direction: Vector2;
  70021. /**
  70022. * Creates a new instance CircleOfConfusionPostProcess
  70023. * @param name The name of the effect.
  70024. * @param scene The scene the effect belongs to.
  70025. * @param direction The direction the blur should be applied.
  70026. * @param kernel The size of the kernel used to blur.
  70027. * @param options The required width/height ratio to downsize to before computing the render pass.
  70028. * @param camera The camera to apply the render pass to.
  70029. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  70030. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  70031. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70032. * @param engine The engine which the post process will be applied. (default: current engine)
  70033. * @param reusable If the post process can be reused on the same frame. (default: false)
  70034. * @param textureType Type of textures used when performing the post process. (default: 0)
  70035. * @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)
  70036. */
  70037. 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);
  70038. }
  70039. }
  70040. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  70041. /** @hidden */
  70042. export var depthOfFieldMergePixelShader: {
  70043. name: string;
  70044. shader: string;
  70045. };
  70046. }
  70047. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  70048. import { Nullable } from "babylonjs/types";
  70049. import { Camera } from "babylonjs/Cameras/camera";
  70050. import { Effect } from "babylonjs/Materials/effect";
  70051. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  70052. import { Engine } from "babylonjs/Engines/engine";
  70053. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  70054. /**
  70055. * Options to be set when merging outputs from the default pipeline.
  70056. */
  70057. export class DepthOfFieldMergePostProcessOptions {
  70058. /**
  70059. * The original image to merge on top of
  70060. */
  70061. originalFromInput: PostProcess;
  70062. /**
  70063. * Parameters to perform the merge of the depth of field effect
  70064. */
  70065. depthOfField?: {
  70066. circleOfConfusion: PostProcess;
  70067. blurSteps: Array<PostProcess>;
  70068. };
  70069. /**
  70070. * Parameters to perform the merge of bloom effect
  70071. */
  70072. bloom?: {
  70073. blurred: PostProcess;
  70074. weight: number;
  70075. };
  70076. }
  70077. /**
  70078. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  70079. */
  70080. export class DepthOfFieldMergePostProcess extends PostProcess {
  70081. private blurSteps;
  70082. /**
  70083. * Creates a new instance of DepthOfFieldMergePostProcess
  70084. * @param name The name of the effect.
  70085. * @param originalFromInput Post process which's input will be used for the merge.
  70086. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  70087. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  70088. * @param options The required width/height ratio to downsize to before computing the render pass.
  70089. * @param camera The camera to apply the render pass to.
  70090. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70091. * @param engine The engine which the post process will be applied. (default: current engine)
  70092. * @param reusable If the post process can be reused on the same frame. (default: false)
  70093. * @param textureType Type of textures used when performing the post process. (default: 0)
  70094. * @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)
  70095. */
  70096. 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);
  70097. /**
  70098. * Updates the effect with the current post process compile time values and recompiles the shader.
  70099. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  70100. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  70101. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  70102. * @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
  70103. * @param onCompiled Called when the shader has been compiled.
  70104. * @param onError Called if there is an error when compiling a shader.
  70105. */
  70106. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  70107. }
  70108. }
  70109. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  70110. import { Nullable } from "babylonjs/types";
  70111. import { Camera } from "babylonjs/Cameras/camera";
  70112. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  70113. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  70114. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  70115. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  70116. import { Scene } from "babylonjs/scene";
  70117. /**
  70118. * Specifies the level of max blur that should be applied when using the depth of field effect
  70119. */
  70120. export enum DepthOfFieldEffectBlurLevel {
  70121. /**
  70122. * Subtle blur
  70123. */
  70124. Low = 0,
  70125. /**
  70126. * Medium blur
  70127. */
  70128. Medium = 1,
  70129. /**
  70130. * Large blur
  70131. */
  70132. High = 2
  70133. }
  70134. /**
  70135. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  70136. */
  70137. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  70138. private _circleOfConfusion;
  70139. /**
  70140. * @hidden Internal, blurs from high to low
  70141. */
  70142. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  70143. private _depthOfFieldBlurY;
  70144. private _dofMerge;
  70145. /**
  70146. * @hidden Internal post processes in depth of field effect
  70147. */
  70148. _effects: Array<PostProcess>;
  70149. /**
  70150. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  70151. */
  70152. set focalLength(value: number);
  70153. get focalLength(): number;
  70154. /**
  70155. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  70156. */
  70157. set fStop(value: number);
  70158. get fStop(): number;
  70159. /**
  70160. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  70161. */
  70162. set focusDistance(value: number);
  70163. get focusDistance(): number;
  70164. /**
  70165. * 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.
  70166. */
  70167. set lensSize(value: number);
  70168. get lensSize(): number;
  70169. /**
  70170. * Creates a new instance DepthOfFieldEffect
  70171. * @param scene The scene the effect belongs to.
  70172. * @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.
  70173. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  70174. * @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)
  70175. */
  70176. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  70177. /**
  70178. * Get the current class name of the current effet
  70179. * @returns "DepthOfFieldEffect"
  70180. */
  70181. getClassName(): string;
  70182. /**
  70183. * 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.
  70184. */
  70185. set depthTexture(value: RenderTargetTexture);
  70186. /**
  70187. * Disposes each of the internal effects for a given camera.
  70188. * @param camera The camera to dispose the effect on.
  70189. */
  70190. disposeEffects(camera: Camera): void;
  70191. /**
  70192. * @hidden Internal
  70193. */
  70194. _updateEffects(): void;
  70195. /**
  70196. * Internal
  70197. * @returns if all the contained post processes are ready.
  70198. * @hidden
  70199. */
  70200. _isReady(): boolean;
  70201. }
  70202. }
  70203. declare module "babylonjs/Shaders/displayPass.fragment" {
  70204. /** @hidden */
  70205. export var displayPassPixelShader: {
  70206. name: string;
  70207. shader: string;
  70208. };
  70209. }
  70210. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  70211. import { Nullable } from "babylonjs/types";
  70212. import { Camera } from "babylonjs/Cameras/camera";
  70213. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  70214. import { Engine } from "babylonjs/Engines/engine";
  70215. import "babylonjs/Shaders/displayPass.fragment";
  70216. /**
  70217. * DisplayPassPostProcess which produces an output the same as it's input
  70218. */
  70219. export class DisplayPassPostProcess extends PostProcess {
  70220. /**
  70221. * Creates the DisplayPassPostProcess
  70222. * @param name The name of the effect.
  70223. * @param options The required width/height ratio to downsize to before computing the render pass.
  70224. * @param camera The camera to apply the render pass to.
  70225. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70226. * @param engine The engine which the post process will be applied. (default: current engine)
  70227. * @param reusable If the post process can be reused on the same frame. (default: false)
  70228. */
  70229. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  70230. }
  70231. }
  70232. declare module "babylonjs/Shaders/filter.fragment" {
  70233. /** @hidden */
  70234. export var filterPixelShader: {
  70235. name: string;
  70236. shader: string;
  70237. };
  70238. }
  70239. declare module "babylonjs/PostProcesses/filterPostProcess" {
  70240. import { Nullable } from "babylonjs/types";
  70241. import { Matrix } from "babylonjs/Maths/math.vector";
  70242. import { Camera } from "babylonjs/Cameras/camera";
  70243. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  70244. import { Engine } from "babylonjs/Engines/engine";
  70245. import "babylonjs/Shaders/filter.fragment";
  70246. /**
  70247. * Applies a kernel filter to the image
  70248. */
  70249. export class FilterPostProcess extends PostProcess {
  70250. /** The matrix to be applied to the image */
  70251. kernelMatrix: Matrix;
  70252. /**
  70253. *
  70254. * @param name The name of the effect.
  70255. * @param kernelMatrix The matrix to be applied to the image
  70256. * @param options The required width/height ratio to downsize to before computing the render pass.
  70257. * @param camera The camera to apply the render pass to.
  70258. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70259. * @param engine The engine which the post process will be applied. (default: current engine)
  70260. * @param reusable If the post process can be reused on the same frame. (default: false)
  70261. */
  70262. constructor(name: string,
  70263. /** The matrix to be applied to the image */
  70264. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  70265. }
  70266. }
  70267. declare module "babylonjs/Shaders/fxaa.fragment" {
  70268. /** @hidden */
  70269. export var fxaaPixelShader: {
  70270. name: string;
  70271. shader: string;
  70272. };
  70273. }
  70274. declare module "babylonjs/Shaders/fxaa.vertex" {
  70275. /** @hidden */
  70276. export var fxaaVertexShader: {
  70277. name: string;
  70278. shader: string;
  70279. };
  70280. }
  70281. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  70282. import { Nullable } from "babylonjs/types";
  70283. import { Camera } from "babylonjs/Cameras/camera";
  70284. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  70285. import { Engine } from "babylonjs/Engines/engine";
  70286. import "babylonjs/Shaders/fxaa.fragment";
  70287. import "babylonjs/Shaders/fxaa.vertex";
  70288. /**
  70289. * Fxaa post process
  70290. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  70291. */
  70292. export class FxaaPostProcess extends PostProcess {
  70293. /** @hidden */
  70294. texelWidth: number;
  70295. /** @hidden */
  70296. texelHeight: number;
  70297. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  70298. private _getDefines;
  70299. }
  70300. }
  70301. declare module "babylonjs/Shaders/grain.fragment" {
  70302. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  70303. /** @hidden */
  70304. export var grainPixelShader: {
  70305. name: string;
  70306. shader: string;
  70307. };
  70308. }
  70309. declare module "babylonjs/PostProcesses/grainPostProcess" {
  70310. import { Nullable } from "babylonjs/types";
  70311. import { Camera } from "babylonjs/Cameras/camera";
  70312. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  70313. import { Engine } from "babylonjs/Engines/engine";
  70314. import "babylonjs/Shaders/grain.fragment";
  70315. /**
  70316. * The GrainPostProcess adds noise to the image at mid luminance levels
  70317. */
  70318. export class GrainPostProcess extends PostProcess {
  70319. /**
  70320. * The intensity of the grain added (default: 30)
  70321. */
  70322. intensity: number;
  70323. /**
  70324. * If the grain should be randomized on every frame
  70325. */
  70326. animated: boolean;
  70327. /**
  70328. * Creates a new instance of @see GrainPostProcess
  70329. * @param name The name of the effect.
  70330. * @param options The required width/height ratio to downsize to before computing the render pass.
  70331. * @param camera The camera to apply the render pass to.
  70332. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70333. * @param engine The engine which the post process will be applied. (default: current engine)
  70334. * @param reusable If the post process can be reused on the same frame. (default: false)
  70335. * @param textureType Type of textures used when performing the post process. (default: 0)
  70336. * @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)
  70337. */
  70338. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  70339. }
  70340. }
  70341. declare module "babylonjs/Shaders/highlights.fragment" {
  70342. /** @hidden */
  70343. export var highlightsPixelShader: {
  70344. name: string;
  70345. shader: string;
  70346. };
  70347. }
  70348. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  70349. import { Nullable } from "babylonjs/types";
  70350. import { Camera } from "babylonjs/Cameras/camera";
  70351. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  70352. import { Engine } from "babylonjs/Engines/engine";
  70353. import "babylonjs/Shaders/highlights.fragment";
  70354. /**
  70355. * Extracts highlights from the image
  70356. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  70357. */
  70358. export class HighlightsPostProcess extends PostProcess {
  70359. /**
  70360. * Extracts highlights from the image
  70361. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  70362. * @param name The name of the effect.
  70363. * @param options The required width/height ratio to downsize to before computing the render pass.
  70364. * @param camera The camera to apply the render pass to.
  70365. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70366. * @param engine The engine which the post process will be applied. (default: current engine)
  70367. * @param reusable If the post process can be reused on the same frame. (default: false)
  70368. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  70369. */
  70370. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  70371. }
  70372. }
  70373. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  70374. /** @hidden */
  70375. export var mrtFragmentDeclaration: {
  70376. name: string;
  70377. shader: string;
  70378. };
  70379. }
  70380. declare module "babylonjs/Shaders/geometry.fragment" {
  70381. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  70382. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  70383. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  70384. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  70385. /** @hidden */
  70386. export var geometryPixelShader: {
  70387. name: string;
  70388. shader: string;
  70389. };
  70390. }
  70391. declare module "babylonjs/Shaders/geometry.vertex" {
  70392. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  70393. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  70394. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  70395. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  70396. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  70397. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  70398. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  70399. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  70400. /** @hidden */
  70401. export var geometryVertexShader: {
  70402. name: string;
  70403. shader: string;
  70404. };
  70405. }
  70406. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  70407. import { Matrix } from "babylonjs/Maths/math.vector";
  70408. import { SubMesh } from "babylonjs/Meshes/subMesh";
  70409. import { Mesh } from "babylonjs/Meshes/mesh";
  70410. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  70411. import { Effect } from "babylonjs/Materials/effect";
  70412. import { Scene } from "babylonjs/scene";
  70413. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  70414. import "babylonjs/Shaders/geometry.fragment";
  70415. import "babylonjs/Shaders/geometry.vertex";
  70416. /** @hidden */
  70417. interface ISavedTransformationMatrix {
  70418. world: Matrix;
  70419. viewProjection: Matrix;
  70420. }
  70421. /**
  70422. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  70423. */
  70424. export class GeometryBufferRenderer {
  70425. /**
  70426. * Constant used to retrieve the position texture index in the G-Buffer textures array
  70427. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  70428. */
  70429. static readonly POSITION_TEXTURE_TYPE: number;
  70430. /**
  70431. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  70432. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  70433. */
  70434. static readonly VELOCITY_TEXTURE_TYPE: number;
  70435. /**
  70436. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  70437. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  70438. */
  70439. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  70440. /**
  70441. * Dictionary used to store the previous transformation matrices of each rendered mesh
  70442. * in order to compute objects velocities when enableVelocity is set to "true"
  70443. * @hidden
  70444. */
  70445. _previousTransformationMatrices: {
  70446. [index: number]: ISavedTransformationMatrix;
  70447. };
  70448. /**
  70449. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  70450. * in order to compute objects velocities when enableVelocity is set to "true"
  70451. * @hidden
  70452. */
  70453. _previousBonesTransformationMatrices: {
  70454. [index: number]: Float32Array;
  70455. };
  70456. /**
  70457. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  70458. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  70459. */
  70460. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  70461. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  70462. renderTransparentMeshes: boolean;
  70463. private _scene;
  70464. private _multiRenderTarget;
  70465. private _ratio;
  70466. private _enablePosition;
  70467. private _enableVelocity;
  70468. private _enableReflectivity;
  70469. private _positionIndex;
  70470. private _velocityIndex;
  70471. private _reflectivityIndex;
  70472. protected _effect: Effect;
  70473. protected _cachedDefines: string;
  70474. /**
  70475. * Set the render list (meshes to be rendered) used in the G buffer.
  70476. */
  70477. set renderList(meshes: Mesh[]);
  70478. /**
  70479. * Gets wether or not G buffer are supported by the running hardware.
  70480. * This requires draw buffer supports
  70481. */
  70482. get isSupported(): boolean;
  70483. /**
  70484. * Returns the index of the given texture type in the G-Buffer textures array
  70485. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  70486. * @returns the index of the given texture type in the G-Buffer textures array
  70487. */
  70488. getTextureIndex(textureType: number): number;
  70489. /**
  70490. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  70491. */
  70492. get enablePosition(): boolean;
  70493. /**
  70494. * Sets whether or not objects positions are enabled for the G buffer.
  70495. */
  70496. set enablePosition(enable: boolean);
  70497. /**
  70498. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  70499. */
  70500. get enableVelocity(): boolean;
  70501. /**
  70502. * Sets wether or not objects velocities are enabled for the G buffer.
  70503. */
  70504. set enableVelocity(enable: boolean);
  70505. /**
  70506. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  70507. */
  70508. get enableReflectivity(): boolean;
  70509. /**
  70510. * Sets wether or not objects roughness are enabled for the G buffer.
  70511. */
  70512. set enableReflectivity(enable: boolean);
  70513. /**
  70514. * Gets the scene associated with the buffer.
  70515. */
  70516. get scene(): Scene;
  70517. /**
  70518. * Gets the ratio used by the buffer during its creation.
  70519. * How big is the buffer related to the main canvas.
  70520. */
  70521. get ratio(): number;
  70522. /** @hidden */
  70523. static _SceneComponentInitialization: (scene: Scene) => void;
  70524. /**
  70525. * Creates a new G Buffer for the scene
  70526. * @param scene The scene the buffer belongs to
  70527. * @param ratio How big is the buffer related to the main canvas.
  70528. */
  70529. constructor(scene: Scene, ratio?: number);
  70530. /**
  70531. * Checks wether everything is ready to render a submesh to the G buffer.
  70532. * @param subMesh the submesh to check readiness for
  70533. * @param useInstances is the mesh drawn using instance or not
  70534. * @returns true if ready otherwise false
  70535. */
  70536. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  70537. /**
  70538. * Gets the current underlying G Buffer.
  70539. * @returns the buffer
  70540. */
  70541. getGBuffer(): MultiRenderTarget;
  70542. /**
  70543. * Gets the number of samples used to render the buffer (anti aliasing).
  70544. */
  70545. get samples(): number;
  70546. /**
  70547. * Sets the number of samples used to render the buffer (anti aliasing).
  70548. */
  70549. set samples(value: number);
  70550. /**
  70551. * Disposes the renderer and frees up associated resources.
  70552. */
  70553. dispose(): void;
  70554. protected _createRenderTargets(): void;
  70555. private _copyBonesTransformationMatrices;
  70556. }
  70557. }
  70558. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  70559. import { Nullable } from "babylonjs/types";
  70560. import { Scene } from "babylonjs/scene";
  70561. import { ISceneComponent } from "babylonjs/sceneComponent";
  70562. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  70563. module "babylonjs/scene" {
  70564. interface Scene {
  70565. /** @hidden (Backing field) */
  70566. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  70567. /**
  70568. * Gets or Sets the current geometry buffer associated to the scene.
  70569. */
  70570. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  70571. /**
  70572. * Enables a GeometryBufferRender and associates it with the scene
  70573. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  70574. * @returns the GeometryBufferRenderer
  70575. */
  70576. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  70577. /**
  70578. * Disables the GeometryBufferRender associated with the scene
  70579. */
  70580. disableGeometryBufferRenderer(): void;
  70581. }
  70582. }
  70583. /**
  70584. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  70585. * in several rendering techniques.
  70586. */
  70587. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  70588. /**
  70589. * The component name helpful to identify the component in the list of scene components.
  70590. */
  70591. readonly name: string;
  70592. /**
  70593. * The scene the component belongs to.
  70594. */
  70595. scene: Scene;
  70596. /**
  70597. * Creates a new instance of the component for the given scene
  70598. * @param scene Defines the scene to register the component in
  70599. */
  70600. constructor(scene: Scene);
  70601. /**
  70602. * Registers the component in a given scene
  70603. */
  70604. register(): void;
  70605. /**
  70606. * Rebuilds the elements related to this component in case of
  70607. * context lost for instance.
  70608. */
  70609. rebuild(): void;
  70610. /**
  70611. * Disposes the component and the associated ressources
  70612. */
  70613. dispose(): void;
  70614. private _gatherRenderTargets;
  70615. }
  70616. }
  70617. declare module "babylonjs/Shaders/motionBlur.fragment" {
  70618. /** @hidden */
  70619. export var motionBlurPixelShader: {
  70620. name: string;
  70621. shader: string;
  70622. };
  70623. }
  70624. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  70625. import { Nullable } from "babylonjs/types";
  70626. import { Camera } from "babylonjs/Cameras/camera";
  70627. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  70628. import { Scene } from "babylonjs/scene";
  70629. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  70630. import "babylonjs/Animations/animatable";
  70631. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  70632. import "babylonjs/Shaders/motionBlur.fragment";
  70633. import { Engine } from "babylonjs/Engines/engine";
  70634. /**
  70635. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  70636. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  70637. * As an example, all you have to do is to create the post-process:
  70638. * var mb = new BABYLON.MotionBlurPostProcess(
  70639. * 'mb', // The name of the effect.
  70640. * scene, // The scene containing the objects to blur according to their velocity.
  70641. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  70642. * camera // The camera to apply the render pass to.
  70643. * );
  70644. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  70645. */
  70646. export class MotionBlurPostProcess extends PostProcess {
  70647. /**
  70648. * Defines how much the image is blurred by the movement. Default value is equal to 1
  70649. */
  70650. motionStrength: number;
  70651. /**
  70652. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  70653. */
  70654. get motionBlurSamples(): number;
  70655. /**
  70656. * Sets the number of iterations to be used for motion blur quality
  70657. */
  70658. set motionBlurSamples(samples: number);
  70659. private _motionBlurSamples;
  70660. private _geometryBufferRenderer;
  70661. /**
  70662. * Creates a new instance MotionBlurPostProcess
  70663. * @param name The name of the effect.
  70664. * @param scene The scene containing the objects to blur according to their velocity.
  70665. * @param options The required width/height ratio to downsize to before computing the render pass.
  70666. * @param camera The camera to apply the render pass to.
  70667. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70668. * @param engine The engine which the post process will be applied. (default: current engine)
  70669. * @param reusable If the post process can be reused on the same frame. (default: false)
  70670. * @param textureType Type of textures used when performing the post process. (default: 0)
  70671. * @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)
  70672. */
  70673. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  70674. /**
  70675. * Excludes the given skinned mesh from computing bones velocities.
  70676. * 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.
  70677. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  70678. */
  70679. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  70680. /**
  70681. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  70682. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  70683. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  70684. */
  70685. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  70686. /**
  70687. * Disposes the post process.
  70688. * @param camera The camera to dispose the post process on.
  70689. */
  70690. dispose(camera?: Camera): void;
  70691. }
  70692. }
  70693. declare module "babylonjs/Shaders/refraction.fragment" {
  70694. /** @hidden */
  70695. export var refractionPixelShader: {
  70696. name: string;
  70697. shader: string;
  70698. };
  70699. }
  70700. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  70701. import { Color3 } from "babylonjs/Maths/math.color";
  70702. import { Camera } from "babylonjs/Cameras/camera";
  70703. import { Texture } from "babylonjs/Materials/Textures/texture";
  70704. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  70705. import { Engine } from "babylonjs/Engines/engine";
  70706. import "babylonjs/Shaders/refraction.fragment";
  70707. /**
  70708. * Post process which applies a refractin texture
  70709. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  70710. */
  70711. export class RefractionPostProcess extends PostProcess {
  70712. /** the base color of the refraction (used to taint the rendering) */
  70713. color: Color3;
  70714. /** simulated refraction depth */
  70715. depth: number;
  70716. /** the coefficient of the base color (0 to remove base color tainting) */
  70717. colorLevel: number;
  70718. private _refTexture;
  70719. private _ownRefractionTexture;
  70720. /**
  70721. * Gets or sets the refraction texture
  70722. * Please note that you are responsible for disposing the texture if you set it manually
  70723. */
  70724. get refractionTexture(): Texture;
  70725. set refractionTexture(value: Texture);
  70726. /**
  70727. * Initializes the RefractionPostProcess
  70728. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  70729. * @param name The name of the effect.
  70730. * @param refractionTextureUrl Url of the refraction texture to use
  70731. * @param color the base color of the refraction (used to taint the rendering)
  70732. * @param depth simulated refraction depth
  70733. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  70734. * @param camera The camera to apply the render pass to.
  70735. * @param options The required width/height ratio to downsize to before computing the render pass.
  70736. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70737. * @param engine The engine which the post process will be applied. (default: current engine)
  70738. * @param reusable If the post process can be reused on the same frame. (default: false)
  70739. */
  70740. constructor(name: string, refractionTextureUrl: string,
  70741. /** the base color of the refraction (used to taint the rendering) */
  70742. color: Color3,
  70743. /** simulated refraction depth */
  70744. depth: number,
  70745. /** the coefficient of the base color (0 to remove base color tainting) */
  70746. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  70747. /**
  70748. * Disposes of the post process
  70749. * @param camera Camera to dispose post process on
  70750. */
  70751. dispose(camera: Camera): void;
  70752. }
  70753. }
  70754. declare module "babylonjs/Shaders/sharpen.fragment" {
  70755. /** @hidden */
  70756. export var sharpenPixelShader: {
  70757. name: string;
  70758. shader: string;
  70759. };
  70760. }
  70761. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  70762. import { Nullable } from "babylonjs/types";
  70763. import { Camera } from "babylonjs/Cameras/camera";
  70764. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  70765. import "babylonjs/Shaders/sharpen.fragment";
  70766. import { Engine } from "babylonjs/Engines/engine";
  70767. /**
  70768. * The SharpenPostProcess applies a sharpen kernel to every pixel
  70769. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  70770. */
  70771. export class SharpenPostProcess extends PostProcess {
  70772. /**
  70773. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  70774. */
  70775. colorAmount: number;
  70776. /**
  70777. * How much sharpness should be applied (default: 0.3)
  70778. */
  70779. edgeAmount: number;
  70780. /**
  70781. * Creates a new instance ConvolutionPostProcess
  70782. * @param name The name of the effect.
  70783. * @param options The required width/height ratio to downsize to before computing the render pass.
  70784. * @param camera The camera to apply the render pass to.
  70785. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70786. * @param engine The engine which the post process will be applied. (default: current engine)
  70787. * @param reusable If the post process can be reused on the same frame. (default: false)
  70788. * @param textureType Type of textures used when performing the post process. (default: 0)
  70789. * @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)
  70790. */
  70791. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  70792. }
  70793. }
  70794. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  70795. import { Nullable } from "babylonjs/types";
  70796. import { Camera } from "babylonjs/Cameras/camera";
  70797. import { Engine } from "babylonjs/Engines/engine";
  70798. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  70799. import { IInspectable } from "babylonjs/Misc/iInspectable";
  70800. /**
  70801. * PostProcessRenderPipeline
  70802. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  70803. */
  70804. export class PostProcessRenderPipeline {
  70805. private engine;
  70806. private _renderEffects;
  70807. private _renderEffectsForIsolatedPass;
  70808. /**
  70809. * List of inspectable custom properties (used by the Inspector)
  70810. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  70811. */
  70812. inspectableCustomProperties: IInspectable[];
  70813. /**
  70814. * @hidden
  70815. */
  70816. protected _cameras: Camera[];
  70817. /** @hidden */
  70818. _name: string;
  70819. /**
  70820. * Gets pipeline name
  70821. */
  70822. get name(): string;
  70823. /** Gets the list of attached cameras */
  70824. get cameras(): Camera[];
  70825. /**
  70826. * Initializes a PostProcessRenderPipeline
  70827. * @param engine engine to add the pipeline to
  70828. * @param name name of the pipeline
  70829. */
  70830. constructor(engine: Engine, name: string);
  70831. /**
  70832. * Gets the class name
  70833. * @returns "PostProcessRenderPipeline"
  70834. */
  70835. getClassName(): string;
  70836. /**
  70837. * If all the render effects in the pipeline are supported
  70838. */
  70839. get isSupported(): boolean;
  70840. /**
  70841. * Adds an effect to the pipeline
  70842. * @param renderEffect the effect to add
  70843. */
  70844. addEffect(renderEffect: PostProcessRenderEffect): void;
  70845. /** @hidden */
  70846. _rebuild(): void;
  70847. /** @hidden */
  70848. _enableEffect(renderEffectName: string, cameras: Camera): void;
  70849. /** @hidden */
  70850. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  70851. /** @hidden */
  70852. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  70853. /** @hidden */
  70854. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  70855. /** @hidden */
  70856. _attachCameras(cameras: Camera, unique: boolean): void;
  70857. /** @hidden */
  70858. _attachCameras(cameras: Camera[], unique: boolean): void;
  70859. /** @hidden */
  70860. _detachCameras(cameras: Camera): void;
  70861. /** @hidden */
  70862. _detachCameras(cameras: Nullable<Camera[]>): void;
  70863. /** @hidden */
  70864. _update(): void;
  70865. /** @hidden */
  70866. _reset(): void;
  70867. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  70868. /**
  70869. * Disposes of the pipeline
  70870. */
  70871. dispose(): void;
  70872. }
  70873. }
  70874. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  70875. import { Camera } from "babylonjs/Cameras/camera";
  70876. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  70877. /**
  70878. * PostProcessRenderPipelineManager class
  70879. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  70880. */
  70881. export class PostProcessRenderPipelineManager {
  70882. private _renderPipelines;
  70883. /**
  70884. * Initializes a PostProcessRenderPipelineManager
  70885. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  70886. */
  70887. constructor();
  70888. /**
  70889. * Gets the list of supported render pipelines
  70890. */
  70891. get supportedPipelines(): PostProcessRenderPipeline[];
  70892. /**
  70893. * Adds a pipeline to the manager
  70894. * @param renderPipeline The pipeline to add
  70895. */
  70896. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  70897. /**
  70898. * Attaches a camera to the pipeline
  70899. * @param renderPipelineName The name of the pipeline to attach to
  70900. * @param cameras the camera to attach
  70901. * @param unique if the camera can be attached multiple times to the pipeline
  70902. */
  70903. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  70904. /**
  70905. * Detaches a camera from the pipeline
  70906. * @param renderPipelineName The name of the pipeline to detach from
  70907. * @param cameras the camera to detach
  70908. */
  70909. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  70910. /**
  70911. * Enables an effect by name on a pipeline
  70912. * @param renderPipelineName the name of the pipeline to enable the effect in
  70913. * @param renderEffectName the name of the effect to enable
  70914. * @param cameras the cameras that the effect should be enabled on
  70915. */
  70916. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  70917. /**
  70918. * Disables an effect by name on a pipeline
  70919. * @param renderPipelineName the name of the pipeline to disable the effect in
  70920. * @param renderEffectName the name of the effect to disable
  70921. * @param cameras the cameras that the effect should be disabled on
  70922. */
  70923. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  70924. /**
  70925. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  70926. */
  70927. update(): void;
  70928. /** @hidden */
  70929. _rebuild(): void;
  70930. /**
  70931. * Disposes of the manager and pipelines
  70932. */
  70933. dispose(): void;
  70934. }
  70935. }
  70936. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  70937. import { ISceneComponent } from "babylonjs/sceneComponent";
  70938. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  70939. import { Scene } from "babylonjs/scene";
  70940. module "babylonjs/scene" {
  70941. interface Scene {
  70942. /** @hidden (Backing field) */
  70943. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  70944. /**
  70945. * Gets the postprocess render pipeline manager
  70946. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  70947. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  70948. */
  70949. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  70950. }
  70951. }
  70952. /**
  70953. * Defines the Render Pipeline scene component responsible to rendering pipelines
  70954. */
  70955. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  70956. /**
  70957. * The component name helpfull to identify the component in the list of scene components.
  70958. */
  70959. readonly name: string;
  70960. /**
  70961. * The scene the component belongs to.
  70962. */
  70963. scene: Scene;
  70964. /**
  70965. * Creates a new instance of the component for the given scene
  70966. * @param scene Defines the scene to register the component in
  70967. */
  70968. constructor(scene: Scene);
  70969. /**
  70970. * Registers the component in a given scene
  70971. */
  70972. register(): void;
  70973. /**
  70974. * Rebuilds the elements related to this component in case of
  70975. * context lost for instance.
  70976. */
  70977. rebuild(): void;
  70978. /**
  70979. * Disposes the component and the associated ressources
  70980. */
  70981. dispose(): void;
  70982. private _gatherRenderTargets;
  70983. }
  70984. }
  70985. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  70986. import { Nullable } from "babylonjs/types";
  70987. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  70988. import { Camera } from "babylonjs/Cameras/camera";
  70989. import { IDisposable } from "babylonjs/scene";
  70990. import { GlowLayer } from "babylonjs/Layers/glowLayer";
  70991. import { Scene } from "babylonjs/scene";
  70992. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  70993. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  70994. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  70995. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  70996. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  70997. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  70998. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  70999. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  71000. import { Animation } from "babylonjs/Animations/animation";
  71001. /**
  71002. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  71003. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  71004. */
  71005. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  71006. private _scene;
  71007. private _camerasToBeAttached;
  71008. /**
  71009. * ID of the sharpen post process,
  71010. */
  71011. private readonly SharpenPostProcessId;
  71012. /**
  71013. * @ignore
  71014. * ID of the image processing post process;
  71015. */
  71016. readonly ImageProcessingPostProcessId: string;
  71017. /**
  71018. * @ignore
  71019. * ID of the Fast Approximate Anti-Aliasing post process;
  71020. */
  71021. readonly FxaaPostProcessId: string;
  71022. /**
  71023. * ID of the chromatic aberration post process,
  71024. */
  71025. private readonly ChromaticAberrationPostProcessId;
  71026. /**
  71027. * ID of the grain post process
  71028. */
  71029. private readonly GrainPostProcessId;
  71030. /**
  71031. * Sharpen post process which will apply a sharpen convolution to enhance edges
  71032. */
  71033. sharpen: SharpenPostProcess;
  71034. private _sharpenEffect;
  71035. private bloom;
  71036. /**
  71037. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  71038. */
  71039. depthOfField: DepthOfFieldEffect;
  71040. /**
  71041. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  71042. */
  71043. fxaa: FxaaPostProcess;
  71044. /**
  71045. * Image post processing pass used to perform operations such as tone mapping or color grading.
  71046. */
  71047. imageProcessing: ImageProcessingPostProcess;
  71048. /**
  71049. * Chromatic aberration post process which will shift rgb colors in the image
  71050. */
  71051. chromaticAberration: ChromaticAberrationPostProcess;
  71052. private _chromaticAberrationEffect;
  71053. /**
  71054. * Grain post process which add noise to the image
  71055. */
  71056. grain: GrainPostProcess;
  71057. private _grainEffect;
  71058. /**
  71059. * Glow post process which adds a glow to emissive areas of the image
  71060. */
  71061. private _glowLayer;
  71062. /**
  71063. * Animations which can be used to tweak settings over a period of time
  71064. */
  71065. animations: Animation[];
  71066. private _imageProcessingConfigurationObserver;
  71067. private _sharpenEnabled;
  71068. private _bloomEnabled;
  71069. private _depthOfFieldEnabled;
  71070. private _depthOfFieldBlurLevel;
  71071. private _fxaaEnabled;
  71072. private _imageProcessingEnabled;
  71073. private _defaultPipelineTextureType;
  71074. private _bloomScale;
  71075. private _chromaticAberrationEnabled;
  71076. private _grainEnabled;
  71077. private _buildAllowed;
  71078. /**
  71079. * Gets active scene
  71080. */
  71081. get scene(): Scene;
  71082. /**
  71083. * Enable or disable the sharpen process from the pipeline
  71084. */
  71085. set sharpenEnabled(enabled: boolean);
  71086. get sharpenEnabled(): boolean;
  71087. private _resizeObserver;
  71088. private _hardwareScaleLevel;
  71089. private _bloomKernel;
  71090. /**
  71091. * Specifies the size of the bloom blur kernel, relative to the final output size
  71092. */
  71093. get bloomKernel(): number;
  71094. set bloomKernel(value: number);
  71095. /**
  71096. * Specifies the weight of the bloom in the final rendering
  71097. */
  71098. private _bloomWeight;
  71099. /**
  71100. * Specifies the luma threshold for the area that will be blurred by the bloom
  71101. */
  71102. private _bloomThreshold;
  71103. private _hdr;
  71104. /**
  71105. * The strength of the bloom.
  71106. */
  71107. set bloomWeight(value: number);
  71108. get bloomWeight(): number;
  71109. /**
  71110. * The strength of the bloom.
  71111. */
  71112. set bloomThreshold(value: number);
  71113. get bloomThreshold(): number;
  71114. /**
  71115. * The scale of the bloom, lower value will provide better performance.
  71116. */
  71117. set bloomScale(value: number);
  71118. get bloomScale(): number;
  71119. /**
  71120. * Enable or disable the bloom from the pipeline
  71121. */
  71122. set bloomEnabled(enabled: boolean);
  71123. get bloomEnabled(): boolean;
  71124. private _rebuildBloom;
  71125. /**
  71126. * If the depth of field is enabled.
  71127. */
  71128. get depthOfFieldEnabled(): boolean;
  71129. set depthOfFieldEnabled(enabled: boolean);
  71130. /**
  71131. * Blur level of the depth of field effect. (Higher blur will effect performance)
  71132. */
  71133. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  71134. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  71135. /**
  71136. * If the anti aliasing is enabled.
  71137. */
  71138. set fxaaEnabled(enabled: boolean);
  71139. get fxaaEnabled(): boolean;
  71140. private _samples;
  71141. /**
  71142. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  71143. */
  71144. set samples(sampleCount: number);
  71145. get samples(): number;
  71146. /**
  71147. * If image processing is enabled.
  71148. */
  71149. set imageProcessingEnabled(enabled: boolean);
  71150. get imageProcessingEnabled(): boolean;
  71151. /**
  71152. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  71153. */
  71154. set glowLayerEnabled(enabled: boolean);
  71155. get glowLayerEnabled(): boolean;
  71156. /**
  71157. * Gets the glow layer (or null if not defined)
  71158. */
  71159. get glowLayer(): Nullable<GlowLayer>;
  71160. /**
  71161. * Enable or disable the chromaticAberration process from the pipeline
  71162. */
  71163. set chromaticAberrationEnabled(enabled: boolean);
  71164. get chromaticAberrationEnabled(): boolean;
  71165. /**
  71166. * Enable or disable the grain process from the pipeline
  71167. */
  71168. set grainEnabled(enabled: boolean);
  71169. get grainEnabled(): boolean;
  71170. /**
  71171. * @constructor
  71172. * @param name - The rendering pipeline name (default: "")
  71173. * @param hdr - If high dynamic range textures should be used (default: true)
  71174. * @param scene - The scene linked to this pipeline (default: the last created scene)
  71175. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  71176. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  71177. */
  71178. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  71179. /**
  71180. * Get the class name
  71181. * @returns "DefaultRenderingPipeline"
  71182. */
  71183. getClassName(): string;
  71184. /**
  71185. * Force the compilation of the entire pipeline.
  71186. */
  71187. prepare(): void;
  71188. private _hasCleared;
  71189. private _prevPostProcess;
  71190. private _prevPrevPostProcess;
  71191. private _setAutoClearAndTextureSharing;
  71192. private _depthOfFieldSceneObserver;
  71193. private _buildPipeline;
  71194. private _disposePostProcesses;
  71195. /**
  71196. * Adds a camera to the pipeline
  71197. * @param camera the camera to be added
  71198. */
  71199. addCamera(camera: Camera): void;
  71200. /**
  71201. * Removes a camera from the pipeline
  71202. * @param camera the camera to remove
  71203. */
  71204. removeCamera(camera: Camera): void;
  71205. /**
  71206. * Dispose of the pipeline and stop all post processes
  71207. */
  71208. dispose(): void;
  71209. /**
  71210. * Serialize the rendering pipeline (Used when exporting)
  71211. * @returns the serialized object
  71212. */
  71213. serialize(): any;
  71214. /**
  71215. * Parse the serialized pipeline
  71216. * @param source Source pipeline.
  71217. * @param scene The scene to load the pipeline to.
  71218. * @param rootUrl The URL of the serialized pipeline.
  71219. * @returns An instantiated pipeline from the serialized object.
  71220. */
  71221. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  71222. }
  71223. }
  71224. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  71225. /** @hidden */
  71226. export var lensHighlightsPixelShader: {
  71227. name: string;
  71228. shader: string;
  71229. };
  71230. }
  71231. declare module "babylonjs/Shaders/depthOfField.fragment" {
  71232. /** @hidden */
  71233. export var depthOfFieldPixelShader: {
  71234. name: string;
  71235. shader: string;
  71236. };
  71237. }
  71238. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  71239. import { Camera } from "babylonjs/Cameras/camera";
  71240. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  71241. import { Scene } from "babylonjs/scene";
  71242. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  71243. import "babylonjs/Shaders/chromaticAberration.fragment";
  71244. import "babylonjs/Shaders/lensHighlights.fragment";
  71245. import "babylonjs/Shaders/depthOfField.fragment";
  71246. /**
  71247. * BABYLON.JS Chromatic Aberration GLSL Shader
  71248. * Author: Olivier Guyot
  71249. * Separates very slightly R, G and B colors on the edges of the screen
  71250. * Inspired by Francois Tarlier & Martins Upitis
  71251. */
  71252. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  71253. /**
  71254. * @ignore
  71255. * The chromatic aberration PostProcess id in the pipeline
  71256. */
  71257. LensChromaticAberrationEffect: string;
  71258. /**
  71259. * @ignore
  71260. * The highlights enhancing PostProcess id in the pipeline
  71261. */
  71262. HighlightsEnhancingEffect: string;
  71263. /**
  71264. * @ignore
  71265. * The depth-of-field PostProcess id in the pipeline
  71266. */
  71267. LensDepthOfFieldEffect: string;
  71268. private _scene;
  71269. private _depthTexture;
  71270. private _grainTexture;
  71271. private _chromaticAberrationPostProcess;
  71272. private _highlightsPostProcess;
  71273. private _depthOfFieldPostProcess;
  71274. private _edgeBlur;
  71275. private _grainAmount;
  71276. private _chromaticAberration;
  71277. private _distortion;
  71278. private _highlightsGain;
  71279. private _highlightsThreshold;
  71280. private _dofDistance;
  71281. private _dofAperture;
  71282. private _dofDarken;
  71283. private _dofPentagon;
  71284. private _blurNoise;
  71285. /**
  71286. * @constructor
  71287. *
  71288. * Effect parameters are as follow:
  71289. * {
  71290. * chromatic_aberration: number; // from 0 to x (1 for realism)
  71291. * edge_blur: number; // from 0 to x (1 for realism)
  71292. * distortion: number; // from 0 to x (1 for realism)
  71293. * grain_amount: number; // from 0 to 1
  71294. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  71295. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  71296. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  71297. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  71298. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  71299. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  71300. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  71301. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  71302. * }
  71303. * Note: if an effect parameter is unset, effect is disabled
  71304. *
  71305. * @param name The rendering pipeline name
  71306. * @param parameters - An object containing all parameters (see above)
  71307. * @param scene The scene linked to this pipeline
  71308. * @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)
  71309. * @param cameras The array of cameras that the rendering pipeline will be attached to
  71310. */
  71311. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  71312. /**
  71313. * Get the class name
  71314. * @returns "LensRenderingPipeline"
  71315. */
  71316. getClassName(): string;
  71317. /**
  71318. * Gets associated scene
  71319. */
  71320. get scene(): Scene;
  71321. /**
  71322. * Gets or sets the edge blur
  71323. */
  71324. get edgeBlur(): number;
  71325. set edgeBlur(value: number);
  71326. /**
  71327. * Gets or sets the grain amount
  71328. */
  71329. get grainAmount(): number;
  71330. set grainAmount(value: number);
  71331. /**
  71332. * Gets or sets the chromatic aberration amount
  71333. */
  71334. get chromaticAberration(): number;
  71335. set chromaticAberration(value: number);
  71336. /**
  71337. * Gets or sets the depth of field aperture
  71338. */
  71339. get dofAperture(): number;
  71340. set dofAperture(value: number);
  71341. /**
  71342. * Gets or sets the edge distortion
  71343. */
  71344. get edgeDistortion(): number;
  71345. set edgeDistortion(value: number);
  71346. /**
  71347. * Gets or sets the depth of field distortion
  71348. */
  71349. get dofDistortion(): number;
  71350. set dofDistortion(value: number);
  71351. /**
  71352. * Gets or sets the darken out of focus amount
  71353. */
  71354. get darkenOutOfFocus(): number;
  71355. set darkenOutOfFocus(value: number);
  71356. /**
  71357. * Gets or sets a boolean indicating if blur noise is enabled
  71358. */
  71359. get blurNoise(): boolean;
  71360. set blurNoise(value: boolean);
  71361. /**
  71362. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  71363. */
  71364. get pentagonBokeh(): boolean;
  71365. set pentagonBokeh(value: boolean);
  71366. /**
  71367. * Gets or sets the highlight grain amount
  71368. */
  71369. get highlightsGain(): number;
  71370. set highlightsGain(value: number);
  71371. /**
  71372. * Gets or sets the highlight threshold
  71373. */
  71374. get highlightsThreshold(): number;
  71375. set highlightsThreshold(value: number);
  71376. /**
  71377. * Sets the amount of blur at the edges
  71378. * @param amount blur amount
  71379. */
  71380. setEdgeBlur(amount: number): void;
  71381. /**
  71382. * Sets edge blur to 0
  71383. */
  71384. disableEdgeBlur(): void;
  71385. /**
  71386. * Sets the amout of grain
  71387. * @param amount Amount of grain
  71388. */
  71389. setGrainAmount(amount: number): void;
  71390. /**
  71391. * Set grain amount to 0
  71392. */
  71393. disableGrain(): void;
  71394. /**
  71395. * Sets the chromatic aberration amount
  71396. * @param amount amount of chromatic aberration
  71397. */
  71398. setChromaticAberration(amount: number): void;
  71399. /**
  71400. * Sets chromatic aberration amount to 0
  71401. */
  71402. disableChromaticAberration(): void;
  71403. /**
  71404. * Sets the EdgeDistortion amount
  71405. * @param amount amount of EdgeDistortion
  71406. */
  71407. setEdgeDistortion(amount: number): void;
  71408. /**
  71409. * Sets edge distortion to 0
  71410. */
  71411. disableEdgeDistortion(): void;
  71412. /**
  71413. * Sets the FocusDistance amount
  71414. * @param amount amount of FocusDistance
  71415. */
  71416. setFocusDistance(amount: number): void;
  71417. /**
  71418. * Disables depth of field
  71419. */
  71420. disableDepthOfField(): void;
  71421. /**
  71422. * Sets the Aperture amount
  71423. * @param amount amount of Aperture
  71424. */
  71425. setAperture(amount: number): void;
  71426. /**
  71427. * Sets the DarkenOutOfFocus amount
  71428. * @param amount amount of DarkenOutOfFocus
  71429. */
  71430. setDarkenOutOfFocus(amount: number): void;
  71431. private _pentagonBokehIsEnabled;
  71432. /**
  71433. * Creates a pentagon bokeh effect
  71434. */
  71435. enablePentagonBokeh(): void;
  71436. /**
  71437. * Disables the pentagon bokeh effect
  71438. */
  71439. disablePentagonBokeh(): void;
  71440. /**
  71441. * Enables noise blur
  71442. */
  71443. enableNoiseBlur(): void;
  71444. /**
  71445. * Disables noise blur
  71446. */
  71447. disableNoiseBlur(): void;
  71448. /**
  71449. * Sets the HighlightsGain amount
  71450. * @param amount amount of HighlightsGain
  71451. */
  71452. setHighlightsGain(amount: number): void;
  71453. /**
  71454. * Sets the HighlightsThreshold amount
  71455. * @param amount amount of HighlightsThreshold
  71456. */
  71457. setHighlightsThreshold(amount: number): void;
  71458. /**
  71459. * Disables highlights
  71460. */
  71461. disableHighlights(): void;
  71462. /**
  71463. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  71464. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  71465. */
  71466. dispose(disableDepthRender?: boolean): void;
  71467. private _createChromaticAberrationPostProcess;
  71468. private _createHighlightsPostProcess;
  71469. private _createDepthOfFieldPostProcess;
  71470. private _createGrainTexture;
  71471. }
  71472. }
  71473. declare module "babylonjs/Shaders/ssao2.fragment" {
  71474. /** @hidden */
  71475. export var ssao2PixelShader: {
  71476. name: string;
  71477. shader: string;
  71478. };
  71479. }
  71480. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  71481. /** @hidden */
  71482. export var ssaoCombinePixelShader: {
  71483. name: string;
  71484. shader: string;
  71485. };
  71486. }
  71487. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  71488. import { Camera } from "babylonjs/Cameras/camera";
  71489. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  71490. import { Scene } from "babylonjs/scene";
  71491. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  71492. import "babylonjs/Shaders/ssao2.fragment";
  71493. import "babylonjs/Shaders/ssaoCombine.fragment";
  71494. /**
  71495. * Render pipeline to produce ssao effect
  71496. */
  71497. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  71498. /**
  71499. * @ignore
  71500. * The PassPostProcess id in the pipeline that contains the original scene color
  71501. */
  71502. SSAOOriginalSceneColorEffect: string;
  71503. /**
  71504. * @ignore
  71505. * The SSAO PostProcess id in the pipeline
  71506. */
  71507. SSAORenderEffect: string;
  71508. /**
  71509. * @ignore
  71510. * The horizontal blur PostProcess id in the pipeline
  71511. */
  71512. SSAOBlurHRenderEffect: string;
  71513. /**
  71514. * @ignore
  71515. * The vertical blur PostProcess id in the pipeline
  71516. */
  71517. SSAOBlurVRenderEffect: string;
  71518. /**
  71519. * @ignore
  71520. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  71521. */
  71522. SSAOCombineRenderEffect: string;
  71523. /**
  71524. * The output strength of the SSAO post-process. Default value is 1.0.
  71525. */
  71526. totalStrength: number;
  71527. /**
  71528. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  71529. */
  71530. maxZ: number;
  71531. /**
  71532. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  71533. */
  71534. minZAspect: number;
  71535. private _samples;
  71536. /**
  71537. * Number of samples used for the SSAO calculations. Default value is 8
  71538. */
  71539. set samples(n: number);
  71540. get samples(): number;
  71541. private _textureSamples;
  71542. /**
  71543. * Number of samples to use for antialiasing
  71544. */
  71545. set textureSamples(n: number);
  71546. get textureSamples(): number;
  71547. /**
  71548. * Ratio object used for SSAO ratio and blur ratio
  71549. */
  71550. private _ratio;
  71551. /**
  71552. * Dynamically generated sphere sampler.
  71553. */
  71554. private _sampleSphere;
  71555. /**
  71556. * Blur filter offsets
  71557. */
  71558. private _samplerOffsets;
  71559. private _expensiveBlur;
  71560. /**
  71561. * If bilateral blur should be used
  71562. */
  71563. set expensiveBlur(b: boolean);
  71564. get expensiveBlur(): boolean;
  71565. /**
  71566. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  71567. */
  71568. radius: number;
  71569. /**
  71570. * The base color of the SSAO post-process
  71571. * The final result is "base + ssao" between [0, 1]
  71572. */
  71573. base: number;
  71574. /**
  71575. * Support test.
  71576. */
  71577. static get IsSupported(): boolean;
  71578. private _scene;
  71579. private _depthTexture;
  71580. private _normalTexture;
  71581. private _randomTexture;
  71582. private _originalColorPostProcess;
  71583. private _ssaoPostProcess;
  71584. private _blurHPostProcess;
  71585. private _blurVPostProcess;
  71586. private _ssaoCombinePostProcess;
  71587. /**
  71588. * Gets active scene
  71589. */
  71590. get scene(): Scene;
  71591. /**
  71592. * @constructor
  71593. * @param name The rendering pipeline name
  71594. * @param scene The scene linked to this pipeline
  71595. * @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 }
  71596. * @param cameras The array of cameras that the rendering pipeline will be attached to
  71597. */
  71598. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  71599. /**
  71600. * Get the class name
  71601. * @returns "SSAO2RenderingPipeline"
  71602. */
  71603. getClassName(): string;
  71604. /**
  71605. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  71606. */
  71607. dispose(disableGeometryBufferRenderer?: boolean): void;
  71608. private _createBlurPostProcess;
  71609. /** @hidden */
  71610. _rebuild(): void;
  71611. private _bits;
  71612. private _radicalInverse_VdC;
  71613. private _hammersley;
  71614. private _hemisphereSample_uniform;
  71615. private _generateHemisphere;
  71616. private _createSSAOPostProcess;
  71617. private _createSSAOCombinePostProcess;
  71618. private _createRandomTexture;
  71619. /**
  71620. * Serialize the rendering pipeline (Used when exporting)
  71621. * @returns the serialized object
  71622. */
  71623. serialize(): any;
  71624. /**
  71625. * Parse the serialized pipeline
  71626. * @param source Source pipeline.
  71627. * @param scene The scene to load the pipeline to.
  71628. * @param rootUrl The URL of the serialized pipeline.
  71629. * @returns An instantiated pipeline from the serialized object.
  71630. */
  71631. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  71632. }
  71633. }
  71634. declare module "babylonjs/Shaders/ssao.fragment" {
  71635. /** @hidden */
  71636. export var ssaoPixelShader: {
  71637. name: string;
  71638. shader: string;
  71639. };
  71640. }
  71641. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  71642. import { Camera } from "babylonjs/Cameras/camera";
  71643. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  71644. import { Scene } from "babylonjs/scene";
  71645. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  71646. import "babylonjs/Shaders/ssao.fragment";
  71647. import "babylonjs/Shaders/ssaoCombine.fragment";
  71648. /**
  71649. * Render pipeline to produce ssao effect
  71650. */
  71651. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  71652. /**
  71653. * @ignore
  71654. * The PassPostProcess id in the pipeline that contains the original scene color
  71655. */
  71656. SSAOOriginalSceneColorEffect: string;
  71657. /**
  71658. * @ignore
  71659. * The SSAO PostProcess id in the pipeline
  71660. */
  71661. SSAORenderEffect: string;
  71662. /**
  71663. * @ignore
  71664. * The horizontal blur PostProcess id in the pipeline
  71665. */
  71666. SSAOBlurHRenderEffect: string;
  71667. /**
  71668. * @ignore
  71669. * The vertical blur PostProcess id in the pipeline
  71670. */
  71671. SSAOBlurVRenderEffect: string;
  71672. /**
  71673. * @ignore
  71674. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  71675. */
  71676. SSAOCombineRenderEffect: string;
  71677. /**
  71678. * The output strength of the SSAO post-process. Default value is 1.0.
  71679. */
  71680. totalStrength: number;
  71681. /**
  71682. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  71683. */
  71684. radius: number;
  71685. /**
  71686. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  71687. * Must not be equal to fallOff and superior to fallOff.
  71688. * Default value is 0.0075
  71689. */
  71690. area: number;
  71691. /**
  71692. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  71693. * Must not be equal to area and inferior to area.
  71694. * Default value is 0.000001
  71695. */
  71696. fallOff: number;
  71697. /**
  71698. * The base color of the SSAO post-process
  71699. * The final result is "base + ssao" between [0, 1]
  71700. */
  71701. base: number;
  71702. private _scene;
  71703. private _depthTexture;
  71704. private _randomTexture;
  71705. private _originalColorPostProcess;
  71706. private _ssaoPostProcess;
  71707. private _blurHPostProcess;
  71708. private _blurVPostProcess;
  71709. private _ssaoCombinePostProcess;
  71710. private _firstUpdate;
  71711. /**
  71712. * Gets active scene
  71713. */
  71714. get scene(): Scene;
  71715. /**
  71716. * @constructor
  71717. * @param name - The rendering pipeline name
  71718. * @param scene - The scene linked to this pipeline
  71719. * @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 }
  71720. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  71721. */
  71722. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  71723. /**
  71724. * Get the class name
  71725. * @returns "SSAORenderingPipeline"
  71726. */
  71727. getClassName(): string;
  71728. /**
  71729. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  71730. */
  71731. dispose(disableDepthRender?: boolean): void;
  71732. private _createBlurPostProcess;
  71733. /** @hidden */
  71734. _rebuild(): void;
  71735. private _createSSAOPostProcess;
  71736. private _createSSAOCombinePostProcess;
  71737. private _createRandomTexture;
  71738. }
  71739. }
  71740. declare module "babylonjs/Shaders/screenSpaceReflection.fragment" {
  71741. /** @hidden */
  71742. export var screenSpaceReflectionPixelShader: {
  71743. name: string;
  71744. shader: string;
  71745. };
  71746. }
  71747. declare module "babylonjs/PostProcesses/screenSpaceReflectionPostProcess" {
  71748. import { Nullable } from "babylonjs/types";
  71749. import { Camera } from "babylonjs/Cameras/camera";
  71750. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  71751. import { Scene } from "babylonjs/scene";
  71752. import "babylonjs/Shaders/screenSpaceReflection.fragment";
  71753. import { Engine } from "babylonjs/Engines/engine";
  71754. /**
  71755. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  71756. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  71757. */
  71758. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  71759. /**
  71760. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  71761. */
  71762. threshold: number;
  71763. /**
  71764. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  71765. */
  71766. strength: number;
  71767. /**
  71768. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  71769. */
  71770. reflectionSpecularFalloffExponent: number;
  71771. /**
  71772. * 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]
  71773. */
  71774. step: number;
  71775. /**
  71776. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  71777. */
  71778. roughnessFactor: number;
  71779. private _geometryBufferRenderer;
  71780. private _enableSmoothReflections;
  71781. private _reflectionSamples;
  71782. private _smoothSteps;
  71783. /**
  71784. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  71785. * @param name The name of the effect.
  71786. * @param scene The scene containing the objects to calculate reflections.
  71787. * @param options The required width/height ratio to downsize to before computing the render pass.
  71788. * @param camera The camera to apply the render pass to.
  71789. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71790. * @param engine The engine which the post process will be applied. (default: current engine)
  71791. * @param reusable If the post process can be reused on the same frame. (default: false)
  71792. * @param textureType Type of textures used when performing the post process. (default: 0)
  71793. * @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)
  71794. */
  71795. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  71796. /**
  71797. * Gets wether or not smoothing reflections is enabled.
  71798. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  71799. */
  71800. get enableSmoothReflections(): boolean;
  71801. /**
  71802. * Sets wether or not smoothing reflections is enabled.
  71803. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  71804. */
  71805. set enableSmoothReflections(enabled: boolean);
  71806. /**
  71807. * Gets the number of samples taken while computing reflections. More samples count is high,
  71808. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  71809. */
  71810. get reflectionSamples(): number;
  71811. /**
  71812. * Sets the number of samples taken while computing reflections. More samples count is high,
  71813. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  71814. */
  71815. set reflectionSamples(samples: number);
  71816. /**
  71817. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  71818. * more the post-process will require GPU power and can generate a drop in FPS.
  71819. * Default value (5.0) work pretty well in all cases but can be adjusted.
  71820. */
  71821. get smoothSteps(): number;
  71822. set smoothSteps(steps: number);
  71823. private _updateEffectDefines;
  71824. }
  71825. }
  71826. declare module "babylonjs/Shaders/standard.fragment" {
  71827. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  71828. /** @hidden */
  71829. export var standardPixelShader: {
  71830. name: string;
  71831. shader: string;
  71832. };
  71833. }
  71834. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  71835. import { Nullable } from "babylonjs/types";
  71836. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  71837. import { Camera } from "babylonjs/Cameras/camera";
  71838. import { Texture } from "babylonjs/Materials/Textures/texture";
  71839. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  71840. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  71841. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  71842. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  71843. import { IDisposable } from "babylonjs/scene";
  71844. import { SpotLight } from "babylonjs/Lights/spotLight";
  71845. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  71846. import { Scene } from "babylonjs/scene";
  71847. import { ScreenSpaceReflectionPostProcess } from "babylonjs/PostProcesses/screenSpaceReflectionPostProcess";
  71848. import { Animation } from "babylonjs/Animations/animation";
  71849. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  71850. import "babylonjs/Shaders/standard.fragment";
  71851. /**
  71852. * Standard rendering pipeline
  71853. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  71854. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  71855. */
  71856. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  71857. /**
  71858. * Public members
  71859. */
  71860. /**
  71861. * Post-process which contains the original scene color before the pipeline applies all the effects
  71862. */
  71863. originalPostProcess: Nullable<PostProcess>;
  71864. /**
  71865. * Post-process used to down scale an image x4
  71866. */
  71867. downSampleX4PostProcess: Nullable<PostProcess>;
  71868. /**
  71869. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  71870. */
  71871. brightPassPostProcess: Nullable<PostProcess>;
  71872. /**
  71873. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  71874. */
  71875. blurHPostProcesses: PostProcess[];
  71876. /**
  71877. * Post-process array storing all the vertical blur post-processes used by the pipeline
  71878. */
  71879. blurVPostProcesses: PostProcess[];
  71880. /**
  71881. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  71882. */
  71883. textureAdderPostProcess: Nullable<PostProcess>;
  71884. /**
  71885. * Post-process used to create volumetric lighting effect
  71886. */
  71887. volumetricLightPostProcess: Nullable<PostProcess>;
  71888. /**
  71889. * Post-process used to smooth the previous volumetric light post-process on the X axis
  71890. */
  71891. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  71892. /**
  71893. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  71894. */
  71895. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  71896. /**
  71897. * Post-process used to merge the volumetric light effect and the real scene color
  71898. */
  71899. volumetricLightMergePostProces: Nullable<PostProcess>;
  71900. /**
  71901. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  71902. */
  71903. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  71904. /**
  71905. * Base post-process used to calculate the average luminance of the final image for HDR
  71906. */
  71907. luminancePostProcess: Nullable<PostProcess>;
  71908. /**
  71909. * Post-processes used to create down sample post-processes in order to get
  71910. * the average luminance of the final image for HDR
  71911. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  71912. */
  71913. luminanceDownSamplePostProcesses: PostProcess[];
  71914. /**
  71915. * Post-process used to create a HDR effect (light adaptation)
  71916. */
  71917. hdrPostProcess: Nullable<PostProcess>;
  71918. /**
  71919. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  71920. */
  71921. textureAdderFinalPostProcess: Nullable<PostProcess>;
  71922. /**
  71923. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  71924. */
  71925. lensFlareFinalPostProcess: Nullable<PostProcess>;
  71926. /**
  71927. * Post-process used to merge the final HDR post-process and the real scene color
  71928. */
  71929. hdrFinalPostProcess: Nullable<PostProcess>;
  71930. /**
  71931. * Post-process used to create a lens flare effect
  71932. */
  71933. lensFlarePostProcess: Nullable<PostProcess>;
  71934. /**
  71935. * Post-process that merges the result of the lens flare post-process and the real scene color
  71936. */
  71937. lensFlareComposePostProcess: Nullable<PostProcess>;
  71938. /**
  71939. * Post-process used to create a motion blur effect
  71940. */
  71941. motionBlurPostProcess: Nullable<PostProcess>;
  71942. /**
  71943. * Post-process used to create a depth of field effect
  71944. */
  71945. depthOfFieldPostProcess: Nullable<PostProcess>;
  71946. /**
  71947. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  71948. */
  71949. fxaaPostProcess: Nullable<FxaaPostProcess>;
  71950. /**
  71951. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  71952. */
  71953. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  71954. /**
  71955. * Represents the brightness threshold in order to configure the illuminated surfaces
  71956. */
  71957. brightThreshold: number;
  71958. /**
  71959. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  71960. */
  71961. blurWidth: number;
  71962. /**
  71963. * Sets if the blur for highlighted surfaces must be only horizontal
  71964. */
  71965. horizontalBlur: boolean;
  71966. /**
  71967. * Gets the overall exposure used by the pipeline
  71968. */
  71969. get exposure(): number;
  71970. /**
  71971. * Sets the overall exposure used by the pipeline
  71972. */
  71973. set exposure(value: number);
  71974. /**
  71975. * Texture used typically to simulate "dirty" on camera lens
  71976. */
  71977. lensTexture: Nullable<Texture>;
  71978. /**
  71979. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  71980. */
  71981. volumetricLightCoefficient: number;
  71982. /**
  71983. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  71984. */
  71985. volumetricLightPower: number;
  71986. /**
  71987. * Used the set the blur intensity to smooth the volumetric lights
  71988. */
  71989. volumetricLightBlurScale: number;
  71990. /**
  71991. * Light (spot or directional) used to generate the volumetric lights rays
  71992. * The source light must have a shadow generate so the pipeline can get its
  71993. * depth map
  71994. */
  71995. sourceLight: Nullable<SpotLight | DirectionalLight>;
  71996. /**
  71997. * For eye adaptation, represents the minimum luminance the eye can see
  71998. */
  71999. hdrMinimumLuminance: number;
  72000. /**
  72001. * For eye adaptation, represents the decrease luminance speed
  72002. */
  72003. hdrDecreaseRate: number;
  72004. /**
  72005. * For eye adaptation, represents the increase luminance speed
  72006. */
  72007. hdrIncreaseRate: number;
  72008. /**
  72009. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  72010. */
  72011. get hdrAutoExposure(): boolean;
  72012. /**
  72013. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  72014. */
  72015. set hdrAutoExposure(value: boolean);
  72016. /**
  72017. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  72018. */
  72019. lensColorTexture: Nullable<Texture>;
  72020. /**
  72021. * The overall strengh for the lens flare effect
  72022. */
  72023. lensFlareStrength: number;
  72024. /**
  72025. * Dispersion coefficient for lens flare ghosts
  72026. */
  72027. lensFlareGhostDispersal: number;
  72028. /**
  72029. * Main lens flare halo width
  72030. */
  72031. lensFlareHaloWidth: number;
  72032. /**
  72033. * Based on the lens distortion effect, defines how much the lens flare result
  72034. * is distorted
  72035. */
  72036. lensFlareDistortionStrength: number;
  72037. /**
  72038. * Configures the blur intensity used for for lens flare (halo)
  72039. */
  72040. lensFlareBlurWidth: number;
  72041. /**
  72042. * Lens star texture must be used to simulate rays on the flares and is available
  72043. * in the documentation
  72044. */
  72045. lensStarTexture: Nullable<Texture>;
  72046. /**
  72047. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  72048. * flare effect by taking account of the dirt texture
  72049. */
  72050. lensFlareDirtTexture: Nullable<Texture>;
  72051. /**
  72052. * Represents the focal length for the depth of field effect
  72053. */
  72054. depthOfFieldDistance: number;
  72055. /**
  72056. * Represents the blur intensity for the blurred part of the depth of field effect
  72057. */
  72058. depthOfFieldBlurWidth: number;
  72059. /**
  72060. * Gets how much the image is blurred by the movement while using the motion blur post-process
  72061. */
  72062. get motionStrength(): number;
  72063. /**
  72064. * Sets how much the image is blurred by the movement while using the motion blur post-process
  72065. */
  72066. set motionStrength(strength: number);
  72067. /**
  72068. * Gets wether or not the motion blur post-process is object based or screen based.
  72069. */
  72070. get objectBasedMotionBlur(): boolean;
  72071. /**
  72072. * Sets wether or not the motion blur post-process should be object based or screen based
  72073. */
  72074. set objectBasedMotionBlur(value: boolean);
  72075. /**
  72076. * List of animations for the pipeline (IAnimatable implementation)
  72077. */
  72078. animations: Animation[];
  72079. /**
  72080. * Private members
  72081. */
  72082. private _scene;
  72083. private _currentDepthOfFieldSource;
  72084. private _basePostProcess;
  72085. private _fixedExposure;
  72086. private _currentExposure;
  72087. private _hdrAutoExposure;
  72088. private _hdrCurrentLuminance;
  72089. private _motionStrength;
  72090. private _isObjectBasedMotionBlur;
  72091. private _floatTextureType;
  72092. private _camerasToBeAttached;
  72093. private _ratio;
  72094. private _bloomEnabled;
  72095. private _depthOfFieldEnabled;
  72096. private _vlsEnabled;
  72097. private _lensFlareEnabled;
  72098. private _hdrEnabled;
  72099. private _motionBlurEnabled;
  72100. private _fxaaEnabled;
  72101. private _screenSpaceReflectionsEnabled;
  72102. private _motionBlurSamples;
  72103. private _volumetricLightStepsCount;
  72104. private _samples;
  72105. /**
  72106. * @ignore
  72107. * Specifies if the bloom pipeline is enabled
  72108. */
  72109. get BloomEnabled(): boolean;
  72110. set BloomEnabled(enabled: boolean);
  72111. /**
  72112. * @ignore
  72113. * Specifies if the depth of field pipeline is enabed
  72114. */
  72115. get DepthOfFieldEnabled(): boolean;
  72116. set DepthOfFieldEnabled(enabled: boolean);
  72117. /**
  72118. * @ignore
  72119. * Specifies if the lens flare pipeline is enabed
  72120. */
  72121. get LensFlareEnabled(): boolean;
  72122. set LensFlareEnabled(enabled: boolean);
  72123. /**
  72124. * @ignore
  72125. * Specifies if the HDR pipeline is enabled
  72126. */
  72127. get HDREnabled(): boolean;
  72128. set HDREnabled(enabled: boolean);
  72129. /**
  72130. * @ignore
  72131. * Specifies if the volumetric lights scattering effect is enabled
  72132. */
  72133. get VLSEnabled(): boolean;
  72134. set VLSEnabled(enabled: boolean);
  72135. /**
  72136. * @ignore
  72137. * Specifies if the motion blur effect is enabled
  72138. */
  72139. get MotionBlurEnabled(): boolean;
  72140. set MotionBlurEnabled(enabled: boolean);
  72141. /**
  72142. * Specifies if anti-aliasing is enabled
  72143. */
  72144. get fxaaEnabled(): boolean;
  72145. set fxaaEnabled(enabled: boolean);
  72146. /**
  72147. * Specifies if screen space reflections are enabled.
  72148. */
  72149. get screenSpaceReflectionsEnabled(): boolean;
  72150. set screenSpaceReflectionsEnabled(enabled: boolean);
  72151. /**
  72152. * Specifies the number of steps used to calculate the volumetric lights
  72153. * Typically in interval [50, 200]
  72154. */
  72155. get volumetricLightStepsCount(): number;
  72156. set volumetricLightStepsCount(count: number);
  72157. /**
  72158. * Specifies the number of samples used for the motion blur effect
  72159. * Typically in interval [16, 64]
  72160. */
  72161. get motionBlurSamples(): number;
  72162. set motionBlurSamples(samples: number);
  72163. /**
  72164. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  72165. */
  72166. get samples(): number;
  72167. set samples(sampleCount: number);
  72168. /**
  72169. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  72170. * @constructor
  72171. * @param name The rendering pipeline name
  72172. * @param scene The scene linked to this pipeline
  72173. * @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)
  72174. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  72175. * @param cameras The array of cameras that the rendering pipeline will be attached to
  72176. */
  72177. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  72178. private _buildPipeline;
  72179. private _createDownSampleX4PostProcess;
  72180. private _createBrightPassPostProcess;
  72181. private _createBlurPostProcesses;
  72182. private _createTextureAdderPostProcess;
  72183. private _createVolumetricLightPostProcess;
  72184. private _createLuminancePostProcesses;
  72185. private _createHdrPostProcess;
  72186. private _createLensFlarePostProcess;
  72187. private _createDepthOfFieldPostProcess;
  72188. private _createMotionBlurPostProcess;
  72189. private _getDepthTexture;
  72190. private _disposePostProcesses;
  72191. /**
  72192. * Dispose of the pipeline and stop all post processes
  72193. */
  72194. dispose(): void;
  72195. /**
  72196. * Serialize the rendering pipeline (Used when exporting)
  72197. * @returns the serialized object
  72198. */
  72199. serialize(): any;
  72200. /**
  72201. * Parse the serialized pipeline
  72202. * @param source Source pipeline.
  72203. * @param scene The scene to load the pipeline to.
  72204. * @param rootUrl The URL of the serialized pipeline.
  72205. * @returns An instantiated pipeline from the serialized object.
  72206. */
  72207. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  72208. /**
  72209. * Luminance steps
  72210. */
  72211. static LuminanceSteps: number;
  72212. }
  72213. }
  72214. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  72215. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  72216. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  72217. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  72218. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  72219. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  72220. }
  72221. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  72222. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  72223. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  72224. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  72225. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  72226. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  72227. }
  72228. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  72229. /** @hidden */
  72230. export var stereoscopicInterlacePixelShader: {
  72231. name: string;
  72232. shader: string;
  72233. };
  72234. }
  72235. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  72236. import { Camera } from "babylonjs/Cameras/camera";
  72237. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  72238. import { Engine } from "babylonjs/Engines/engine";
  72239. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  72240. /**
  72241. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  72242. */
  72243. export class StereoscopicInterlacePostProcessI extends PostProcess {
  72244. private _stepSize;
  72245. private _passedProcess;
  72246. /**
  72247. * Initializes a StereoscopicInterlacePostProcessI
  72248. * @param name The name of the effect.
  72249. * @param rigCameras The rig cameras to be appled to the post process
  72250. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  72251. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  72252. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72253. * @param engine The engine which the post process will be applied. (default: current engine)
  72254. * @param reusable If the post process can be reused on the same frame. (default: false)
  72255. */
  72256. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  72257. }
  72258. /**
  72259. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  72260. */
  72261. export class StereoscopicInterlacePostProcess extends PostProcess {
  72262. private _stepSize;
  72263. private _passedProcess;
  72264. /**
  72265. * Initializes a StereoscopicInterlacePostProcess
  72266. * @param name The name of the effect.
  72267. * @param rigCameras The rig cameras to be appled to the post process
  72268. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  72269. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72270. * @param engine The engine which the post process will be applied. (default: current engine)
  72271. * @param reusable If the post process can be reused on the same frame. (default: false)
  72272. */
  72273. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  72274. }
  72275. }
  72276. declare module "babylonjs/Shaders/tonemap.fragment" {
  72277. /** @hidden */
  72278. export var tonemapPixelShader: {
  72279. name: string;
  72280. shader: string;
  72281. };
  72282. }
  72283. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  72284. import { Camera } from "babylonjs/Cameras/camera";
  72285. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  72286. import "babylonjs/Shaders/tonemap.fragment";
  72287. import { Engine } from "babylonjs/Engines/engine";
  72288. /** Defines operator used for tonemapping */
  72289. export enum TonemappingOperator {
  72290. /** Hable */
  72291. Hable = 0,
  72292. /** Reinhard */
  72293. Reinhard = 1,
  72294. /** HejiDawson */
  72295. HejiDawson = 2,
  72296. /** Photographic */
  72297. Photographic = 3
  72298. }
  72299. /**
  72300. * Defines a post process to apply tone mapping
  72301. */
  72302. export class TonemapPostProcess extends PostProcess {
  72303. private _operator;
  72304. /** Defines the required exposure adjustement */
  72305. exposureAdjustment: number;
  72306. /**
  72307. * Creates a new TonemapPostProcess
  72308. * @param name defines the name of the postprocess
  72309. * @param _operator defines the operator to use
  72310. * @param exposureAdjustment defines the required exposure adjustement
  72311. * @param camera defines the camera to use (can be null)
  72312. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  72313. * @param engine defines the hosting engine (can be ignore if camera is set)
  72314. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  72315. */
  72316. constructor(name: string, _operator: TonemappingOperator,
  72317. /** Defines the required exposure adjustement */
  72318. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  72319. }
  72320. }
  72321. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  72322. /** @hidden */
  72323. export var volumetricLightScatteringPixelShader: {
  72324. name: string;
  72325. shader: string;
  72326. };
  72327. }
  72328. declare module "babylonjs/Shaders/volumetricLightScatteringPass.vertex" {
  72329. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  72330. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  72331. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  72332. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  72333. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  72334. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  72335. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  72336. /** @hidden */
  72337. export var volumetricLightScatteringPassVertexShader: {
  72338. name: string;
  72339. shader: string;
  72340. };
  72341. }
  72342. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  72343. /** @hidden */
  72344. export var volumetricLightScatteringPassPixelShader: {
  72345. name: string;
  72346. shader: string;
  72347. };
  72348. }
  72349. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  72350. import { Vector3 } from "babylonjs/Maths/math.vector";
  72351. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  72352. import { Mesh } from "babylonjs/Meshes/mesh";
  72353. import { Camera } from "babylonjs/Cameras/camera";
  72354. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  72355. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  72356. import { Scene } from "babylonjs/scene";
  72357. import "babylonjs/Meshes/Builders/planeBuilder";
  72358. import "babylonjs/Shaders/depth.vertex";
  72359. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  72360. import "babylonjs/Shaders/volumetricLightScatteringPass.vertex";
  72361. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  72362. import { Engine } from "babylonjs/Engines/engine";
  72363. /**
  72364. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  72365. */
  72366. export class VolumetricLightScatteringPostProcess extends PostProcess {
  72367. private _volumetricLightScatteringPass;
  72368. private _volumetricLightScatteringRTT;
  72369. private _viewPort;
  72370. private _screenCoordinates;
  72371. private _cachedDefines;
  72372. /**
  72373. * If not undefined, the mesh position is computed from the attached node position
  72374. */
  72375. attachedNode: {
  72376. position: Vector3;
  72377. };
  72378. /**
  72379. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  72380. */
  72381. customMeshPosition: Vector3;
  72382. /**
  72383. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  72384. */
  72385. useCustomMeshPosition: boolean;
  72386. /**
  72387. * If the post-process should inverse the light scattering direction
  72388. */
  72389. invert: boolean;
  72390. /**
  72391. * The internal mesh used by the post-process
  72392. */
  72393. mesh: Mesh;
  72394. /**
  72395. * @hidden
  72396. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  72397. */
  72398. get useDiffuseColor(): boolean;
  72399. set useDiffuseColor(useDiffuseColor: boolean);
  72400. /**
  72401. * Array containing the excluded meshes not rendered in the internal pass
  72402. */
  72403. excludedMeshes: AbstractMesh[];
  72404. /**
  72405. * Controls the overall intensity of the post-process
  72406. */
  72407. exposure: number;
  72408. /**
  72409. * Dissipates each sample's contribution in range [0, 1]
  72410. */
  72411. decay: number;
  72412. /**
  72413. * Controls the overall intensity of each sample
  72414. */
  72415. weight: number;
  72416. /**
  72417. * Controls the density of each sample
  72418. */
  72419. density: number;
  72420. /**
  72421. * @constructor
  72422. * @param name The post-process name
  72423. * @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)
  72424. * @param camera The camera that the post-process will be attached to
  72425. * @param mesh The mesh used to create the light scattering
  72426. * @param samples The post-process quality, default 100
  72427. * @param samplingModeThe post-process filtering mode
  72428. * @param engine The babylon engine
  72429. * @param reusable If the post-process is reusable
  72430. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  72431. */
  72432. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  72433. /**
  72434. * Returns the string "VolumetricLightScatteringPostProcess"
  72435. * @returns "VolumetricLightScatteringPostProcess"
  72436. */
  72437. getClassName(): string;
  72438. private _isReady;
  72439. /**
  72440. * Sets the new light position for light scattering effect
  72441. * @param position The new custom light position
  72442. */
  72443. setCustomMeshPosition(position: Vector3): void;
  72444. /**
  72445. * Returns the light position for light scattering effect
  72446. * @return Vector3 The custom light position
  72447. */
  72448. getCustomMeshPosition(): Vector3;
  72449. /**
  72450. * Disposes the internal assets and detaches the post-process from the camera
  72451. */
  72452. dispose(camera: Camera): void;
  72453. /**
  72454. * Returns the render target texture used by the post-process
  72455. * @return the render target texture used by the post-process
  72456. */
  72457. getPass(): RenderTargetTexture;
  72458. private _meshExcluded;
  72459. private _createPass;
  72460. private _updateMeshScreenCoordinates;
  72461. /**
  72462. * Creates a default mesh for the Volumeric Light Scattering post-process
  72463. * @param name The mesh name
  72464. * @param scene The scene where to create the mesh
  72465. * @return the default mesh
  72466. */
  72467. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  72468. }
  72469. }
  72470. declare module "babylonjs/PostProcesses/index" {
  72471. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  72472. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  72473. export * from "babylonjs/PostProcesses/bloomEffect";
  72474. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  72475. export * from "babylonjs/PostProcesses/blurPostProcess";
  72476. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  72477. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  72478. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  72479. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  72480. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  72481. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  72482. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  72483. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  72484. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  72485. export * from "babylonjs/PostProcesses/filterPostProcess";
  72486. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  72487. export * from "babylonjs/PostProcesses/grainPostProcess";
  72488. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  72489. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  72490. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  72491. export * from "babylonjs/PostProcesses/passPostProcess";
  72492. export * from "babylonjs/PostProcesses/postProcess";
  72493. export * from "babylonjs/PostProcesses/postProcessManager";
  72494. export * from "babylonjs/PostProcesses/refractionPostProcess";
  72495. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  72496. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  72497. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  72498. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  72499. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  72500. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  72501. export * from "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess";
  72502. export * from "babylonjs/PostProcesses/screenSpaceReflectionPostProcess";
  72503. }
  72504. declare module "babylonjs/Probes/index" {
  72505. export * from "babylonjs/Probes/reflectionProbe";
  72506. }
  72507. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  72508. import { Scene } from "babylonjs/scene";
  72509. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  72510. import { SmartArray } from "babylonjs/Misc/smartArray";
  72511. import { ISceneComponent } from "babylonjs/sceneComponent";
  72512. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  72513. import "babylonjs/Meshes/Builders/boxBuilder";
  72514. import "babylonjs/Shaders/color.fragment";
  72515. import "babylonjs/Shaders/color.vertex";
  72516. import { Color3 } from "babylonjs/Maths/math.color";
  72517. module "babylonjs/scene" {
  72518. interface Scene {
  72519. /** @hidden (Backing field) */
  72520. _boundingBoxRenderer: BoundingBoxRenderer;
  72521. /** @hidden (Backing field) */
  72522. _forceShowBoundingBoxes: boolean;
  72523. /**
  72524. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  72525. */
  72526. forceShowBoundingBoxes: boolean;
  72527. /**
  72528. * Gets the bounding box renderer associated with the scene
  72529. * @returns a BoundingBoxRenderer
  72530. */
  72531. getBoundingBoxRenderer(): BoundingBoxRenderer;
  72532. }
  72533. }
  72534. module "babylonjs/Meshes/abstractMesh" {
  72535. interface AbstractMesh {
  72536. /** @hidden (Backing field) */
  72537. _showBoundingBox: boolean;
  72538. /**
  72539. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  72540. */
  72541. showBoundingBox: boolean;
  72542. }
  72543. }
  72544. /**
  72545. * Component responsible of rendering the bounding box of the meshes in a scene.
  72546. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  72547. */
  72548. export class BoundingBoxRenderer implements ISceneComponent {
  72549. /**
  72550. * The component name helpfull to identify the component in the list of scene components.
  72551. */
  72552. readonly name: string;
  72553. /**
  72554. * The scene the component belongs to.
  72555. */
  72556. scene: Scene;
  72557. /**
  72558. * Color of the bounding box lines placed in front of an object
  72559. */
  72560. frontColor: Color3;
  72561. /**
  72562. * Color of the bounding box lines placed behind an object
  72563. */
  72564. backColor: Color3;
  72565. /**
  72566. * Defines if the renderer should show the back lines or not
  72567. */
  72568. showBackLines: boolean;
  72569. /**
  72570. * @hidden
  72571. */
  72572. renderList: SmartArray<BoundingBox>;
  72573. private _colorShader;
  72574. private _vertexBuffers;
  72575. private _indexBuffer;
  72576. private _fillIndexBuffer;
  72577. private _fillIndexData;
  72578. /**
  72579. * Instantiates a new bounding box renderer in a scene.
  72580. * @param scene the scene the renderer renders in
  72581. */
  72582. constructor(scene: Scene);
  72583. /**
  72584. * Registers the component in a given scene
  72585. */
  72586. register(): void;
  72587. private _evaluateSubMesh;
  72588. private _activeMesh;
  72589. private _prepareRessources;
  72590. private _createIndexBuffer;
  72591. /**
  72592. * Rebuilds the elements related to this component in case of
  72593. * context lost for instance.
  72594. */
  72595. rebuild(): void;
  72596. /**
  72597. * @hidden
  72598. */
  72599. reset(): void;
  72600. /**
  72601. * Render the bounding boxes of a specific rendering group
  72602. * @param renderingGroupId defines the rendering group to render
  72603. */
  72604. render(renderingGroupId: number): void;
  72605. /**
  72606. * In case of occlusion queries, we can render the occlusion bounding box through this method
  72607. * @param mesh Define the mesh to render the occlusion bounding box for
  72608. */
  72609. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  72610. /**
  72611. * Dispose and release the resources attached to this renderer.
  72612. */
  72613. dispose(): void;
  72614. }
  72615. }
  72616. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  72617. import { Nullable } from "babylonjs/types";
  72618. import { Scene } from "babylonjs/scene";
  72619. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  72620. import { Camera } from "babylonjs/Cameras/camera";
  72621. import { ISceneComponent } from "babylonjs/sceneComponent";
  72622. module "babylonjs/scene" {
  72623. interface Scene {
  72624. /** @hidden (Backing field) */
  72625. _depthRenderer: {
  72626. [id: string]: DepthRenderer;
  72627. };
  72628. /**
  72629. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  72630. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  72631. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  72632. * @returns the created depth renderer
  72633. */
  72634. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  72635. /**
  72636. * Disables a depth renderer for a given camera
  72637. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  72638. */
  72639. disableDepthRenderer(camera?: Nullable<Camera>): void;
  72640. }
  72641. }
  72642. /**
  72643. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  72644. * in several rendering techniques.
  72645. */
  72646. export class DepthRendererSceneComponent implements ISceneComponent {
  72647. /**
  72648. * The component name helpfull to identify the component in the list of scene components.
  72649. */
  72650. readonly name: string;
  72651. /**
  72652. * The scene the component belongs to.
  72653. */
  72654. scene: Scene;
  72655. /**
  72656. * Creates a new instance of the component for the given scene
  72657. * @param scene Defines the scene to register the component in
  72658. */
  72659. constructor(scene: Scene);
  72660. /**
  72661. * Registers the component in a given scene
  72662. */
  72663. register(): void;
  72664. /**
  72665. * Rebuilds the elements related to this component in case of
  72666. * context lost for instance.
  72667. */
  72668. rebuild(): void;
  72669. /**
  72670. * Disposes the component and the associated ressources
  72671. */
  72672. dispose(): void;
  72673. private _gatherRenderTargets;
  72674. private _gatherActiveCameraRenderTargets;
  72675. }
  72676. }
  72677. declare module "babylonjs/Shaders/outline.fragment" {
  72678. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  72679. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  72680. /** @hidden */
  72681. export var outlinePixelShader: {
  72682. name: string;
  72683. shader: string;
  72684. };
  72685. }
  72686. declare module "babylonjs/Shaders/outline.vertex" {
  72687. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  72688. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  72689. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  72690. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  72691. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  72692. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  72693. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  72694. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  72695. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  72696. /** @hidden */
  72697. export var outlineVertexShader: {
  72698. name: string;
  72699. shader: string;
  72700. };
  72701. }
  72702. declare module "babylonjs/Rendering/outlineRenderer" {
  72703. import { SubMesh } from "babylonjs/Meshes/subMesh";
  72704. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  72705. import { Scene } from "babylonjs/scene";
  72706. import { ISceneComponent } from "babylonjs/sceneComponent";
  72707. import "babylonjs/Shaders/outline.fragment";
  72708. import "babylonjs/Shaders/outline.vertex";
  72709. module "babylonjs/scene" {
  72710. interface Scene {
  72711. /** @hidden */
  72712. _outlineRenderer: OutlineRenderer;
  72713. /**
  72714. * Gets the outline renderer associated with the scene
  72715. * @returns a OutlineRenderer
  72716. */
  72717. getOutlineRenderer(): OutlineRenderer;
  72718. }
  72719. }
  72720. module "babylonjs/Meshes/abstractMesh" {
  72721. interface AbstractMesh {
  72722. /** @hidden (Backing field) */
  72723. _renderOutline: boolean;
  72724. /**
  72725. * Gets or sets a boolean indicating if the outline must be rendered as well
  72726. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  72727. */
  72728. renderOutline: boolean;
  72729. /** @hidden (Backing field) */
  72730. _renderOverlay: boolean;
  72731. /**
  72732. * Gets or sets a boolean indicating if the overlay must be rendered as well
  72733. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  72734. */
  72735. renderOverlay: boolean;
  72736. }
  72737. }
  72738. /**
  72739. * This class is responsible to draw bothe outline/overlay of meshes.
  72740. * It should not be used directly but through the available method on mesh.
  72741. */
  72742. export class OutlineRenderer implements ISceneComponent {
  72743. /**
  72744. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  72745. */
  72746. private static _StencilReference;
  72747. /**
  72748. * The name of the component. Each component must have a unique name.
  72749. */
  72750. name: string;
  72751. /**
  72752. * The scene the component belongs to.
  72753. */
  72754. scene: Scene;
  72755. /**
  72756. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  72757. */
  72758. zOffset: number;
  72759. private _engine;
  72760. private _effect;
  72761. private _cachedDefines;
  72762. private _savedDepthWrite;
  72763. /**
  72764. * Instantiates a new outline renderer. (There could be only one per scene).
  72765. * @param scene Defines the scene it belongs to
  72766. */
  72767. constructor(scene: Scene);
  72768. /**
  72769. * Register the component to one instance of a scene.
  72770. */
  72771. register(): void;
  72772. /**
  72773. * Rebuilds the elements related to this component in case of
  72774. * context lost for instance.
  72775. */
  72776. rebuild(): void;
  72777. /**
  72778. * Disposes the component and the associated ressources.
  72779. */
  72780. dispose(): void;
  72781. /**
  72782. * Renders the outline in the canvas.
  72783. * @param subMesh Defines the sumesh to render
  72784. * @param batch Defines the batch of meshes in case of instances
  72785. * @param useOverlay Defines if the rendering is for the overlay or the outline
  72786. */
  72787. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  72788. /**
  72789. * Returns whether or not the outline renderer is ready for a given submesh.
  72790. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  72791. * @param subMesh Defines the submesh to check readyness for
  72792. * @param useInstances Defines wheter wee are trying to render instances or not
  72793. * @returns true if ready otherwise false
  72794. */
  72795. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  72796. private _beforeRenderingMesh;
  72797. private _afterRenderingMesh;
  72798. }
  72799. }
  72800. declare module "babylonjs/Rendering/index" {
  72801. export * from "babylonjs/Rendering/boundingBoxRenderer";
  72802. export * from "babylonjs/Rendering/depthRenderer";
  72803. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  72804. export * from "babylonjs/Rendering/edgesRenderer";
  72805. export * from "babylonjs/Rendering/geometryBufferRenderer";
  72806. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  72807. export * from "babylonjs/Rendering/outlineRenderer";
  72808. export * from "babylonjs/Rendering/renderingGroup";
  72809. export * from "babylonjs/Rendering/renderingManager";
  72810. export * from "babylonjs/Rendering/utilityLayerRenderer";
  72811. }
  72812. declare module "babylonjs/Sprites/ISprites" {
  72813. /**
  72814. * Defines the basic options interface of a Sprite Frame Source Size.
  72815. */
  72816. export interface ISpriteJSONSpriteSourceSize {
  72817. /**
  72818. * number of the original width of the Frame
  72819. */
  72820. w: number;
  72821. /**
  72822. * number of the original height of the Frame
  72823. */
  72824. h: number;
  72825. }
  72826. /**
  72827. * Defines the basic options interface of a Sprite Frame Data.
  72828. */
  72829. export interface ISpriteJSONSpriteFrameData {
  72830. /**
  72831. * number of the x offset of the Frame
  72832. */
  72833. x: number;
  72834. /**
  72835. * number of the y offset of the Frame
  72836. */
  72837. y: number;
  72838. /**
  72839. * number of the width of the Frame
  72840. */
  72841. w: number;
  72842. /**
  72843. * number of the height of the Frame
  72844. */
  72845. h: number;
  72846. }
  72847. /**
  72848. * Defines the basic options interface of a JSON Sprite.
  72849. */
  72850. export interface ISpriteJSONSprite {
  72851. /**
  72852. * string name of the Frame
  72853. */
  72854. filename: string;
  72855. /**
  72856. * ISpriteJSONSpriteFrame basic object of the frame data
  72857. */
  72858. frame: ISpriteJSONSpriteFrameData;
  72859. /**
  72860. * boolean to flag is the frame was rotated.
  72861. */
  72862. rotated: boolean;
  72863. /**
  72864. * boolean to flag is the frame was trimmed.
  72865. */
  72866. trimmed: boolean;
  72867. /**
  72868. * ISpriteJSONSpriteFrame basic object of the source data
  72869. */
  72870. spriteSourceSize: ISpriteJSONSpriteFrameData;
  72871. /**
  72872. * ISpriteJSONSpriteFrame basic object of the source data
  72873. */
  72874. sourceSize: ISpriteJSONSpriteSourceSize;
  72875. }
  72876. /**
  72877. * Defines the basic options interface of a JSON atlas.
  72878. */
  72879. export interface ISpriteJSONAtlas {
  72880. /**
  72881. * Array of objects that contain the frame data.
  72882. */
  72883. frames: Array<ISpriteJSONSprite>;
  72884. /**
  72885. * object basic object containing the sprite meta data.
  72886. */
  72887. meta?: object;
  72888. }
  72889. }
  72890. declare module "babylonjs/Shaders/spriteMap.fragment" {
  72891. /** @hidden */
  72892. export var spriteMapPixelShader: {
  72893. name: string;
  72894. shader: string;
  72895. };
  72896. }
  72897. declare module "babylonjs/Shaders/spriteMap.vertex" {
  72898. /** @hidden */
  72899. export var spriteMapVertexShader: {
  72900. name: string;
  72901. shader: string;
  72902. };
  72903. }
  72904. declare module "babylonjs/Sprites/spriteMap" {
  72905. import { IDisposable, Scene } from "babylonjs/scene";
  72906. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  72907. import { Texture } from "babylonjs/Materials/Textures/texture";
  72908. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  72909. import { ISpriteJSONSprite, ISpriteJSONAtlas } from "babylonjs/Sprites/ISprites";
  72910. import "babylonjs/Meshes/Builders/planeBuilder";
  72911. import "babylonjs/Shaders/spriteMap.fragment";
  72912. import "babylonjs/Shaders/spriteMap.vertex";
  72913. /**
  72914. * Defines the basic options interface of a SpriteMap
  72915. */
  72916. export interface ISpriteMapOptions {
  72917. /**
  72918. * Vector2 of the number of cells in the grid.
  72919. */
  72920. stageSize?: Vector2;
  72921. /**
  72922. * Vector2 of the size of the output plane in World Units.
  72923. */
  72924. outputSize?: Vector2;
  72925. /**
  72926. * Vector3 of the position of the output plane in World Units.
  72927. */
  72928. outputPosition?: Vector3;
  72929. /**
  72930. * Vector3 of the rotation of the output plane.
  72931. */
  72932. outputRotation?: Vector3;
  72933. /**
  72934. * number of layers that the system will reserve in resources.
  72935. */
  72936. layerCount?: number;
  72937. /**
  72938. * number of max animation frames a single cell will reserve in resources.
  72939. */
  72940. maxAnimationFrames?: number;
  72941. /**
  72942. * number cell index of the base tile when the system compiles.
  72943. */
  72944. baseTile?: number;
  72945. /**
  72946. * boolean flip the sprite after its been repositioned by the framing data.
  72947. */
  72948. flipU?: boolean;
  72949. /**
  72950. * Vector3 scalar of the global RGB values of the SpriteMap.
  72951. */
  72952. colorMultiply?: Vector3;
  72953. }
  72954. /**
  72955. * Defines the IDisposable interface in order to be cleanable from resources.
  72956. */
  72957. export interface ISpriteMap extends IDisposable {
  72958. /**
  72959. * String name of the SpriteMap.
  72960. */
  72961. name: string;
  72962. /**
  72963. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  72964. */
  72965. atlasJSON: ISpriteJSONAtlas;
  72966. /**
  72967. * Texture of the SpriteMap.
  72968. */
  72969. spriteSheet: Texture;
  72970. /**
  72971. * The parameters to initialize the SpriteMap with.
  72972. */
  72973. options: ISpriteMapOptions;
  72974. }
  72975. /**
  72976. * Class used to manage a grid restricted sprite deployment on an Output plane.
  72977. */
  72978. export class SpriteMap implements ISpriteMap {
  72979. /** The Name of the spriteMap */
  72980. name: string;
  72981. /** The JSON file with the frame and meta data */
  72982. atlasJSON: ISpriteJSONAtlas;
  72983. /** The systems Sprite Sheet Texture */
  72984. spriteSheet: Texture;
  72985. /** Arguments passed with the Constructor */
  72986. options: ISpriteMapOptions;
  72987. /** Public Sprite Storage array, parsed from atlasJSON */
  72988. sprites: Array<ISpriteJSONSprite>;
  72989. /** Returns the Number of Sprites in the System */
  72990. get spriteCount(): number;
  72991. /** Returns the Position of Output Plane*/
  72992. get position(): Vector3;
  72993. /** Returns the Position of Output Plane*/
  72994. set position(v: Vector3);
  72995. /** Returns the Rotation of Output Plane*/
  72996. get rotation(): Vector3;
  72997. /** Returns the Rotation of Output Plane*/
  72998. set rotation(v: Vector3);
  72999. /** Sets the AnimationMap*/
  73000. get animationMap(): RawTexture;
  73001. /** Sets the AnimationMap*/
  73002. set animationMap(v: RawTexture);
  73003. /** Scene that the SpriteMap was created in */
  73004. private _scene;
  73005. /** Texture Buffer of Float32 that holds tile frame data*/
  73006. private _frameMap;
  73007. /** Texture Buffers of Float32 that holds tileMap data*/
  73008. private _tileMaps;
  73009. /** Texture Buffer of Float32 that holds Animation Data*/
  73010. private _animationMap;
  73011. /** Custom ShaderMaterial Central to the System*/
  73012. private _material;
  73013. /** Custom ShaderMaterial Central to the System*/
  73014. private _output;
  73015. /** Systems Time Ticker*/
  73016. private _time;
  73017. /**
  73018. * Creates a new SpriteMap
  73019. * @param name defines the SpriteMaps Name
  73020. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  73021. * @param spriteSheet is the Texture that the Sprites are on.
  73022. * @param options a basic deployment configuration
  73023. * @param scene The Scene that the map is deployed on
  73024. */
  73025. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  73026. /**
  73027. * Returns tileID location
  73028. * @returns Vector2 the cell position ID
  73029. */
  73030. getTileID(): Vector2;
  73031. /**
  73032. * Gets the UV location of the mouse over the SpriteMap.
  73033. * @returns Vector2 the UV position of the mouse interaction
  73034. */
  73035. getMousePosition(): Vector2;
  73036. /**
  73037. * Creates the "frame" texture Buffer
  73038. * -------------------------------------
  73039. * Structure of frames
  73040. * "filename": "Falling-Water-2.png",
  73041. * "frame": {"x":69,"y":103,"w":24,"h":32},
  73042. * "rotated": true,
  73043. * "trimmed": true,
  73044. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  73045. * "sourceSize": {"w":32,"h":32}
  73046. * @returns RawTexture of the frameMap
  73047. */
  73048. private _createFrameBuffer;
  73049. /**
  73050. * Creates the tileMap texture Buffer
  73051. * @param buffer normally and array of numbers, or a false to generate from scratch
  73052. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  73053. * @returns RawTexture of the tileMap
  73054. */
  73055. private _createTileBuffer;
  73056. /**
  73057. * Modifies the data of the tileMaps
  73058. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  73059. * @param pos is the iVector2 Coordinates of the Tile
  73060. * @param tile The SpriteIndex of the new Tile
  73061. */
  73062. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  73063. /**
  73064. * Creates the animationMap texture Buffer
  73065. * @param buffer normally and array of numbers, or a false to generate from scratch
  73066. * @returns RawTexture of the animationMap
  73067. */
  73068. private _createTileAnimationBuffer;
  73069. /**
  73070. * Modifies the data of the animationMap
  73071. * @param cellID is the Index of the Sprite
  73072. * @param _frame is the target Animation frame
  73073. * @param toCell is the Target Index of the next frame of the animation
  73074. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  73075. * @param speed is a global scalar of the time variable on the map.
  73076. */
  73077. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  73078. /**
  73079. * Exports the .tilemaps file
  73080. */
  73081. saveTileMaps(): void;
  73082. /**
  73083. * Imports the .tilemaps file
  73084. * @param url of the .tilemaps file
  73085. */
  73086. loadTileMaps(url: string): void;
  73087. /**
  73088. * Release associated resources
  73089. */
  73090. dispose(): void;
  73091. }
  73092. }
  73093. declare module "babylonjs/Sprites/spritePackedManager" {
  73094. import { SpriteManager } from "babylonjs/Sprites/spriteManager";
  73095. import { Scene } from "babylonjs/scene";
  73096. /**
  73097. * Class used to manage multiple sprites of different sizes on the same spritesheet
  73098. * @see http://doc.babylonjs.com/babylon101/sprites
  73099. */
  73100. export class SpritePackedManager extends SpriteManager {
  73101. /** defines the packed manager's name */
  73102. name: string;
  73103. /**
  73104. * Creates a new sprite manager from a packed sprite sheet
  73105. * @param name defines the manager's name
  73106. * @param imgUrl defines the sprite sheet url
  73107. * @param capacity defines the maximum allowed number of sprites
  73108. * @param scene defines the hosting scene
  73109. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  73110. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  73111. * @param samplingMode defines the smapling mode to use with spritesheet
  73112. * @param fromPacked set to true; do not alter
  73113. */
  73114. constructor(
  73115. /** defines the packed manager's name */
  73116. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  73117. }
  73118. }
  73119. declare module "babylonjs/Sprites/index" {
  73120. export * from "babylonjs/Sprites/sprite";
  73121. export * from "babylonjs/Sprites/ISprites";
  73122. export * from "babylonjs/Sprites/spriteManager";
  73123. export * from "babylonjs/Sprites/spriteMap";
  73124. export * from "babylonjs/Sprites/spritePackedManager";
  73125. export * from "babylonjs/Sprites/spriteSceneComponent";
  73126. }
  73127. declare module "babylonjs/States/index" {
  73128. export * from "babylonjs/States/alphaCullingState";
  73129. export * from "babylonjs/States/depthCullingState";
  73130. export * from "babylonjs/States/stencilState";
  73131. }
  73132. declare module "babylonjs/Misc/assetsManager" {
  73133. import { Scene } from "babylonjs/scene";
  73134. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  73135. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  73136. import { Skeleton } from "babylonjs/Bones/skeleton";
  73137. import { Observable } from "babylonjs/Misc/observable";
  73138. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  73139. import { Texture } from "babylonjs/Materials/Textures/texture";
  73140. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  73141. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  73142. import { EquiRectangularCubeTexture } from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  73143. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  73144. /**
  73145. * Defines the list of states available for a task inside a AssetsManager
  73146. */
  73147. export enum AssetTaskState {
  73148. /**
  73149. * Initialization
  73150. */
  73151. INIT = 0,
  73152. /**
  73153. * Running
  73154. */
  73155. RUNNING = 1,
  73156. /**
  73157. * Done
  73158. */
  73159. DONE = 2,
  73160. /**
  73161. * Error
  73162. */
  73163. ERROR = 3
  73164. }
  73165. /**
  73166. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  73167. */
  73168. export abstract class AbstractAssetTask {
  73169. /**
  73170. * Task name
  73171. */ name: string;
  73172. /**
  73173. * Callback called when the task is successful
  73174. */
  73175. onSuccess: (task: any) => void;
  73176. /**
  73177. * Callback called when the task is not successful
  73178. */
  73179. onError: (task: any, message?: string, exception?: any) => void;
  73180. /**
  73181. * Creates a new AssetsManager
  73182. * @param name defines the name of the task
  73183. */
  73184. constructor(
  73185. /**
  73186. * Task name
  73187. */ name: string);
  73188. private _isCompleted;
  73189. private _taskState;
  73190. private _errorObject;
  73191. /**
  73192. * Get if the task is completed
  73193. */
  73194. get isCompleted(): boolean;
  73195. /**
  73196. * Gets the current state of the task
  73197. */
  73198. get taskState(): AssetTaskState;
  73199. /**
  73200. * Gets the current error object (if task is in error)
  73201. */
  73202. get errorObject(): {
  73203. message?: string;
  73204. exception?: any;
  73205. };
  73206. /**
  73207. * Internal only
  73208. * @hidden
  73209. */
  73210. _setErrorObject(message?: string, exception?: any): void;
  73211. /**
  73212. * Execute the current task
  73213. * @param scene defines the scene where you want your assets to be loaded
  73214. * @param onSuccess is a callback called when the task is successfully executed
  73215. * @param onError is a callback called if an error occurs
  73216. */
  73217. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  73218. /**
  73219. * Execute the current task
  73220. * @param scene defines the scene where you want your assets to be loaded
  73221. * @param onSuccess is a callback called when the task is successfully executed
  73222. * @param onError is a callback called if an error occurs
  73223. */
  73224. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  73225. /**
  73226. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  73227. * This can be used with failed tasks that have the reason for failure fixed.
  73228. */
  73229. reset(): void;
  73230. private onErrorCallback;
  73231. private onDoneCallback;
  73232. }
  73233. /**
  73234. * Define the interface used by progress events raised during assets loading
  73235. */
  73236. export interface IAssetsProgressEvent {
  73237. /**
  73238. * Defines the number of remaining tasks to process
  73239. */
  73240. remainingCount: number;
  73241. /**
  73242. * Defines the total number of tasks
  73243. */
  73244. totalCount: number;
  73245. /**
  73246. * Defines the task that was just processed
  73247. */
  73248. task: AbstractAssetTask;
  73249. }
  73250. /**
  73251. * Class used to share progress information about assets loading
  73252. */
  73253. export class AssetsProgressEvent implements IAssetsProgressEvent {
  73254. /**
  73255. * Defines the number of remaining tasks to process
  73256. */
  73257. remainingCount: number;
  73258. /**
  73259. * Defines the total number of tasks
  73260. */
  73261. totalCount: number;
  73262. /**
  73263. * Defines the task that was just processed
  73264. */
  73265. task: AbstractAssetTask;
  73266. /**
  73267. * Creates a AssetsProgressEvent
  73268. * @param remainingCount defines the number of remaining tasks to process
  73269. * @param totalCount defines the total number of tasks
  73270. * @param task defines the task that was just processed
  73271. */
  73272. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  73273. }
  73274. /**
  73275. * Define a task used by AssetsManager to load meshes
  73276. */
  73277. export class MeshAssetTask extends AbstractAssetTask {
  73278. /**
  73279. * Defines the name of the task
  73280. */
  73281. name: string;
  73282. /**
  73283. * Defines the list of mesh's names you want to load
  73284. */
  73285. meshesNames: any;
  73286. /**
  73287. * Defines the root url to use as a base to load your meshes and associated resources
  73288. */
  73289. rootUrl: string;
  73290. /**
  73291. * Defines the filename or File of the scene to load from
  73292. */
  73293. sceneFilename: string | File;
  73294. /**
  73295. * Gets the list of loaded meshes
  73296. */
  73297. loadedMeshes: Array<AbstractMesh>;
  73298. /**
  73299. * Gets the list of loaded particle systems
  73300. */
  73301. loadedParticleSystems: Array<IParticleSystem>;
  73302. /**
  73303. * Gets the list of loaded skeletons
  73304. */
  73305. loadedSkeletons: Array<Skeleton>;
  73306. /**
  73307. * Gets the list of loaded animation groups
  73308. */
  73309. loadedAnimationGroups: Array<AnimationGroup>;
  73310. /**
  73311. * Callback called when the task is successful
  73312. */
  73313. onSuccess: (task: MeshAssetTask) => void;
  73314. /**
  73315. * Callback called when the task is successful
  73316. */
  73317. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  73318. /**
  73319. * Creates a new MeshAssetTask
  73320. * @param name defines the name of the task
  73321. * @param meshesNames defines the list of mesh's names you want to load
  73322. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  73323. * @param sceneFilename defines the filename or File of the scene to load from
  73324. */
  73325. constructor(
  73326. /**
  73327. * Defines the name of the task
  73328. */
  73329. name: string,
  73330. /**
  73331. * Defines the list of mesh's names you want to load
  73332. */
  73333. meshesNames: any,
  73334. /**
  73335. * Defines the root url to use as a base to load your meshes and associated resources
  73336. */
  73337. rootUrl: string,
  73338. /**
  73339. * Defines the filename or File of the scene to load from
  73340. */
  73341. sceneFilename: string | File);
  73342. /**
  73343. * Execute the current task
  73344. * @param scene defines the scene where you want your assets to be loaded
  73345. * @param onSuccess is a callback called when the task is successfully executed
  73346. * @param onError is a callback called if an error occurs
  73347. */
  73348. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  73349. }
  73350. /**
  73351. * Define a task used by AssetsManager to load text content
  73352. */
  73353. export class TextFileAssetTask extends AbstractAssetTask {
  73354. /**
  73355. * Defines the name of the task
  73356. */
  73357. name: string;
  73358. /**
  73359. * Defines the location of the file to load
  73360. */
  73361. url: string;
  73362. /**
  73363. * Gets the loaded text string
  73364. */
  73365. text: string;
  73366. /**
  73367. * Callback called when the task is successful
  73368. */
  73369. onSuccess: (task: TextFileAssetTask) => void;
  73370. /**
  73371. * Callback called when the task is successful
  73372. */
  73373. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  73374. /**
  73375. * Creates a new TextFileAssetTask object
  73376. * @param name defines the name of the task
  73377. * @param url defines the location of the file to load
  73378. */
  73379. constructor(
  73380. /**
  73381. * Defines the name of the task
  73382. */
  73383. name: string,
  73384. /**
  73385. * Defines the location of the file to load
  73386. */
  73387. url: string);
  73388. /**
  73389. * Execute the current task
  73390. * @param scene defines the scene where you want your assets to be loaded
  73391. * @param onSuccess is a callback called when the task is successfully executed
  73392. * @param onError is a callback called if an error occurs
  73393. */
  73394. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  73395. }
  73396. /**
  73397. * Define a task used by AssetsManager to load binary data
  73398. */
  73399. export class BinaryFileAssetTask extends AbstractAssetTask {
  73400. /**
  73401. * Defines the name of the task
  73402. */
  73403. name: string;
  73404. /**
  73405. * Defines the location of the file to load
  73406. */
  73407. url: string;
  73408. /**
  73409. * Gets the lodaded data (as an array buffer)
  73410. */
  73411. data: ArrayBuffer;
  73412. /**
  73413. * Callback called when the task is successful
  73414. */
  73415. onSuccess: (task: BinaryFileAssetTask) => void;
  73416. /**
  73417. * Callback called when the task is successful
  73418. */
  73419. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  73420. /**
  73421. * Creates a new BinaryFileAssetTask object
  73422. * @param name defines the name of the new task
  73423. * @param url defines the location of the file to load
  73424. */
  73425. constructor(
  73426. /**
  73427. * Defines the name of the task
  73428. */
  73429. name: string,
  73430. /**
  73431. * Defines the location of the file to load
  73432. */
  73433. url: string);
  73434. /**
  73435. * Execute the current task
  73436. * @param scene defines the scene where you want your assets to be loaded
  73437. * @param onSuccess is a callback called when the task is successfully executed
  73438. * @param onError is a callback called if an error occurs
  73439. */
  73440. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  73441. }
  73442. /**
  73443. * Define a task used by AssetsManager to load images
  73444. */
  73445. export class ImageAssetTask extends AbstractAssetTask {
  73446. /**
  73447. * Defines the name of the task
  73448. */
  73449. name: string;
  73450. /**
  73451. * Defines the location of the image to load
  73452. */
  73453. url: string;
  73454. /**
  73455. * Gets the loaded images
  73456. */
  73457. image: HTMLImageElement;
  73458. /**
  73459. * Callback called when the task is successful
  73460. */
  73461. onSuccess: (task: ImageAssetTask) => void;
  73462. /**
  73463. * Callback called when the task is successful
  73464. */
  73465. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  73466. /**
  73467. * Creates a new ImageAssetTask
  73468. * @param name defines the name of the task
  73469. * @param url defines the location of the image to load
  73470. */
  73471. constructor(
  73472. /**
  73473. * Defines the name of the task
  73474. */
  73475. name: string,
  73476. /**
  73477. * Defines the location of the image to load
  73478. */
  73479. url: string);
  73480. /**
  73481. * Execute the current task
  73482. * @param scene defines the scene where you want your assets to be loaded
  73483. * @param onSuccess is a callback called when the task is successfully executed
  73484. * @param onError is a callback called if an error occurs
  73485. */
  73486. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  73487. }
  73488. /**
  73489. * Defines the interface used by texture loading tasks
  73490. */
  73491. export interface ITextureAssetTask<TEX extends BaseTexture> {
  73492. /**
  73493. * Gets the loaded texture
  73494. */
  73495. texture: TEX;
  73496. }
  73497. /**
  73498. * Define a task used by AssetsManager to load 2D textures
  73499. */
  73500. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  73501. /**
  73502. * Defines the name of the task
  73503. */
  73504. name: string;
  73505. /**
  73506. * Defines the location of the file to load
  73507. */
  73508. url: string;
  73509. /**
  73510. * Defines if mipmap should not be generated (default is false)
  73511. */
  73512. noMipmap?: boolean | undefined;
  73513. /**
  73514. * Defines if texture must be inverted on Y axis (default is true)
  73515. */
  73516. invertY: boolean;
  73517. /**
  73518. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  73519. */
  73520. samplingMode: number;
  73521. /**
  73522. * Gets the loaded texture
  73523. */
  73524. texture: Texture;
  73525. /**
  73526. * Callback called when the task is successful
  73527. */
  73528. onSuccess: (task: TextureAssetTask) => void;
  73529. /**
  73530. * Callback called when the task is successful
  73531. */
  73532. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  73533. /**
  73534. * Creates a new TextureAssetTask object
  73535. * @param name defines the name of the task
  73536. * @param url defines the location of the file to load
  73537. * @param noMipmap defines if mipmap should not be generated (default is false)
  73538. * @param invertY defines if texture must be inverted on Y axis (default is true)
  73539. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  73540. */
  73541. constructor(
  73542. /**
  73543. * Defines the name of the task
  73544. */
  73545. name: string,
  73546. /**
  73547. * Defines the location of the file to load
  73548. */
  73549. url: string,
  73550. /**
  73551. * Defines if mipmap should not be generated (default is false)
  73552. */
  73553. noMipmap?: boolean | undefined,
  73554. /**
  73555. * Defines if texture must be inverted on Y axis (default is true)
  73556. */
  73557. invertY?: boolean,
  73558. /**
  73559. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  73560. */
  73561. samplingMode?: number);
  73562. /**
  73563. * Execute the current task
  73564. * @param scene defines the scene where you want your assets to be loaded
  73565. * @param onSuccess is a callback called when the task is successfully executed
  73566. * @param onError is a callback called if an error occurs
  73567. */
  73568. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  73569. }
  73570. /**
  73571. * Define a task used by AssetsManager to load cube textures
  73572. */
  73573. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  73574. /**
  73575. * Defines the name of the task
  73576. */
  73577. name: string;
  73578. /**
  73579. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  73580. */
  73581. url: string;
  73582. /**
  73583. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  73584. */
  73585. extensions?: string[] | undefined;
  73586. /**
  73587. * Defines if mipmaps should not be generated (default is false)
  73588. */
  73589. noMipmap?: boolean | undefined;
  73590. /**
  73591. * Defines the explicit list of files (undefined by default)
  73592. */
  73593. files?: string[] | undefined;
  73594. /**
  73595. * Gets the loaded texture
  73596. */
  73597. texture: CubeTexture;
  73598. /**
  73599. * Callback called when the task is successful
  73600. */
  73601. onSuccess: (task: CubeTextureAssetTask) => void;
  73602. /**
  73603. * Callback called when the task is successful
  73604. */
  73605. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  73606. /**
  73607. * Creates a new CubeTextureAssetTask
  73608. * @param name defines the name of the task
  73609. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  73610. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  73611. * @param noMipmap defines if mipmaps should not be generated (default is false)
  73612. * @param files defines the explicit list of files (undefined by default)
  73613. */
  73614. constructor(
  73615. /**
  73616. * Defines the name of the task
  73617. */
  73618. name: string,
  73619. /**
  73620. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  73621. */
  73622. url: string,
  73623. /**
  73624. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  73625. */
  73626. extensions?: string[] | undefined,
  73627. /**
  73628. * Defines if mipmaps should not be generated (default is false)
  73629. */
  73630. noMipmap?: boolean | undefined,
  73631. /**
  73632. * Defines the explicit list of files (undefined by default)
  73633. */
  73634. files?: string[] | undefined);
  73635. /**
  73636. * Execute the current task
  73637. * @param scene defines the scene where you want your assets to be loaded
  73638. * @param onSuccess is a callback called when the task is successfully executed
  73639. * @param onError is a callback called if an error occurs
  73640. */
  73641. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  73642. }
  73643. /**
  73644. * Define a task used by AssetsManager to load HDR cube textures
  73645. */
  73646. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  73647. /**
  73648. * Defines the name of the task
  73649. */
  73650. name: string;
  73651. /**
  73652. * Defines the location of the file to load
  73653. */
  73654. url: string;
  73655. /**
  73656. * Defines the desired size (the more it increases the longer the generation will be)
  73657. */
  73658. size: number;
  73659. /**
  73660. * Defines if mipmaps should not be generated (default is false)
  73661. */
  73662. noMipmap: boolean;
  73663. /**
  73664. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  73665. */
  73666. generateHarmonics: boolean;
  73667. /**
  73668. * 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)
  73669. */
  73670. gammaSpace: boolean;
  73671. /**
  73672. * Internal Use Only
  73673. */
  73674. reserved: boolean;
  73675. /**
  73676. * Gets the loaded texture
  73677. */
  73678. texture: HDRCubeTexture;
  73679. /**
  73680. * Callback called when the task is successful
  73681. */
  73682. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  73683. /**
  73684. * Callback called when the task is successful
  73685. */
  73686. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  73687. /**
  73688. * Creates a new HDRCubeTextureAssetTask object
  73689. * @param name defines the name of the task
  73690. * @param url defines the location of the file to load
  73691. * @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.
  73692. * @param noMipmap defines if mipmaps should not be generated (default is false)
  73693. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  73694. * @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)
  73695. * @param reserved Internal use only
  73696. */
  73697. constructor(
  73698. /**
  73699. * Defines the name of the task
  73700. */
  73701. name: string,
  73702. /**
  73703. * Defines the location of the file to load
  73704. */
  73705. url: string,
  73706. /**
  73707. * Defines the desired size (the more it increases the longer the generation will be)
  73708. */
  73709. size: number,
  73710. /**
  73711. * Defines if mipmaps should not be generated (default is false)
  73712. */
  73713. noMipmap?: boolean,
  73714. /**
  73715. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  73716. */
  73717. generateHarmonics?: boolean,
  73718. /**
  73719. * 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)
  73720. */
  73721. gammaSpace?: boolean,
  73722. /**
  73723. * Internal Use Only
  73724. */
  73725. reserved?: boolean);
  73726. /**
  73727. * Execute the current task
  73728. * @param scene defines the scene where you want your assets to be loaded
  73729. * @param onSuccess is a callback called when the task is successfully executed
  73730. * @param onError is a callback called if an error occurs
  73731. */
  73732. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  73733. }
  73734. /**
  73735. * Define a task used by AssetsManager to load Equirectangular cube textures
  73736. */
  73737. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  73738. /**
  73739. * Defines the name of the task
  73740. */
  73741. name: string;
  73742. /**
  73743. * Defines the location of the file to load
  73744. */
  73745. url: string;
  73746. /**
  73747. * Defines the desired size (the more it increases the longer the generation will be)
  73748. */
  73749. size: number;
  73750. /**
  73751. * Defines if mipmaps should not be generated (default is false)
  73752. */
  73753. noMipmap: boolean;
  73754. /**
  73755. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  73756. * but the standard material would require them in Gamma space) (default is true)
  73757. */
  73758. gammaSpace: boolean;
  73759. /**
  73760. * Gets the loaded texture
  73761. */
  73762. texture: EquiRectangularCubeTexture;
  73763. /**
  73764. * Callback called when the task is successful
  73765. */
  73766. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  73767. /**
  73768. * Callback called when the task is successful
  73769. */
  73770. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  73771. /**
  73772. * Creates a new EquiRectangularCubeTextureAssetTask object
  73773. * @param name defines the name of the task
  73774. * @param url defines the location of the file to load
  73775. * @param size defines the desired size (the more it increases the longer the generation will be)
  73776. * If the size is omitted this implies you are using a preprocessed cubemap.
  73777. * @param noMipmap defines if mipmaps should not be generated (default is false)
  73778. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  73779. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  73780. * (default is true)
  73781. */
  73782. constructor(
  73783. /**
  73784. * Defines the name of the task
  73785. */
  73786. name: string,
  73787. /**
  73788. * Defines the location of the file to load
  73789. */
  73790. url: string,
  73791. /**
  73792. * Defines the desired size (the more it increases the longer the generation will be)
  73793. */
  73794. size: number,
  73795. /**
  73796. * Defines if mipmaps should not be generated (default is false)
  73797. */
  73798. noMipmap?: boolean,
  73799. /**
  73800. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  73801. * but the standard material would require them in Gamma space) (default is true)
  73802. */
  73803. gammaSpace?: boolean);
  73804. /**
  73805. * Execute the current task
  73806. * @param scene defines the scene where you want your assets to be loaded
  73807. * @param onSuccess is a callback called when the task is successfully executed
  73808. * @param onError is a callback called if an error occurs
  73809. */
  73810. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  73811. }
  73812. /**
  73813. * This class can be used to easily import assets into a scene
  73814. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  73815. */
  73816. export class AssetsManager {
  73817. private _scene;
  73818. private _isLoading;
  73819. protected _tasks: AbstractAssetTask[];
  73820. protected _waitingTasksCount: number;
  73821. protected _totalTasksCount: number;
  73822. /**
  73823. * Callback called when all tasks are processed
  73824. */
  73825. onFinish: (tasks: AbstractAssetTask[]) => void;
  73826. /**
  73827. * Callback called when a task is successful
  73828. */
  73829. onTaskSuccess: (task: AbstractAssetTask) => void;
  73830. /**
  73831. * Callback called when a task had an error
  73832. */
  73833. onTaskError: (task: AbstractAssetTask) => void;
  73834. /**
  73835. * Callback called when a task is done (whatever the result is)
  73836. */
  73837. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  73838. /**
  73839. * Observable called when all tasks are processed
  73840. */
  73841. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  73842. /**
  73843. * Observable called when a task had an error
  73844. */
  73845. onTaskErrorObservable: Observable<AbstractAssetTask>;
  73846. /**
  73847. * Observable called when all tasks were executed
  73848. */
  73849. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  73850. /**
  73851. * Observable called when a task is done (whatever the result is)
  73852. */
  73853. onProgressObservable: Observable<IAssetsProgressEvent>;
  73854. /**
  73855. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  73856. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  73857. */
  73858. useDefaultLoadingScreen: boolean;
  73859. /**
  73860. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  73861. * when all assets have been downloaded.
  73862. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  73863. */
  73864. autoHideLoadingUI: boolean;
  73865. /**
  73866. * Creates a new AssetsManager
  73867. * @param scene defines the scene to work on
  73868. */
  73869. constructor(scene: Scene);
  73870. /**
  73871. * Add a MeshAssetTask to the list of active tasks
  73872. * @param taskName defines the name of the new task
  73873. * @param meshesNames defines the name of meshes to load
  73874. * @param rootUrl defines the root url to use to locate files
  73875. * @param sceneFilename defines the filename of the scene file
  73876. * @returns a new MeshAssetTask object
  73877. */
  73878. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  73879. /**
  73880. * Add a TextFileAssetTask to the list of active tasks
  73881. * @param taskName defines the name of the new task
  73882. * @param url defines the url of the file to load
  73883. * @returns a new TextFileAssetTask object
  73884. */
  73885. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  73886. /**
  73887. * Add a BinaryFileAssetTask to the list of active tasks
  73888. * @param taskName defines the name of the new task
  73889. * @param url defines the url of the file to load
  73890. * @returns a new BinaryFileAssetTask object
  73891. */
  73892. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  73893. /**
  73894. * Add a ImageAssetTask to the list of active tasks
  73895. * @param taskName defines the name of the new task
  73896. * @param url defines the url of the file to load
  73897. * @returns a new ImageAssetTask object
  73898. */
  73899. addImageTask(taskName: string, url: string): ImageAssetTask;
  73900. /**
  73901. * Add a TextureAssetTask to the list of active tasks
  73902. * @param taskName defines the name of the new task
  73903. * @param url defines the url of the file to load
  73904. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  73905. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  73906. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  73907. * @returns a new TextureAssetTask object
  73908. */
  73909. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  73910. /**
  73911. * Add a CubeTextureAssetTask to the list of active tasks
  73912. * @param taskName defines the name of the new task
  73913. * @param url defines the url of the file to load
  73914. * @param extensions defines the extension to use to load the cube map (can be null)
  73915. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  73916. * @param files defines the list of files to load (can be null)
  73917. * @returns a new CubeTextureAssetTask object
  73918. */
  73919. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  73920. /**
  73921. *
  73922. * Add a HDRCubeTextureAssetTask to the list of active tasks
  73923. * @param taskName defines the name of the new task
  73924. * @param url defines the url of the file to load
  73925. * @param size defines the size you want for the cubemap (can be null)
  73926. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  73927. * @param generateHarmonics defines if you want to automatically generate (true by default)
  73928. * @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)
  73929. * @param reserved Internal use only
  73930. * @returns a new HDRCubeTextureAssetTask object
  73931. */
  73932. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  73933. /**
  73934. *
  73935. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  73936. * @param taskName defines the name of the new task
  73937. * @param url defines the url of the file to load
  73938. * @param size defines the size you want for the cubemap (can be null)
  73939. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  73940. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  73941. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  73942. * @returns a new EquiRectangularCubeTextureAssetTask object
  73943. */
  73944. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  73945. /**
  73946. * Remove a task from the assets manager.
  73947. * @param task the task to remove
  73948. */
  73949. removeTask(task: AbstractAssetTask): void;
  73950. private _decreaseWaitingTasksCount;
  73951. private _runTask;
  73952. /**
  73953. * Reset the AssetsManager and remove all tasks
  73954. * @return the current instance of the AssetsManager
  73955. */
  73956. reset(): AssetsManager;
  73957. /**
  73958. * Start the loading process
  73959. * @return the current instance of the AssetsManager
  73960. */
  73961. load(): AssetsManager;
  73962. /**
  73963. * Start the loading process as an async operation
  73964. * @return a promise returning the list of failed tasks
  73965. */
  73966. loadAsync(): Promise<void>;
  73967. }
  73968. }
  73969. declare module "babylonjs/Misc/deferred" {
  73970. /**
  73971. * Wrapper class for promise with external resolve and reject.
  73972. */
  73973. export class Deferred<T> {
  73974. /**
  73975. * The promise associated with this deferred object.
  73976. */
  73977. readonly promise: Promise<T>;
  73978. private _resolve;
  73979. private _reject;
  73980. /**
  73981. * The resolve method of the promise associated with this deferred object.
  73982. */
  73983. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  73984. /**
  73985. * The reject method of the promise associated with this deferred object.
  73986. */
  73987. get reject(): (reason?: any) => void;
  73988. /**
  73989. * Constructor for this deferred object.
  73990. */
  73991. constructor();
  73992. }
  73993. }
  73994. declare module "babylonjs/Misc/meshExploder" {
  73995. import { Mesh } from "babylonjs/Meshes/mesh";
  73996. /**
  73997. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  73998. */
  73999. export class MeshExploder {
  74000. private _centerMesh;
  74001. private _meshes;
  74002. private _meshesOrigins;
  74003. private _toCenterVectors;
  74004. private _scaledDirection;
  74005. private _newPosition;
  74006. private _centerPosition;
  74007. /**
  74008. * Explodes meshes from a center mesh.
  74009. * @param meshes The meshes to explode.
  74010. * @param centerMesh The mesh to be center of explosion.
  74011. */
  74012. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  74013. private _setCenterMesh;
  74014. /**
  74015. * Get class name
  74016. * @returns "MeshExploder"
  74017. */
  74018. getClassName(): string;
  74019. /**
  74020. * "Exploded meshes"
  74021. * @returns Array of meshes with the centerMesh at index 0.
  74022. */
  74023. getMeshes(): Array<Mesh>;
  74024. /**
  74025. * Explodes meshes giving a specific direction
  74026. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  74027. */
  74028. explode(direction?: number): void;
  74029. }
  74030. }
  74031. declare module "babylonjs/Misc/filesInput" {
  74032. import { Engine } from "babylonjs/Engines/engine";
  74033. import { Scene } from "babylonjs/scene";
  74034. import { SceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  74035. /**
  74036. * Class used to help managing file picking and drag'n'drop
  74037. */
  74038. export class FilesInput {
  74039. /**
  74040. * List of files ready to be loaded
  74041. */
  74042. static get FilesToLoad(): {
  74043. [key: string]: File;
  74044. };
  74045. /**
  74046. * Callback called when a file is processed
  74047. */
  74048. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  74049. private _engine;
  74050. private _currentScene;
  74051. private _sceneLoadedCallback;
  74052. private _progressCallback;
  74053. private _additionalRenderLoopLogicCallback;
  74054. private _textureLoadingCallback;
  74055. private _startingProcessingFilesCallback;
  74056. private _onReloadCallback;
  74057. private _errorCallback;
  74058. private _elementToMonitor;
  74059. private _sceneFileToLoad;
  74060. private _filesToLoad;
  74061. /**
  74062. * Creates a new FilesInput
  74063. * @param engine defines the rendering engine
  74064. * @param scene defines the hosting scene
  74065. * @param sceneLoadedCallback callback called when scene is loaded
  74066. * @param progressCallback callback called to track progress
  74067. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  74068. * @param textureLoadingCallback callback called when a texture is loading
  74069. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  74070. * @param onReloadCallback callback called when a reload is requested
  74071. * @param errorCallback callback call if an error occurs
  74072. */
  74073. 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);
  74074. private _dragEnterHandler;
  74075. private _dragOverHandler;
  74076. private _dropHandler;
  74077. /**
  74078. * Calls this function to listen to drag'n'drop events on a specific DOM element
  74079. * @param elementToMonitor defines the DOM element to track
  74080. */
  74081. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  74082. /**
  74083. * Release all associated resources
  74084. */
  74085. dispose(): void;
  74086. private renderFunction;
  74087. private drag;
  74088. private drop;
  74089. private _traverseFolder;
  74090. private _processFiles;
  74091. /**
  74092. * Load files from a drop event
  74093. * @param event defines the drop event to use as source
  74094. */
  74095. loadFiles(event: any): void;
  74096. private _processReload;
  74097. /**
  74098. * Reload the current scene from the loaded files
  74099. */
  74100. reload(): void;
  74101. }
  74102. }
  74103. declare module "babylonjs/Misc/HighDynamicRange/index" {
  74104. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  74105. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  74106. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  74107. }
  74108. declare module "babylonjs/Misc/sceneOptimizer" {
  74109. import { Scene, IDisposable } from "babylonjs/scene";
  74110. import { Observable } from "babylonjs/Misc/observable";
  74111. /**
  74112. * Defines the root class used to create scene optimization to use with SceneOptimizer
  74113. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74114. */
  74115. export class SceneOptimization {
  74116. /**
  74117. * Defines the priority of this optimization (0 by default which means first in the list)
  74118. */
  74119. priority: number;
  74120. /**
  74121. * Gets a string describing the action executed by the current optimization
  74122. * @returns description string
  74123. */
  74124. getDescription(): string;
  74125. /**
  74126. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  74127. * @param scene defines the current scene where to apply this optimization
  74128. * @param optimizer defines the current optimizer
  74129. * @returns true if everything that can be done was applied
  74130. */
  74131. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  74132. /**
  74133. * Creates the SceneOptimization object
  74134. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  74135. * @param desc defines the description associated with the optimization
  74136. */
  74137. constructor(
  74138. /**
  74139. * Defines the priority of this optimization (0 by default which means first in the list)
  74140. */
  74141. priority?: number);
  74142. }
  74143. /**
  74144. * Defines an optimization used to reduce the size of render target textures
  74145. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74146. */
  74147. export class TextureOptimization extends SceneOptimization {
  74148. /**
  74149. * Defines the priority of this optimization (0 by default which means first in the list)
  74150. */
  74151. priority: number;
  74152. /**
  74153. * 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
  74154. */
  74155. maximumSize: number;
  74156. /**
  74157. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  74158. */
  74159. step: number;
  74160. /**
  74161. * Gets a string describing the action executed by the current optimization
  74162. * @returns description string
  74163. */
  74164. getDescription(): string;
  74165. /**
  74166. * Creates the TextureOptimization object
  74167. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  74168. * @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
  74169. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  74170. */
  74171. constructor(
  74172. /**
  74173. * Defines the priority of this optimization (0 by default which means first in the list)
  74174. */
  74175. priority?: number,
  74176. /**
  74177. * 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
  74178. */
  74179. maximumSize?: number,
  74180. /**
  74181. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  74182. */
  74183. step?: number);
  74184. /**
  74185. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  74186. * @param scene defines the current scene where to apply this optimization
  74187. * @param optimizer defines the current optimizer
  74188. * @returns true if everything that can be done was applied
  74189. */
  74190. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  74191. }
  74192. /**
  74193. * Defines an optimization used to increase or decrease the rendering resolution
  74194. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74195. */
  74196. export class HardwareScalingOptimization extends SceneOptimization {
  74197. /**
  74198. * Defines the priority of this optimization (0 by default which means first in the list)
  74199. */
  74200. priority: number;
  74201. /**
  74202. * Defines the maximum scale to use (2 by default)
  74203. */
  74204. maximumScale: number;
  74205. /**
  74206. * Defines the step to use between two passes (0.5 by default)
  74207. */
  74208. step: number;
  74209. private _currentScale;
  74210. private _directionOffset;
  74211. /**
  74212. * Gets a string describing the action executed by the current optimization
  74213. * @return description string
  74214. */
  74215. getDescription(): string;
  74216. /**
  74217. * Creates the HardwareScalingOptimization object
  74218. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  74219. * @param maximumScale defines the maximum scale to use (2 by default)
  74220. * @param step defines the step to use between two passes (0.5 by default)
  74221. */
  74222. constructor(
  74223. /**
  74224. * Defines the priority of this optimization (0 by default which means first in the list)
  74225. */
  74226. priority?: number,
  74227. /**
  74228. * Defines the maximum scale to use (2 by default)
  74229. */
  74230. maximumScale?: number,
  74231. /**
  74232. * Defines the step to use between two passes (0.5 by default)
  74233. */
  74234. step?: number);
  74235. /**
  74236. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  74237. * @param scene defines the current scene where to apply this optimization
  74238. * @param optimizer defines the current optimizer
  74239. * @returns true if everything that can be done was applied
  74240. */
  74241. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  74242. }
  74243. /**
  74244. * Defines an optimization used to remove shadows
  74245. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74246. */
  74247. export class ShadowsOptimization extends SceneOptimization {
  74248. /**
  74249. * Gets a string describing the action executed by the current optimization
  74250. * @return description string
  74251. */
  74252. getDescription(): string;
  74253. /**
  74254. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  74255. * @param scene defines the current scene where to apply this optimization
  74256. * @param optimizer defines the current optimizer
  74257. * @returns true if everything that can be done was applied
  74258. */
  74259. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  74260. }
  74261. /**
  74262. * Defines an optimization used to turn post-processes off
  74263. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74264. */
  74265. export class PostProcessesOptimization extends SceneOptimization {
  74266. /**
  74267. * Gets a string describing the action executed by the current optimization
  74268. * @return description string
  74269. */
  74270. getDescription(): string;
  74271. /**
  74272. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  74273. * @param scene defines the current scene where to apply this optimization
  74274. * @param optimizer defines the current optimizer
  74275. * @returns true if everything that can be done was applied
  74276. */
  74277. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  74278. }
  74279. /**
  74280. * Defines an optimization used to turn lens flares off
  74281. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74282. */
  74283. export class LensFlaresOptimization extends SceneOptimization {
  74284. /**
  74285. * Gets a string describing the action executed by the current optimization
  74286. * @return description string
  74287. */
  74288. getDescription(): string;
  74289. /**
  74290. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  74291. * @param scene defines the current scene where to apply this optimization
  74292. * @param optimizer defines the current optimizer
  74293. * @returns true if everything that can be done was applied
  74294. */
  74295. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  74296. }
  74297. /**
  74298. * Defines an optimization based on user defined callback.
  74299. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74300. */
  74301. export class CustomOptimization extends SceneOptimization {
  74302. /**
  74303. * Callback called to apply the custom optimization.
  74304. */
  74305. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  74306. /**
  74307. * Callback called to get custom description
  74308. */
  74309. onGetDescription: () => string;
  74310. /**
  74311. * Gets a string describing the action executed by the current optimization
  74312. * @returns description string
  74313. */
  74314. getDescription(): string;
  74315. /**
  74316. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  74317. * @param scene defines the current scene where to apply this optimization
  74318. * @param optimizer defines the current optimizer
  74319. * @returns true if everything that can be done was applied
  74320. */
  74321. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  74322. }
  74323. /**
  74324. * Defines an optimization used to turn particles off
  74325. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74326. */
  74327. export class ParticlesOptimization extends SceneOptimization {
  74328. /**
  74329. * Gets a string describing the action executed by the current optimization
  74330. * @return description string
  74331. */
  74332. getDescription(): string;
  74333. /**
  74334. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  74335. * @param scene defines the current scene where to apply this optimization
  74336. * @param optimizer defines the current optimizer
  74337. * @returns true if everything that can be done was applied
  74338. */
  74339. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  74340. }
  74341. /**
  74342. * Defines an optimization used to turn render targets off
  74343. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74344. */
  74345. export class RenderTargetsOptimization extends SceneOptimization {
  74346. /**
  74347. * Gets a string describing the action executed by the current optimization
  74348. * @return description string
  74349. */
  74350. getDescription(): string;
  74351. /**
  74352. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  74353. * @param scene defines the current scene where to apply this optimization
  74354. * @param optimizer defines the current optimizer
  74355. * @returns true if everything that can be done was applied
  74356. */
  74357. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  74358. }
  74359. /**
  74360. * Defines an optimization used to merge meshes with compatible materials
  74361. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74362. */
  74363. export class MergeMeshesOptimization extends SceneOptimization {
  74364. private static _UpdateSelectionTree;
  74365. /**
  74366. * Gets or sets a boolean which defines if optimization octree has to be updated
  74367. */
  74368. static get UpdateSelectionTree(): boolean;
  74369. /**
  74370. * Gets or sets a boolean which defines if optimization octree has to be updated
  74371. */
  74372. static set UpdateSelectionTree(value: boolean);
  74373. /**
  74374. * Gets a string describing the action executed by the current optimization
  74375. * @return description string
  74376. */
  74377. getDescription(): string;
  74378. private _canBeMerged;
  74379. /**
  74380. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  74381. * @param scene defines the current scene where to apply this optimization
  74382. * @param optimizer defines the current optimizer
  74383. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  74384. * @returns true if everything that can be done was applied
  74385. */
  74386. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  74387. }
  74388. /**
  74389. * Defines a list of options used by SceneOptimizer
  74390. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74391. */
  74392. export class SceneOptimizerOptions {
  74393. /**
  74394. * Defines the target frame rate to reach (60 by default)
  74395. */
  74396. targetFrameRate: number;
  74397. /**
  74398. * Defines the interval between two checkes (2000ms by default)
  74399. */
  74400. trackerDuration: number;
  74401. /**
  74402. * Gets the list of optimizations to apply
  74403. */
  74404. optimizations: SceneOptimization[];
  74405. /**
  74406. * Creates a new list of options used by SceneOptimizer
  74407. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  74408. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  74409. */
  74410. constructor(
  74411. /**
  74412. * Defines the target frame rate to reach (60 by default)
  74413. */
  74414. targetFrameRate?: number,
  74415. /**
  74416. * Defines the interval between two checkes (2000ms by default)
  74417. */
  74418. trackerDuration?: number);
  74419. /**
  74420. * Add a new optimization
  74421. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  74422. * @returns the current SceneOptimizerOptions
  74423. */
  74424. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  74425. /**
  74426. * Add a new custom optimization
  74427. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  74428. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  74429. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  74430. * @returns the current SceneOptimizerOptions
  74431. */
  74432. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  74433. /**
  74434. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  74435. * @param targetFrameRate defines the target frame rate (60 by default)
  74436. * @returns a SceneOptimizerOptions object
  74437. */
  74438. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  74439. /**
  74440. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  74441. * @param targetFrameRate defines the target frame rate (60 by default)
  74442. * @returns a SceneOptimizerOptions object
  74443. */
  74444. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  74445. /**
  74446. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  74447. * @param targetFrameRate defines the target frame rate (60 by default)
  74448. * @returns a SceneOptimizerOptions object
  74449. */
  74450. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  74451. }
  74452. /**
  74453. * Class used to run optimizations in order to reach a target frame rate
  74454. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74455. */
  74456. export class SceneOptimizer implements IDisposable {
  74457. private _isRunning;
  74458. private _options;
  74459. private _scene;
  74460. private _currentPriorityLevel;
  74461. private _targetFrameRate;
  74462. private _trackerDuration;
  74463. private _currentFrameRate;
  74464. private _sceneDisposeObserver;
  74465. private _improvementMode;
  74466. /**
  74467. * Defines an observable called when the optimizer reaches the target frame rate
  74468. */
  74469. onSuccessObservable: Observable<SceneOptimizer>;
  74470. /**
  74471. * Defines an observable called when the optimizer enables an optimization
  74472. */
  74473. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  74474. /**
  74475. * Defines an observable called when the optimizer is not able to reach the target frame rate
  74476. */
  74477. onFailureObservable: Observable<SceneOptimizer>;
  74478. /**
  74479. * Gets a boolean indicating if the optimizer is in improvement mode
  74480. */
  74481. get isInImprovementMode(): boolean;
  74482. /**
  74483. * Gets the current priority level (0 at start)
  74484. */
  74485. get currentPriorityLevel(): number;
  74486. /**
  74487. * Gets the current frame rate checked by the SceneOptimizer
  74488. */
  74489. get currentFrameRate(): number;
  74490. /**
  74491. * Gets or sets the current target frame rate (60 by default)
  74492. */
  74493. get targetFrameRate(): number;
  74494. /**
  74495. * Gets or sets the current target frame rate (60 by default)
  74496. */
  74497. set targetFrameRate(value: number);
  74498. /**
  74499. * Gets or sets the current interval between two checks (every 2000ms by default)
  74500. */
  74501. get trackerDuration(): number;
  74502. /**
  74503. * Gets or sets the current interval between two checks (every 2000ms by default)
  74504. */
  74505. set trackerDuration(value: number);
  74506. /**
  74507. * Gets the list of active optimizations
  74508. */
  74509. get optimizations(): SceneOptimization[];
  74510. /**
  74511. * Creates a new SceneOptimizer
  74512. * @param scene defines the scene to work on
  74513. * @param options defines the options to use with the SceneOptimizer
  74514. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  74515. * @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)
  74516. */
  74517. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  74518. /**
  74519. * Stops the current optimizer
  74520. */
  74521. stop(): void;
  74522. /**
  74523. * Reset the optimizer to initial step (current priority level = 0)
  74524. */
  74525. reset(): void;
  74526. /**
  74527. * Start the optimizer. By default it will try to reach a specific framerate
  74528. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  74529. */
  74530. start(): void;
  74531. private _checkCurrentState;
  74532. /**
  74533. * Release all resources
  74534. */
  74535. dispose(): void;
  74536. /**
  74537. * Helper function to create a SceneOptimizer with one single line of code
  74538. * @param scene defines the scene to work on
  74539. * @param options defines the options to use with the SceneOptimizer
  74540. * @param onSuccess defines a callback to call on success
  74541. * @param onFailure defines a callback to call on failure
  74542. * @returns the new SceneOptimizer object
  74543. */
  74544. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  74545. }
  74546. }
  74547. declare module "babylonjs/Misc/sceneSerializer" {
  74548. import { Scene } from "babylonjs/scene";
  74549. /**
  74550. * Class used to serialize a scene into a string
  74551. */
  74552. export class SceneSerializer {
  74553. /**
  74554. * Clear cache used by a previous serialization
  74555. */
  74556. static ClearCache(): void;
  74557. /**
  74558. * Serialize a scene into a JSON compatible object
  74559. * @param scene defines the scene to serialize
  74560. * @returns a JSON compatible object
  74561. */
  74562. static Serialize(scene: Scene): any;
  74563. /**
  74564. * Serialize a mesh into a JSON compatible object
  74565. * @param toSerialize defines the mesh to serialize
  74566. * @param withParents defines if parents must be serialized as well
  74567. * @param withChildren defines if children must be serialized as well
  74568. * @returns a JSON compatible object
  74569. */
  74570. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  74571. }
  74572. }
  74573. declare module "babylonjs/Misc/textureTools" {
  74574. import { Texture } from "babylonjs/Materials/Textures/texture";
  74575. /**
  74576. * Class used to host texture specific utilities
  74577. */
  74578. export class TextureTools {
  74579. /**
  74580. * Uses the GPU to create a copy texture rescaled at a given size
  74581. * @param texture Texture to copy from
  74582. * @param width defines the desired width
  74583. * @param height defines the desired height
  74584. * @param useBilinearMode defines if bilinear mode has to be used
  74585. * @return the generated texture
  74586. */
  74587. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  74588. }
  74589. }
  74590. declare module "babylonjs/Misc/videoRecorder" {
  74591. import { Nullable } from "babylonjs/types";
  74592. import { Engine } from "babylonjs/Engines/engine";
  74593. /**
  74594. * This represents the different options available for the video capture.
  74595. */
  74596. export interface VideoRecorderOptions {
  74597. /** Defines the mime type of the video. */
  74598. mimeType: string;
  74599. /** Defines the FPS the video should be recorded at. */
  74600. fps: number;
  74601. /** Defines the chunk size for the recording data. */
  74602. recordChunckSize: number;
  74603. /** The audio tracks to attach to the recording. */
  74604. audioTracks?: MediaStreamTrack[];
  74605. }
  74606. /**
  74607. * This can help with recording videos from BabylonJS.
  74608. * This is based on the available WebRTC functionalities of the browser.
  74609. *
  74610. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  74611. */
  74612. export class VideoRecorder {
  74613. private static readonly _defaultOptions;
  74614. /**
  74615. * Returns whether or not the VideoRecorder is available in your browser.
  74616. * @param engine Defines the Babylon Engine.
  74617. * @returns true if supported otherwise false.
  74618. */
  74619. static IsSupported(engine: Engine): boolean;
  74620. private readonly _options;
  74621. private _canvas;
  74622. private _mediaRecorder;
  74623. private _recordedChunks;
  74624. private _fileName;
  74625. private _resolve;
  74626. private _reject;
  74627. /**
  74628. * True when a recording is already in progress.
  74629. */
  74630. get isRecording(): boolean;
  74631. /**
  74632. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  74633. * @param engine Defines the BabylonJS Engine you wish to record.
  74634. * @param options Defines options that can be used to customize the capture.
  74635. */
  74636. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  74637. /**
  74638. * Stops the current recording before the default capture timeout passed in the startRecording function.
  74639. */
  74640. stopRecording(): void;
  74641. /**
  74642. * Starts recording the canvas for a max duration specified in parameters.
  74643. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  74644. * If null no automatic download will start and you can rely on the promise to get the data back.
  74645. * @param maxDuration Defines the maximum recording time in seconds.
  74646. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  74647. * @return A promise callback at the end of the recording with the video data in Blob.
  74648. */
  74649. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  74650. /**
  74651. * Releases internal resources used during the recording.
  74652. */
  74653. dispose(): void;
  74654. private _handleDataAvailable;
  74655. private _handleError;
  74656. private _handleStop;
  74657. }
  74658. }
  74659. declare module "babylonjs/Misc/screenshotTools" {
  74660. import { Camera } from "babylonjs/Cameras/camera";
  74661. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  74662. import { Engine } from "babylonjs/Engines/engine";
  74663. /**
  74664. * Class containing a set of static utilities functions for screenshots
  74665. */
  74666. export class ScreenshotTools {
  74667. /**
  74668. * Captures a screenshot of the current rendering
  74669. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  74670. * @param engine defines the rendering engine
  74671. * @param camera defines the source camera
  74672. * @param size This parameter can be set to a single number or to an object with the
  74673. * following (optional) properties: precision, width, height. If a single number is passed,
  74674. * it will be used for both width and height. If an object is passed, the screenshot size
  74675. * will be derived from the parameters. The precision property is a multiplier allowing
  74676. * rendering at a higher or lower resolution
  74677. * @param successCallback defines the callback receives a single parameter which contains the
  74678. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  74679. * src parameter of an <img> to display it
  74680. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  74681. * Check your browser for supported MIME types
  74682. */
  74683. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  74684. /**
  74685. * Captures a screenshot of the current rendering
  74686. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  74687. * @param engine defines the rendering engine
  74688. * @param camera defines the source camera
  74689. * @param size This parameter can be set to a single number or to an object with the
  74690. * following (optional) properties: precision, width, height. If a single number is passed,
  74691. * it will be used for both width and height. If an object is passed, the screenshot size
  74692. * will be derived from the parameters. The precision property is a multiplier allowing
  74693. * rendering at a higher or lower resolution
  74694. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  74695. * Check your browser for supported MIME types
  74696. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  74697. * to the src parameter of an <img> to display it
  74698. */
  74699. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  74700. /**
  74701. * Generates an image screenshot from the specified camera.
  74702. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  74703. * @param engine The engine to use for rendering
  74704. * @param camera The camera to use for rendering
  74705. * @param size This parameter can be set to a single number or to an object with the
  74706. * following (optional) properties: precision, width, height. If a single number is passed,
  74707. * it will be used for both width and height. If an object is passed, the screenshot size
  74708. * will be derived from the parameters. The precision property is a multiplier allowing
  74709. * rendering at a higher or lower resolution
  74710. * @param successCallback The callback receives a single parameter which contains the
  74711. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  74712. * src parameter of an <img> to display it
  74713. * @param mimeType The MIME type of the screenshot image (default: image/png).
  74714. * Check your browser for supported MIME types
  74715. * @param samples Texture samples (default: 1)
  74716. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  74717. * @param fileName A name for for the downloaded file.
  74718. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  74719. */
  74720. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): void;
  74721. /**
  74722. * Generates an image screenshot from the specified camera.
  74723. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  74724. * @param engine The engine to use for rendering
  74725. * @param camera The camera to use for rendering
  74726. * @param size This parameter can be set to a single number or to an object with the
  74727. * following (optional) properties: precision, width, height. If a single number is passed,
  74728. * it will be used for both width and height. If an object is passed, the screenshot size
  74729. * will be derived from the parameters. The precision property is a multiplier allowing
  74730. * rendering at a higher or lower resolution
  74731. * @param mimeType The MIME type of the screenshot image (default: image/png).
  74732. * Check your browser for supported MIME types
  74733. * @param samples Texture samples (default: 1)
  74734. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  74735. * @param fileName A name for for the downloaded file.
  74736. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  74737. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  74738. * to the src parameter of an <img> to display it
  74739. */
  74740. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  74741. /**
  74742. * Gets height and width for screenshot size
  74743. * @private
  74744. */
  74745. private static _getScreenshotSize;
  74746. }
  74747. }
  74748. declare module "babylonjs/Misc/dataReader" {
  74749. /**
  74750. * Interface for a data buffer
  74751. */
  74752. export interface IDataBuffer {
  74753. /**
  74754. * Reads bytes from the data buffer.
  74755. * @param byteOffset The byte offset to read
  74756. * @param byteLength The byte length to read
  74757. * @returns A promise that resolves when the bytes are read
  74758. */
  74759. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  74760. /**
  74761. * The byte length of the buffer.
  74762. */
  74763. readonly byteLength: number;
  74764. }
  74765. /**
  74766. * Utility class for reading from a data buffer
  74767. */
  74768. export class DataReader {
  74769. /**
  74770. * The data buffer associated with this data reader.
  74771. */
  74772. readonly buffer: IDataBuffer;
  74773. /**
  74774. * The current byte offset from the beginning of the data buffer.
  74775. */
  74776. byteOffset: number;
  74777. private _dataView;
  74778. private _dataByteOffset;
  74779. /**
  74780. * Constructor
  74781. * @param buffer The buffer to read
  74782. */
  74783. constructor(buffer: IDataBuffer);
  74784. /**
  74785. * Loads the given byte length.
  74786. * @param byteLength The byte length to load
  74787. * @returns A promise that resolves when the load is complete
  74788. */
  74789. loadAsync(byteLength: number): Promise<void>;
  74790. /**
  74791. * Read a unsigned 32-bit integer from the currently loaded data range.
  74792. * @returns The 32-bit integer read
  74793. */
  74794. readUint32(): number;
  74795. /**
  74796. * Read a byte array from the currently loaded data range.
  74797. * @param byteLength The byte length to read
  74798. * @returns The byte array read
  74799. */
  74800. readUint8Array(byteLength: number): Uint8Array;
  74801. /**
  74802. * Read a string from the currently loaded data range.
  74803. * @param byteLength The byte length to read
  74804. * @returns The string read
  74805. */
  74806. readString(byteLength: number): string;
  74807. /**
  74808. * Skips the given byte length the currently loaded data range.
  74809. * @param byteLength The byte length to skip
  74810. */
  74811. skipBytes(byteLength: number): void;
  74812. }
  74813. }
  74814. declare module "babylonjs/Misc/dataStorage" {
  74815. /**
  74816. * Class for storing data to local storage if available or in-memory storage otherwise
  74817. */
  74818. export class DataStorage {
  74819. private static _Storage;
  74820. private static _GetStorage;
  74821. /**
  74822. * Reads a string from the data storage
  74823. * @param key The key to read
  74824. * @param defaultValue The value if the key doesn't exist
  74825. * @returns The string value
  74826. */
  74827. static ReadString(key: string, defaultValue: string): string;
  74828. /**
  74829. * Writes a string to the data storage
  74830. * @param key The key to write
  74831. * @param value The value to write
  74832. */
  74833. static WriteString(key: string, value: string): void;
  74834. /**
  74835. * Reads a boolean from the data storage
  74836. * @param key The key to read
  74837. * @param defaultValue The value if the key doesn't exist
  74838. * @returns The boolean value
  74839. */
  74840. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  74841. /**
  74842. * Writes a boolean to the data storage
  74843. * @param key The key to write
  74844. * @param value The value to write
  74845. */
  74846. static WriteBoolean(key: string, value: boolean): void;
  74847. /**
  74848. * Reads a number from the data storage
  74849. * @param key The key to read
  74850. * @param defaultValue The value if the key doesn't exist
  74851. * @returns The number value
  74852. */
  74853. static ReadNumber(key: string, defaultValue: number): number;
  74854. /**
  74855. * Writes a number to the data storage
  74856. * @param key The key to write
  74857. * @param value The value to write
  74858. */
  74859. static WriteNumber(key: string, value: number): void;
  74860. }
  74861. }
  74862. declare module "babylonjs/Misc/index" {
  74863. export * from "babylonjs/Misc/andOrNotEvaluator";
  74864. export * from "babylonjs/Misc/assetsManager";
  74865. export * from "babylonjs/Misc/basis";
  74866. export * from "babylonjs/Misc/dds";
  74867. export * from "babylonjs/Misc/decorators";
  74868. export * from "babylonjs/Misc/deferred";
  74869. export * from "babylonjs/Misc/environmentTextureTools";
  74870. export * from "babylonjs/Misc/meshExploder";
  74871. export * from "babylonjs/Misc/filesInput";
  74872. export * from "babylonjs/Misc/HighDynamicRange/index";
  74873. export * from "babylonjs/Misc/khronosTextureContainer";
  74874. export * from "babylonjs/Misc/observable";
  74875. export * from "babylonjs/Misc/performanceMonitor";
  74876. export * from "babylonjs/Misc/promise";
  74877. export * from "babylonjs/Misc/sceneOptimizer";
  74878. export * from "babylonjs/Misc/sceneSerializer";
  74879. export * from "babylonjs/Misc/smartArray";
  74880. export * from "babylonjs/Misc/stringDictionary";
  74881. export * from "babylonjs/Misc/tags";
  74882. export * from "babylonjs/Misc/textureTools";
  74883. export * from "babylonjs/Misc/tga";
  74884. export * from "babylonjs/Misc/tools";
  74885. export * from "babylonjs/Misc/videoRecorder";
  74886. export * from "babylonjs/Misc/virtualJoystick";
  74887. export * from "babylonjs/Misc/workerPool";
  74888. export * from "babylonjs/Misc/logger";
  74889. export * from "babylonjs/Misc/typeStore";
  74890. export * from "babylonjs/Misc/filesInputStore";
  74891. export * from "babylonjs/Misc/deepCopier";
  74892. export * from "babylonjs/Misc/pivotTools";
  74893. export * from "babylonjs/Misc/precisionDate";
  74894. export * from "babylonjs/Misc/screenshotTools";
  74895. export * from "babylonjs/Misc/typeStore";
  74896. export * from "babylonjs/Misc/webRequest";
  74897. export * from "babylonjs/Misc/iInspectable";
  74898. export * from "babylonjs/Misc/brdfTextureTools";
  74899. export * from "babylonjs/Misc/rgbdTextureTools";
  74900. export * from "babylonjs/Misc/gradients";
  74901. export * from "babylonjs/Misc/perfCounter";
  74902. export * from "babylonjs/Misc/fileRequest";
  74903. export * from "babylonjs/Misc/customAnimationFrameRequester";
  74904. export * from "babylonjs/Misc/retryStrategy";
  74905. export * from "babylonjs/Misc/interfaces/screenshotSize";
  74906. export * from "babylonjs/Misc/canvasGenerator";
  74907. export * from "babylonjs/Misc/fileTools";
  74908. export * from "babylonjs/Misc/stringTools";
  74909. export * from "babylonjs/Misc/dataReader";
  74910. export * from "babylonjs/Misc/minMaxReducer";
  74911. export * from "babylonjs/Misc/depthReducer";
  74912. export * from "babylonjs/Misc/dataStorage";
  74913. }
  74914. declare module "babylonjs/XR/features/WebXRHitTestLegacy" {
  74915. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  74916. import { Observable } from "babylonjs/Misc/observable";
  74917. import { Matrix } from "babylonjs/Maths/math.vector";
  74918. import { TransformNode } from "babylonjs/Meshes/transformNode";
  74919. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  74920. /**
  74921. * Options used for hit testing
  74922. */
  74923. export interface IWebXRLegacyHitTestOptions {
  74924. /**
  74925. * Only test when user interacted with the scene. Default - hit test every frame
  74926. */
  74927. testOnPointerDownOnly?: boolean;
  74928. /**
  74929. * The node to use to transform the local results to world coordinates
  74930. */
  74931. worldParentNode?: TransformNode;
  74932. }
  74933. /**
  74934. * Interface defining the babylon result of raycasting/hit-test
  74935. */
  74936. export interface IWebXRLegacyHitResult {
  74937. /**
  74938. * Transformation matrix that can be applied to a node that will put it in the hit point location
  74939. */
  74940. transformationMatrix: Matrix;
  74941. /**
  74942. * The native hit test result
  74943. */
  74944. xrHitResult: XRHitResult | XRHitTestResult;
  74945. }
  74946. /**
  74947. * The currently-working hit-test module.
  74948. * Hit test (or Ray-casting) is used to interact with the real world.
  74949. * For further information read here - https://github.com/immersive-web/hit-test
  74950. */
  74951. export class WebXRHitTestLegacy extends WebXRAbstractFeature {
  74952. /**
  74953. * options to use when constructing this feature
  74954. */
  74955. readonly options: IWebXRLegacyHitTestOptions;
  74956. private _direction;
  74957. private _mat;
  74958. private _onSelectEnabled;
  74959. private _origin;
  74960. /**
  74961. * The module's name
  74962. */
  74963. static readonly Name: string;
  74964. /**
  74965. * The (Babylon) version of this module.
  74966. * This is an integer representing the implementation version.
  74967. * This number does not correspond to the WebXR specs version
  74968. */
  74969. static readonly Version: number;
  74970. /**
  74971. * Populated with the last native XR Hit Results
  74972. */
  74973. lastNativeXRHitResults: XRHitResult[];
  74974. /**
  74975. * Triggered when new babylon (transformed) hit test results are available
  74976. */
  74977. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  74978. /**
  74979. * Creates a new instance of the (legacy version) hit test feature
  74980. * @param _xrSessionManager an instance of WebXRSessionManager
  74981. * @param options options to use when constructing this feature
  74982. */
  74983. constructor(_xrSessionManager: WebXRSessionManager,
  74984. /**
  74985. * options to use when constructing this feature
  74986. */
  74987. options?: IWebXRLegacyHitTestOptions);
  74988. /**
  74989. * execute a hit test with an XR Ray
  74990. *
  74991. * @param xrSession a native xrSession that will execute this hit test
  74992. * @param xrRay the ray (position and direction) to use for ray-casting
  74993. * @param referenceSpace native XR reference space to use for the hit-test
  74994. * @param filter filter function that will filter the results
  74995. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  74996. */
  74997. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  74998. /**
  74999. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  75000. * @param event the (select) event to use to select with
  75001. * @param referenceSpace the reference space to use for this hit test
  75002. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  75003. */
  75004. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  75005. /**
  75006. * attach this feature
  75007. * Will usually be called by the features manager
  75008. *
  75009. * @returns true if successful.
  75010. */
  75011. attach(): boolean;
  75012. /**
  75013. * detach this feature.
  75014. * Will usually be called by the features manager
  75015. *
  75016. * @returns true if successful.
  75017. */
  75018. detach(): boolean;
  75019. /**
  75020. * Dispose this feature and all of the resources attached
  75021. */
  75022. dispose(): void;
  75023. protected _onXRFrame(frame: XRFrame): void;
  75024. private _onHitTestResults;
  75025. private _onSelect;
  75026. }
  75027. }
  75028. declare module "babylonjs/XR/features/WebXRPlaneDetector" {
  75029. import { TransformNode } from "babylonjs/Meshes/transformNode";
  75030. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  75031. import { Observable } from "babylonjs/Misc/observable";
  75032. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  75033. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  75034. /**
  75035. * Options used in the plane detector module
  75036. */
  75037. export interface IWebXRPlaneDetectorOptions {
  75038. /**
  75039. * The node to use to transform the local results to world coordinates
  75040. */
  75041. worldParentNode?: TransformNode;
  75042. }
  75043. /**
  75044. * A babylon interface for a WebXR plane.
  75045. * A Plane is actually a polygon, built from N points in space
  75046. *
  75047. * Supported in chrome 79, not supported in canary 81 ATM
  75048. */
  75049. export interface IWebXRPlane {
  75050. /**
  75051. * a babylon-assigned ID for this polygon
  75052. */
  75053. id: number;
  75054. /**
  75055. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  75056. */
  75057. polygonDefinition: Array<Vector3>;
  75058. /**
  75059. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  75060. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  75061. */
  75062. transformationMatrix: Matrix;
  75063. /**
  75064. * the native xr-plane object
  75065. */
  75066. xrPlane: XRPlane;
  75067. }
  75068. /**
  75069. * The plane detector is used to detect planes in the real world when in AR
  75070. * For more information see https://github.com/immersive-web/real-world-geometry/
  75071. */
  75072. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  75073. private _options;
  75074. private _detectedPlanes;
  75075. private _enabled;
  75076. private _lastFrameDetected;
  75077. /**
  75078. * The module's name
  75079. */
  75080. static readonly Name: string;
  75081. /**
  75082. * The (Babylon) version of this module.
  75083. * This is an integer representing the implementation version.
  75084. * This number does not correspond to the WebXR specs version
  75085. */
  75086. static readonly Version: number;
  75087. /**
  75088. * Observers registered here will be executed when a new plane was added to the session
  75089. */
  75090. onPlaneAddedObservable: Observable<IWebXRPlane>;
  75091. /**
  75092. * Observers registered here will be executed when a plane is no longer detected in the session
  75093. */
  75094. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  75095. /**
  75096. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  75097. * This can execute N times every frame
  75098. */
  75099. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  75100. /**
  75101. * construct a new Plane Detector
  75102. * @param _xrSessionManager an instance of xr Session manager
  75103. * @param _options configuration to use when constructing this feature
  75104. */
  75105. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  75106. /**
  75107. * Dispose this feature and all of the resources attached
  75108. */
  75109. dispose(): void;
  75110. protected _onXRFrame(frame: XRFrame): void;
  75111. private _init;
  75112. private _updatePlaneWithXRPlane;
  75113. /**
  75114. * avoiding using Array.find for global support.
  75115. * @param xrPlane the plane to find in the array
  75116. */
  75117. private findIndexInPlaneArray;
  75118. }
  75119. }
  75120. declare module "babylonjs/XR/features/WebXRAnchorSystem" {
  75121. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  75122. import { Observable } from "babylonjs/Misc/observable";
  75123. import { Matrix } from "babylonjs/Maths/math.vector";
  75124. import { TransformNode } from "babylonjs/Meshes/transformNode";
  75125. import { WebXRPlaneDetector } from "babylonjs/XR/features/WebXRPlaneDetector";
  75126. import { WebXRHitTestLegacy } from "babylonjs/XR/features/WebXRHitTestLegacy";
  75127. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  75128. /**
  75129. * Configuration options of the anchor system
  75130. */
  75131. export interface IWebXRAnchorSystemOptions {
  75132. /**
  75133. * Should a new anchor be added every time a select event is triggered
  75134. */
  75135. addAnchorOnSelect?: boolean;
  75136. /**
  75137. * should the anchor system use plane detection.
  75138. * If set to true, the plane-detection feature should be set using setPlaneDetector
  75139. */
  75140. usePlaneDetection?: boolean;
  75141. /**
  75142. * a node that will be used to convert local to world coordinates
  75143. */
  75144. worldParentNode?: TransformNode;
  75145. }
  75146. /**
  75147. * A babylon container for an XR Anchor
  75148. */
  75149. export interface IWebXRAnchor {
  75150. /**
  75151. * A babylon-assigned ID for this anchor
  75152. */
  75153. id: number;
  75154. /**
  75155. * Transformation matrix to apply to an object attached to this anchor
  75156. */
  75157. transformationMatrix: Matrix;
  75158. /**
  75159. * The native anchor object
  75160. */
  75161. xrAnchor: XRAnchor;
  75162. }
  75163. /**
  75164. * An implementation of the anchor system of WebXR.
  75165. * Note that the current documented implementation is not available in any browser. Future implementations
  75166. * will use the frame to create an anchor and not the session or a detected plane
  75167. * For further information see https://github.com/immersive-web/anchors/
  75168. */
  75169. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  75170. private _options;
  75171. private _enabled;
  75172. private _hitTestModule;
  75173. private _lastFrameDetected;
  75174. private _onSelect;
  75175. private _planeDetector;
  75176. private _trackedAnchors;
  75177. /**
  75178. * The module's name
  75179. */
  75180. static readonly Name: string;
  75181. /**
  75182. * The (Babylon) version of this module.
  75183. * This is an integer representing the implementation version.
  75184. * This number does not correspond to the WebXR specs version
  75185. */
  75186. static readonly Version: number;
  75187. /**
  75188. * Observers registered here will be executed when a new anchor was added to the session
  75189. */
  75190. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  75191. /**
  75192. * Observers registered here will be executed when an anchor was removed from the session
  75193. */
  75194. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  75195. /**
  75196. * Observers registered here will be executed when an existing anchor updates
  75197. * This can execute N times every frame
  75198. */
  75199. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  75200. /**
  75201. * constructs a new anchor system
  75202. * @param _xrSessionManager an instance of WebXRSessionManager
  75203. * @param _options configuration object for this feature
  75204. */
  75205. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  75206. /**
  75207. * Add anchor at a specific XR point.
  75208. *
  75209. * @param xrRigidTransformation xr-coordinates where a new anchor should be added
  75210. * @param anchorCreator the object o use to create an anchor with. either a session or a plane
  75211. * @returns a promise the fulfills when the anchor was created
  75212. */
  75213. addAnchorAtRigidTransformation(xrRigidTransformation: XRRigidTransform, anchorCreator?: XRAnchorCreator): Promise<XRAnchor>;
  75214. /**
  75215. * attach this feature
  75216. * Will usually be called by the features manager
  75217. *
  75218. * @returns true if successful.
  75219. */
  75220. attach(): boolean;
  75221. /**
  75222. * detach this feature.
  75223. * Will usually be called by the features manager
  75224. *
  75225. * @returns true if successful.
  75226. */
  75227. detach(): boolean;
  75228. /**
  75229. * Dispose this feature and all of the resources attached
  75230. */
  75231. dispose(): void;
  75232. /**
  75233. * If set, it will improve performance by using the current hit-test results instead of executing a new hit-test
  75234. * @param hitTestModule the hit-test module to use.
  75235. */
  75236. setHitTestModule(hitTestModule: WebXRHitTestLegacy): void;
  75237. /**
  75238. * set the plane detector to use in order to create anchors from frames
  75239. * @param planeDetector the plane-detector module to use
  75240. * @param enable enable plane-anchors. default is true
  75241. */
  75242. setPlaneDetector(planeDetector: WebXRPlaneDetector, enable?: boolean): void;
  75243. protected _onXRFrame(frame: XRFrame): void;
  75244. /**
  75245. * avoiding using Array.find for global support.
  75246. * @param xrAnchor the plane to find in the array
  75247. */
  75248. private _findIndexInAnchorArray;
  75249. private _updateAnchorWithXRFrame;
  75250. }
  75251. }
  75252. declare module "babylonjs/XR/features/WebXRBackgroundRemover" {
  75253. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  75254. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  75255. import { Observable } from "babylonjs/Misc/observable";
  75256. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  75257. /**
  75258. * Options interface for the background remover plugin
  75259. */
  75260. export interface IWebXRBackgroundRemoverOptions {
  75261. /**
  75262. * Further background meshes to disable when entering AR
  75263. */
  75264. backgroundMeshes?: AbstractMesh[];
  75265. /**
  75266. * flags to configure the removal of the environment helper.
  75267. * If not set, the entire background will be removed. If set, flags should be set as well.
  75268. */
  75269. environmentHelperRemovalFlags?: {
  75270. /**
  75271. * Should the skybox be removed (default false)
  75272. */
  75273. skyBox?: boolean;
  75274. /**
  75275. * Should the ground be removed (default false)
  75276. */
  75277. ground?: boolean;
  75278. };
  75279. /**
  75280. * don't disable the environment helper
  75281. */
  75282. ignoreEnvironmentHelper?: boolean;
  75283. }
  75284. /**
  75285. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  75286. */
  75287. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  75288. /**
  75289. * read-only options to be used in this module
  75290. */
  75291. readonly options: IWebXRBackgroundRemoverOptions;
  75292. /**
  75293. * The module's name
  75294. */
  75295. static readonly Name: string;
  75296. /**
  75297. * The (Babylon) version of this module.
  75298. * This is an integer representing the implementation version.
  75299. * This number does not correspond to the WebXR specs version
  75300. */
  75301. static readonly Version: number;
  75302. /**
  75303. * registered observers will be triggered when the background state changes
  75304. */
  75305. onBackgroundStateChangedObservable: Observable<boolean>;
  75306. /**
  75307. * constructs a new background remover module
  75308. * @param _xrSessionManager the session manager for this module
  75309. * @param options read-only options to be used in this module
  75310. */
  75311. constructor(_xrSessionManager: WebXRSessionManager,
  75312. /**
  75313. * read-only options to be used in this module
  75314. */
  75315. options?: IWebXRBackgroundRemoverOptions);
  75316. /**
  75317. * attach this feature
  75318. * Will usually be called by the features manager
  75319. *
  75320. * @returns true if successful.
  75321. */
  75322. attach(): boolean;
  75323. /**
  75324. * detach this feature.
  75325. * Will usually be called by the features manager
  75326. *
  75327. * @returns true if successful.
  75328. */
  75329. detach(): boolean;
  75330. /**
  75331. * Dispose this feature and all of the resources attached
  75332. */
  75333. dispose(): void;
  75334. protected _onXRFrame(_xrFrame: XRFrame): void;
  75335. private _setBackgroundState;
  75336. }
  75337. }
  75338. declare module "babylonjs/XR/features/WebXRControllerPhysics" {
  75339. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  75340. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  75341. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  75342. import { WebXRInput } from "babylonjs/XR/webXRInput";
  75343. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  75344. import { Nullable } from "babylonjs/types";
  75345. /**
  75346. * Options for the controller physics feature
  75347. */
  75348. export class IWebXRControllerPhysicsOptions {
  75349. /**
  75350. * Should the headset get its own impostor
  75351. */
  75352. enableHeadsetImpostor?: boolean;
  75353. /**
  75354. * Optional parameters for the headset impostor
  75355. */
  75356. headsetImpostorParams?: {
  75357. /**
  75358. * The type of impostor to create. Default is sphere
  75359. */
  75360. impostorType: number;
  75361. /**
  75362. * the size of the impostor. Defaults to 10cm
  75363. */
  75364. impostorSize?: number | {
  75365. width: number;
  75366. height: number;
  75367. depth: number;
  75368. };
  75369. /**
  75370. * Friction definitions
  75371. */
  75372. friction?: number;
  75373. /**
  75374. * Restitution
  75375. */
  75376. restitution?: number;
  75377. };
  75378. /**
  75379. * The physics properties of the future impostors
  75380. */
  75381. physicsProperties?: {
  75382. /**
  75383. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  75384. * Note that this requires a physics engine that supports mesh impostors!
  75385. */
  75386. useControllerMesh?: boolean;
  75387. /**
  75388. * The type of impostor to create. Default is sphere
  75389. */
  75390. impostorType?: number;
  75391. /**
  75392. * the size of the impostor. Defaults to 10cm
  75393. */
  75394. impostorSize?: number | {
  75395. width: number;
  75396. height: number;
  75397. depth: number;
  75398. };
  75399. /**
  75400. * Friction definitions
  75401. */
  75402. friction?: number;
  75403. /**
  75404. * Restitution
  75405. */
  75406. restitution?: number;
  75407. };
  75408. /**
  75409. * the xr input to use with this pointer selection
  75410. */
  75411. xrInput: WebXRInput;
  75412. }
  75413. /**
  75414. * Add physics impostor to your webxr controllers,
  75415. * including naive calculation of their linear and angular velocity
  75416. */
  75417. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  75418. private readonly _options;
  75419. private _attachController;
  75420. private _controllers;
  75421. private _debugMode;
  75422. private _delta;
  75423. private _headsetImpostor?;
  75424. private _headsetMesh?;
  75425. private _lastTimestamp;
  75426. private _tmpQuaternion;
  75427. private _tmpVector;
  75428. /**
  75429. * The module's name
  75430. */
  75431. static readonly Name: string;
  75432. /**
  75433. * The (Babylon) version of this module.
  75434. * This is an integer representing the implementation version.
  75435. * This number does not correspond to the webxr specs version
  75436. */
  75437. static readonly Version: number;
  75438. /**
  75439. * Construct a new Controller Physics Feature
  75440. * @param _xrSessionManager the corresponding xr session manager
  75441. * @param _options options to create this feature with
  75442. */
  75443. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  75444. /**
  75445. * @hidden
  75446. * enable debugging - will show console outputs and the impostor mesh
  75447. */
  75448. _enablePhysicsDebug(): void;
  75449. /**
  75450. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  75451. * @param xrController the controller to add
  75452. */
  75453. addController(xrController: WebXRInputSource): void;
  75454. /**
  75455. * attach this feature
  75456. * Will usually be called by the features manager
  75457. *
  75458. * @returns true if successful.
  75459. */
  75460. attach(): boolean;
  75461. /**
  75462. * detach this feature.
  75463. * Will usually be called by the features manager
  75464. *
  75465. * @returns true if successful.
  75466. */
  75467. detach(): boolean;
  75468. /**
  75469. * Get the headset impostor, if enabled
  75470. * @returns the impostor
  75471. */
  75472. getHeadsetImpostor(): PhysicsImpostor | undefined;
  75473. /**
  75474. * Get the physics impostor of a specific controller.
  75475. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  75476. * @param controller the controller or the controller id of which to get the impostor
  75477. * @returns the impostor or null
  75478. */
  75479. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  75480. /**
  75481. * Update the physics properties provided in the constructor
  75482. * @param newProperties the new properties object
  75483. */
  75484. setPhysicsProperties(newProperties: {
  75485. impostorType?: number;
  75486. impostorSize?: number | {
  75487. width: number;
  75488. height: number;
  75489. depth: number;
  75490. };
  75491. friction?: number;
  75492. restitution?: number;
  75493. }): void;
  75494. protected _onXRFrame(_xrFrame: any): void;
  75495. private _detachController;
  75496. }
  75497. }
  75498. declare module "babylonjs/XR/features/WebXRHitTest" {
  75499. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  75500. import { Observable } from "babylonjs/Misc/observable";
  75501. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  75502. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  75503. import { IWebXRLegacyHitTestOptions, IWebXRLegacyHitResult } from "babylonjs/XR/features/WebXRHitTestLegacy";
  75504. /**
  75505. * Options used for hit testing (version 2)
  75506. */
  75507. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  75508. /**
  75509. * Do not create a permanent hit test. Will usually be used when only
  75510. * transient inputs are needed.
  75511. */
  75512. disablePermanentHitTest?: boolean;
  75513. /**
  75514. * Enable transient (for example touch-based) hit test inspections
  75515. */
  75516. enableTransientHitTest?: boolean;
  75517. /**
  75518. * Offset ray for the permanent hit test
  75519. */
  75520. offsetRay?: Vector3;
  75521. /**
  75522. * Offset ray for the transient hit test
  75523. */
  75524. transientOffsetRay?: Vector3;
  75525. /**
  75526. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  75527. */
  75528. useReferenceSpace?: boolean;
  75529. }
  75530. /**
  75531. * Interface defining the babylon result of hit-test
  75532. */
  75533. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  75534. /**
  75535. * The input source that generated this hit test (if transient)
  75536. */
  75537. inputSource?: XRInputSource;
  75538. /**
  75539. * Is this a transient hit test
  75540. */
  75541. isTransient?: boolean;
  75542. /**
  75543. * Position of the hit test result
  75544. */
  75545. position: Vector3;
  75546. /**
  75547. * Rotation of the hit test result
  75548. */
  75549. rotationQuaternion: Quaternion;
  75550. }
  75551. /**
  75552. * The currently-working hit-test module.
  75553. * Hit test (or Ray-casting) is used to interact with the real world.
  75554. * For further information read here - https://github.com/immersive-web/hit-test
  75555. *
  75556. * Tested on chrome (mobile) 80.
  75557. */
  75558. export class WebXRHitTest extends WebXRAbstractFeature {
  75559. /**
  75560. * options to use when constructing this feature
  75561. */
  75562. readonly options: IWebXRHitTestOptions;
  75563. private _tmpMat;
  75564. private _tmpPos;
  75565. private _tmpQuat;
  75566. private _transientXrHitTestSource;
  75567. private _xrHitTestSource;
  75568. private initHitTestSource;
  75569. /**
  75570. * The module's name
  75571. */
  75572. static readonly Name: string;
  75573. /**
  75574. * The (Babylon) version of this module.
  75575. * This is an integer representing the implementation version.
  75576. * This number does not correspond to the WebXR specs version
  75577. */
  75578. static readonly Version: number;
  75579. /**
  75580. * When set to true, each hit test will have its own position/rotation objects
  75581. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  75582. * the developers will clone them or copy them as they see fit.
  75583. */
  75584. autoCloneTransformation: boolean;
  75585. /**
  75586. * Populated with the last native XR Hit Results
  75587. */
  75588. lastNativeXRHitResults: XRHitResult[];
  75589. /**
  75590. * Triggered when new babylon (transformed) hit test results are available
  75591. */
  75592. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  75593. /**
  75594. * Use this to temporarily pause hit test checks.
  75595. */
  75596. paused: boolean;
  75597. /**
  75598. * Creates a new instance of the hit test feature
  75599. * @param _xrSessionManager an instance of WebXRSessionManager
  75600. * @param options options to use when constructing this feature
  75601. */
  75602. constructor(_xrSessionManager: WebXRSessionManager,
  75603. /**
  75604. * options to use when constructing this feature
  75605. */
  75606. options?: IWebXRHitTestOptions);
  75607. /**
  75608. * attach this feature
  75609. * Will usually be called by the features manager
  75610. *
  75611. * @returns true if successful.
  75612. */
  75613. attach(): boolean;
  75614. /**
  75615. * detach this feature.
  75616. * Will usually be called by the features manager
  75617. *
  75618. * @returns true if successful.
  75619. */
  75620. detach(): boolean;
  75621. /**
  75622. * Dispose this feature and all of the resources attached
  75623. */
  75624. dispose(): void;
  75625. protected _onXRFrame(frame: XRFrame): void;
  75626. private _processWebXRHitTestResult;
  75627. }
  75628. }
  75629. declare module "babylonjs/XR/features/index" {
  75630. export * from "babylonjs/XR/features/WebXRHitTestLegacy";
  75631. export * from "babylonjs/XR/features/WebXRAnchorSystem";
  75632. export * from "babylonjs/XR/features/WebXRPlaneDetector";
  75633. export * from "babylonjs/XR/features/WebXRBackgroundRemover";
  75634. export * from "babylonjs/XR/features/WebXRControllerTeleportation";
  75635. export * from "babylonjs/XR/features/WebXRControllerPointerSelection";
  75636. export * from "babylonjs/XR/features/WebXRControllerPhysics";
  75637. export * from "babylonjs/XR/features/WebXRHitTest";
  75638. }
  75639. declare module "babylonjs/XR/motionController/webXRMicrosoftMixedRealityController" {
  75640. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandedness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  75641. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  75642. import { Scene } from "babylonjs/scene";
  75643. /**
  75644. * The motion controller class for all microsoft mixed reality controllers
  75645. */
  75646. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  75647. protected readonly _mapping: {
  75648. defaultButton: {
  75649. valueNodeName: string;
  75650. unpressedNodeName: string;
  75651. pressedNodeName: string;
  75652. };
  75653. defaultAxis: {
  75654. valueNodeName: string;
  75655. minNodeName: string;
  75656. maxNodeName: string;
  75657. };
  75658. buttons: {
  75659. "xr-standard-trigger": {
  75660. rootNodeName: string;
  75661. componentProperty: string;
  75662. states: string[];
  75663. };
  75664. "xr-standard-squeeze": {
  75665. rootNodeName: string;
  75666. componentProperty: string;
  75667. states: string[];
  75668. };
  75669. "xr-standard-touchpad": {
  75670. rootNodeName: string;
  75671. labelAnchorNodeName: string;
  75672. touchPointNodeName: string;
  75673. };
  75674. "xr-standard-thumbstick": {
  75675. rootNodeName: string;
  75676. componentProperty: string;
  75677. states: string[];
  75678. };
  75679. };
  75680. axes: {
  75681. "xr-standard-touchpad": {
  75682. "x-axis": {
  75683. rootNodeName: string;
  75684. };
  75685. "y-axis": {
  75686. rootNodeName: string;
  75687. };
  75688. };
  75689. "xr-standard-thumbstick": {
  75690. "x-axis": {
  75691. rootNodeName: string;
  75692. };
  75693. "y-axis": {
  75694. rootNodeName: string;
  75695. };
  75696. };
  75697. };
  75698. };
  75699. /**
  75700. * The base url used to load the left and right controller models
  75701. */
  75702. static MODEL_BASE_URL: string;
  75703. /**
  75704. * The name of the left controller model file
  75705. */
  75706. static MODEL_LEFT_FILENAME: string;
  75707. /**
  75708. * The name of the right controller model file
  75709. */
  75710. static MODEL_RIGHT_FILENAME: string;
  75711. profileId: string;
  75712. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  75713. protected _getFilenameAndPath(): {
  75714. filename: string;
  75715. path: string;
  75716. };
  75717. protected _getModelLoadingConstraints(): boolean;
  75718. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  75719. protected _setRootMesh(meshes: AbstractMesh[]): void;
  75720. protected _updateModel(): void;
  75721. }
  75722. }
  75723. declare module "babylonjs/XR/motionController/webXROculusTouchMotionController" {
  75724. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandedness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  75725. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  75726. import { Scene } from "babylonjs/scene";
  75727. /**
  75728. * The motion controller class for oculus touch (quest, rift).
  75729. * This class supports legacy mapping as well the standard xr mapping
  75730. */
  75731. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  75732. private _forceLegacyControllers;
  75733. private _modelRootNode;
  75734. /**
  75735. * The base url used to load the left and right controller models
  75736. */
  75737. static MODEL_BASE_URL: string;
  75738. /**
  75739. * The name of the left controller model file
  75740. */
  75741. static MODEL_LEFT_FILENAME: string;
  75742. /**
  75743. * The name of the right controller model file
  75744. */
  75745. static MODEL_RIGHT_FILENAME: string;
  75746. /**
  75747. * Base Url for the Quest controller model.
  75748. */
  75749. static QUEST_MODEL_BASE_URL: string;
  75750. profileId: string;
  75751. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  75752. protected _getFilenameAndPath(): {
  75753. filename: string;
  75754. path: string;
  75755. };
  75756. protected _getModelLoadingConstraints(): boolean;
  75757. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  75758. protected _setRootMesh(meshes: AbstractMesh[]): void;
  75759. protected _updateModel(): void;
  75760. /**
  75761. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  75762. * between the touch and touch 2.
  75763. */
  75764. private _isQuest;
  75765. }
  75766. }
  75767. declare module "babylonjs/XR/motionController/webXRHTCViveMotionController" {
  75768. import { IMinimalMotionControllerObject, MotionControllerHandedness, WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  75769. import { Scene } from "babylonjs/scene";
  75770. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  75771. /**
  75772. * The motion controller class for the standard HTC-Vive controllers
  75773. */
  75774. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  75775. private _modelRootNode;
  75776. /**
  75777. * The base url used to load the left and right controller models
  75778. */
  75779. static MODEL_BASE_URL: string;
  75780. /**
  75781. * File name for the controller model.
  75782. */
  75783. static MODEL_FILENAME: string;
  75784. profileId: string;
  75785. /**
  75786. * Create a new Vive motion controller object
  75787. * @param scene the scene to use to create this controller
  75788. * @param gamepadObject the corresponding gamepad object
  75789. * @param handedness the handedness of the controller
  75790. */
  75791. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  75792. protected _getFilenameAndPath(): {
  75793. filename: string;
  75794. path: string;
  75795. };
  75796. protected _getModelLoadingConstraints(): boolean;
  75797. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  75798. protected _setRootMesh(meshes: AbstractMesh[]): void;
  75799. protected _updateModel(): void;
  75800. }
  75801. }
  75802. declare module "babylonjs/XR/motionController/index" {
  75803. export * from "babylonjs/XR/motionController/webXRAbstractMotionController";
  75804. export * from "babylonjs/XR/motionController/webXRControllerComponent";
  75805. export * from "babylonjs/XR/motionController/webXRGenericMotionController";
  75806. export * from "babylonjs/XR/motionController/webXRMicrosoftMixedRealityController";
  75807. export * from "babylonjs/XR/motionController/webXRMotionControllerManager";
  75808. export * from "babylonjs/XR/motionController/webXROculusTouchMotionController";
  75809. export * from "babylonjs/XR/motionController/webXRHTCViveMotionController";
  75810. export * from "babylonjs/XR/motionController/webXRProfiledMotionController";
  75811. }
  75812. declare module "babylonjs/XR/index" {
  75813. export * from "babylonjs/XR/webXRCamera";
  75814. export * from "babylonjs/XR/webXREnterExitUI";
  75815. export * from "babylonjs/XR/webXRExperienceHelper";
  75816. export * from "babylonjs/XR/webXRInput";
  75817. export * from "babylonjs/XR/webXRInputSource";
  75818. export * from "babylonjs/XR/webXRManagedOutputCanvas";
  75819. export * from "babylonjs/XR/webXRTypes";
  75820. export * from "babylonjs/XR/webXRSessionManager";
  75821. export * from "babylonjs/XR/webXRDefaultExperience";
  75822. export * from "babylonjs/XR/webXRFeaturesManager";
  75823. export * from "babylonjs/XR/features/index";
  75824. export * from "babylonjs/XR/motionController/index";
  75825. }
  75826. declare module "babylonjs/index" {
  75827. export * from "babylonjs/abstractScene";
  75828. export * from "babylonjs/Actions/index";
  75829. export * from "babylonjs/Animations/index";
  75830. export * from "babylonjs/assetContainer";
  75831. export * from "babylonjs/Audio/index";
  75832. export * from "babylonjs/Behaviors/index";
  75833. export * from "babylonjs/Bones/index";
  75834. export * from "babylonjs/Cameras/index";
  75835. export * from "babylonjs/Collisions/index";
  75836. export * from "babylonjs/Culling/index";
  75837. export * from "babylonjs/Debug/index";
  75838. export * from "babylonjs/DeviceInput/index";
  75839. export * from "babylonjs/Engines/index";
  75840. export * from "babylonjs/Events/index";
  75841. export * from "babylonjs/Gamepads/index";
  75842. export * from "babylonjs/Gizmos/index";
  75843. export * from "babylonjs/Helpers/index";
  75844. export * from "babylonjs/Instrumentation/index";
  75845. export * from "babylonjs/Layers/index";
  75846. export * from "babylonjs/LensFlares/index";
  75847. export * from "babylonjs/Lights/index";
  75848. export * from "babylonjs/Loading/index";
  75849. export * from "babylonjs/Materials/index";
  75850. export * from "babylonjs/Maths/index";
  75851. export * from "babylonjs/Meshes/index";
  75852. export * from "babylonjs/Morph/index";
  75853. export * from "babylonjs/Navigation/index";
  75854. export * from "babylonjs/node";
  75855. export * from "babylonjs/Offline/index";
  75856. export * from "babylonjs/Particles/index";
  75857. export * from "babylonjs/Physics/index";
  75858. export * from "babylonjs/PostProcesses/index";
  75859. export * from "babylonjs/Probes/index";
  75860. export * from "babylonjs/Rendering/index";
  75861. export * from "babylonjs/scene";
  75862. export * from "babylonjs/sceneComponent";
  75863. export * from "babylonjs/Sprites/index";
  75864. export * from "babylonjs/States/index";
  75865. export * from "babylonjs/Misc/index";
  75866. export * from "babylonjs/XR/index";
  75867. export * from "babylonjs/types";
  75868. }
  75869. declare module "babylonjs/Animations/pathCursor" {
  75870. import { Vector3 } from "babylonjs/Maths/math.vector";
  75871. import { Path2 } from "babylonjs/Maths/math.path";
  75872. /**
  75873. * A cursor which tracks a point on a path
  75874. */
  75875. export class PathCursor {
  75876. private path;
  75877. /**
  75878. * Stores path cursor callbacks for when an onchange event is triggered
  75879. */
  75880. private _onchange;
  75881. /**
  75882. * The value of the path cursor
  75883. */
  75884. value: number;
  75885. /**
  75886. * The animation array of the path cursor
  75887. */
  75888. animations: Animation[];
  75889. /**
  75890. * Initializes the path cursor
  75891. * @param path The path to track
  75892. */
  75893. constructor(path: Path2);
  75894. /**
  75895. * Gets the cursor point on the path
  75896. * @returns A point on the path cursor at the cursor location
  75897. */
  75898. getPoint(): Vector3;
  75899. /**
  75900. * Moves the cursor ahead by the step amount
  75901. * @param step The amount to move the cursor forward
  75902. * @returns This path cursor
  75903. */
  75904. moveAhead(step?: number): PathCursor;
  75905. /**
  75906. * Moves the cursor behind by the step amount
  75907. * @param step The amount to move the cursor back
  75908. * @returns This path cursor
  75909. */
  75910. moveBack(step?: number): PathCursor;
  75911. /**
  75912. * Moves the cursor by the step amount
  75913. * If the step amount is greater than one, an exception is thrown
  75914. * @param step The amount to move the cursor
  75915. * @returns This path cursor
  75916. */
  75917. move(step: number): PathCursor;
  75918. /**
  75919. * Ensures that the value is limited between zero and one
  75920. * @returns This path cursor
  75921. */
  75922. private ensureLimits;
  75923. /**
  75924. * Runs onchange callbacks on change (used by the animation engine)
  75925. * @returns This path cursor
  75926. */
  75927. private raiseOnChange;
  75928. /**
  75929. * Executes a function on change
  75930. * @param f A path cursor onchange callback
  75931. * @returns This path cursor
  75932. */
  75933. onchange(f: (cursor: PathCursor) => void): PathCursor;
  75934. }
  75935. }
  75936. declare module "babylonjs/Engines/Processors/Expressions/Operators/index" {
  75937. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator";
  75938. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator";
  75939. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator";
  75940. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator";
  75941. }
  75942. declare module "babylonjs/Engines/Processors/Expressions/index" {
  75943. export * from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  75944. export * from "babylonjs/Engines/Processors/Expressions/Operators/index";
  75945. }
  75946. declare module "babylonjs/Engines/Processors/index" {
  75947. export * from "babylonjs/Engines/Processors/iShaderProcessor";
  75948. export * from "babylonjs/Engines/Processors/Expressions/index";
  75949. export * from "babylonjs/Engines/Processors/shaderCodeConditionNode";
  75950. export * from "babylonjs/Engines/Processors/shaderCodeCursor";
  75951. export * from "babylonjs/Engines/Processors/shaderCodeNode";
  75952. export * from "babylonjs/Engines/Processors/shaderCodeTestNode";
  75953. export * from "babylonjs/Engines/Processors/shaderProcessingOptions";
  75954. export * from "babylonjs/Engines/Processors/shaderProcessor";
  75955. }
  75956. declare module "babylonjs/Legacy/legacy" {
  75957. import * as Babylon from "babylonjs/index";
  75958. export * from "babylonjs/index";
  75959. }
  75960. declare module "babylonjs/Shaders/blur.fragment" {
  75961. /** @hidden */
  75962. export var blurPixelShader: {
  75963. name: string;
  75964. shader: string;
  75965. };
  75966. }
  75967. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  75968. /** @hidden */
  75969. export var pointCloudVertexDeclaration: {
  75970. name: string;
  75971. shader: string;
  75972. };
  75973. }
  75974. declare module "babylonjs" {
  75975. export * from "babylonjs/Legacy/legacy";
  75976. }
  75977. declare module BABYLON {
  75978. /** Alias type for value that can be null */
  75979. export type Nullable<T> = T | null;
  75980. /**
  75981. * Alias type for number that are floats
  75982. * @ignorenaming
  75983. */
  75984. export type float = number;
  75985. /**
  75986. * Alias type for number that are doubles.
  75987. * @ignorenaming
  75988. */
  75989. export type double = number;
  75990. /**
  75991. * Alias type for number that are integer
  75992. * @ignorenaming
  75993. */
  75994. export type int = number;
  75995. /** Alias type for number array or Float32Array */
  75996. export type FloatArray = number[] | Float32Array;
  75997. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  75998. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  75999. /**
  76000. * Alias for types that can be used by a Buffer or VertexBuffer.
  76001. */
  76002. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  76003. /**
  76004. * Alias type for primitive types
  76005. * @ignorenaming
  76006. */
  76007. type Primitive = undefined | null | boolean | string | number | Function;
  76008. /**
  76009. * Type modifier to make all the properties of an object Readonly
  76010. */
  76011. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  76012. /**
  76013. * Type modifier to make all the properties of an object Readonly recursively
  76014. */
  76015. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  76016. /**
  76017. * Type modifier to make object properties readonly.
  76018. */
  76019. export type DeepImmutableObject<T> = {
  76020. readonly [K in keyof T]: DeepImmutable<T[K]>;
  76021. };
  76022. /** @hidden */
  76023. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  76024. }
  76025. }
  76026. declare module BABYLON {
  76027. /**
  76028. * A class serves as a medium between the observable and its observers
  76029. */
  76030. export class EventState {
  76031. /**
  76032. * Create a new EventState
  76033. * @param mask defines the mask associated with this state
  76034. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  76035. * @param target defines the original target of the state
  76036. * @param currentTarget defines the current target of the state
  76037. */
  76038. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  76039. /**
  76040. * Initialize the current event state
  76041. * @param mask defines the mask associated with this state
  76042. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  76043. * @param target defines the original target of the state
  76044. * @param currentTarget defines the current target of the state
  76045. * @returns the current event state
  76046. */
  76047. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  76048. /**
  76049. * An Observer can set this property to true to prevent subsequent observers of being notified
  76050. */
  76051. skipNextObservers: boolean;
  76052. /**
  76053. * Get the mask value that were used to trigger the event corresponding to this EventState object
  76054. */
  76055. mask: number;
  76056. /**
  76057. * The object that originally notified the event
  76058. */
  76059. target?: any;
  76060. /**
  76061. * The current object in the bubbling phase
  76062. */
  76063. currentTarget?: any;
  76064. /**
  76065. * This will be populated with the return value of the last function that was executed.
  76066. * If it is the first function in the callback chain it will be the event data.
  76067. */
  76068. lastReturnValue?: any;
  76069. }
  76070. /**
  76071. * Represent an Observer registered to a given Observable object.
  76072. */
  76073. export class Observer<T> {
  76074. /**
  76075. * Defines the callback to call when the observer is notified
  76076. */
  76077. callback: (eventData: T, eventState: EventState) => void;
  76078. /**
  76079. * Defines the mask of the observer (used to filter notifications)
  76080. */
  76081. mask: number;
  76082. /**
  76083. * Defines the current scope used to restore the JS context
  76084. */
  76085. scope: any;
  76086. /** @hidden */
  76087. _willBeUnregistered: boolean;
  76088. /**
  76089. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  76090. */
  76091. unregisterOnNextCall: boolean;
  76092. /**
  76093. * Creates a new observer
  76094. * @param callback defines the callback to call when the observer is notified
  76095. * @param mask defines the mask of the observer (used to filter notifications)
  76096. * @param scope defines the current scope used to restore the JS context
  76097. */
  76098. constructor(
  76099. /**
  76100. * Defines the callback to call when the observer is notified
  76101. */
  76102. callback: (eventData: T, eventState: EventState) => void,
  76103. /**
  76104. * Defines the mask of the observer (used to filter notifications)
  76105. */
  76106. mask: number,
  76107. /**
  76108. * Defines the current scope used to restore the JS context
  76109. */
  76110. scope?: any);
  76111. }
  76112. /**
  76113. * Represent a list of observers registered to multiple Observables object.
  76114. */
  76115. export class MultiObserver<T> {
  76116. private _observers;
  76117. private _observables;
  76118. /**
  76119. * Release associated resources
  76120. */
  76121. dispose(): void;
  76122. /**
  76123. * Raise a callback when one of the observable will notify
  76124. * @param observables defines a list of observables to watch
  76125. * @param callback defines the callback to call on notification
  76126. * @param mask defines the mask used to filter notifications
  76127. * @param scope defines the current scope used to restore the JS context
  76128. * @returns the new MultiObserver
  76129. */
  76130. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  76131. }
  76132. /**
  76133. * The Observable class is a simple implementation of the Observable pattern.
  76134. *
  76135. * 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.
  76136. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  76137. * 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).
  76138. * 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.
  76139. */
  76140. export class Observable<T> {
  76141. private _observers;
  76142. private _eventState;
  76143. private _onObserverAdded;
  76144. /**
  76145. * Gets the list of observers
  76146. */
  76147. get observers(): Array<Observer<T>>;
  76148. /**
  76149. * Creates a new observable
  76150. * @param onObserverAdded defines a callback to call when a new observer is added
  76151. */
  76152. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  76153. /**
  76154. * Create a new Observer with the specified callback
  76155. * @param callback the callback that will be executed for that Observer
  76156. * @param mask the mask used to filter observers
  76157. * @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.
  76158. * @param scope optional scope for the callback to be called from
  76159. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  76160. * @returns the new observer created for the callback
  76161. */
  76162. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  76163. /**
  76164. * Create a new Observer with the specified callback and unregisters after the next notification
  76165. * @param callback the callback that will be executed for that Observer
  76166. * @returns the new observer created for the callback
  76167. */
  76168. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  76169. /**
  76170. * Remove an Observer from the Observable object
  76171. * @param observer the instance of the Observer to remove
  76172. * @returns false if it doesn't belong to this Observable
  76173. */
  76174. remove(observer: Nullable<Observer<T>>): boolean;
  76175. /**
  76176. * Remove a callback from the Observable object
  76177. * @param callback the callback to remove
  76178. * @param scope optional scope. If used only the callbacks with this scope will be removed
  76179. * @returns false if it doesn't belong to this Observable
  76180. */
  76181. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  76182. private _deferUnregister;
  76183. private _remove;
  76184. /**
  76185. * Moves the observable to the top of the observer list making it get called first when notified
  76186. * @param observer the observer to move
  76187. */
  76188. makeObserverTopPriority(observer: Observer<T>): void;
  76189. /**
  76190. * Moves the observable to the bottom of the observer list making it get called last when notified
  76191. * @param observer the observer to move
  76192. */
  76193. makeObserverBottomPriority(observer: Observer<T>): void;
  76194. /**
  76195. * Notify all Observers by calling their respective callback with the given data
  76196. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  76197. * @param eventData defines the data to send to all observers
  76198. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  76199. * @param target defines the original target of the state
  76200. * @param currentTarget defines the current target of the state
  76201. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  76202. */
  76203. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  76204. /**
  76205. * Calling this will execute each callback, expecting it to be a promise or return a value.
  76206. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  76207. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  76208. * and it is crucial that all callbacks will be executed.
  76209. * The order of the callbacks is kept, callbacks are not executed parallel.
  76210. *
  76211. * @param eventData The data to be sent to each callback
  76212. * @param mask is used to filter observers defaults to -1
  76213. * @param target defines the callback target (see EventState)
  76214. * @param currentTarget defines he current object in the bubbling phase
  76215. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  76216. */
  76217. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  76218. /**
  76219. * Notify a specific observer
  76220. * @param observer defines the observer to notify
  76221. * @param eventData defines the data to be sent to each callback
  76222. * @param mask is used to filter observers defaults to -1
  76223. */
  76224. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  76225. /**
  76226. * Gets a boolean indicating if the observable has at least one observer
  76227. * @returns true is the Observable has at least one Observer registered
  76228. */
  76229. hasObservers(): boolean;
  76230. /**
  76231. * Clear the list of observers
  76232. */
  76233. clear(): void;
  76234. /**
  76235. * Clone the current observable
  76236. * @returns a new observable
  76237. */
  76238. clone(): Observable<T>;
  76239. /**
  76240. * Does this observable handles observer registered with a given mask
  76241. * @param mask defines the mask to be tested
  76242. * @return whether or not one observer registered with the given mask is handeled
  76243. **/
  76244. hasSpecificMask(mask?: number): boolean;
  76245. }
  76246. }
  76247. declare module BABYLON {
  76248. /**
  76249. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  76250. * Babylon.js
  76251. */
  76252. export class DomManagement {
  76253. /**
  76254. * Checks if the window object exists
  76255. * @returns true if the window object exists
  76256. */
  76257. static IsWindowObjectExist(): boolean;
  76258. /**
  76259. * Checks if the navigator object exists
  76260. * @returns true if the navigator object exists
  76261. */
  76262. static IsNavigatorAvailable(): boolean;
  76263. /**
  76264. * Check if the document object exists
  76265. * @returns true if the document object exists
  76266. */
  76267. static IsDocumentAvailable(): boolean;
  76268. /**
  76269. * Extracts text content from a DOM element hierarchy
  76270. * @param element defines the root element
  76271. * @returns a string
  76272. */
  76273. static GetDOMTextContent(element: HTMLElement): string;
  76274. }
  76275. }
  76276. declare module BABYLON {
  76277. /**
  76278. * Logger used througouht the application to allow configuration of
  76279. * the log level required for the messages.
  76280. */
  76281. export class Logger {
  76282. /**
  76283. * No log
  76284. */
  76285. static readonly NoneLogLevel: number;
  76286. /**
  76287. * Only message logs
  76288. */
  76289. static readonly MessageLogLevel: number;
  76290. /**
  76291. * Only warning logs
  76292. */
  76293. static readonly WarningLogLevel: number;
  76294. /**
  76295. * Only error logs
  76296. */
  76297. static readonly ErrorLogLevel: number;
  76298. /**
  76299. * All logs
  76300. */
  76301. static readonly AllLogLevel: number;
  76302. private static _LogCache;
  76303. /**
  76304. * Gets a value indicating the number of loading errors
  76305. * @ignorenaming
  76306. */
  76307. static errorsCount: number;
  76308. /**
  76309. * Callback called when a new log is added
  76310. */
  76311. static OnNewCacheEntry: (entry: string) => void;
  76312. private static _AddLogEntry;
  76313. private static _FormatMessage;
  76314. private static _LogDisabled;
  76315. private static _LogEnabled;
  76316. private static _WarnDisabled;
  76317. private static _WarnEnabled;
  76318. private static _ErrorDisabled;
  76319. private static _ErrorEnabled;
  76320. /**
  76321. * Log a message to the console
  76322. */
  76323. static Log: (message: string) => void;
  76324. /**
  76325. * Write a warning message to the console
  76326. */
  76327. static Warn: (message: string) => void;
  76328. /**
  76329. * Write an error message to the console
  76330. */
  76331. static Error: (message: string) => void;
  76332. /**
  76333. * Gets current log cache (list of logs)
  76334. */
  76335. static get LogCache(): string;
  76336. /**
  76337. * Clears the log cache
  76338. */
  76339. static ClearLogCache(): void;
  76340. /**
  76341. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  76342. */
  76343. static set LogLevels(level: number);
  76344. }
  76345. }
  76346. declare module BABYLON {
  76347. /** @hidden */
  76348. export class _TypeStore {
  76349. /** @hidden */
  76350. static RegisteredTypes: {
  76351. [key: string]: Object;
  76352. };
  76353. /** @hidden */
  76354. static GetClass(fqdn: string): any;
  76355. }
  76356. }
  76357. declare module BABYLON {
  76358. /**
  76359. * Helper to manipulate strings
  76360. */
  76361. export class StringTools {
  76362. /**
  76363. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  76364. * @param str Source string
  76365. * @param suffix Suffix to search for in the source string
  76366. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  76367. */
  76368. static EndsWith(str: string, suffix: string): boolean;
  76369. /**
  76370. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  76371. * @param str Source string
  76372. * @param suffix Suffix to search for in the source string
  76373. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  76374. */
  76375. static StartsWith(str: string, suffix: string): boolean;
  76376. /**
  76377. * Decodes a buffer into a string
  76378. * @param buffer The buffer to decode
  76379. * @returns The decoded string
  76380. */
  76381. static Decode(buffer: Uint8Array | Uint16Array): string;
  76382. /**
  76383. * Encode a buffer to a base64 string
  76384. * @param buffer defines the buffer to encode
  76385. * @returns the encoded string
  76386. */
  76387. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  76388. /**
  76389. * Converts a number to string and pads with preceeding zeroes until it is of specified length.
  76390. * @param num the number to convert and pad
  76391. * @param length the expected length of the string
  76392. * @returns the padded string
  76393. */
  76394. static PadNumber(num: number, length: number): string;
  76395. }
  76396. }
  76397. declare module BABYLON {
  76398. /**
  76399. * Class containing a set of static utilities functions for deep copy.
  76400. */
  76401. export class DeepCopier {
  76402. /**
  76403. * Tries to copy an object by duplicating every property
  76404. * @param source defines the source object
  76405. * @param destination defines the target object
  76406. * @param doNotCopyList defines a list of properties to avoid
  76407. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  76408. */
  76409. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  76410. }
  76411. }
  76412. declare module BABYLON {
  76413. /**
  76414. * Class containing a set of static utilities functions for precision date
  76415. */
  76416. export class PrecisionDate {
  76417. /**
  76418. * Gets either window.performance.now() if supported or Date.now() else
  76419. */
  76420. static get Now(): number;
  76421. }
  76422. }
  76423. declare module BABYLON {
  76424. /** @hidden */
  76425. export class _DevTools {
  76426. static WarnImport(name: string): string;
  76427. }
  76428. }
  76429. declare module BABYLON {
  76430. /**
  76431. * Interface used to define the mechanism to get data from the network
  76432. */
  76433. export interface IWebRequest {
  76434. /**
  76435. * Returns client's response url
  76436. */
  76437. responseURL: string;
  76438. /**
  76439. * Returns client's status
  76440. */
  76441. status: number;
  76442. /**
  76443. * Returns client's status as a text
  76444. */
  76445. statusText: string;
  76446. }
  76447. }
  76448. declare module BABYLON {
  76449. /**
  76450. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  76451. */
  76452. export class WebRequest implements IWebRequest {
  76453. private _xhr;
  76454. /**
  76455. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  76456. * i.e. when loading files, where the server/service expects an Authorization header
  76457. */
  76458. static CustomRequestHeaders: {
  76459. [key: string]: string;
  76460. };
  76461. /**
  76462. * Add callback functions in this array to update all the requests before they get sent to the network
  76463. */
  76464. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  76465. private _injectCustomRequestHeaders;
  76466. /**
  76467. * Gets or sets a function to be called when loading progress changes
  76468. */
  76469. get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  76470. set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
  76471. /**
  76472. * Returns client's state
  76473. */
  76474. get readyState(): number;
  76475. /**
  76476. * Returns client's status
  76477. */
  76478. get status(): number;
  76479. /**
  76480. * Returns client's status as a text
  76481. */
  76482. get statusText(): string;
  76483. /**
  76484. * Returns client's response
  76485. */
  76486. get response(): any;
  76487. /**
  76488. * Returns client's response url
  76489. */
  76490. get responseURL(): string;
  76491. /**
  76492. * Returns client's response as text
  76493. */
  76494. get responseText(): string;
  76495. /**
  76496. * Gets or sets the expected response type
  76497. */
  76498. get responseType(): XMLHttpRequestResponseType;
  76499. set responseType(value: XMLHttpRequestResponseType);
  76500. /** @hidden */
  76501. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  76502. /** @hidden */
  76503. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  76504. /**
  76505. * Cancels any network activity
  76506. */
  76507. abort(): void;
  76508. /**
  76509. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  76510. * @param body defines an optional request body
  76511. */
  76512. send(body?: Document | BodyInit | null): void;
  76513. /**
  76514. * Sets the request method, request URL
  76515. * @param method defines the method to use (GET, POST, etc..)
  76516. * @param url defines the url to connect with
  76517. */
  76518. open(method: string, url: string): void;
  76519. /**
  76520. * Sets the value of a request header.
  76521. * @param name The name of the header whose value is to be set
  76522. * @param value The value to set as the body of the header
  76523. */
  76524. setRequestHeader(name: string, value: string): void;
  76525. /**
  76526. * Get the string containing the text of a particular header's value.
  76527. * @param name The name of the header
  76528. * @returns The string containing the text of the given header name
  76529. */
  76530. getResponseHeader(name: string): Nullable<string>;
  76531. }
  76532. }
  76533. declare module BABYLON {
  76534. /**
  76535. * File request interface
  76536. */
  76537. export interface IFileRequest {
  76538. /**
  76539. * Raised when the request is complete (success or error).
  76540. */
  76541. onCompleteObservable: Observable<IFileRequest>;
  76542. /**
  76543. * Aborts the request for a file.
  76544. */
  76545. abort: () => void;
  76546. }
  76547. }
  76548. declare module BABYLON {
  76549. /**
  76550. * Define options used to create a render target texture
  76551. */
  76552. export class RenderTargetCreationOptions {
  76553. /**
  76554. * Specifies is mipmaps must be generated
  76555. */
  76556. generateMipMaps?: boolean;
  76557. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  76558. generateDepthBuffer?: boolean;
  76559. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  76560. generateStencilBuffer?: boolean;
  76561. /** Defines texture type (int by default) */
  76562. type?: number;
  76563. /** Defines sampling mode (trilinear by default) */
  76564. samplingMode?: number;
  76565. /** Defines format (RGBA by default) */
  76566. format?: number;
  76567. }
  76568. }
  76569. declare module BABYLON {
  76570. /** Defines the cross module used constants to avoid circular dependncies */
  76571. export class Constants {
  76572. /** Defines that alpha blending is disabled */
  76573. static readonly ALPHA_DISABLE: number;
  76574. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  76575. static readonly ALPHA_ADD: number;
  76576. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  76577. static readonly ALPHA_COMBINE: number;
  76578. /** Defines that alpha blending is DEST - SRC * DEST */
  76579. static readonly ALPHA_SUBTRACT: number;
  76580. /** Defines that alpha blending is SRC * DEST */
  76581. static readonly ALPHA_MULTIPLY: number;
  76582. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  76583. static readonly ALPHA_MAXIMIZED: number;
  76584. /** Defines that alpha blending is SRC + DEST */
  76585. static readonly ALPHA_ONEONE: number;
  76586. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  76587. static readonly ALPHA_PREMULTIPLIED: number;
  76588. /**
  76589. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  76590. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  76591. */
  76592. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  76593. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  76594. static readonly ALPHA_INTERPOLATE: number;
  76595. /**
  76596. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  76597. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  76598. */
  76599. static readonly ALPHA_SCREENMODE: number;
  76600. /**
  76601. * Defines that alpha blending is SRC + DST
  76602. * Alpha will be set to SRC ALPHA + DST ALPHA
  76603. */
  76604. static readonly ALPHA_ONEONE_ONEONE: number;
  76605. /**
  76606. * Defines that alpha blending is SRC * DST ALPHA + DST
  76607. * Alpha will be set to 0
  76608. */
  76609. static readonly ALPHA_ALPHATOCOLOR: number;
  76610. /**
  76611. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  76612. */
  76613. static readonly ALPHA_REVERSEONEMINUS: number;
  76614. /**
  76615. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  76616. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  76617. */
  76618. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  76619. /**
  76620. * Defines that alpha blending is SRC + DST
  76621. * Alpha will be set to SRC ALPHA
  76622. */
  76623. static readonly ALPHA_ONEONE_ONEZERO: number;
  76624. /**
  76625. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  76626. * Alpha will be set to DST ALPHA
  76627. */
  76628. static readonly ALPHA_EXCLUSION: number;
  76629. /** Defines that alpha blending equation a SUM */
  76630. static readonly ALPHA_EQUATION_ADD: number;
  76631. /** Defines that alpha blending equation a SUBSTRACTION */
  76632. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  76633. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  76634. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  76635. /** Defines that alpha blending equation a MAX operation */
  76636. static readonly ALPHA_EQUATION_MAX: number;
  76637. /** Defines that alpha blending equation a MIN operation */
  76638. static readonly ALPHA_EQUATION_MIN: number;
  76639. /**
  76640. * Defines that alpha blending equation a DARKEN operation:
  76641. * It takes the min of the src and sums the alpha channels.
  76642. */
  76643. static readonly ALPHA_EQUATION_DARKEN: number;
  76644. /** Defines that the ressource is not delayed*/
  76645. static readonly DELAYLOADSTATE_NONE: number;
  76646. /** Defines that the ressource was successfully delay loaded */
  76647. static readonly DELAYLOADSTATE_LOADED: number;
  76648. /** Defines that the ressource is currently delay loading */
  76649. static readonly DELAYLOADSTATE_LOADING: number;
  76650. /** Defines that the ressource is delayed and has not started loading */
  76651. static readonly DELAYLOADSTATE_NOTLOADED: number;
  76652. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  76653. static readonly NEVER: number;
  76654. /** 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 */
  76655. static readonly ALWAYS: number;
  76656. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  76657. static readonly LESS: number;
  76658. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  76659. static readonly EQUAL: number;
  76660. /** 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 */
  76661. static readonly LEQUAL: number;
  76662. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  76663. static readonly GREATER: number;
  76664. /** 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 */
  76665. static readonly GEQUAL: number;
  76666. /** 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 */
  76667. static readonly NOTEQUAL: number;
  76668. /** Passed to stencilOperation to specify that stencil value must be kept */
  76669. static readonly KEEP: number;
  76670. /** Passed to stencilOperation to specify that stencil value must be replaced */
  76671. static readonly REPLACE: number;
  76672. /** Passed to stencilOperation to specify that stencil value must be incremented */
  76673. static readonly INCR: number;
  76674. /** Passed to stencilOperation to specify that stencil value must be decremented */
  76675. static readonly DECR: number;
  76676. /** Passed to stencilOperation to specify that stencil value must be inverted */
  76677. static readonly INVERT: number;
  76678. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  76679. static readonly INCR_WRAP: number;
  76680. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  76681. static readonly DECR_WRAP: number;
  76682. /** Texture is not repeating outside of 0..1 UVs */
  76683. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  76684. /** Texture is repeating outside of 0..1 UVs */
  76685. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  76686. /** Texture is repeating and mirrored */
  76687. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  76688. /** ALPHA */
  76689. static readonly TEXTUREFORMAT_ALPHA: number;
  76690. /** LUMINANCE */
  76691. static readonly TEXTUREFORMAT_LUMINANCE: number;
  76692. /** LUMINANCE_ALPHA */
  76693. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  76694. /** RGB */
  76695. static readonly TEXTUREFORMAT_RGB: number;
  76696. /** RGBA */
  76697. static readonly TEXTUREFORMAT_RGBA: number;
  76698. /** RED */
  76699. static readonly TEXTUREFORMAT_RED: number;
  76700. /** RED (2nd reference) */
  76701. static readonly TEXTUREFORMAT_R: number;
  76702. /** RG */
  76703. static readonly TEXTUREFORMAT_RG: number;
  76704. /** RED_INTEGER */
  76705. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  76706. /** RED_INTEGER (2nd reference) */
  76707. static readonly TEXTUREFORMAT_R_INTEGER: number;
  76708. /** RG_INTEGER */
  76709. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  76710. /** RGB_INTEGER */
  76711. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  76712. /** RGBA_INTEGER */
  76713. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  76714. /** UNSIGNED_BYTE */
  76715. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  76716. /** UNSIGNED_BYTE (2nd reference) */
  76717. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  76718. /** FLOAT */
  76719. static readonly TEXTURETYPE_FLOAT: number;
  76720. /** HALF_FLOAT */
  76721. static readonly TEXTURETYPE_HALF_FLOAT: number;
  76722. /** BYTE */
  76723. static readonly TEXTURETYPE_BYTE: number;
  76724. /** SHORT */
  76725. static readonly TEXTURETYPE_SHORT: number;
  76726. /** UNSIGNED_SHORT */
  76727. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  76728. /** INT */
  76729. static readonly TEXTURETYPE_INT: number;
  76730. /** UNSIGNED_INT */
  76731. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  76732. /** UNSIGNED_SHORT_4_4_4_4 */
  76733. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  76734. /** UNSIGNED_SHORT_5_5_5_1 */
  76735. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  76736. /** UNSIGNED_SHORT_5_6_5 */
  76737. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  76738. /** UNSIGNED_INT_2_10_10_10_REV */
  76739. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  76740. /** UNSIGNED_INT_24_8 */
  76741. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  76742. /** UNSIGNED_INT_10F_11F_11F_REV */
  76743. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  76744. /** UNSIGNED_INT_5_9_9_9_REV */
  76745. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  76746. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  76747. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  76748. /** nearest is mag = nearest and min = nearest and no mip */
  76749. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  76750. /** mag = nearest and min = nearest and mip = none */
  76751. static readonly TEXTURE_NEAREST_NEAREST: number;
  76752. /** Bilinear is mag = linear and min = linear and no mip */
  76753. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  76754. /** mag = linear and min = linear and mip = none */
  76755. static readonly TEXTURE_LINEAR_LINEAR: number;
  76756. /** Trilinear is mag = linear and min = linear and mip = linear */
  76757. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  76758. /** Trilinear is mag = linear and min = linear and mip = linear */
  76759. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  76760. /** mag = nearest and min = nearest and mip = nearest */
  76761. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  76762. /** mag = nearest and min = linear and mip = nearest */
  76763. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  76764. /** mag = nearest and min = linear and mip = linear */
  76765. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  76766. /** mag = nearest and min = linear and mip = none */
  76767. static readonly TEXTURE_NEAREST_LINEAR: number;
  76768. /** nearest is mag = nearest and min = nearest and mip = linear */
  76769. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  76770. /** mag = linear and min = nearest and mip = nearest */
  76771. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  76772. /** mag = linear and min = nearest and mip = linear */
  76773. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  76774. /** Bilinear is mag = linear and min = linear and mip = nearest */
  76775. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  76776. /** mag = linear and min = nearest and mip = none */
  76777. static readonly TEXTURE_LINEAR_NEAREST: number;
  76778. /** Explicit coordinates mode */
  76779. static readonly TEXTURE_EXPLICIT_MODE: number;
  76780. /** Spherical coordinates mode */
  76781. static readonly TEXTURE_SPHERICAL_MODE: number;
  76782. /** Planar coordinates mode */
  76783. static readonly TEXTURE_PLANAR_MODE: number;
  76784. /** Cubic coordinates mode */
  76785. static readonly TEXTURE_CUBIC_MODE: number;
  76786. /** Projection coordinates mode */
  76787. static readonly TEXTURE_PROJECTION_MODE: number;
  76788. /** Skybox coordinates mode */
  76789. static readonly TEXTURE_SKYBOX_MODE: number;
  76790. /** Inverse Cubic coordinates mode */
  76791. static readonly TEXTURE_INVCUBIC_MODE: number;
  76792. /** Equirectangular coordinates mode */
  76793. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  76794. /** Equirectangular Fixed coordinates mode */
  76795. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  76796. /** Equirectangular Fixed Mirrored coordinates mode */
  76797. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  76798. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  76799. static readonly SCALEMODE_FLOOR: number;
  76800. /** Defines that texture rescaling will look for the nearest power of 2 size */
  76801. static readonly SCALEMODE_NEAREST: number;
  76802. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  76803. static readonly SCALEMODE_CEILING: number;
  76804. /**
  76805. * The dirty texture flag value
  76806. */
  76807. static readonly MATERIAL_TextureDirtyFlag: number;
  76808. /**
  76809. * The dirty light flag value
  76810. */
  76811. static readonly MATERIAL_LightDirtyFlag: number;
  76812. /**
  76813. * The dirty fresnel flag value
  76814. */
  76815. static readonly MATERIAL_FresnelDirtyFlag: number;
  76816. /**
  76817. * The dirty attribute flag value
  76818. */
  76819. static readonly MATERIAL_AttributesDirtyFlag: number;
  76820. /**
  76821. * The dirty misc flag value
  76822. */
  76823. static readonly MATERIAL_MiscDirtyFlag: number;
  76824. /**
  76825. * The all dirty flag value
  76826. */
  76827. static readonly MATERIAL_AllDirtyFlag: number;
  76828. /**
  76829. * Returns the triangle fill mode
  76830. */
  76831. static readonly MATERIAL_TriangleFillMode: number;
  76832. /**
  76833. * Returns the wireframe mode
  76834. */
  76835. static readonly MATERIAL_WireFrameFillMode: number;
  76836. /**
  76837. * Returns the point fill mode
  76838. */
  76839. static readonly MATERIAL_PointFillMode: number;
  76840. /**
  76841. * Returns the point list draw mode
  76842. */
  76843. static readonly MATERIAL_PointListDrawMode: number;
  76844. /**
  76845. * Returns the line list draw mode
  76846. */
  76847. static readonly MATERIAL_LineListDrawMode: number;
  76848. /**
  76849. * Returns the line loop draw mode
  76850. */
  76851. static readonly MATERIAL_LineLoopDrawMode: number;
  76852. /**
  76853. * Returns the line strip draw mode
  76854. */
  76855. static readonly MATERIAL_LineStripDrawMode: number;
  76856. /**
  76857. * Returns the triangle strip draw mode
  76858. */
  76859. static readonly MATERIAL_TriangleStripDrawMode: number;
  76860. /**
  76861. * Returns the triangle fan draw mode
  76862. */
  76863. static readonly MATERIAL_TriangleFanDrawMode: number;
  76864. /**
  76865. * Stores the clock-wise side orientation
  76866. */
  76867. static readonly MATERIAL_ClockWiseSideOrientation: number;
  76868. /**
  76869. * Stores the counter clock-wise side orientation
  76870. */
  76871. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  76872. /**
  76873. * Nothing
  76874. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76875. */
  76876. static readonly ACTION_NothingTrigger: number;
  76877. /**
  76878. * On pick
  76879. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76880. */
  76881. static readonly ACTION_OnPickTrigger: number;
  76882. /**
  76883. * On left pick
  76884. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76885. */
  76886. static readonly ACTION_OnLeftPickTrigger: number;
  76887. /**
  76888. * On right pick
  76889. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76890. */
  76891. static readonly ACTION_OnRightPickTrigger: number;
  76892. /**
  76893. * On center pick
  76894. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76895. */
  76896. static readonly ACTION_OnCenterPickTrigger: number;
  76897. /**
  76898. * On pick down
  76899. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76900. */
  76901. static readonly ACTION_OnPickDownTrigger: number;
  76902. /**
  76903. * On double pick
  76904. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76905. */
  76906. static readonly ACTION_OnDoublePickTrigger: number;
  76907. /**
  76908. * On pick up
  76909. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76910. */
  76911. static readonly ACTION_OnPickUpTrigger: number;
  76912. /**
  76913. * On pick out.
  76914. * This trigger will only be raised if you also declared a OnPickDown
  76915. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76916. */
  76917. static readonly ACTION_OnPickOutTrigger: number;
  76918. /**
  76919. * On long press
  76920. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76921. */
  76922. static readonly ACTION_OnLongPressTrigger: number;
  76923. /**
  76924. * On pointer over
  76925. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76926. */
  76927. static readonly ACTION_OnPointerOverTrigger: number;
  76928. /**
  76929. * On pointer out
  76930. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76931. */
  76932. static readonly ACTION_OnPointerOutTrigger: number;
  76933. /**
  76934. * On every frame
  76935. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76936. */
  76937. static readonly ACTION_OnEveryFrameTrigger: number;
  76938. /**
  76939. * On intersection enter
  76940. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76941. */
  76942. static readonly ACTION_OnIntersectionEnterTrigger: number;
  76943. /**
  76944. * On intersection exit
  76945. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76946. */
  76947. static readonly ACTION_OnIntersectionExitTrigger: number;
  76948. /**
  76949. * On key down
  76950. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76951. */
  76952. static readonly ACTION_OnKeyDownTrigger: number;
  76953. /**
  76954. * On key up
  76955. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76956. */
  76957. static readonly ACTION_OnKeyUpTrigger: number;
  76958. /**
  76959. * Billboard mode will only apply to Y axis
  76960. */
  76961. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  76962. /**
  76963. * Billboard mode will apply to all axes
  76964. */
  76965. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  76966. /**
  76967. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  76968. */
  76969. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  76970. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  76971. * Test order :
  76972. * Is the bounding sphere outside the frustum ?
  76973. * If not, are the bounding box vertices outside the frustum ?
  76974. * It not, then the cullable object is in the frustum.
  76975. */
  76976. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  76977. /** Culling strategy : Bounding Sphere Only.
  76978. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  76979. * It's also less accurate than the standard because some not visible objects can still be selected.
  76980. * Test : is the bounding sphere outside the frustum ?
  76981. * If not, then the cullable object is in the frustum.
  76982. */
  76983. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  76984. /** Culling strategy : Optimistic Inclusion.
  76985. * This in an inclusion test first, then the standard exclusion test.
  76986. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  76987. * 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.
  76988. * Anyway, it's as accurate as the standard strategy.
  76989. * Test :
  76990. * Is the cullable object bounding sphere center in the frustum ?
  76991. * If not, apply the default culling strategy.
  76992. */
  76993. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  76994. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  76995. * This in an inclusion test first, then the bounding sphere only exclusion test.
  76996. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  76997. * 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.
  76998. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  76999. * Test :
  77000. * Is the cullable object bounding sphere center in the frustum ?
  77001. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  77002. */
  77003. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  77004. /**
  77005. * No logging while loading
  77006. */
  77007. static readonly SCENELOADER_NO_LOGGING: number;
  77008. /**
  77009. * Minimal logging while loading
  77010. */
  77011. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  77012. /**
  77013. * Summary logging while loading
  77014. */
  77015. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  77016. /**
  77017. * Detailled logging while loading
  77018. */
  77019. static readonly SCENELOADER_DETAILED_LOGGING: number;
  77020. }
  77021. }
  77022. declare module BABYLON {
  77023. /**
  77024. * This represents the required contract to create a new type of texture loader.
  77025. */
  77026. export interface IInternalTextureLoader {
  77027. /**
  77028. * Defines wether the loader supports cascade loading the different faces.
  77029. */
  77030. supportCascades: boolean;
  77031. /**
  77032. * This returns if the loader support the current file information.
  77033. * @param extension defines the file extension of the file being loaded
  77034. * @returns true if the loader can load the specified file
  77035. */
  77036. canLoad(extension: string): boolean;
  77037. /**
  77038. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  77039. * @param data contains the texture data
  77040. * @param texture defines the BabylonJS internal texture
  77041. * @param createPolynomials will be true if polynomials have been requested
  77042. * @param onLoad defines the callback to trigger once the texture is ready
  77043. * @param onError defines the callback to trigger in case of error
  77044. */
  77045. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  77046. /**
  77047. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  77048. * @param data contains the texture data
  77049. * @param texture defines the BabylonJS internal texture
  77050. * @param callback defines the method to call once ready to upload
  77051. */
  77052. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  77053. }
  77054. }
  77055. declare module BABYLON {
  77056. /**
  77057. * Class used to store and describe the pipeline context associated with an effect
  77058. */
  77059. export interface IPipelineContext {
  77060. /**
  77061. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  77062. */
  77063. isAsync: boolean;
  77064. /**
  77065. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  77066. */
  77067. isReady: boolean;
  77068. /** @hidden */
  77069. _getVertexShaderCode(): string | null;
  77070. /** @hidden */
  77071. _getFragmentShaderCode(): string | null;
  77072. /** @hidden */
  77073. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  77074. }
  77075. }
  77076. declare module BABYLON {
  77077. /**
  77078. * Class used to store gfx data (like WebGLBuffer)
  77079. */
  77080. export class DataBuffer {
  77081. /**
  77082. * Gets or sets the number of objects referencing this buffer
  77083. */
  77084. references: number;
  77085. /** Gets or sets the size of the underlying buffer */
  77086. capacity: number;
  77087. /**
  77088. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  77089. */
  77090. is32Bits: boolean;
  77091. /**
  77092. * Gets the underlying buffer
  77093. */
  77094. get underlyingResource(): any;
  77095. }
  77096. }
  77097. declare module BABYLON {
  77098. /** @hidden */
  77099. export interface IShaderProcessor {
  77100. attributeProcessor?: (attribute: string) => string;
  77101. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  77102. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  77103. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  77104. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  77105. lineProcessor?: (line: string, isFragment: boolean) => string;
  77106. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  77107. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  77108. }
  77109. }
  77110. declare module BABYLON {
  77111. /** @hidden */
  77112. export interface ProcessingOptions {
  77113. defines: string[];
  77114. indexParameters: any;
  77115. isFragment: boolean;
  77116. shouldUseHighPrecisionShader: boolean;
  77117. supportsUniformBuffers: boolean;
  77118. shadersRepository: string;
  77119. includesShadersStore: {
  77120. [key: string]: string;
  77121. };
  77122. processor?: IShaderProcessor;
  77123. version: string;
  77124. platformName: string;
  77125. lookForClosingBracketForUniformBuffer?: boolean;
  77126. }
  77127. }
  77128. declare module BABYLON {
  77129. /** @hidden */
  77130. export class ShaderCodeNode {
  77131. line: string;
  77132. children: ShaderCodeNode[];
  77133. additionalDefineKey?: string;
  77134. additionalDefineValue?: string;
  77135. isValid(preprocessors: {
  77136. [key: string]: string;
  77137. }): boolean;
  77138. process(preprocessors: {
  77139. [key: string]: string;
  77140. }, options: ProcessingOptions): string;
  77141. }
  77142. }
  77143. declare module BABYLON {
  77144. /** @hidden */
  77145. export class ShaderCodeCursor {
  77146. private _lines;
  77147. lineIndex: number;
  77148. get currentLine(): string;
  77149. get canRead(): boolean;
  77150. set lines(value: string[]);
  77151. }
  77152. }
  77153. declare module BABYLON {
  77154. /** @hidden */
  77155. export class ShaderCodeConditionNode extends ShaderCodeNode {
  77156. process(preprocessors: {
  77157. [key: string]: string;
  77158. }, options: ProcessingOptions): string;
  77159. }
  77160. }
  77161. declare module BABYLON {
  77162. /** @hidden */
  77163. export class ShaderDefineExpression {
  77164. isTrue(preprocessors: {
  77165. [key: string]: string;
  77166. }): boolean;
  77167. private static _OperatorPriority;
  77168. private static _Stack;
  77169. static postfixToInfix(postfix: string[]): string;
  77170. static infixToPostfix(infix: string): string[];
  77171. }
  77172. }
  77173. declare module BABYLON {
  77174. /** @hidden */
  77175. export class ShaderCodeTestNode extends ShaderCodeNode {
  77176. testExpression: ShaderDefineExpression;
  77177. isValid(preprocessors: {
  77178. [key: string]: string;
  77179. }): boolean;
  77180. }
  77181. }
  77182. declare module BABYLON {
  77183. /** @hidden */
  77184. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  77185. define: string;
  77186. not: boolean;
  77187. constructor(define: string, not?: boolean);
  77188. isTrue(preprocessors: {
  77189. [key: string]: string;
  77190. }): boolean;
  77191. }
  77192. }
  77193. declare module BABYLON {
  77194. /** @hidden */
  77195. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  77196. leftOperand: ShaderDefineExpression;
  77197. rightOperand: ShaderDefineExpression;
  77198. isTrue(preprocessors: {
  77199. [key: string]: string;
  77200. }): boolean;
  77201. }
  77202. }
  77203. declare module BABYLON {
  77204. /** @hidden */
  77205. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  77206. leftOperand: ShaderDefineExpression;
  77207. rightOperand: ShaderDefineExpression;
  77208. isTrue(preprocessors: {
  77209. [key: string]: string;
  77210. }): boolean;
  77211. }
  77212. }
  77213. declare module BABYLON {
  77214. /** @hidden */
  77215. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  77216. define: string;
  77217. operand: string;
  77218. testValue: string;
  77219. constructor(define: string, operand: string, testValue: string);
  77220. isTrue(preprocessors: {
  77221. [key: string]: string;
  77222. }): boolean;
  77223. }
  77224. }
  77225. declare module BABYLON {
  77226. /**
  77227. * Class used to enable access to offline support
  77228. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  77229. */
  77230. export interface IOfflineProvider {
  77231. /**
  77232. * Gets a boolean indicating if scene must be saved in the database
  77233. */
  77234. enableSceneOffline: boolean;
  77235. /**
  77236. * Gets a boolean indicating if textures must be saved in the database
  77237. */
  77238. enableTexturesOffline: boolean;
  77239. /**
  77240. * Open the offline support and make it available
  77241. * @param successCallback defines the callback to call on success
  77242. * @param errorCallback defines the callback to call on error
  77243. */
  77244. open(successCallback: () => void, errorCallback: () => void): void;
  77245. /**
  77246. * Loads an image from the offline support
  77247. * @param url defines the url to load from
  77248. * @param image defines the target DOM image
  77249. */
  77250. loadImage(url: string, image: HTMLImageElement): void;
  77251. /**
  77252. * Loads a file from offline support
  77253. * @param url defines the URL to load from
  77254. * @param sceneLoaded defines a callback to call on success
  77255. * @param progressCallBack defines a callback to call when progress changed
  77256. * @param errorCallback defines a callback to call on error
  77257. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  77258. */
  77259. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  77260. }
  77261. }
  77262. declare module BABYLON {
  77263. /**
  77264. * Class used to help managing file picking and drag'n'drop
  77265. * File Storage
  77266. */
  77267. export class FilesInputStore {
  77268. /**
  77269. * List of files ready to be loaded
  77270. */
  77271. static FilesToLoad: {
  77272. [key: string]: File;
  77273. };
  77274. }
  77275. }
  77276. declare module BABYLON {
  77277. /**
  77278. * Class used to define a retry strategy when error happens while loading assets
  77279. */
  77280. export class RetryStrategy {
  77281. /**
  77282. * Function used to defines an exponential back off strategy
  77283. * @param maxRetries defines the maximum number of retries (3 by default)
  77284. * @param baseInterval defines the interval between retries
  77285. * @returns the strategy function to use
  77286. */
  77287. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  77288. }
  77289. }
  77290. declare module BABYLON {
  77291. /**
  77292. * @ignore
  77293. * Application error to support additional information when loading a file
  77294. */
  77295. export abstract class BaseError extends Error {
  77296. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  77297. }
  77298. }
  77299. declare module BABYLON {
  77300. /** @ignore */
  77301. export class LoadFileError extends BaseError {
  77302. request?: WebRequest;
  77303. file?: File;
  77304. /**
  77305. * Creates a new LoadFileError
  77306. * @param message defines the message of the error
  77307. * @param request defines the optional web request
  77308. * @param file defines the optional file
  77309. */
  77310. constructor(message: string, object?: WebRequest | File);
  77311. }
  77312. /** @ignore */
  77313. export class RequestFileError extends BaseError {
  77314. request: WebRequest;
  77315. /**
  77316. * Creates a new LoadFileError
  77317. * @param message defines the message of the error
  77318. * @param request defines the optional web request
  77319. */
  77320. constructor(message: string, request: WebRequest);
  77321. }
  77322. /** @ignore */
  77323. export class ReadFileError extends BaseError {
  77324. file: File;
  77325. /**
  77326. * Creates a new ReadFileError
  77327. * @param message defines the message of the error
  77328. * @param file defines the optional file
  77329. */
  77330. constructor(message: string, file: File);
  77331. }
  77332. /**
  77333. * @hidden
  77334. */
  77335. export class FileTools {
  77336. /**
  77337. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  77338. */
  77339. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  77340. /**
  77341. * Gets or sets the base URL to use to load assets
  77342. */
  77343. static BaseUrl: string;
  77344. /**
  77345. * Default behaviour for cors in the application.
  77346. * It can be a string if the expected behavior is identical in the entire app.
  77347. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  77348. */
  77349. static CorsBehavior: string | ((url: string | string[]) => string);
  77350. /**
  77351. * Gets or sets a function used to pre-process url before using them to load assets
  77352. */
  77353. static PreprocessUrl: (url: string) => string;
  77354. /**
  77355. * Removes unwanted characters from an url
  77356. * @param url defines the url to clean
  77357. * @returns the cleaned url
  77358. */
  77359. private static _CleanUrl;
  77360. /**
  77361. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  77362. * @param url define the url we are trying
  77363. * @param element define the dom element where to configure the cors policy
  77364. */
  77365. static SetCorsBehavior(url: string | string[], element: {
  77366. crossOrigin: string | null;
  77367. }): void;
  77368. /**
  77369. * Loads an image as an HTMLImageElement.
  77370. * @param input url string, ArrayBuffer, or Blob to load
  77371. * @param onLoad callback called when the image successfully loads
  77372. * @param onError callback called when the image fails to load
  77373. * @param offlineProvider offline provider for caching
  77374. * @param mimeType optional mime type
  77375. * @returns the HTMLImageElement of the loaded image
  77376. */
  77377. 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>;
  77378. /**
  77379. * Reads a file from a File object
  77380. * @param file defines the file to load
  77381. * @param onSuccess defines the callback to call when data is loaded
  77382. * @param onProgress defines the callback to call during loading process
  77383. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  77384. * @param onError defines the callback to call when an error occurs
  77385. * @returns a file request object
  77386. */
  77387. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  77388. /**
  77389. * Loads a file from a url
  77390. * @param url url to load
  77391. * @param onSuccess callback called when the file successfully loads
  77392. * @param onProgress callback called while file is loading (if the server supports this mode)
  77393. * @param offlineProvider defines the offline provider for caching
  77394. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  77395. * @param onError callback called when the file fails to load
  77396. * @returns a file request object
  77397. */
  77398. 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;
  77399. /**
  77400. * Loads a file
  77401. * @param url url to load
  77402. * @param onSuccess callback called when the file successfully loads
  77403. * @param onProgress callback called while file is loading (if the server supports this mode)
  77404. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  77405. * @param onError callback called when the file fails to load
  77406. * @param onOpened callback called when the web request is opened
  77407. * @returns a file request object
  77408. */
  77409. 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;
  77410. /**
  77411. * Checks if the loaded document was accessed via `file:`-Protocol.
  77412. * @returns boolean
  77413. */
  77414. static IsFileURL(): boolean;
  77415. }
  77416. }
  77417. declare module BABYLON {
  77418. /** @hidden */
  77419. export class ShaderProcessor {
  77420. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  77421. private static _ProcessPrecision;
  77422. private static _ExtractOperation;
  77423. private static _BuildSubExpression;
  77424. private static _BuildExpression;
  77425. private static _MoveCursorWithinIf;
  77426. private static _MoveCursor;
  77427. private static _EvaluatePreProcessors;
  77428. private static _PreparePreProcessors;
  77429. private static _ProcessShaderConversion;
  77430. private static _ProcessIncludes;
  77431. /**
  77432. * Loads a file from a url
  77433. * @param url url to load
  77434. * @param onSuccess callback called when the file successfully loads
  77435. * @param onProgress callback called while file is loading (if the server supports this mode)
  77436. * @param offlineProvider defines the offline provider for caching
  77437. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  77438. * @param onError callback called when the file fails to load
  77439. * @returns a file request object
  77440. * @hidden
  77441. */
  77442. 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;
  77443. }
  77444. }
  77445. declare module BABYLON {
  77446. /**
  77447. * @hidden
  77448. */
  77449. export interface IColor4Like {
  77450. r: float;
  77451. g: float;
  77452. b: float;
  77453. a: float;
  77454. }
  77455. /**
  77456. * @hidden
  77457. */
  77458. export interface IColor3Like {
  77459. r: float;
  77460. g: float;
  77461. b: float;
  77462. }
  77463. /**
  77464. * @hidden
  77465. */
  77466. export interface IVector4Like {
  77467. x: float;
  77468. y: float;
  77469. z: float;
  77470. w: float;
  77471. }
  77472. /**
  77473. * @hidden
  77474. */
  77475. export interface IVector3Like {
  77476. x: float;
  77477. y: float;
  77478. z: float;
  77479. }
  77480. /**
  77481. * @hidden
  77482. */
  77483. export interface IVector2Like {
  77484. x: float;
  77485. y: float;
  77486. }
  77487. /**
  77488. * @hidden
  77489. */
  77490. export interface IMatrixLike {
  77491. toArray(): DeepImmutable<Float32Array>;
  77492. updateFlag: int;
  77493. }
  77494. /**
  77495. * @hidden
  77496. */
  77497. export interface IViewportLike {
  77498. x: float;
  77499. y: float;
  77500. width: float;
  77501. height: float;
  77502. }
  77503. /**
  77504. * @hidden
  77505. */
  77506. export interface IPlaneLike {
  77507. normal: IVector3Like;
  77508. d: float;
  77509. normalize(): void;
  77510. }
  77511. }
  77512. declare module BABYLON {
  77513. /**
  77514. * Interface used to define common properties for effect fallbacks
  77515. */
  77516. export interface IEffectFallbacks {
  77517. /**
  77518. * Removes the defines that should be removed when falling back.
  77519. * @param currentDefines defines the current define statements for the shader.
  77520. * @param effect defines the current effect we try to compile
  77521. * @returns The resulting defines with defines of the current rank removed.
  77522. */
  77523. reduce(currentDefines: string, effect: Effect): string;
  77524. /**
  77525. * Removes the fallback from the bound mesh.
  77526. */
  77527. unBindMesh(): void;
  77528. /**
  77529. * Checks to see if more fallbacks are still availible.
  77530. */
  77531. hasMoreFallbacks: boolean;
  77532. }
  77533. }
  77534. declare module BABYLON {
  77535. /**
  77536. * Class used to evalaute queries containing `and` and `or` operators
  77537. */
  77538. export class AndOrNotEvaluator {
  77539. /**
  77540. * Evaluate a query
  77541. * @param query defines the query to evaluate
  77542. * @param evaluateCallback defines the callback used to filter result
  77543. * @returns true if the query matches
  77544. */
  77545. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  77546. private static _HandleParenthesisContent;
  77547. private static _SimplifyNegation;
  77548. }
  77549. }
  77550. declare module BABYLON {
  77551. /**
  77552. * Class used to store custom tags
  77553. */
  77554. export class Tags {
  77555. /**
  77556. * Adds support for tags on the given object
  77557. * @param obj defines the object to use
  77558. */
  77559. static EnableFor(obj: any): void;
  77560. /**
  77561. * Removes tags support
  77562. * @param obj defines the object to use
  77563. */
  77564. static DisableFor(obj: any): void;
  77565. /**
  77566. * Gets a boolean indicating if the given object has tags
  77567. * @param obj defines the object to use
  77568. * @returns a boolean
  77569. */
  77570. static HasTags(obj: any): boolean;
  77571. /**
  77572. * Gets the tags available on a given object
  77573. * @param obj defines the object to use
  77574. * @param asString defines if the tags must be returned as a string instead of an array of strings
  77575. * @returns the tags
  77576. */
  77577. static GetTags(obj: any, asString?: boolean): any;
  77578. /**
  77579. * Adds tags to an object
  77580. * @param obj defines the object to use
  77581. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  77582. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  77583. */
  77584. static AddTagsTo(obj: any, tagsString: string): void;
  77585. /**
  77586. * @hidden
  77587. */
  77588. static _AddTagTo(obj: any, tag: string): void;
  77589. /**
  77590. * Removes specific tags from a specific object
  77591. * @param obj defines the object to use
  77592. * @param tagsString defines the tags to remove
  77593. */
  77594. static RemoveTagsFrom(obj: any, tagsString: string): void;
  77595. /**
  77596. * @hidden
  77597. */
  77598. static _RemoveTagFrom(obj: any, tag: string): void;
  77599. /**
  77600. * Defines if tags hosted on an object match a given query
  77601. * @param obj defines the object to use
  77602. * @param tagsQuery defines the tag query
  77603. * @returns a boolean
  77604. */
  77605. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  77606. }
  77607. }
  77608. declare module BABYLON {
  77609. /**
  77610. * Scalar computation library
  77611. */
  77612. export class Scalar {
  77613. /**
  77614. * Two pi constants convenient for computation.
  77615. */
  77616. static TwoPi: number;
  77617. /**
  77618. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  77619. * @param a number
  77620. * @param b number
  77621. * @param epsilon (default = 1.401298E-45)
  77622. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  77623. */
  77624. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  77625. /**
  77626. * Returns a string : the upper case translation of the number i to hexadecimal.
  77627. * @param i number
  77628. * @returns the upper case translation of the number i to hexadecimal.
  77629. */
  77630. static ToHex(i: number): string;
  77631. /**
  77632. * Returns -1 if value is negative and +1 is value is positive.
  77633. * @param value the value
  77634. * @returns the value itself if it's equal to zero.
  77635. */
  77636. static Sign(value: number): number;
  77637. /**
  77638. * Returns the value itself if it's between min and max.
  77639. * Returns min if the value is lower than min.
  77640. * Returns max if the value is greater than max.
  77641. * @param value the value to clmap
  77642. * @param min the min value to clamp to (default: 0)
  77643. * @param max the max value to clamp to (default: 1)
  77644. * @returns the clamped value
  77645. */
  77646. static Clamp(value: number, min?: number, max?: number): number;
  77647. /**
  77648. * the log2 of value.
  77649. * @param value the value to compute log2 of
  77650. * @returns the log2 of value.
  77651. */
  77652. static Log2(value: number): number;
  77653. /**
  77654. * Loops the value, so that it is never larger than length and never smaller than 0.
  77655. *
  77656. * This is similar to the modulo operator but it works with floating point numbers.
  77657. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  77658. * With t = 5 and length = 2.5, the result would be 0.0.
  77659. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  77660. * @param value the value
  77661. * @param length the length
  77662. * @returns the looped value
  77663. */
  77664. static Repeat(value: number, length: number): number;
  77665. /**
  77666. * Normalize the value between 0.0 and 1.0 using min and max values
  77667. * @param value value to normalize
  77668. * @param min max to normalize between
  77669. * @param max min to normalize between
  77670. * @returns the normalized value
  77671. */
  77672. static Normalize(value: number, min: number, max: number): number;
  77673. /**
  77674. * Denormalize the value from 0.0 and 1.0 using min and max values
  77675. * @param normalized value to denormalize
  77676. * @param min max to denormalize between
  77677. * @param max min to denormalize between
  77678. * @returns the denormalized value
  77679. */
  77680. static Denormalize(normalized: number, min: number, max: number): number;
  77681. /**
  77682. * Calculates the shortest difference between two given angles given in degrees.
  77683. * @param current current angle in degrees
  77684. * @param target target angle in degrees
  77685. * @returns the delta
  77686. */
  77687. static DeltaAngle(current: number, target: number): number;
  77688. /**
  77689. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  77690. * @param tx value
  77691. * @param length length
  77692. * @returns The returned value will move back and forth between 0 and length
  77693. */
  77694. static PingPong(tx: number, length: number): number;
  77695. /**
  77696. * Interpolates between min and max with smoothing at the limits.
  77697. *
  77698. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  77699. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  77700. * @param from from
  77701. * @param to to
  77702. * @param tx value
  77703. * @returns the smooth stepped value
  77704. */
  77705. static SmoothStep(from: number, to: number, tx: number): number;
  77706. /**
  77707. * Moves a value current towards target.
  77708. *
  77709. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  77710. * Negative values of maxDelta pushes the value away from target.
  77711. * @param current current value
  77712. * @param target target value
  77713. * @param maxDelta max distance to move
  77714. * @returns resulting value
  77715. */
  77716. static MoveTowards(current: number, target: number, maxDelta: number): number;
  77717. /**
  77718. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  77719. *
  77720. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  77721. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  77722. * @param current current value
  77723. * @param target target value
  77724. * @param maxDelta max distance to move
  77725. * @returns resulting angle
  77726. */
  77727. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  77728. /**
  77729. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  77730. * @param start start value
  77731. * @param end target value
  77732. * @param amount amount to lerp between
  77733. * @returns the lerped value
  77734. */
  77735. static Lerp(start: number, end: number, amount: number): number;
  77736. /**
  77737. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  77738. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  77739. * @param start start value
  77740. * @param end target value
  77741. * @param amount amount to lerp between
  77742. * @returns the lerped value
  77743. */
  77744. static LerpAngle(start: number, end: number, amount: number): number;
  77745. /**
  77746. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  77747. * @param a start value
  77748. * @param b target value
  77749. * @param value value between a and b
  77750. * @returns the inverseLerp value
  77751. */
  77752. static InverseLerp(a: number, b: number, value: number): number;
  77753. /**
  77754. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  77755. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  77756. * @param value1 spline value
  77757. * @param tangent1 spline value
  77758. * @param value2 spline value
  77759. * @param tangent2 spline value
  77760. * @param amount input value
  77761. * @returns hermite result
  77762. */
  77763. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  77764. /**
  77765. * Returns a random float number between and min and max values
  77766. * @param min min value of random
  77767. * @param max max value of random
  77768. * @returns random value
  77769. */
  77770. static RandomRange(min: number, max: number): number;
  77771. /**
  77772. * This function returns percentage of a number in a given range.
  77773. *
  77774. * RangeToPercent(40,20,60) will return 0.5 (50%)
  77775. * RangeToPercent(34,0,100) will return 0.34 (34%)
  77776. * @param number to convert to percentage
  77777. * @param min min range
  77778. * @param max max range
  77779. * @returns the percentage
  77780. */
  77781. static RangeToPercent(number: number, min: number, max: number): number;
  77782. /**
  77783. * This function returns number that corresponds to the percentage in a given range.
  77784. *
  77785. * PercentToRange(0.34,0,100) will return 34.
  77786. * @param percent to convert to number
  77787. * @param min min range
  77788. * @param max max range
  77789. * @returns the number
  77790. */
  77791. static PercentToRange(percent: number, min: number, max: number): number;
  77792. /**
  77793. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  77794. * @param angle The angle to normalize in radian.
  77795. * @return The converted angle.
  77796. */
  77797. static NormalizeRadians(angle: number): number;
  77798. }
  77799. }
  77800. declare module BABYLON {
  77801. /**
  77802. * Constant used to convert a value to gamma space
  77803. * @ignorenaming
  77804. */
  77805. export const ToGammaSpace: number;
  77806. /**
  77807. * Constant used to convert a value to linear space
  77808. * @ignorenaming
  77809. */
  77810. export const ToLinearSpace = 2.2;
  77811. /**
  77812. * Constant used to define the minimal number value in Babylon.js
  77813. * @ignorenaming
  77814. */
  77815. let Epsilon: number;
  77816. }
  77817. declare module BABYLON {
  77818. /**
  77819. * Class used to represent a viewport on screen
  77820. */
  77821. export class Viewport {
  77822. /** viewport left coordinate */
  77823. x: number;
  77824. /** viewport top coordinate */
  77825. y: number;
  77826. /**viewport width */
  77827. width: number;
  77828. /** viewport height */
  77829. height: number;
  77830. /**
  77831. * Creates a Viewport object located at (x, y) and sized (width, height)
  77832. * @param x defines viewport left coordinate
  77833. * @param y defines viewport top coordinate
  77834. * @param width defines the viewport width
  77835. * @param height defines the viewport height
  77836. */
  77837. constructor(
  77838. /** viewport left coordinate */
  77839. x: number,
  77840. /** viewport top coordinate */
  77841. y: number,
  77842. /**viewport width */
  77843. width: number,
  77844. /** viewport height */
  77845. height: number);
  77846. /**
  77847. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  77848. * @param renderWidth defines the rendering width
  77849. * @param renderHeight defines the rendering height
  77850. * @returns a new Viewport
  77851. */
  77852. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  77853. /**
  77854. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  77855. * @param renderWidth defines the rendering width
  77856. * @param renderHeight defines the rendering height
  77857. * @param ref defines the target viewport
  77858. * @returns the current viewport
  77859. */
  77860. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  77861. /**
  77862. * Returns a new Viewport copied from the current one
  77863. * @returns a new Viewport
  77864. */
  77865. clone(): Viewport;
  77866. }
  77867. }
  77868. declare module BABYLON {
  77869. /**
  77870. * Class containing a set of static utilities functions for arrays.
  77871. */
  77872. export class ArrayTools {
  77873. /**
  77874. * Returns an array of the given size filled with element built from the given constructor and the paramters
  77875. * @param size the number of element to construct and put in the array
  77876. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  77877. * @returns a new array filled with new objects
  77878. */
  77879. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  77880. }
  77881. }
  77882. declare module BABYLON {
  77883. /**
  77884. * Represens a plane by the equation ax + by + cz + d = 0
  77885. */
  77886. export class Plane {
  77887. private static _TmpMatrix;
  77888. /**
  77889. * Normal of the plane (a,b,c)
  77890. */
  77891. normal: Vector3;
  77892. /**
  77893. * d component of the plane
  77894. */
  77895. d: number;
  77896. /**
  77897. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  77898. * @param a a component of the plane
  77899. * @param b b component of the plane
  77900. * @param c c component of the plane
  77901. * @param d d component of the plane
  77902. */
  77903. constructor(a: number, b: number, c: number, d: number);
  77904. /**
  77905. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  77906. */
  77907. asArray(): number[];
  77908. /**
  77909. * @returns a new plane copied from the current Plane.
  77910. */
  77911. clone(): Plane;
  77912. /**
  77913. * @returns the string "Plane".
  77914. */
  77915. getClassName(): string;
  77916. /**
  77917. * @returns the Plane hash code.
  77918. */
  77919. getHashCode(): number;
  77920. /**
  77921. * Normalize the current Plane in place.
  77922. * @returns the updated Plane.
  77923. */
  77924. normalize(): Plane;
  77925. /**
  77926. * Applies a transformation the plane and returns the result
  77927. * @param transformation the transformation matrix to be applied to the plane
  77928. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  77929. */
  77930. transform(transformation: DeepImmutable<Matrix>): Plane;
  77931. /**
  77932. * Compute the dot product between the point and the plane normal
  77933. * @param point point to calculate the dot product with
  77934. * @returns the dot product (float) of the point coordinates and the plane normal.
  77935. */
  77936. dotCoordinate(point: DeepImmutable<Vector3>): number;
  77937. /**
  77938. * Updates the current Plane from the plane defined by the three given points.
  77939. * @param point1 one of the points used to contruct the plane
  77940. * @param point2 one of the points used to contruct the plane
  77941. * @param point3 one of the points used to contruct the plane
  77942. * @returns the updated Plane.
  77943. */
  77944. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  77945. /**
  77946. * Checks if the plane is facing a given direction
  77947. * @param direction the direction to check if the plane is facing
  77948. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  77949. * @returns True is the vector "direction" is the same side than the plane normal.
  77950. */
  77951. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  77952. /**
  77953. * Calculates the distance to a point
  77954. * @param point point to calculate distance to
  77955. * @returns the signed distance (float) from the given point to the Plane.
  77956. */
  77957. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  77958. /**
  77959. * Creates a plane from an array
  77960. * @param array the array to create a plane from
  77961. * @returns a new Plane from the given array.
  77962. */
  77963. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  77964. /**
  77965. * Creates a plane from three points
  77966. * @param point1 point used to create the plane
  77967. * @param point2 point used to create the plane
  77968. * @param point3 point used to create the plane
  77969. * @returns a new Plane defined by the three given points.
  77970. */
  77971. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  77972. /**
  77973. * Creates a plane from an origin point and a normal
  77974. * @param origin origin of the plane to be constructed
  77975. * @param normal normal of the plane to be constructed
  77976. * @returns a new Plane the normal vector to this plane at the given origin point.
  77977. * Note : the vector "normal" is updated because normalized.
  77978. */
  77979. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  77980. /**
  77981. * Calculates the distance from a plane and a point
  77982. * @param origin origin of the plane to be constructed
  77983. * @param normal normal of the plane to be constructed
  77984. * @param point point to calculate distance to
  77985. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  77986. */
  77987. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  77988. }
  77989. }
  77990. declare module BABYLON {
  77991. /**
  77992. * Class representing a vector containing 2 coordinates
  77993. */
  77994. export class Vector2 {
  77995. /** defines the first coordinate */
  77996. x: number;
  77997. /** defines the second coordinate */
  77998. y: number;
  77999. /**
  78000. * Creates a new Vector2 from the given x and y coordinates
  78001. * @param x defines the first coordinate
  78002. * @param y defines the second coordinate
  78003. */
  78004. constructor(
  78005. /** defines the first coordinate */
  78006. x?: number,
  78007. /** defines the second coordinate */
  78008. y?: number);
  78009. /**
  78010. * Gets a string with the Vector2 coordinates
  78011. * @returns a string with the Vector2 coordinates
  78012. */
  78013. toString(): string;
  78014. /**
  78015. * Gets class name
  78016. * @returns the string "Vector2"
  78017. */
  78018. getClassName(): string;
  78019. /**
  78020. * Gets current vector hash code
  78021. * @returns the Vector2 hash code as a number
  78022. */
  78023. getHashCode(): number;
  78024. /**
  78025. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  78026. * @param array defines the source array
  78027. * @param index defines the offset in source array
  78028. * @returns the current Vector2
  78029. */
  78030. toArray(array: FloatArray, index?: number): Vector2;
  78031. /**
  78032. * Copy the current vector to an array
  78033. * @returns a new array with 2 elements: the Vector2 coordinates.
  78034. */
  78035. asArray(): number[];
  78036. /**
  78037. * Sets the Vector2 coordinates with the given Vector2 coordinates
  78038. * @param source defines the source Vector2
  78039. * @returns the current updated Vector2
  78040. */
  78041. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  78042. /**
  78043. * Sets the Vector2 coordinates with the given floats
  78044. * @param x defines the first coordinate
  78045. * @param y defines the second coordinate
  78046. * @returns the current updated Vector2
  78047. */
  78048. copyFromFloats(x: number, y: number): Vector2;
  78049. /**
  78050. * Sets the Vector2 coordinates with the given floats
  78051. * @param x defines the first coordinate
  78052. * @param y defines the second coordinate
  78053. * @returns the current updated Vector2
  78054. */
  78055. set(x: number, y: number): Vector2;
  78056. /**
  78057. * Add another vector with the current one
  78058. * @param otherVector defines the other vector
  78059. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  78060. */
  78061. add(otherVector: DeepImmutable<Vector2>): Vector2;
  78062. /**
  78063. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  78064. * @param otherVector defines the other vector
  78065. * @param result defines the target vector
  78066. * @returns the unmodified current Vector2
  78067. */
  78068. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  78069. /**
  78070. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  78071. * @param otherVector defines the other vector
  78072. * @returns the current updated Vector2
  78073. */
  78074. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  78075. /**
  78076. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  78077. * @param otherVector defines the other vector
  78078. * @returns a new Vector2
  78079. */
  78080. addVector3(otherVector: Vector3): Vector2;
  78081. /**
  78082. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  78083. * @param otherVector defines the other vector
  78084. * @returns a new Vector2
  78085. */
  78086. subtract(otherVector: Vector2): Vector2;
  78087. /**
  78088. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  78089. * @param otherVector defines the other vector
  78090. * @param result defines the target vector
  78091. * @returns the unmodified current Vector2
  78092. */
  78093. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  78094. /**
  78095. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  78096. * @param otherVector defines the other vector
  78097. * @returns the current updated Vector2
  78098. */
  78099. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  78100. /**
  78101. * Multiplies in place the current Vector2 coordinates by the given ones
  78102. * @param otherVector defines the other vector
  78103. * @returns the current updated Vector2
  78104. */
  78105. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  78106. /**
  78107. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  78108. * @param otherVector defines the other vector
  78109. * @returns a new Vector2
  78110. */
  78111. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  78112. /**
  78113. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  78114. * @param otherVector defines the other vector
  78115. * @param result defines the target vector
  78116. * @returns the unmodified current Vector2
  78117. */
  78118. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  78119. /**
  78120. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  78121. * @param x defines the first coordinate
  78122. * @param y defines the second coordinate
  78123. * @returns a new Vector2
  78124. */
  78125. multiplyByFloats(x: number, y: number): Vector2;
  78126. /**
  78127. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  78128. * @param otherVector defines the other vector
  78129. * @returns a new Vector2
  78130. */
  78131. divide(otherVector: Vector2): Vector2;
  78132. /**
  78133. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  78134. * @param otherVector defines the other vector
  78135. * @param result defines the target vector
  78136. * @returns the unmodified current Vector2
  78137. */
  78138. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  78139. /**
  78140. * Divides the current Vector2 coordinates by the given ones
  78141. * @param otherVector defines the other vector
  78142. * @returns the current updated Vector2
  78143. */
  78144. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  78145. /**
  78146. * Gets a new Vector2 with current Vector2 negated coordinates
  78147. * @returns a new Vector2
  78148. */
  78149. negate(): Vector2;
  78150. /**
  78151. * Negate this vector in place
  78152. * @returns this
  78153. */
  78154. negateInPlace(): Vector2;
  78155. /**
  78156. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  78157. * @param result defines the Vector3 object where to store the result
  78158. * @returns the current Vector2
  78159. */
  78160. negateToRef(result: Vector2): Vector2;
  78161. /**
  78162. * Multiply the Vector2 coordinates by scale
  78163. * @param scale defines the scaling factor
  78164. * @returns the current updated Vector2
  78165. */
  78166. scaleInPlace(scale: number): Vector2;
  78167. /**
  78168. * Returns a new Vector2 scaled by "scale" from the current Vector2
  78169. * @param scale defines the scaling factor
  78170. * @returns a new Vector2
  78171. */
  78172. scale(scale: number): Vector2;
  78173. /**
  78174. * Scale the current Vector2 values by a factor to a given Vector2
  78175. * @param scale defines the scale factor
  78176. * @param result defines the Vector2 object where to store the result
  78177. * @returns the unmodified current Vector2
  78178. */
  78179. scaleToRef(scale: number, result: Vector2): Vector2;
  78180. /**
  78181. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  78182. * @param scale defines the scale factor
  78183. * @param result defines the Vector2 object where to store the result
  78184. * @returns the unmodified current Vector2
  78185. */
  78186. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  78187. /**
  78188. * Gets a boolean if two vectors are equals
  78189. * @param otherVector defines the other vector
  78190. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  78191. */
  78192. equals(otherVector: DeepImmutable<Vector2>): boolean;
  78193. /**
  78194. * Gets a boolean if two vectors are equals (using an epsilon value)
  78195. * @param otherVector defines the other vector
  78196. * @param epsilon defines the minimal distance to consider equality
  78197. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  78198. */
  78199. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  78200. /**
  78201. * Gets a new Vector2 from current Vector2 floored values
  78202. * @returns a new Vector2
  78203. */
  78204. floor(): Vector2;
  78205. /**
  78206. * Gets a new Vector2 from current Vector2 floored values
  78207. * @returns a new Vector2
  78208. */
  78209. fract(): Vector2;
  78210. /**
  78211. * Gets the length of the vector
  78212. * @returns the vector length (float)
  78213. */
  78214. length(): number;
  78215. /**
  78216. * Gets the vector squared length
  78217. * @returns the vector squared length (float)
  78218. */
  78219. lengthSquared(): number;
  78220. /**
  78221. * Normalize the vector
  78222. * @returns the current updated Vector2
  78223. */
  78224. normalize(): Vector2;
  78225. /**
  78226. * Gets a new Vector2 copied from the Vector2
  78227. * @returns a new Vector2
  78228. */
  78229. clone(): Vector2;
  78230. /**
  78231. * Gets a new Vector2(0, 0)
  78232. * @returns a new Vector2
  78233. */
  78234. static Zero(): Vector2;
  78235. /**
  78236. * Gets a new Vector2(1, 1)
  78237. * @returns a new Vector2
  78238. */
  78239. static One(): Vector2;
  78240. /**
  78241. * Gets a new Vector2 set from the given index element of the given array
  78242. * @param array defines the data source
  78243. * @param offset defines the offset in the data source
  78244. * @returns a new Vector2
  78245. */
  78246. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  78247. /**
  78248. * Sets "result" from the given index element of the given array
  78249. * @param array defines the data source
  78250. * @param offset defines the offset in the data source
  78251. * @param result defines the target vector
  78252. */
  78253. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  78254. /**
  78255. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  78256. * @param value1 defines 1st point of control
  78257. * @param value2 defines 2nd point of control
  78258. * @param value3 defines 3rd point of control
  78259. * @param value4 defines 4th point of control
  78260. * @param amount defines the interpolation factor
  78261. * @returns a new Vector2
  78262. */
  78263. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  78264. /**
  78265. * 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".
  78266. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  78267. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  78268. * @param value defines the value to clamp
  78269. * @param min defines the lower limit
  78270. * @param max defines the upper limit
  78271. * @returns a new Vector2
  78272. */
  78273. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  78274. /**
  78275. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  78276. * @param value1 defines the 1st control point
  78277. * @param tangent1 defines the outgoing tangent
  78278. * @param value2 defines the 2nd control point
  78279. * @param tangent2 defines the incoming tangent
  78280. * @param amount defines the interpolation factor
  78281. * @returns a new Vector2
  78282. */
  78283. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  78284. /**
  78285. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  78286. * @param start defines the start vector
  78287. * @param end defines the end vector
  78288. * @param amount defines the interpolation factor
  78289. * @returns a new Vector2
  78290. */
  78291. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  78292. /**
  78293. * Gets the dot product of the vector "left" and the vector "right"
  78294. * @param left defines first vector
  78295. * @param right defines second vector
  78296. * @returns the dot product (float)
  78297. */
  78298. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  78299. /**
  78300. * Returns a new Vector2 equal to the normalized given vector
  78301. * @param vector defines the vector to normalize
  78302. * @returns a new Vector2
  78303. */
  78304. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  78305. /**
  78306. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  78307. * @param left defines 1st vector
  78308. * @param right defines 2nd vector
  78309. * @returns a new Vector2
  78310. */
  78311. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  78312. /**
  78313. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  78314. * @param left defines 1st vector
  78315. * @param right defines 2nd vector
  78316. * @returns a new Vector2
  78317. */
  78318. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  78319. /**
  78320. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  78321. * @param vector defines the vector to transform
  78322. * @param transformation defines the matrix to apply
  78323. * @returns a new Vector2
  78324. */
  78325. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  78326. /**
  78327. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  78328. * @param vector defines the vector to transform
  78329. * @param transformation defines the matrix to apply
  78330. * @param result defines the target vector
  78331. */
  78332. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  78333. /**
  78334. * Determines if a given vector is included in a triangle
  78335. * @param p defines the vector to test
  78336. * @param p0 defines 1st triangle point
  78337. * @param p1 defines 2nd triangle point
  78338. * @param p2 defines 3rd triangle point
  78339. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  78340. */
  78341. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  78342. /**
  78343. * Gets the distance between the vectors "value1" and "value2"
  78344. * @param value1 defines first vector
  78345. * @param value2 defines second vector
  78346. * @returns the distance between vectors
  78347. */
  78348. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  78349. /**
  78350. * Returns the squared distance between the vectors "value1" and "value2"
  78351. * @param value1 defines first vector
  78352. * @param value2 defines second vector
  78353. * @returns the squared distance between vectors
  78354. */
  78355. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  78356. /**
  78357. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  78358. * @param value1 defines first vector
  78359. * @param value2 defines second vector
  78360. * @returns a new Vector2
  78361. */
  78362. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  78363. /**
  78364. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  78365. * @param p defines the middle point
  78366. * @param segA defines one point of the segment
  78367. * @param segB defines the other point of the segment
  78368. * @returns the shortest distance
  78369. */
  78370. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  78371. }
  78372. /**
  78373. * Class used to store (x,y,z) vector representation
  78374. * A Vector3 is the main object used in 3D geometry
  78375. * It can represent etiher the coordinates of a point the space, either a direction
  78376. * Reminder: js uses a left handed forward facing system
  78377. */
  78378. export class Vector3 {
  78379. /**
  78380. * Defines the first coordinates (on X axis)
  78381. */
  78382. x: number;
  78383. /**
  78384. * Defines the second coordinates (on Y axis)
  78385. */
  78386. y: number;
  78387. /**
  78388. * Defines the third coordinates (on Z axis)
  78389. */
  78390. z: number;
  78391. private static _UpReadOnly;
  78392. private static _ZeroReadOnly;
  78393. /**
  78394. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  78395. * @param x defines the first coordinates (on X axis)
  78396. * @param y defines the second coordinates (on Y axis)
  78397. * @param z defines the third coordinates (on Z axis)
  78398. */
  78399. constructor(
  78400. /**
  78401. * Defines the first coordinates (on X axis)
  78402. */
  78403. x?: number,
  78404. /**
  78405. * Defines the second coordinates (on Y axis)
  78406. */
  78407. y?: number,
  78408. /**
  78409. * Defines the third coordinates (on Z axis)
  78410. */
  78411. z?: number);
  78412. /**
  78413. * Creates a string representation of the Vector3
  78414. * @returns a string with the Vector3 coordinates.
  78415. */
  78416. toString(): string;
  78417. /**
  78418. * Gets the class name
  78419. * @returns the string "Vector3"
  78420. */
  78421. getClassName(): string;
  78422. /**
  78423. * Creates the Vector3 hash code
  78424. * @returns a number which tends to be unique between Vector3 instances
  78425. */
  78426. getHashCode(): number;
  78427. /**
  78428. * Creates an array containing three elements : the coordinates of the Vector3
  78429. * @returns a new array of numbers
  78430. */
  78431. asArray(): number[];
  78432. /**
  78433. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  78434. * @param array defines the destination array
  78435. * @param index defines the offset in the destination array
  78436. * @returns the current Vector3
  78437. */
  78438. toArray(array: FloatArray, index?: number): Vector3;
  78439. /**
  78440. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  78441. * @returns a new Quaternion object, computed from the Vector3 coordinates
  78442. */
  78443. toQuaternion(): Quaternion;
  78444. /**
  78445. * Adds the given vector to the current Vector3
  78446. * @param otherVector defines the second operand
  78447. * @returns the current updated Vector3
  78448. */
  78449. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  78450. /**
  78451. * Adds the given coordinates to the current Vector3
  78452. * @param x defines the x coordinate of the operand
  78453. * @param y defines the y coordinate of the operand
  78454. * @param z defines the z coordinate of the operand
  78455. * @returns the current updated Vector3
  78456. */
  78457. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  78458. /**
  78459. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  78460. * @param otherVector defines the second operand
  78461. * @returns the resulting Vector3
  78462. */
  78463. add(otherVector: DeepImmutable<Vector3>): Vector3;
  78464. /**
  78465. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  78466. * @param otherVector defines the second operand
  78467. * @param result defines the Vector3 object where to store the result
  78468. * @returns the current Vector3
  78469. */
  78470. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  78471. /**
  78472. * Subtract the given vector from the current Vector3
  78473. * @param otherVector defines the second operand
  78474. * @returns the current updated Vector3
  78475. */
  78476. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  78477. /**
  78478. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  78479. * @param otherVector defines the second operand
  78480. * @returns the resulting Vector3
  78481. */
  78482. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  78483. /**
  78484. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  78485. * @param otherVector defines the second operand
  78486. * @param result defines the Vector3 object where to store the result
  78487. * @returns the current Vector3
  78488. */
  78489. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  78490. /**
  78491. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  78492. * @param x defines the x coordinate of the operand
  78493. * @param y defines the y coordinate of the operand
  78494. * @param z defines the z coordinate of the operand
  78495. * @returns the resulting Vector3
  78496. */
  78497. subtractFromFloats(x: number, y: number, z: number): Vector3;
  78498. /**
  78499. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  78500. * @param x defines the x coordinate of the operand
  78501. * @param y defines the y coordinate of the operand
  78502. * @param z defines the z coordinate of the operand
  78503. * @param result defines the Vector3 object where to store the result
  78504. * @returns the current Vector3
  78505. */
  78506. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  78507. /**
  78508. * Gets a new Vector3 set with the current Vector3 negated coordinates
  78509. * @returns a new Vector3
  78510. */
  78511. negate(): Vector3;
  78512. /**
  78513. * Negate this vector in place
  78514. * @returns this
  78515. */
  78516. negateInPlace(): Vector3;
  78517. /**
  78518. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  78519. * @param result defines the Vector3 object where to store the result
  78520. * @returns the current Vector3
  78521. */
  78522. negateToRef(result: Vector3): Vector3;
  78523. /**
  78524. * Multiplies the Vector3 coordinates by the float "scale"
  78525. * @param scale defines the multiplier factor
  78526. * @returns the current updated Vector3
  78527. */
  78528. scaleInPlace(scale: number): Vector3;
  78529. /**
  78530. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  78531. * @param scale defines the multiplier factor
  78532. * @returns a new Vector3
  78533. */
  78534. scale(scale: number): Vector3;
  78535. /**
  78536. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  78537. * @param scale defines the multiplier factor
  78538. * @param result defines the Vector3 object where to store the result
  78539. * @returns the current Vector3
  78540. */
  78541. scaleToRef(scale: number, result: Vector3): Vector3;
  78542. /**
  78543. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  78544. * @param scale defines the scale factor
  78545. * @param result defines the Vector3 object where to store the result
  78546. * @returns the unmodified current Vector3
  78547. */
  78548. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  78549. /**
  78550. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  78551. * @param origin defines the origin of the projection ray
  78552. * @param plane defines the plane to project to
  78553. * @returns the projected vector3
  78554. */
  78555. projectOnPlane(plane: Plane, origin: Vector3): Vector3;
  78556. /**
  78557. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  78558. * @param origin defines the origin of the projection ray
  78559. * @param plane defines the plane to project to
  78560. * @param result defines the Vector3 where to store the result
  78561. */
  78562. projectOnPlaneToRef(plane: Plane, origin: Vector3, result: Vector3): void;
  78563. /**
  78564. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  78565. * @param otherVector defines the second operand
  78566. * @returns true if both vectors are equals
  78567. */
  78568. equals(otherVector: DeepImmutable<Vector3>): boolean;
  78569. /**
  78570. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  78571. * @param otherVector defines the second operand
  78572. * @param epsilon defines the minimal distance to define values as equals
  78573. * @returns true if both vectors are distant less than epsilon
  78574. */
  78575. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  78576. /**
  78577. * Returns true if the current Vector3 coordinates equals the given floats
  78578. * @param x defines the x coordinate of the operand
  78579. * @param y defines the y coordinate of the operand
  78580. * @param z defines the z coordinate of the operand
  78581. * @returns true if both vectors are equals
  78582. */
  78583. equalsToFloats(x: number, y: number, z: number): boolean;
  78584. /**
  78585. * Multiplies the current Vector3 coordinates by the given ones
  78586. * @param otherVector defines the second operand
  78587. * @returns the current updated Vector3
  78588. */
  78589. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  78590. /**
  78591. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  78592. * @param otherVector defines the second operand
  78593. * @returns the new Vector3
  78594. */
  78595. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  78596. /**
  78597. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  78598. * @param otherVector defines the second operand
  78599. * @param result defines the Vector3 object where to store the result
  78600. * @returns the current Vector3
  78601. */
  78602. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  78603. /**
  78604. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  78605. * @param x defines the x coordinate of the operand
  78606. * @param y defines the y coordinate of the operand
  78607. * @param z defines the z coordinate of the operand
  78608. * @returns the new Vector3
  78609. */
  78610. multiplyByFloats(x: number, y: number, z: number): Vector3;
  78611. /**
  78612. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  78613. * @param otherVector defines the second operand
  78614. * @returns the new Vector3
  78615. */
  78616. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  78617. /**
  78618. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  78619. * @param otherVector defines the second operand
  78620. * @param result defines the Vector3 object where to store the result
  78621. * @returns the current Vector3
  78622. */
  78623. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  78624. /**
  78625. * Divides the current Vector3 coordinates by the given ones.
  78626. * @param otherVector defines the second operand
  78627. * @returns the current updated Vector3
  78628. */
  78629. divideInPlace(otherVector: Vector3): Vector3;
  78630. /**
  78631. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  78632. * @param other defines the second operand
  78633. * @returns the current updated Vector3
  78634. */
  78635. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  78636. /**
  78637. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  78638. * @param other defines the second operand
  78639. * @returns the current updated Vector3
  78640. */
  78641. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  78642. /**
  78643. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  78644. * @param x defines the x coordinate of the operand
  78645. * @param y defines the y coordinate of the operand
  78646. * @param z defines the z coordinate of the operand
  78647. * @returns the current updated Vector3
  78648. */
  78649. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  78650. /**
  78651. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  78652. * @param x defines the x coordinate of the operand
  78653. * @param y defines the y coordinate of the operand
  78654. * @param z defines the z coordinate of the operand
  78655. * @returns the current updated Vector3
  78656. */
  78657. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  78658. /**
  78659. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  78660. * Check if is non uniform within a certain amount of decimal places to account for this
  78661. * @param epsilon the amount the values can differ
  78662. * @returns if the the vector is non uniform to a certain number of decimal places
  78663. */
  78664. isNonUniformWithinEpsilon(epsilon: number): boolean;
  78665. /**
  78666. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  78667. */
  78668. get isNonUniform(): boolean;
  78669. /**
  78670. * Gets a new Vector3 from current Vector3 floored values
  78671. * @returns a new Vector3
  78672. */
  78673. floor(): Vector3;
  78674. /**
  78675. * Gets a new Vector3 from current Vector3 floored values
  78676. * @returns a new Vector3
  78677. */
  78678. fract(): Vector3;
  78679. /**
  78680. * Gets the length of the Vector3
  78681. * @returns the length of the Vector3
  78682. */
  78683. length(): number;
  78684. /**
  78685. * Gets the squared length of the Vector3
  78686. * @returns squared length of the Vector3
  78687. */
  78688. lengthSquared(): number;
  78689. /**
  78690. * Normalize the current Vector3.
  78691. * Please note that this is an in place operation.
  78692. * @returns the current updated Vector3
  78693. */
  78694. normalize(): Vector3;
  78695. /**
  78696. * Reorders the x y z properties of the vector in place
  78697. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  78698. * @returns the current updated vector
  78699. */
  78700. reorderInPlace(order: string): this;
  78701. /**
  78702. * Rotates the vector around 0,0,0 by a quaternion
  78703. * @param quaternion the rotation quaternion
  78704. * @param result vector to store the result
  78705. * @returns the resulting vector
  78706. */
  78707. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  78708. /**
  78709. * Rotates a vector around a given point
  78710. * @param quaternion the rotation quaternion
  78711. * @param point the point to rotate around
  78712. * @param result vector to store the result
  78713. * @returns the resulting vector
  78714. */
  78715. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  78716. /**
  78717. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  78718. * The cross product is then orthogonal to both current and "other"
  78719. * @param other defines the right operand
  78720. * @returns the cross product
  78721. */
  78722. cross(other: Vector3): Vector3;
  78723. /**
  78724. * Normalize the current Vector3 with the given input length.
  78725. * Please note that this is an in place operation.
  78726. * @param len the length of the vector
  78727. * @returns the current updated Vector3
  78728. */
  78729. normalizeFromLength(len: number): Vector3;
  78730. /**
  78731. * Normalize the current Vector3 to a new vector
  78732. * @returns the new Vector3
  78733. */
  78734. normalizeToNew(): Vector3;
  78735. /**
  78736. * Normalize the current Vector3 to the reference
  78737. * @param reference define the Vector3 to update
  78738. * @returns the updated Vector3
  78739. */
  78740. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  78741. /**
  78742. * Creates a new Vector3 copied from the current Vector3
  78743. * @returns the new Vector3
  78744. */
  78745. clone(): Vector3;
  78746. /**
  78747. * Copies the given vector coordinates to the current Vector3 ones
  78748. * @param source defines the source Vector3
  78749. * @returns the current updated Vector3
  78750. */
  78751. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  78752. /**
  78753. * Copies the given floats to the current Vector3 coordinates
  78754. * @param x defines the x coordinate of the operand
  78755. * @param y defines the y coordinate of the operand
  78756. * @param z defines the z coordinate of the operand
  78757. * @returns the current updated Vector3
  78758. */
  78759. copyFromFloats(x: number, y: number, z: number): Vector3;
  78760. /**
  78761. * Copies the given floats to the current Vector3 coordinates
  78762. * @param x defines the x coordinate of the operand
  78763. * @param y defines the y coordinate of the operand
  78764. * @param z defines the z coordinate of the operand
  78765. * @returns the current updated Vector3
  78766. */
  78767. set(x: number, y: number, z: number): Vector3;
  78768. /**
  78769. * Copies the given float to the current Vector3 coordinates
  78770. * @param v defines the x, y and z coordinates of the operand
  78771. * @returns the current updated Vector3
  78772. */
  78773. setAll(v: number): Vector3;
  78774. /**
  78775. * Get the clip factor between two vectors
  78776. * @param vector0 defines the first operand
  78777. * @param vector1 defines the second operand
  78778. * @param axis defines the axis to use
  78779. * @param size defines the size along the axis
  78780. * @returns the clip factor
  78781. */
  78782. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  78783. /**
  78784. * Get angle between two vectors
  78785. * @param vector0 angle between vector0 and vector1
  78786. * @param vector1 angle between vector0 and vector1
  78787. * @param normal direction of the normal
  78788. * @return the angle between vector0 and vector1
  78789. */
  78790. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  78791. /**
  78792. * Returns a new Vector3 set from the index "offset" of the given array
  78793. * @param array defines the source array
  78794. * @param offset defines the offset in the source array
  78795. * @returns the new Vector3
  78796. */
  78797. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  78798. /**
  78799. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  78800. * @param array defines the source array
  78801. * @param offset defines the offset in the source array
  78802. * @returns the new Vector3
  78803. * @deprecated Please use FromArray instead.
  78804. */
  78805. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  78806. /**
  78807. * Sets the given vector "result" with the element values from the index "offset" of the given array
  78808. * @param array defines the source array
  78809. * @param offset defines the offset in the source array
  78810. * @param result defines the Vector3 where to store the result
  78811. */
  78812. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  78813. /**
  78814. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  78815. * @param array defines the source array
  78816. * @param offset defines the offset in the source array
  78817. * @param result defines the Vector3 where to store the result
  78818. * @deprecated Please use FromArrayToRef instead.
  78819. */
  78820. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  78821. /**
  78822. * Sets the given vector "result" with the given floats.
  78823. * @param x defines the x coordinate of the source
  78824. * @param y defines the y coordinate of the source
  78825. * @param z defines the z coordinate of the source
  78826. * @param result defines the Vector3 where to store the result
  78827. */
  78828. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  78829. /**
  78830. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  78831. * @returns a new empty Vector3
  78832. */
  78833. static Zero(): Vector3;
  78834. /**
  78835. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  78836. * @returns a new unit Vector3
  78837. */
  78838. static One(): Vector3;
  78839. /**
  78840. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  78841. * @returns a new up Vector3
  78842. */
  78843. static Up(): Vector3;
  78844. /**
  78845. * Gets a up Vector3 that must not be updated
  78846. */
  78847. static get UpReadOnly(): DeepImmutable<Vector3>;
  78848. /**
  78849. * Gets a zero Vector3 that must not be updated
  78850. */
  78851. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  78852. /**
  78853. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  78854. * @returns a new down Vector3
  78855. */
  78856. static Down(): Vector3;
  78857. /**
  78858. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  78859. * @param rightHandedSystem is the scene right-handed (negative z)
  78860. * @returns a new forward Vector3
  78861. */
  78862. static Forward(rightHandedSystem?: boolean): Vector3;
  78863. /**
  78864. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  78865. * @param rightHandedSystem is the scene right-handed (negative-z)
  78866. * @returns a new forward Vector3
  78867. */
  78868. static Backward(rightHandedSystem?: boolean): Vector3;
  78869. /**
  78870. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  78871. * @returns a new right Vector3
  78872. */
  78873. static Right(): Vector3;
  78874. /**
  78875. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  78876. * @returns a new left Vector3
  78877. */
  78878. static Left(): Vector3;
  78879. /**
  78880. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  78881. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  78882. * @param vector defines the Vector3 to transform
  78883. * @param transformation defines the transformation matrix
  78884. * @returns the transformed Vector3
  78885. */
  78886. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  78887. /**
  78888. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  78889. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  78890. * @param vector defines the Vector3 to transform
  78891. * @param transformation defines the transformation matrix
  78892. * @param result defines the Vector3 where to store the result
  78893. */
  78894. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  78895. /**
  78896. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  78897. * This method computes tranformed coordinates only, not transformed direction vectors
  78898. * @param x define the x coordinate of the source vector
  78899. * @param y define the y coordinate of the source vector
  78900. * @param z define the z coordinate of the source vector
  78901. * @param transformation defines the transformation matrix
  78902. * @param result defines the Vector3 where to store the result
  78903. */
  78904. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  78905. /**
  78906. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  78907. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  78908. * @param vector defines the Vector3 to transform
  78909. * @param transformation defines the transformation matrix
  78910. * @returns the new Vector3
  78911. */
  78912. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  78913. /**
  78914. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  78915. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  78916. * @param vector defines the Vector3 to transform
  78917. * @param transformation defines the transformation matrix
  78918. * @param result defines the Vector3 where to store the result
  78919. */
  78920. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  78921. /**
  78922. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  78923. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  78924. * @param x define the x coordinate of the source vector
  78925. * @param y define the y coordinate of the source vector
  78926. * @param z define the z coordinate of the source vector
  78927. * @param transformation defines the transformation matrix
  78928. * @param result defines the Vector3 where to store the result
  78929. */
  78930. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  78931. /**
  78932. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  78933. * @param value1 defines the first control point
  78934. * @param value2 defines the second control point
  78935. * @param value3 defines the third control point
  78936. * @param value4 defines the fourth control point
  78937. * @param amount defines the amount on the spline to use
  78938. * @returns the new Vector3
  78939. */
  78940. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  78941. /**
  78942. * 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"
  78943. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  78944. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  78945. * @param value defines the current value
  78946. * @param min defines the lower range value
  78947. * @param max defines the upper range value
  78948. * @returns the new Vector3
  78949. */
  78950. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  78951. /**
  78952. * 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"
  78953. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  78954. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  78955. * @param value defines the current value
  78956. * @param min defines the lower range value
  78957. * @param max defines the upper range value
  78958. * @param result defines the Vector3 where to store the result
  78959. */
  78960. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  78961. /**
  78962. * Checks if a given vector is inside a specific range
  78963. * @param v defines the vector to test
  78964. * @param min defines the minimum range
  78965. * @param max defines the maximum range
  78966. */
  78967. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  78968. /**
  78969. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  78970. * @param value1 defines the first control point
  78971. * @param tangent1 defines the first tangent vector
  78972. * @param value2 defines the second control point
  78973. * @param tangent2 defines the second tangent vector
  78974. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  78975. * @returns the new Vector3
  78976. */
  78977. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  78978. /**
  78979. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  78980. * @param start defines the start value
  78981. * @param end defines the end value
  78982. * @param amount max defines amount between both (between 0 and 1)
  78983. * @returns the new Vector3
  78984. */
  78985. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  78986. /**
  78987. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  78988. * @param start defines the start value
  78989. * @param end defines the end value
  78990. * @param amount max defines amount between both (between 0 and 1)
  78991. * @param result defines the Vector3 where to store the result
  78992. */
  78993. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  78994. /**
  78995. * Returns the dot product (float) between the vectors "left" and "right"
  78996. * @param left defines the left operand
  78997. * @param right defines the right operand
  78998. * @returns the dot product
  78999. */
  79000. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  79001. /**
  79002. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  79003. * The cross product is then orthogonal to both "left" and "right"
  79004. * @param left defines the left operand
  79005. * @param right defines the right operand
  79006. * @returns the cross product
  79007. */
  79008. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  79009. /**
  79010. * Sets the given vector "result" with the cross product of "left" and "right"
  79011. * The cross product is then orthogonal to both "left" and "right"
  79012. * @param left defines the left operand
  79013. * @param right defines the right operand
  79014. * @param result defines the Vector3 where to store the result
  79015. */
  79016. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  79017. /**
  79018. * Returns a new Vector3 as the normalization of the given vector
  79019. * @param vector defines the Vector3 to normalize
  79020. * @returns the new Vector3
  79021. */
  79022. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  79023. /**
  79024. * Sets the given vector "result" with the normalization of the given first vector
  79025. * @param vector defines the Vector3 to normalize
  79026. * @param result defines the Vector3 where to store the result
  79027. */
  79028. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  79029. /**
  79030. * Project a Vector3 onto screen space
  79031. * @param vector defines the Vector3 to project
  79032. * @param world defines the world matrix to use
  79033. * @param transform defines the transform (view x projection) matrix to use
  79034. * @param viewport defines the screen viewport to use
  79035. * @returns the new Vector3
  79036. */
  79037. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  79038. /** @hidden */
  79039. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  79040. /**
  79041. * Unproject from screen space to object space
  79042. * @param source defines the screen space Vector3 to use
  79043. * @param viewportWidth defines the current width of the viewport
  79044. * @param viewportHeight defines the current height of the viewport
  79045. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  79046. * @param transform defines the transform (view x projection) matrix to use
  79047. * @returns the new Vector3
  79048. */
  79049. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  79050. /**
  79051. * Unproject from screen space to object space
  79052. * @param source defines the screen space Vector3 to use
  79053. * @param viewportWidth defines the current width of the viewport
  79054. * @param viewportHeight defines the current height of the viewport
  79055. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  79056. * @param view defines the view matrix to use
  79057. * @param projection defines the projection matrix to use
  79058. * @returns the new Vector3
  79059. */
  79060. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  79061. /**
  79062. * Unproject from screen space to object space
  79063. * @param source defines the screen space Vector3 to use
  79064. * @param viewportWidth defines the current width of the viewport
  79065. * @param viewportHeight defines the current height of the viewport
  79066. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  79067. * @param view defines the view matrix to use
  79068. * @param projection defines the projection matrix to use
  79069. * @param result defines the Vector3 where to store the result
  79070. */
  79071. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  79072. /**
  79073. * Unproject from screen space to object space
  79074. * @param sourceX defines the screen space x coordinate to use
  79075. * @param sourceY defines the screen space y coordinate to use
  79076. * @param sourceZ defines the screen space z coordinate to use
  79077. * @param viewportWidth defines the current width of the viewport
  79078. * @param viewportHeight defines the current height of the viewport
  79079. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  79080. * @param view defines the view matrix to use
  79081. * @param projection defines the projection matrix to use
  79082. * @param result defines the Vector3 where to store the result
  79083. */
  79084. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  79085. /**
  79086. * Gets the minimal coordinate values between two Vector3
  79087. * @param left defines the first operand
  79088. * @param right defines the second operand
  79089. * @returns the new Vector3
  79090. */
  79091. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  79092. /**
  79093. * Gets the maximal coordinate values between two Vector3
  79094. * @param left defines the first operand
  79095. * @param right defines the second operand
  79096. * @returns the new Vector3
  79097. */
  79098. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  79099. /**
  79100. * Returns the distance between the vectors "value1" and "value2"
  79101. * @param value1 defines the first operand
  79102. * @param value2 defines the second operand
  79103. * @returns the distance
  79104. */
  79105. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  79106. /**
  79107. * Returns the squared distance between the vectors "value1" and "value2"
  79108. * @param value1 defines the first operand
  79109. * @param value2 defines the second operand
  79110. * @returns the squared distance
  79111. */
  79112. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  79113. /**
  79114. * Returns a new Vector3 located at the center between "value1" and "value2"
  79115. * @param value1 defines the first operand
  79116. * @param value2 defines the second operand
  79117. * @returns the new Vector3
  79118. */
  79119. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  79120. /**
  79121. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  79122. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  79123. * to something in order to rotate it from its local system to the given target system
  79124. * Note: axis1, axis2 and axis3 are normalized during this operation
  79125. * @param axis1 defines the first axis
  79126. * @param axis2 defines the second axis
  79127. * @param axis3 defines the third axis
  79128. * @returns a new Vector3
  79129. */
  79130. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  79131. /**
  79132. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  79133. * @param axis1 defines the first axis
  79134. * @param axis2 defines the second axis
  79135. * @param axis3 defines the third axis
  79136. * @param ref defines the Vector3 where to store the result
  79137. */
  79138. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  79139. }
  79140. /**
  79141. * Vector4 class created for EulerAngle class conversion to Quaternion
  79142. */
  79143. export class Vector4 {
  79144. /** x value of the vector */
  79145. x: number;
  79146. /** y value of the vector */
  79147. y: number;
  79148. /** z value of the vector */
  79149. z: number;
  79150. /** w value of the vector */
  79151. w: number;
  79152. /**
  79153. * Creates a Vector4 object from the given floats.
  79154. * @param x x value of the vector
  79155. * @param y y value of the vector
  79156. * @param z z value of the vector
  79157. * @param w w value of the vector
  79158. */
  79159. constructor(
  79160. /** x value of the vector */
  79161. x: number,
  79162. /** y value of the vector */
  79163. y: number,
  79164. /** z value of the vector */
  79165. z: number,
  79166. /** w value of the vector */
  79167. w: number);
  79168. /**
  79169. * Returns the string with the Vector4 coordinates.
  79170. * @returns a string containing all the vector values
  79171. */
  79172. toString(): string;
  79173. /**
  79174. * Returns the string "Vector4".
  79175. * @returns "Vector4"
  79176. */
  79177. getClassName(): string;
  79178. /**
  79179. * Returns the Vector4 hash code.
  79180. * @returns a unique hash code
  79181. */
  79182. getHashCode(): number;
  79183. /**
  79184. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  79185. * @returns the resulting array
  79186. */
  79187. asArray(): number[];
  79188. /**
  79189. * Populates the given array from the given index with the Vector4 coordinates.
  79190. * @param array array to populate
  79191. * @param index index of the array to start at (default: 0)
  79192. * @returns the Vector4.
  79193. */
  79194. toArray(array: FloatArray, index?: number): Vector4;
  79195. /**
  79196. * Adds the given vector to the current Vector4.
  79197. * @param otherVector the vector to add
  79198. * @returns the updated Vector4.
  79199. */
  79200. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  79201. /**
  79202. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  79203. * @param otherVector the vector to add
  79204. * @returns the resulting vector
  79205. */
  79206. add(otherVector: DeepImmutable<Vector4>): Vector4;
  79207. /**
  79208. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  79209. * @param otherVector the vector to add
  79210. * @param result the vector to store the result
  79211. * @returns the current Vector4.
  79212. */
  79213. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  79214. /**
  79215. * Subtract in place the given vector from the current Vector4.
  79216. * @param otherVector the vector to subtract
  79217. * @returns the updated Vector4.
  79218. */
  79219. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  79220. /**
  79221. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  79222. * @param otherVector the vector to add
  79223. * @returns the new vector with the result
  79224. */
  79225. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  79226. /**
  79227. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  79228. * @param otherVector the vector to subtract
  79229. * @param result the vector to store the result
  79230. * @returns the current Vector4.
  79231. */
  79232. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  79233. /**
  79234. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  79235. */
  79236. /**
  79237. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  79238. * @param x value to subtract
  79239. * @param y value to subtract
  79240. * @param z value to subtract
  79241. * @param w value to subtract
  79242. * @returns new vector containing the result
  79243. */
  79244. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  79245. /**
  79246. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  79247. * @param x value to subtract
  79248. * @param y value to subtract
  79249. * @param z value to subtract
  79250. * @param w value to subtract
  79251. * @param result the vector to store the result in
  79252. * @returns the current Vector4.
  79253. */
  79254. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  79255. /**
  79256. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  79257. * @returns a new vector with the negated values
  79258. */
  79259. negate(): Vector4;
  79260. /**
  79261. * Negate this vector in place
  79262. * @returns this
  79263. */
  79264. negateInPlace(): Vector4;
  79265. /**
  79266. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  79267. * @param result defines the Vector3 object where to store the result
  79268. * @returns the current Vector4
  79269. */
  79270. negateToRef(result: Vector4): Vector4;
  79271. /**
  79272. * Multiplies the current Vector4 coordinates by scale (float).
  79273. * @param scale the number to scale with
  79274. * @returns the updated Vector4.
  79275. */
  79276. scaleInPlace(scale: number): Vector4;
  79277. /**
  79278. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  79279. * @param scale the number to scale with
  79280. * @returns a new vector with the result
  79281. */
  79282. scale(scale: number): Vector4;
  79283. /**
  79284. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  79285. * @param scale the number to scale with
  79286. * @param result a vector to store the result in
  79287. * @returns the current Vector4.
  79288. */
  79289. scaleToRef(scale: number, result: Vector4): Vector4;
  79290. /**
  79291. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  79292. * @param scale defines the scale factor
  79293. * @param result defines the Vector4 object where to store the result
  79294. * @returns the unmodified current Vector4
  79295. */
  79296. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  79297. /**
  79298. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  79299. * @param otherVector the vector to compare against
  79300. * @returns true if they are equal
  79301. */
  79302. equals(otherVector: DeepImmutable<Vector4>): boolean;
  79303. /**
  79304. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  79305. * @param otherVector vector to compare against
  79306. * @param epsilon (Default: very small number)
  79307. * @returns true if they are equal
  79308. */
  79309. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  79310. /**
  79311. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  79312. * @param x x value to compare against
  79313. * @param y y value to compare against
  79314. * @param z z value to compare against
  79315. * @param w w value to compare against
  79316. * @returns true if equal
  79317. */
  79318. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  79319. /**
  79320. * Multiplies in place the current Vector4 by the given one.
  79321. * @param otherVector vector to multiple with
  79322. * @returns the updated Vector4.
  79323. */
  79324. multiplyInPlace(otherVector: Vector4): Vector4;
  79325. /**
  79326. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  79327. * @param otherVector vector to multiple with
  79328. * @returns resulting new vector
  79329. */
  79330. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  79331. /**
  79332. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  79333. * @param otherVector vector to multiple with
  79334. * @param result vector to store the result
  79335. * @returns the current Vector4.
  79336. */
  79337. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  79338. /**
  79339. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  79340. * @param x x value multiply with
  79341. * @param y y value multiply with
  79342. * @param z z value multiply with
  79343. * @param w w value multiply with
  79344. * @returns resulting new vector
  79345. */
  79346. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  79347. /**
  79348. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  79349. * @param otherVector vector to devide with
  79350. * @returns resulting new vector
  79351. */
  79352. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  79353. /**
  79354. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  79355. * @param otherVector vector to devide with
  79356. * @param result vector to store the result
  79357. * @returns the current Vector4.
  79358. */
  79359. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  79360. /**
  79361. * Divides the current Vector3 coordinates by the given ones.
  79362. * @param otherVector vector to devide with
  79363. * @returns the updated Vector3.
  79364. */
  79365. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  79366. /**
  79367. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  79368. * @param other defines the second operand
  79369. * @returns the current updated Vector4
  79370. */
  79371. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  79372. /**
  79373. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  79374. * @param other defines the second operand
  79375. * @returns the current updated Vector4
  79376. */
  79377. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  79378. /**
  79379. * Gets a new Vector4 from current Vector4 floored values
  79380. * @returns a new Vector4
  79381. */
  79382. floor(): Vector4;
  79383. /**
  79384. * Gets a new Vector4 from current Vector3 floored values
  79385. * @returns a new Vector4
  79386. */
  79387. fract(): Vector4;
  79388. /**
  79389. * Returns the Vector4 length (float).
  79390. * @returns the length
  79391. */
  79392. length(): number;
  79393. /**
  79394. * Returns the Vector4 squared length (float).
  79395. * @returns the length squared
  79396. */
  79397. lengthSquared(): number;
  79398. /**
  79399. * Normalizes in place the Vector4.
  79400. * @returns the updated Vector4.
  79401. */
  79402. normalize(): Vector4;
  79403. /**
  79404. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  79405. * @returns this converted to a new vector3
  79406. */
  79407. toVector3(): Vector3;
  79408. /**
  79409. * Returns a new Vector4 copied from the current one.
  79410. * @returns the new cloned vector
  79411. */
  79412. clone(): Vector4;
  79413. /**
  79414. * Updates the current Vector4 with the given one coordinates.
  79415. * @param source the source vector to copy from
  79416. * @returns the updated Vector4.
  79417. */
  79418. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  79419. /**
  79420. * Updates the current Vector4 coordinates with the given floats.
  79421. * @param x float to copy from
  79422. * @param y float to copy from
  79423. * @param z float to copy from
  79424. * @param w float to copy from
  79425. * @returns the updated Vector4.
  79426. */
  79427. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  79428. /**
  79429. * Updates the current Vector4 coordinates with the given floats.
  79430. * @param x float to set from
  79431. * @param y float to set from
  79432. * @param z float to set from
  79433. * @param w float to set from
  79434. * @returns the updated Vector4.
  79435. */
  79436. set(x: number, y: number, z: number, w: number): Vector4;
  79437. /**
  79438. * Copies the given float to the current Vector3 coordinates
  79439. * @param v defines the x, y, z and w coordinates of the operand
  79440. * @returns the current updated Vector3
  79441. */
  79442. setAll(v: number): Vector4;
  79443. /**
  79444. * Returns a new Vector4 set from the starting index of the given array.
  79445. * @param array the array to pull values from
  79446. * @param offset the offset into the array to start at
  79447. * @returns the new vector
  79448. */
  79449. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  79450. /**
  79451. * Updates the given vector "result" from the starting index of the given array.
  79452. * @param array the array to pull values from
  79453. * @param offset the offset into the array to start at
  79454. * @param result the vector to store the result in
  79455. */
  79456. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  79457. /**
  79458. * Updates the given vector "result" from the starting index of the given Float32Array.
  79459. * @param array the array to pull values from
  79460. * @param offset the offset into the array to start at
  79461. * @param result the vector to store the result in
  79462. */
  79463. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  79464. /**
  79465. * Updates the given vector "result" coordinates from the given floats.
  79466. * @param x float to set from
  79467. * @param y float to set from
  79468. * @param z float to set from
  79469. * @param w float to set from
  79470. * @param result the vector to the floats in
  79471. */
  79472. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  79473. /**
  79474. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  79475. * @returns the new vector
  79476. */
  79477. static Zero(): Vector4;
  79478. /**
  79479. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  79480. * @returns the new vector
  79481. */
  79482. static One(): Vector4;
  79483. /**
  79484. * Returns a new normalized Vector4 from the given one.
  79485. * @param vector the vector to normalize
  79486. * @returns the vector
  79487. */
  79488. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  79489. /**
  79490. * Updates the given vector "result" from the normalization of the given one.
  79491. * @param vector the vector to normalize
  79492. * @param result the vector to store the result in
  79493. */
  79494. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  79495. /**
  79496. * Returns a vector with the minimum values from the left and right vectors
  79497. * @param left left vector to minimize
  79498. * @param right right vector to minimize
  79499. * @returns a new vector with the minimum of the left and right vector values
  79500. */
  79501. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  79502. /**
  79503. * Returns a vector with the maximum values from the left and right vectors
  79504. * @param left left vector to maximize
  79505. * @param right right vector to maximize
  79506. * @returns a new vector with the maximum of the left and right vector values
  79507. */
  79508. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  79509. /**
  79510. * Returns the distance (float) between the vectors "value1" and "value2".
  79511. * @param value1 value to calulate the distance between
  79512. * @param value2 value to calulate the distance between
  79513. * @return the distance between the two vectors
  79514. */
  79515. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  79516. /**
  79517. * Returns the squared distance (float) between the vectors "value1" and "value2".
  79518. * @param value1 value to calulate the distance between
  79519. * @param value2 value to calulate the distance between
  79520. * @return the distance between the two vectors squared
  79521. */
  79522. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  79523. /**
  79524. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  79525. * @param value1 value to calulate the center between
  79526. * @param value2 value to calulate the center between
  79527. * @return the center between the two vectors
  79528. */
  79529. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  79530. /**
  79531. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  79532. * This methods computes transformed normalized direction vectors only.
  79533. * @param vector the vector to transform
  79534. * @param transformation the transformation matrix to apply
  79535. * @returns the new vector
  79536. */
  79537. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  79538. /**
  79539. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  79540. * This methods computes transformed normalized direction vectors only.
  79541. * @param vector the vector to transform
  79542. * @param transformation the transformation matrix to apply
  79543. * @param result the vector to store the result in
  79544. */
  79545. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  79546. /**
  79547. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  79548. * This methods computes transformed normalized direction vectors only.
  79549. * @param x value to transform
  79550. * @param y value to transform
  79551. * @param z value to transform
  79552. * @param w value to transform
  79553. * @param transformation the transformation matrix to apply
  79554. * @param result the vector to store the results in
  79555. */
  79556. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  79557. /**
  79558. * Creates a new Vector4 from a Vector3
  79559. * @param source defines the source data
  79560. * @param w defines the 4th component (default is 0)
  79561. * @returns a new Vector4
  79562. */
  79563. static FromVector3(source: Vector3, w?: number): Vector4;
  79564. }
  79565. /**
  79566. * Class used to store quaternion data
  79567. * @see https://en.wikipedia.org/wiki/Quaternion
  79568. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  79569. */
  79570. export class Quaternion {
  79571. /** defines the first component (0 by default) */
  79572. x: number;
  79573. /** defines the second component (0 by default) */
  79574. y: number;
  79575. /** defines the third component (0 by default) */
  79576. z: number;
  79577. /** defines the fourth component (1.0 by default) */
  79578. w: number;
  79579. /**
  79580. * Creates a new Quaternion from the given floats
  79581. * @param x defines the first component (0 by default)
  79582. * @param y defines the second component (0 by default)
  79583. * @param z defines the third component (0 by default)
  79584. * @param w defines the fourth component (1.0 by default)
  79585. */
  79586. constructor(
  79587. /** defines the first component (0 by default) */
  79588. x?: number,
  79589. /** defines the second component (0 by default) */
  79590. y?: number,
  79591. /** defines the third component (0 by default) */
  79592. z?: number,
  79593. /** defines the fourth component (1.0 by default) */
  79594. w?: number);
  79595. /**
  79596. * Gets a string representation for the current quaternion
  79597. * @returns a string with the Quaternion coordinates
  79598. */
  79599. toString(): string;
  79600. /**
  79601. * Gets the class name of the quaternion
  79602. * @returns the string "Quaternion"
  79603. */
  79604. getClassName(): string;
  79605. /**
  79606. * Gets a hash code for this quaternion
  79607. * @returns the quaternion hash code
  79608. */
  79609. getHashCode(): number;
  79610. /**
  79611. * Copy the quaternion to an array
  79612. * @returns a new array populated with 4 elements from the quaternion coordinates
  79613. */
  79614. asArray(): number[];
  79615. /**
  79616. * Check if two quaternions are equals
  79617. * @param otherQuaternion defines the second operand
  79618. * @return true if the current quaternion and the given one coordinates are strictly equals
  79619. */
  79620. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  79621. /**
  79622. * Gets a boolean if two quaternions are equals (using an epsilon value)
  79623. * @param otherQuaternion defines the other quaternion
  79624. * @param epsilon defines the minimal distance to consider equality
  79625. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  79626. */
  79627. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  79628. /**
  79629. * Clone the current quaternion
  79630. * @returns a new quaternion copied from the current one
  79631. */
  79632. clone(): Quaternion;
  79633. /**
  79634. * Copy a quaternion to the current one
  79635. * @param other defines the other quaternion
  79636. * @returns the updated current quaternion
  79637. */
  79638. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  79639. /**
  79640. * Updates the current quaternion with the given float coordinates
  79641. * @param x defines the x coordinate
  79642. * @param y defines the y coordinate
  79643. * @param z defines the z coordinate
  79644. * @param w defines the w coordinate
  79645. * @returns the updated current quaternion
  79646. */
  79647. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  79648. /**
  79649. * Updates the current quaternion from the given float coordinates
  79650. * @param x defines the x coordinate
  79651. * @param y defines the y coordinate
  79652. * @param z defines the z coordinate
  79653. * @param w defines the w coordinate
  79654. * @returns the updated current quaternion
  79655. */
  79656. set(x: number, y: number, z: number, w: number): Quaternion;
  79657. /**
  79658. * Adds two quaternions
  79659. * @param other defines the second operand
  79660. * @returns a new quaternion as the addition result of the given one and the current quaternion
  79661. */
  79662. add(other: DeepImmutable<Quaternion>): Quaternion;
  79663. /**
  79664. * Add a quaternion to the current one
  79665. * @param other defines the quaternion to add
  79666. * @returns the current quaternion
  79667. */
  79668. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  79669. /**
  79670. * Subtract two quaternions
  79671. * @param other defines the second operand
  79672. * @returns a new quaternion as the subtraction result of the given one from the current one
  79673. */
  79674. subtract(other: Quaternion): Quaternion;
  79675. /**
  79676. * Multiplies the current quaternion by a scale factor
  79677. * @param value defines the scale factor
  79678. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  79679. */
  79680. scale(value: number): Quaternion;
  79681. /**
  79682. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  79683. * @param scale defines the scale factor
  79684. * @param result defines the Quaternion object where to store the result
  79685. * @returns the unmodified current quaternion
  79686. */
  79687. scaleToRef(scale: number, result: Quaternion): Quaternion;
  79688. /**
  79689. * Multiplies in place the current quaternion by a scale factor
  79690. * @param value defines the scale factor
  79691. * @returns the current modified quaternion
  79692. */
  79693. scaleInPlace(value: number): Quaternion;
  79694. /**
  79695. * Scale the current quaternion values by a factor and add the result to a given quaternion
  79696. * @param scale defines the scale factor
  79697. * @param result defines the Quaternion object where to store the result
  79698. * @returns the unmodified current quaternion
  79699. */
  79700. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  79701. /**
  79702. * Multiplies two quaternions
  79703. * @param q1 defines the second operand
  79704. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  79705. */
  79706. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  79707. /**
  79708. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  79709. * @param q1 defines the second operand
  79710. * @param result defines the target quaternion
  79711. * @returns the current quaternion
  79712. */
  79713. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  79714. /**
  79715. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  79716. * @param q1 defines the second operand
  79717. * @returns the currentupdated quaternion
  79718. */
  79719. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  79720. /**
  79721. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  79722. * @param ref defines the target quaternion
  79723. * @returns the current quaternion
  79724. */
  79725. conjugateToRef(ref: Quaternion): Quaternion;
  79726. /**
  79727. * Conjugates in place (1-q) the current quaternion
  79728. * @returns the current updated quaternion
  79729. */
  79730. conjugateInPlace(): Quaternion;
  79731. /**
  79732. * Conjugates in place (1-q) the current quaternion
  79733. * @returns a new quaternion
  79734. */
  79735. conjugate(): Quaternion;
  79736. /**
  79737. * Gets length of current quaternion
  79738. * @returns the quaternion length (float)
  79739. */
  79740. length(): number;
  79741. /**
  79742. * Normalize in place the current quaternion
  79743. * @returns the current updated quaternion
  79744. */
  79745. normalize(): Quaternion;
  79746. /**
  79747. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  79748. * @param order is a reserved parameter and is ignore for now
  79749. * @returns a new Vector3 containing the Euler angles
  79750. */
  79751. toEulerAngles(order?: string): Vector3;
  79752. /**
  79753. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  79754. * @param result defines the vector which will be filled with the Euler angles
  79755. * @param order is a reserved parameter and is ignore for now
  79756. * @returns the current unchanged quaternion
  79757. */
  79758. toEulerAnglesToRef(result: Vector3): Quaternion;
  79759. /**
  79760. * Updates the given rotation matrix with the current quaternion values
  79761. * @param result defines the target matrix
  79762. * @returns the current unchanged quaternion
  79763. */
  79764. toRotationMatrix(result: Matrix): Quaternion;
  79765. /**
  79766. * Updates the current quaternion from the given rotation matrix values
  79767. * @param matrix defines the source matrix
  79768. * @returns the current updated quaternion
  79769. */
  79770. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  79771. /**
  79772. * Creates a new quaternion from a rotation matrix
  79773. * @param matrix defines the source matrix
  79774. * @returns a new quaternion created from the given rotation matrix values
  79775. */
  79776. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  79777. /**
  79778. * Updates the given quaternion with the given rotation matrix values
  79779. * @param matrix defines the source matrix
  79780. * @param result defines the target quaternion
  79781. */
  79782. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  79783. /**
  79784. * Returns the dot product (float) between the quaternions "left" and "right"
  79785. * @param left defines the left operand
  79786. * @param right defines the right operand
  79787. * @returns the dot product
  79788. */
  79789. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  79790. /**
  79791. * Checks if the two quaternions are close to each other
  79792. * @param quat0 defines the first quaternion to check
  79793. * @param quat1 defines the second quaternion to check
  79794. * @returns true if the two quaternions are close to each other
  79795. */
  79796. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  79797. /**
  79798. * Creates an empty quaternion
  79799. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  79800. */
  79801. static Zero(): Quaternion;
  79802. /**
  79803. * Inverse a given quaternion
  79804. * @param q defines the source quaternion
  79805. * @returns a new quaternion as the inverted current quaternion
  79806. */
  79807. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  79808. /**
  79809. * Inverse a given quaternion
  79810. * @param q defines the source quaternion
  79811. * @param result the quaternion the result will be stored in
  79812. * @returns the result quaternion
  79813. */
  79814. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  79815. /**
  79816. * Creates an identity quaternion
  79817. * @returns the identity quaternion
  79818. */
  79819. static Identity(): Quaternion;
  79820. /**
  79821. * Gets a boolean indicating if the given quaternion is identity
  79822. * @param quaternion defines the quaternion to check
  79823. * @returns true if the quaternion is identity
  79824. */
  79825. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  79826. /**
  79827. * Creates a quaternion from a rotation around an axis
  79828. * @param axis defines the axis to use
  79829. * @param angle defines the angle to use
  79830. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  79831. */
  79832. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  79833. /**
  79834. * Creates a rotation around an axis and stores it into the given quaternion
  79835. * @param axis defines the axis to use
  79836. * @param angle defines the angle to use
  79837. * @param result defines the target quaternion
  79838. * @returns the target quaternion
  79839. */
  79840. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  79841. /**
  79842. * Creates a new quaternion from data stored into an array
  79843. * @param array defines the data source
  79844. * @param offset defines the offset in the source array where the data starts
  79845. * @returns a new quaternion
  79846. */
  79847. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  79848. /**
  79849. * Updates the given quaternion "result" from the starting index of the given array.
  79850. * @param array the array to pull values from
  79851. * @param offset the offset into the array to start at
  79852. * @param result the quaternion to store the result in
  79853. */
  79854. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Quaternion): void;
  79855. /**
  79856. * Create a quaternion from Euler rotation angles
  79857. * @param x Pitch
  79858. * @param y Yaw
  79859. * @param z Roll
  79860. * @returns the new Quaternion
  79861. */
  79862. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  79863. /**
  79864. * Updates a quaternion from Euler rotation angles
  79865. * @param x Pitch
  79866. * @param y Yaw
  79867. * @param z Roll
  79868. * @param result the quaternion to store the result
  79869. * @returns the updated quaternion
  79870. */
  79871. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  79872. /**
  79873. * Create a quaternion from Euler rotation vector
  79874. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  79875. * @returns the new Quaternion
  79876. */
  79877. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  79878. /**
  79879. * Updates a quaternion from Euler rotation vector
  79880. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  79881. * @param result the quaternion to store the result
  79882. * @returns the updated quaternion
  79883. */
  79884. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  79885. /**
  79886. * Creates a new quaternion from the given Euler float angles (y, x, z)
  79887. * @param yaw defines the rotation around Y axis
  79888. * @param pitch defines the rotation around X axis
  79889. * @param roll defines the rotation around Z axis
  79890. * @returns the new quaternion
  79891. */
  79892. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  79893. /**
  79894. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  79895. * @param yaw defines the rotation around Y axis
  79896. * @param pitch defines the rotation around X axis
  79897. * @param roll defines the rotation around Z axis
  79898. * @param result defines the target quaternion
  79899. */
  79900. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  79901. /**
  79902. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  79903. * @param alpha defines the rotation around first axis
  79904. * @param beta defines the rotation around second axis
  79905. * @param gamma defines the rotation around third axis
  79906. * @returns the new quaternion
  79907. */
  79908. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  79909. /**
  79910. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  79911. * @param alpha defines the rotation around first axis
  79912. * @param beta defines the rotation around second axis
  79913. * @param gamma defines the rotation around third axis
  79914. * @param result defines the target quaternion
  79915. */
  79916. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  79917. /**
  79918. * 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)
  79919. * @param axis1 defines the first axis
  79920. * @param axis2 defines the second axis
  79921. * @param axis3 defines the third axis
  79922. * @returns the new quaternion
  79923. */
  79924. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  79925. /**
  79926. * 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
  79927. * @param axis1 defines the first axis
  79928. * @param axis2 defines the second axis
  79929. * @param axis3 defines the third axis
  79930. * @param ref defines the target quaternion
  79931. */
  79932. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  79933. /**
  79934. * Interpolates between two quaternions
  79935. * @param left defines first quaternion
  79936. * @param right defines second quaternion
  79937. * @param amount defines the gradient to use
  79938. * @returns the new interpolated quaternion
  79939. */
  79940. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  79941. /**
  79942. * Interpolates between two quaternions and stores it into a target quaternion
  79943. * @param left defines first quaternion
  79944. * @param right defines second quaternion
  79945. * @param amount defines the gradient to use
  79946. * @param result defines the target quaternion
  79947. */
  79948. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  79949. /**
  79950. * Interpolate between two quaternions using Hermite interpolation
  79951. * @param value1 defines first quaternion
  79952. * @param tangent1 defines the incoming tangent
  79953. * @param value2 defines second quaternion
  79954. * @param tangent2 defines the outgoing tangent
  79955. * @param amount defines the target quaternion
  79956. * @returns the new interpolated quaternion
  79957. */
  79958. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  79959. }
  79960. /**
  79961. * Class used to store matrix data (4x4)
  79962. */
  79963. export class Matrix {
  79964. private static _updateFlagSeed;
  79965. private static _identityReadOnly;
  79966. private _isIdentity;
  79967. private _isIdentityDirty;
  79968. private _isIdentity3x2;
  79969. private _isIdentity3x2Dirty;
  79970. /**
  79971. * Gets the update flag of the matrix which is an unique number for the matrix.
  79972. * It will be incremented every time the matrix data change.
  79973. * You can use it to speed the comparison between two versions of the same matrix.
  79974. */
  79975. updateFlag: number;
  79976. private readonly _m;
  79977. /**
  79978. * Gets the internal data of the matrix
  79979. */
  79980. get m(): DeepImmutable<Float32Array>;
  79981. /** @hidden */
  79982. _markAsUpdated(): void;
  79983. /** @hidden */
  79984. private _updateIdentityStatus;
  79985. /**
  79986. * Creates an empty matrix (filled with zeros)
  79987. */
  79988. constructor();
  79989. /**
  79990. * Check if the current matrix is identity
  79991. * @returns true is the matrix is the identity matrix
  79992. */
  79993. isIdentity(): boolean;
  79994. /**
  79995. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  79996. * @returns true is the matrix is the identity matrix
  79997. */
  79998. isIdentityAs3x2(): boolean;
  79999. /**
  80000. * Gets the determinant of the matrix
  80001. * @returns the matrix determinant
  80002. */
  80003. determinant(): number;
  80004. /**
  80005. * Returns the matrix as a Float32Array
  80006. * @returns the matrix underlying array
  80007. */
  80008. toArray(): DeepImmutable<Float32Array>;
  80009. /**
  80010. * Returns the matrix as a Float32Array
  80011. * @returns the matrix underlying array.
  80012. */
  80013. asArray(): DeepImmutable<Float32Array>;
  80014. /**
  80015. * Inverts the current matrix in place
  80016. * @returns the current inverted matrix
  80017. */
  80018. invert(): Matrix;
  80019. /**
  80020. * Sets all the matrix elements to zero
  80021. * @returns the current matrix
  80022. */
  80023. reset(): Matrix;
  80024. /**
  80025. * Adds the current matrix with a second one
  80026. * @param other defines the matrix to add
  80027. * @returns a new matrix as the addition of the current matrix and the given one
  80028. */
  80029. add(other: DeepImmutable<Matrix>): Matrix;
  80030. /**
  80031. * Sets the given matrix "result" to the addition of the current matrix and the given one
  80032. * @param other defines the matrix to add
  80033. * @param result defines the target matrix
  80034. * @returns the current matrix
  80035. */
  80036. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  80037. /**
  80038. * Adds in place the given matrix to the current matrix
  80039. * @param other defines the second operand
  80040. * @returns the current updated matrix
  80041. */
  80042. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  80043. /**
  80044. * Sets the given matrix to the current inverted Matrix
  80045. * @param other defines the target matrix
  80046. * @returns the unmodified current matrix
  80047. */
  80048. invertToRef(other: Matrix): Matrix;
  80049. /**
  80050. * add a value at the specified position in the current Matrix
  80051. * @param index the index of the value within the matrix. between 0 and 15.
  80052. * @param value the value to be added
  80053. * @returns the current updated matrix
  80054. */
  80055. addAtIndex(index: number, value: number): Matrix;
  80056. /**
  80057. * mutiply the specified position in the current Matrix by a value
  80058. * @param index the index of the value within the matrix. between 0 and 15.
  80059. * @param value the value to be added
  80060. * @returns the current updated matrix
  80061. */
  80062. multiplyAtIndex(index: number, value: number): Matrix;
  80063. /**
  80064. * Inserts the translation vector (using 3 floats) in the current matrix
  80065. * @param x defines the 1st component of the translation
  80066. * @param y defines the 2nd component of the translation
  80067. * @param z defines the 3rd component of the translation
  80068. * @returns the current updated matrix
  80069. */
  80070. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  80071. /**
  80072. * Adds the translation vector (using 3 floats) in the current matrix
  80073. * @param x defines the 1st component of the translation
  80074. * @param y defines the 2nd component of the translation
  80075. * @param z defines the 3rd component of the translation
  80076. * @returns the current updated matrix
  80077. */
  80078. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  80079. /**
  80080. * Inserts the translation vector in the current matrix
  80081. * @param vector3 defines the translation to insert
  80082. * @returns the current updated matrix
  80083. */
  80084. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  80085. /**
  80086. * Gets the translation value of the current matrix
  80087. * @returns a new Vector3 as the extracted translation from the matrix
  80088. */
  80089. getTranslation(): Vector3;
  80090. /**
  80091. * Fill a Vector3 with the extracted translation from the matrix
  80092. * @param result defines the Vector3 where to store the translation
  80093. * @returns the current matrix
  80094. */
  80095. getTranslationToRef(result: Vector3): Matrix;
  80096. /**
  80097. * Remove rotation and scaling part from the matrix
  80098. * @returns the updated matrix
  80099. */
  80100. removeRotationAndScaling(): Matrix;
  80101. /**
  80102. * Multiply two matrices
  80103. * @param other defines the second operand
  80104. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  80105. */
  80106. multiply(other: DeepImmutable<Matrix>): Matrix;
  80107. /**
  80108. * Copy the current matrix from the given one
  80109. * @param other defines the source matrix
  80110. * @returns the current updated matrix
  80111. */
  80112. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  80113. /**
  80114. * Populates the given array from the starting index with the current matrix values
  80115. * @param array defines the target array
  80116. * @param offset defines the offset in the target array where to start storing values
  80117. * @returns the current matrix
  80118. */
  80119. copyToArray(array: Float32Array, offset?: number): Matrix;
  80120. /**
  80121. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  80122. * @param other defines the second operand
  80123. * @param result defines the matrix where to store the multiplication
  80124. * @returns the current matrix
  80125. */
  80126. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  80127. /**
  80128. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  80129. * @param other defines the second operand
  80130. * @param result defines the array where to store the multiplication
  80131. * @param offset defines the offset in the target array where to start storing values
  80132. * @returns the current matrix
  80133. */
  80134. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  80135. /**
  80136. * Check equality between this matrix and a second one
  80137. * @param value defines the second matrix to compare
  80138. * @returns true is the current matrix and the given one values are strictly equal
  80139. */
  80140. equals(value: DeepImmutable<Matrix>): boolean;
  80141. /**
  80142. * Clone the current matrix
  80143. * @returns a new matrix from the current matrix
  80144. */
  80145. clone(): Matrix;
  80146. /**
  80147. * Returns the name of the current matrix class
  80148. * @returns the string "Matrix"
  80149. */
  80150. getClassName(): string;
  80151. /**
  80152. * Gets the hash code of the current matrix
  80153. * @returns the hash code
  80154. */
  80155. getHashCode(): number;
  80156. /**
  80157. * Decomposes the current Matrix into a translation, rotation and scaling components
  80158. * @param scale defines the scale vector3 given as a reference to update
  80159. * @param rotation defines the rotation quaternion given as a reference to update
  80160. * @param translation defines the translation vector3 given as a reference to update
  80161. * @returns true if operation was successful
  80162. */
  80163. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  80164. /**
  80165. * Gets specific row of the matrix
  80166. * @param index defines the number of the row to get
  80167. * @returns the index-th row of the current matrix as a new Vector4
  80168. */
  80169. getRow(index: number): Nullable<Vector4>;
  80170. /**
  80171. * Sets the index-th row of the current matrix to the vector4 values
  80172. * @param index defines the number of the row to set
  80173. * @param row defines the target vector4
  80174. * @returns the updated current matrix
  80175. */
  80176. setRow(index: number, row: Vector4): Matrix;
  80177. /**
  80178. * Compute the transpose of the matrix
  80179. * @returns the new transposed matrix
  80180. */
  80181. transpose(): Matrix;
  80182. /**
  80183. * Compute the transpose of the matrix and store it in a given matrix
  80184. * @param result defines the target matrix
  80185. * @returns the current matrix
  80186. */
  80187. transposeToRef(result: Matrix): Matrix;
  80188. /**
  80189. * Sets the index-th row of the current matrix with the given 4 x float values
  80190. * @param index defines the row index
  80191. * @param x defines the x component to set
  80192. * @param y defines the y component to set
  80193. * @param z defines the z component to set
  80194. * @param w defines the w component to set
  80195. * @returns the updated current matrix
  80196. */
  80197. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  80198. /**
  80199. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  80200. * @param scale defines the scale factor
  80201. * @returns a new matrix
  80202. */
  80203. scale(scale: number): Matrix;
  80204. /**
  80205. * Scale the current matrix values by a factor to a given result matrix
  80206. * @param scale defines the scale factor
  80207. * @param result defines the matrix to store the result
  80208. * @returns the current matrix
  80209. */
  80210. scaleToRef(scale: number, result: Matrix): Matrix;
  80211. /**
  80212. * Scale the current matrix values by a factor and add the result to a given matrix
  80213. * @param scale defines the scale factor
  80214. * @param result defines the Matrix to store the result
  80215. * @returns the current matrix
  80216. */
  80217. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  80218. /**
  80219. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  80220. * @param ref matrix to store the result
  80221. */
  80222. toNormalMatrix(ref: Matrix): void;
  80223. /**
  80224. * Gets only rotation part of the current matrix
  80225. * @returns a new matrix sets to the extracted rotation matrix from the current one
  80226. */
  80227. getRotationMatrix(): Matrix;
  80228. /**
  80229. * Extracts the rotation matrix from the current one and sets it as the given "result"
  80230. * @param result defines the target matrix to store data to
  80231. * @returns the current matrix
  80232. */
  80233. getRotationMatrixToRef(result: Matrix): Matrix;
  80234. /**
  80235. * Toggles model matrix from being right handed to left handed in place and vice versa
  80236. */
  80237. toggleModelMatrixHandInPlace(): void;
  80238. /**
  80239. * Toggles projection matrix from being right handed to left handed in place and vice versa
  80240. */
  80241. toggleProjectionMatrixHandInPlace(): void;
  80242. /**
  80243. * Creates a matrix from an array
  80244. * @param array defines the source array
  80245. * @param offset defines an offset in the source array
  80246. * @returns a new Matrix set from the starting index of the given array
  80247. */
  80248. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  80249. /**
  80250. * Copy the content of an array into a given matrix
  80251. * @param array defines the source array
  80252. * @param offset defines an offset in the source array
  80253. * @param result defines the target matrix
  80254. */
  80255. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  80256. /**
  80257. * Stores an array into a matrix after having multiplied each component by a given factor
  80258. * @param array defines the source array
  80259. * @param offset defines the offset in the source array
  80260. * @param scale defines the scaling factor
  80261. * @param result defines the target matrix
  80262. */
  80263. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  80264. /**
  80265. * Gets an identity matrix that must not be updated
  80266. */
  80267. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  80268. /**
  80269. * Stores a list of values (16) inside a given matrix
  80270. * @param initialM11 defines 1st value of 1st row
  80271. * @param initialM12 defines 2nd value of 1st row
  80272. * @param initialM13 defines 3rd value of 1st row
  80273. * @param initialM14 defines 4th value of 1st row
  80274. * @param initialM21 defines 1st value of 2nd row
  80275. * @param initialM22 defines 2nd value of 2nd row
  80276. * @param initialM23 defines 3rd value of 2nd row
  80277. * @param initialM24 defines 4th value of 2nd row
  80278. * @param initialM31 defines 1st value of 3rd row
  80279. * @param initialM32 defines 2nd value of 3rd row
  80280. * @param initialM33 defines 3rd value of 3rd row
  80281. * @param initialM34 defines 4th value of 3rd row
  80282. * @param initialM41 defines 1st value of 4th row
  80283. * @param initialM42 defines 2nd value of 4th row
  80284. * @param initialM43 defines 3rd value of 4th row
  80285. * @param initialM44 defines 4th value of 4th row
  80286. * @param result defines the target matrix
  80287. */
  80288. 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;
  80289. /**
  80290. * Creates new matrix from a list of values (16)
  80291. * @param initialM11 defines 1st value of 1st row
  80292. * @param initialM12 defines 2nd value of 1st row
  80293. * @param initialM13 defines 3rd value of 1st row
  80294. * @param initialM14 defines 4th value of 1st row
  80295. * @param initialM21 defines 1st value of 2nd row
  80296. * @param initialM22 defines 2nd value of 2nd row
  80297. * @param initialM23 defines 3rd value of 2nd row
  80298. * @param initialM24 defines 4th value of 2nd row
  80299. * @param initialM31 defines 1st value of 3rd row
  80300. * @param initialM32 defines 2nd value of 3rd row
  80301. * @param initialM33 defines 3rd value of 3rd row
  80302. * @param initialM34 defines 4th value of 3rd row
  80303. * @param initialM41 defines 1st value of 4th row
  80304. * @param initialM42 defines 2nd value of 4th row
  80305. * @param initialM43 defines 3rd value of 4th row
  80306. * @param initialM44 defines 4th value of 4th row
  80307. * @returns the new matrix
  80308. */
  80309. 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;
  80310. /**
  80311. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  80312. * @param scale defines the scale vector3
  80313. * @param rotation defines the rotation quaternion
  80314. * @param translation defines the translation vector3
  80315. * @returns a new matrix
  80316. */
  80317. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  80318. /**
  80319. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  80320. * @param scale defines the scale vector3
  80321. * @param rotation defines the rotation quaternion
  80322. * @param translation defines the translation vector3
  80323. * @param result defines the target matrix
  80324. */
  80325. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  80326. /**
  80327. * Creates a new identity matrix
  80328. * @returns a new identity matrix
  80329. */
  80330. static Identity(): Matrix;
  80331. /**
  80332. * Creates a new identity matrix and stores the result in a given matrix
  80333. * @param result defines the target matrix
  80334. */
  80335. static IdentityToRef(result: Matrix): void;
  80336. /**
  80337. * Creates a new zero matrix
  80338. * @returns a new zero matrix
  80339. */
  80340. static Zero(): Matrix;
  80341. /**
  80342. * Creates a new rotation matrix for "angle" radians around the X axis
  80343. * @param angle defines the angle (in radians) to use
  80344. * @return the new matrix
  80345. */
  80346. static RotationX(angle: number): Matrix;
  80347. /**
  80348. * Creates a new matrix as the invert of a given matrix
  80349. * @param source defines the source matrix
  80350. * @returns the new matrix
  80351. */
  80352. static Invert(source: DeepImmutable<Matrix>): Matrix;
  80353. /**
  80354. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  80355. * @param angle defines the angle (in radians) to use
  80356. * @param result defines the target matrix
  80357. */
  80358. static RotationXToRef(angle: number, result: Matrix): void;
  80359. /**
  80360. * Creates a new rotation matrix for "angle" radians around the Y axis
  80361. * @param angle defines the angle (in radians) to use
  80362. * @return the new matrix
  80363. */
  80364. static RotationY(angle: number): Matrix;
  80365. /**
  80366. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  80367. * @param angle defines the angle (in radians) to use
  80368. * @param result defines the target matrix
  80369. */
  80370. static RotationYToRef(angle: number, result: Matrix): void;
  80371. /**
  80372. * Creates a new rotation matrix for "angle" radians around the Z axis
  80373. * @param angle defines the angle (in radians) to use
  80374. * @return the new matrix
  80375. */
  80376. static RotationZ(angle: number): Matrix;
  80377. /**
  80378. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  80379. * @param angle defines the angle (in radians) to use
  80380. * @param result defines the target matrix
  80381. */
  80382. static RotationZToRef(angle: number, result: Matrix): void;
  80383. /**
  80384. * Creates a new rotation matrix for "angle" radians around the given axis
  80385. * @param axis defines the axis to use
  80386. * @param angle defines the angle (in radians) to use
  80387. * @return the new matrix
  80388. */
  80389. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  80390. /**
  80391. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  80392. * @param axis defines the axis to use
  80393. * @param angle defines the angle (in radians) to use
  80394. * @param result defines the target matrix
  80395. */
  80396. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  80397. /**
  80398. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  80399. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  80400. * @param from defines the vector to align
  80401. * @param to defines the vector to align to
  80402. * @param result defines the target matrix
  80403. */
  80404. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  80405. /**
  80406. * Creates a rotation matrix
  80407. * @param yaw defines the yaw angle in radians (Y axis)
  80408. * @param pitch defines the pitch angle in radians (X axis)
  80409. * @param roll defines the roll angle in radians (X axis)
  80410. * @returns the new rotation matrix
  80411. */
  80412. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  80413. /**
  80414. * Creates a rotation matrix and stores it in a given matrix
  80415. * @param yaw defines the yaw angle in radians (Y axis)
  80416. * @param pitch defines the pitch angle in radians (X axis)
  80417. * @param roll defines the roll angle in radians (X axis)
  80418. * @param result defines the target matrix
  80419. */
  80420. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  80421. /**
  80422. * Creates a scaling matrix
  80423. * @param x defines the scale factor on X axis
  80424. * @param y defines the scale factor on Y axis
  80425. * @param z defines the scale factor on Z axis
  80426. * @returns the new matrix
  80427. */
  80428. static Scaling(x: number, y: number, z: number): Matrix;
  80429. /**
  80430. * Creates a scaling matrix and stores it in a given matrix
  80431. * @param x defines the scale factor on X axis
  80432. * @param y defines the scale factor on Y axis
  80433. * @param z defines the scale factor on Z axis
  80434. * @param result defines the target matrix
  80435. */
  80436. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  80437. /**
  80438. * Creates a translation matrix
  80439. * @param x defines the translation on X axis
  80440. * @param y defines the translation on Y axis
  80441. * @param z defines the translationon Z axis
  80442. * @returns the new matrix
  80443. */
  80444. static Translation(x: number, y: number, z: number): Matrix;
  80445. /**
  80446. * Creates a translation matrix and stores it in a given matrix
  80447. * @param x defines the translation on X axis
  80448. * @param y defines the translation on Y axis
  80449. * @param z defines the translationon Z axis
  80450. * @param result defines the target matrix
  80451. */
  80452. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  80453. /**
  80454. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  80455. * @param startValue defines the start value
  80456. * @param endValue defines the end value
  80457. * @param gradient defines the gradient factor
  80458. * @returns the new matrix
  80459. */
  80460. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  80461. /**
  80462. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  80463. * @param startValue defines the start value
  80464. * @param endValue defines the end value
  80465. * @param gradient defines the gradient factor
  80466. * @param result defines the Matrix object where to store data
  80467. */
  80468. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  80469. /**
  80470. * Builds a new matrix whose values are computed by:
  80471. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  80472. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  80473. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  80474. * @param startValue defines the first matrix
  80475. * @param endValue defines the second matrix
  80476. * @param gradient defines the gradient between the two matrices
  80477. * @returns the new matrix
  80478. */
  80479. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  80480. /**
  80481. * Update a matrix to values which are computed by:
  80482. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  80483. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  80484. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  80485. * @param startValue defines the first matrix
  80486. * @param endValue defines the second matrix
  80487. * @param gradient defines the gradient between the two matrices
  80488. * @param result defines the target matrix
  80489. */
  80490. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  80491. /**
  80492. * 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"
  80493. * This function works in left handed mode
  80494. * @param eye defines the final position of the entity
  80495. * @param target defines where the entity should look at
  80496. * @param up defines the up vector for the entity
  80497. * @returns the new matrix
  80498. */
  80499. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  80500. /**
  80501. * 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".
  80502. * This function works in left handed mode
  80503. * @param eye defines the final position of the entity
  80504. * @param target defines where the entity should look at
  80505. * @param up defines the up vector for the entity
  80506. * @param result defines the target matrix
  80507. */
  80508. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  80509. /**
  80510. * 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"
  80511. * This function works in right handed mode
  80512. * @param eye defines the final position of the entity
  80513. * @param target defines where the entity should look at
  80514. * @param up defines the up vector for the entity
  80515. * @returns the new matrix
  80516. */
  80517. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  80518. /**
  80519. * 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".
  80520. * This function works in right handed mode
  80521. * @param eye defines the final position of the entity
  80522. * @param target defines where the entity should look at
  80523. * @param up defines the up vector for the entity
  80524. * @param result defines the target matrix
  80525. */
  80526. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  80527. /**
  80528. * Create a left-handed orthographic projection matrix
  80529. * @param width defines the viewport width
  80530. * @param height defines the viewport height
  80531. * @param znear defines the near clip plane
  80532. * @param zfar defines the far clip plane
  80533. * @returns a new matrix as a left-handed orthographic projection matrix
  80534. */
  80535. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  80536. /**
  80537. * Store a left-handed orthographic projection to a given matrix
  80538. * @param width defines the viewport width
  80539. * @param height defines the viewport height
  80540. * @param znear defines the near clip plane
  80541. * @param zfar defines the far clip plane
  80542. * @param result defines the target matrix
  80543. */
  80544. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  80545. /**
  80546. * Create a left-handed orthographic projection matrix
  80547. * @param left defines the viewport left coordinate
  80548. * @param right defines the viewport right coordinate
  80549. * @param bottom defines the viewport bottom coordinate
  80550. * @param top defines the viewport top coordinate
  80551. * @param znear defines the near clip plane
  80552. * @param zfar defines the far clip plane
  80553. * @returns a new matrix as a left-handed orthographic projection matrix
  80554. */
  80555. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  80556. /**
  80557. * Stores a left-handed orthographic projection into a given matrix
  80558. * @param left defines the viewport left coordinate
  80559. * @param right defines the viewport right coordinate
  80560. * @param bottom defines the viewport bottom coordinate
  80561. * @param top defines the viewport top coordinate
  80562. * @param znear defines the near clip plane
  80563. * @param zfar defines the far clip plane
  80564. * @param result defines the target matrix
  80565. */
  80566. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  80567. /**
  80568. * Creates a right-handed orthographic projection matrix
  80569. * @param left defines the viewport left coordinate
  80570. * @param right defines the viewport right coordinate
  80571. * @param bottom defines the viewport bottom coordinate
  80572. * @param top defines the viewport top coordinate
  80573. * @param znear defines the near clip plane
  80574. * @param zfar defines the far clip plane
  80575. * @returns a new matrix as a right-handed orthographic projection matrix
  80576. */
  80577. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  80578. /**
  80579. * Stores a right-handed orthographic projection into a given matrix
  80580. * @param left defines the viewport left coordinate
  80581. * @param right defines the viewport right coordinate
  80582. * @param bottom defines the viewport bottom coordinate
  80583. * @param top defines the viewport top coordinate
  80584. * @param znear defines the near clip plane
  80585. * @param zfar defines the far clip plane
  80586. * @param result defines the target matrix
  80587. */
  80588. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  80589. /**
  80590. * Creates a left-handed perspective projection matrix
  80591. * @param width defines the viewport width
  80592. * @param height defines the viewport height
  80593. * @param znear defines the near clip plane
  80594. * @param zfar defines the far clip plane
  80595. * @returns a new matrix as a left-handed perspective projection matrix
  80596. */
  80597. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  80598. /**
  80599. * Creates a left-handed perspective projection matrix
  80600. * @param fov defines the horizontal field of view
  80601. * @param aspect defines the aspect ratio
  80602. * @param znear defines the near clip plane
  80603. * @param zfar defines the far clip plane
  80604. * @returns a new matrix as a left-handed perspective projection matrix
  80605. */
  80606. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  80607. /**
  80608. * Stores a left-handed perspective projection into a given matrix
  80609. * @param fov defines the horizontal field of view
  80610. * @param aspect defines the aspect ratio
  80611. * @param znear defines the near clip plane
  80612. * @param zfar defines the far clip plane
  80613. * @param result defines the target matrix
  80614. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  80615. */
  80616. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  80617. /**
  80618. * Stores a left-handed perspective projection into a given matrix with depth reversed
  80619. * @param fov defines the horizontal field of view
  80620. * @param aspect defines the aspect ratio
  80621. * @param znear defines the near clip plane
  80622. * @param zfar not used as infinity is used as far clip
  80623. * @param result defines the target matrix
  80624. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  80625. */
  80626. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  80627. /**
  80628. * Creates a right-handed perspective projection matrix
  80629. * @param fov defines the horizontal field of view
  80630. * @param aspect defines the aspect ratio
  80631. * @param znear defines the near clip plane
  80632. * @param zfar defines the far clip plane
  80633. * @returns a new matrix as a right-handed perspective projection matrix
  80634. */
  80635. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  80636. /**
  80637. * Stores a right-handed perspective projection into a given matrix
  80638. * @param fov defines the horizontal field of view
  80639. * @param aspect defines the aspect ratio
  80640. * @param znear defines the near clip plane
  80641. * @param zfar defines the far clip plane
  80642. * @param result defines the target matrix
  80643. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  80644. */
  80645. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  80646. /**
  80647. * Stores a right-handed perspective projection into a given matrix
  80648. * @param fov defines the horizontal field of view
  80649. * @param aspect defines the aspect ratio
  80650. * @param znear defines the near clip plane
  80651. * @param zfar not used as infinity is used as far clip
  80652. * @param result defines the target matrix
  80653. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  80654. */
  80655. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  80656. /**
  80657. * Stores a perspective projection for WebVR info a given matrix
  80658. * @param fov defines the field of view
  80659. * @param znear defines the near clip plane
  80660. * @param zfar defines the far clip plane
  80661. * @param result defines the target matrix
  80662. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  80663. */
  80664. static PerspectiveFovWebVRToRef(fov: {
  80665. upDegrees: number;
  80666. downDegrees: number;
  80667. leftDegrees: number;
  80668. rightDegrees: number;
  80669. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  80670. /**
  80671. * Computes a complete transformation matrix
  80672. * @param viewport defines the viewport to use
  80673. * @param world defines the world matrix
  80674. * @param view defines the view matrix
  80675. * @param projection defines the projection matrix
  80676. * @param zmin defines the near clip plane
  80677. * @param zmax defines the far clip plane
  80678. * @returns the transformation matrix
  80679. */
  80680. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  80681. /**
  80682. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  80683. * @param matrix defines the matrix to use
  80684. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  80685. */
  80686. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  80687. /**
  80688. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  80689. * @param matrix defines the matrix to use
  80690. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  80691. */
  80692. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  80693. /**
  80694. * Compute the transpose of a given matrix
  80695. * @param matrix defines the matrix to transpose
  80696. * @returns the new matrix
  80697. */
  80698. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  80699. /**
  80700. * Compute the transpose of a matrix and store it in a target matrix
  80701. * @param matrix defines the matrix to transpose
  80702. * @param result defines the target matrix
  80703. */
  80704. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  80705. /**
  80706. * Computes a reflection matrix from a plane
  80707. * @param plane defines the reflection plane
  80708. * @returns a new matrix
  80709. */
  80710. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  80711. /**
  80712. * Computes a reflection matrix from a plane
  80713. * @param plane defines the reflection plane
  80714. * @param result defines the target matrix
  80715. */
  80716. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  80717. /**
  80718. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  80719. * @param xaxis defines the value of the 1st axis
  80720. * @param yaxis defines the value of the 2nd axis
  80721. * @param zaxis defines the value of the 3rd axis
  80722. * @param result defines the target matrix
  80723. */
  80724. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  80725. /**
  80726. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  80727. * @param quat defines the quaternion to use
  80728. * @param result defines the target matrix
  80729. */
  80730. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  80731. }
  80732. /**
  80733. * @hidden
  80734. */
  80735. export class TmpVectors {
  80736. static Vector2: Vector2[];
  80737. static Vector3: Vector3[];
  80738. static Vector4: Vector4[];
  80739. static Quaternion: Quaternion[];
  80740. static Matrix: Matrix[];
  80741. }
  80742. }
  80743. declare module BABYLON {
  80744. /**
  80745. * Defines potential orientation for back face culling
  80746. */
  80747. export enum Orientation {
  80748. /**
  80749. * Clockwise
  80750. */
  80751. CW = 0,
  80752. /** Counter clockwise */
  80753. CCW = 1
  80754. }
  80755. /** Class used to represent a Bezier curve */
  80756. export class BezierCurve {
  80757. /**
  80758. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  80759. * @param t defines the time
  80760. * @param x1 defines the left coordinate on X axis
  80761. * @param y1 defines the left coordinate on Y axis
  80762. * @param x2 defines the right coordinate on X axis
  80763. * @param y2 defines the right coordinate on Y axis
  80764. * @returns the interpolated value
  80765. */
  80766. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  80767. }
  80768. /**
  80769. * Defines angle representation
  80770. */
  80771. export class Angle {
  80772. private _radians;
  80773. /**
  80774. * Creates an Angle object of "radians" radians (float).
  80775. * @param radians the angle in radians
  80776. */
  80777. constructor(radians: number);
  80778. /**
  80779. * Get value in degrees
  80780. * @returns the Angle value in degrees (float)
  80781. */
  80782. degrees(): number;
  80783. /**
  80784. * Get value in radians
  80785. * @returns the Angle value in radians (float)
  80786. */
  80787. radians(): number;
  80788. /**
  80789. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  80790. * @param a defines first vector
  80791. * @param b defines second vector
  80792. * @returns a new Angle
  80793. */
  80794. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  80795. /**
  80796. * Gets a new Angle object from the given float in radians
  80797. * @param radians defines the angle value in radians
  80798. * @returns a new Angle
  80799. */
  80800. static FromRadians(radians: number): Angle;
  80801. /**
  80802. * Gets a new Angle object from the given float in degrees
  80803. * @param degrees defines the angle value in degrees
  80804. * @returns a new Angle
  80805. */
  80806. static FromDegrees(degrees: number): Angle;
  80807. }
  80808. /**
  80809. * This represents an arc in a 2d space.
  80810. */
  80811. export class Arc2 {
  80812. /** Defines the start point of the arc */
  80813. startPoint: Vector2;
  80814. /** Defines the mid point of the arc */
  80815. midPoint: Vector2;
  80816. /** Defines the end point of the arc */
  80817. endPoint: Vector2;
  80818. /**
  80819. * Defines the center point of the arc.
  80820. */
  80821. centerPoint: Vector2;
  80822. /**
  80823. * Defines the radius of the arc.
  80824. */
  80825. radius: number;
  80826. /**
  80827. * Defines the angle of the arc (from mid point to end point).
  80828. */
  80829. angle: Angle;
  80830. /**
  80831. * Defines the start angle of the arc (from start point to middle point).
  80832. */
  80833. startAngle: Angle;
  80834. /**
  80835. * Defines the orientation of the arc (clock wise/counter clock wise).
  80836. */
  80837. orientation: Orientation;
  80838. /**
  80839. * Creates an Arc object from the three given points : start, middle and end.
  80840. * @param startPoint Defines the start point of the arc
  80841. * @param midPoint Defines the midlle point of the arc
  80842. * @param endPoint Defines the end point of the arc
  80843. */
  80844. constructor(
  80845. /** Defines the start point of the arc */
  80846. startPoint: Vector2,
  80847. /** Defines the mid point of the arc */
  80848. midPoint: Vector2,
  80849. /** Defines the end point of the arc */
  80850. endPoint: Vector2);
  80851. }
  80852. /**
  80853. * Represents a 2D path made up of multiple 2D points
  80854. */
  80855. export class Path2 {
  80856. private _points;
  80857. private _length;
  80858. /**
  80859. * If the path start and end point are the same
  80860. */
  80861. closed: boolean;
  80862. /**
  80863. * Creates a Path2 object from the starting 2D coordinates x and y.
  80864. * @param x the starting points x value
  80865. * @param y the starting points y value
  80866. */
  80867. constructor(x: number, y: number);
  80868. /**
  80869. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  80870. * @param x the added points x value
  80871. * @param y the added points y value
  80872. * @returns the updated Path2.
  80873. */
  80874. addLineTo(x: number, y: number): Path2;
  80875. /**
  80876. * 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.
  80877. * @param midX middle point x value
  80878. * @param midY middle point y value
  80879. * @param endX end point x value
  80880. * @param endY end point y value
  80881. * @param numberOfSegments (default: 36)
  80882. * @returns the updated Path2.
  80883. */
  80884. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  80885. /**
  80886. * Closes the Path2.
  80887. * @returns the Path2.
  80888. */
  80889. close(): Path2;
  80890. /**
  80891. * Gets the sum of the distance between each sequential point in the path
  80892. * @returns the Path2 total length (float).
  80893. */
  80894. length(): number;
  80895. /**
  80896. * Gets the points which construct the path
  80897. * @returns the Path2 internal array of points.
  80898. */
  80899. getPoints(): Vector2[];
  80900. /**
  80901. * Retreives the point at the distance aways from the starting point
  80902. * @param normalizedLengthPosition the length along the path to retreive the point from
  80903. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  80904. */
  80905. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  80906. /**
  80907. * Creates a new path starting from an x and y position
  80908. * @param x starting x value
  80909. * @param y starting y value
  80910. * @returns a new Path2 starting at the coordinates (x, y).
  80911. */
  80912. static StartingAt(x: number, y: number): Path2;
  80913. }
  80914. /**
  80915. * Represents a 3D path made up of multiple 3D points
  80916. */
  80917. export class Path3D {
  80918. /**
  80919. * an array of Vector3, the curve axis of the Path3D
  80920. */
  80921. path: Vector3[];
  80922. private _curve;
  80923. private _distances;
  80924. private _tangents;
  80925. private _normals;
  80926. private _binormals;
  80927. private _raw;
  80928. private _alignTangentsWithPath;
  80929. private readonly _pointAtData;
  80930. /**
  80931. * new Path3D(path, normal, raw)
  80932. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  80933. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  80934. * @param path an array of Vector3, the curve axis of the Path3D
  80935. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  80936. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  80937. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  80938. */
  80939. constructor(
  80940. /**
  80941. * an array of Vector3, the curve axis of the Path3D
  80942. */
  80943. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  80944. /**
  80945. * Returns the Path3D array of successive Vector3 designing its curve.
  80946. * @returns the Path3D array of successive Vector3 designing its curve.
  80947. */
  80948. getCurve(): Vector3[];
  80949. /**
  80950. * Returns the Path3D array of successive Vector3 designing its curve.
  80951. * @returns the Path3D array of successive Vector3 designing its curve.
  80952. */
  80953. getPoints(): Vector3[];
  80954. /**
  80955. * @returns the computed length (float) of the path.
  80956. */
  80957. length(): number;
  80958. /**
  80959. * Returns an array populated with tangent vectors on each Path3D curve point.
  80960. * @returns an array populated with tangent vectors on each Path3D curve point.
  80961. */
  80962. getTangents(): Vector3[];
  80963. /**
  80964. * Returns an array populated with normal vectors on each Path3D curve point.
  80965. * @returns an array populated with normal vectors on each Path3D curve point.
  80966. */
  80967. getNormals(): Vector3[];
  80968. /**
  80969. * Returns an array populated with binormal vectors on each Path3D curve point.
  80970. * @returns an array populated with binormal vectors on each Path3D curve point.
  80971. */
  80972. getBinormals(): Vector3[];
  80973. /**
  80974. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  80975. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  80976. */
  80977. getDistances(): number[];
  80978. /**
  80979. * Returns an interpolated point along this path
  80980. * @param position the position of the point along this path, from 0.0 to 1.0
  80981. * @returns a new Vector3 as the point
  80982. */
  80983. getPointAt(position: number): Vector3;
  80984. /**
  80985. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  80986. * @param position the position of the point along this path, from 0.0 to 1.0
  80987. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  80988. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  80989. */
  80990. getTangentAt(position: number, interpolated?: boolean): Vector3;
  80991. /**
  80992. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  80993. * @param position the position of the point along this path, from 0.0 to 1.0
  80994. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  80995. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  80996. */
  80997. getNormalAt(position: number, interpolated?: boolean): Vector3;
  80998. /**
  80999. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  81000. * @param position the position of the point along this path, from 0.0 to 1.0
  81001. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  81002. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  81003. */
  81004. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  81005. /**
  81006. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  81007. * @param position the position of the point along this path, from 0.0 to 1.0
  81008. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  81009. */
  81010. getDistanceAt(position: number): number;
  81011. /**
  81012. * Returns the array index of the previous point of an interpolated point along this path
  81013. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  81014. * @returns the array index
  81015. */
  81016. getPreviousPointIndexAt(position: number): number;
  81017. /**
  81018. * 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)
  81019. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  81020. * @returns the sub position
  81021. */
  81022. getSubPositionAt(position: number): number;
  81023. /**
  81024. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  81025. * @param target the vector of which to get the closest position to
  81026. * @returns the position of the closest virtual point on this path to the target vector
  81027. */
  81028. getClosestPositionTo(target: Vector3): number;
  81029. /**
  81030. * Returns a sub path (slice) of this path
  81031. * @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
  81032. * @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
  81033. * @returns a sub path (slice) of this path
  81034. */
  81035. slice(start?: number, end?: number): Path3D;
  81036. /**
  81037. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  81038. * @param path path which all values are copied into the curves points
  81039. * @param firstNormal which should be projected onto the curve
  81040. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  81041. * @returns the same object updated.
  81042. */
  81043. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  81044. private _compute;
  81045. private _getFirstNonNullVector;
  81046. private _getLastNonNullVector;
  81047. private _normalVector;
  81048. /**
  81049. * Updates the point at data for an interpolated point along this curve
  81050. * @param position the position of the point along this curve, from 0.0 to 1.0
  81051. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  81052. * @returns the (updated) point at data
  81053. */
  81054. private _updatePointAtData;
  81055. /**
  81056. * Updates the point at data from the specified parameters
  81057. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  81058. * @param point the interpolated point
  81059. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  81060. */
  81061. private _setPointAtData;
  81062. /**
  81063. * Updates the point at interpolation matrix for the tangents, normals and binormals
  81064. */
  81065. private _updateInterpolationMatrix;
  81066. }
  81067. /**
  81068. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  81069. * A Curve3 is designed from a series of successive Vector3.
  81070. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  81071. */
  81072. export class Curve3 {
  81073. private _points;
  81074. private _length;
  81075. /**
  81076. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  81077. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  81078. * @param v1 (Vector3) the control point
  81079. * @param v2 (Vector3) the end point of the Quadratic Bezier
  81080. * @param nbPoints (integer) the wanted number of points in the curve
  81081. * @returns the created Curve3
  81082. */
  81083. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  81084. /**
  81085. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  81086. * @param v0 (Vector3) the origin point of the Cubic Bezier
  81087. * @param v1 (Vector3) the first control point
  81088. * @param v2 (Vector3) the second control point
  81089. * @param v3 (Vector3) the end point of the Cubic Bezier
  81090. * @param nbPoints (integer) the wanted number of points in the curve
  81091. * @returns the created Curve3
  81092. */
  81093. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  81094. /**
  81095. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  81096. * @param p1 (Vector3) the origin point of the Hermite Spline
  81097. * @param t1 (Vector3) the tangent vector at the origin point
  81098. * @param p2 (Vector3) the end point of the Hermite Spline
  81099. * @param t2 (Vector3) the tangent vector at the end point
  81100. * @param nbPoints (integer) the wanted number of points in the curve
  81101. * @returns the created Curve3
  81102. */
  81103. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  81104. /**
  81105. * Returns a Curve3 object along a CatmullRom Spline curve :
  81106. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  81107. * @param nbPoints (integer) the wanted number of points between each curve control points
  81108. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  81109. * @returns the created Curve3
  81110. */
  81111. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  81112. /**
  81113. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  81114. * A Curve3 is designed from a series of successive Vector3.
  81115. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  81116. * @param points points which make up the curve
  81117. */
  81118. constructor(points: Vector3[]);
  81119. /**
  81120. * @returns the Curve3 stored array of successive Vector3
  81121. */
  81122. getPoints(): Vector3[];
  81123. /**
  81124. * @returns the computed length (float) of the curve.
  81125. */
  81126. length(): number;
  81127. /**
  81128. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  81129. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  81130. * curveA and curveB keep unchanged.
  81131. * @param curve the curve to continue from this curve
  81132. * @returns the newly constructed curve
  81133. */
  81134. continue(curve: DeepImmutable<Curve3>): Curve3;
  81135. private _computeLength;
  81136. }
  81137. }
  81138. declare module BABYLON {
  81139. /**
  81140. * This represents the main contract an easing function should follow.
  81141. * Easing functions are used throughout the animation system.
  81142. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  81143. */
  81144. export interface IEasingFunction {
  81145. /**
  81146. * Given an input gradient between 0 and 1, this returns the corrseponding value
  81147. * of the easing function.
  81148. * The link below provides some of the most common examples of easing functions.
  81149. * @see https://easings.net/
  81150. * @param gradient Defines the value between 0 and 1 we want the easing value for
  81151. * @returns the corresponding value on the curve defined by the easing function
  81152. */
  81153. ease(gradient: number): number;
  81154. }
  81155. /**
  81156. * Base class used for every default easing function.
  81157. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  81158. */
  81159. export class EasingFunction implements IEasingFunction {
  81160. /**
  81161. * Interpolation follows the mathematical formula associated with the easing function.
  81162. */
  81163. static readonly EASINGMODE_EASEIN: number;
  81164. /**
  81165. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  81166. */
  81167. static readonly EASINGMODE_EASEOUT: number;
  81168. /**
  81169. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  81170. */
  81171. static readonly EASINGMODE_EASEINOUT: number;
  81172. private _easingMode;
  81173. /**
  81174. * Sets the easing mode of the current function.
  81175. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  81176. */
  81177. setEasingMode(easingMode: number): void;
  81178. /**
  81179. * Gets the current easing mode.
  81180. * @returns the easing mode
  81181. */
  81182. getEasingMode(): number;
  81183. /**
  81184. * @hidden
  81185. */
  81186. easeInCore(gradient: number): number;
  81187. /**
  81188. * Given an input gradient between 0 and 1, this returns the corresponding value
  81189. * of the easing function.
  81190. * @param gradient Defines the value between 0 and 1 we want the easing value for
  81191. * @returns the corresponding value on the curve defined by the easing function
  81192. */
  81193. ease(gradient: number): number;
  81194. }
  81195. /**
  81196. * Easing function with a circle shape (see link below).
  81197. * @see https://easings.net/#easeInCirc
  81198. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  81199. */
  81200. export class CircleEase extends EasingFunction implements IEasingFunction {
  81201. /** @hidden */
  81202. easeInCore(gradient: number): number;
  81203. }
  81204. /**
  81205. * Easing function with a ease back shape (see link below).
  81206. * @see https://easings.net/#easeInBack
  81207. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  81208. */
  81209. export class BackEase extends EasingFunction implements IEasingFunction {
  81210. /** Defines the amplitude of the function */
  81211. amplitude: number;
  81212. /**
  81213. * Instantiates a back ease easing
  81214. * @see https://easings.net/#easeInBack
  81215. * @param amplitude Defines the amplitude of the function
  81216. */
  81217. constructor(
  81218. /** Defines the amplitude of the function */
  81219. amplitude?: number);
  81220. /** @hidden */
  81221. easeInCore(gradient: number): number;
  81222. }
  81223. /**
  81224. * Easing function with a bouncing shape (see link below).
  81225. * @see https://easings.net/#easeInBounce
  81226. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  81227. */
  81228. export class BounceEase extends EasingFunction implements IEasingFunction {
  81229. /** Defines the number of bounces */
  81230. bounces: number;
  81231. /** Defines the amplitude of the bounce */
  81232. bounciness: number;
  81233. /**
  81234. * Instantiates a bounce easing
  81235. * @see https://easings.net/#easeInBounce
  81236. * @param bounces Defines the number of bounces
  81237. * @param bounciness Defines the amplitude of the bounce
  81238. */
  81239. constructor(
  81240. /** Defines the number of bounces */
  81241. bounces?: number,
  81242. /** Defines the amplitude of the bounce */
  81243. bounciness?: number);
  81244. /** @hidden */
  81245. easeInCore(gradient: number): number;
  81246. }
  81247. /**
  81248. * Easing function with a power of 3 shape (see link below).
  81249. * @see https://easings.net/#easeInCubic
  81250. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  81251. */
  81252. export class CubicEase extends EasingFunction implements IEasingFunction {
  81253. /** @hidden */
  81254. easeInCore(gradient: number): number;
  81255. }
  81256. /**
  81257. * Easing function with an elastic shape (see link below).
  81258. * @see https://easings.net/#easeInElastic
  81259. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  81260. */
  81261. export class ElasticEase extends EasingFunction implements IEasingFunction {
  81262. /** Defines the number of oscillations*/
  81263. oscillations: number;
  81264. /** Defines the amplitude of the oscillations*/
  81265. springiness: number;
  81266. /**
  81267. * Instantiates an elastic easing function
  81268. * @see https://easings.net/#easeInElastic
  81269. * @param oscillations Defines the number of oscillations
  81270. * @param springiness Defines the amplitude of the oscillations
  81271. */
  81272. constructor(
  81273. /** Defines the number of oscillations*/
  81274. oscillations?: number,
  81275. /** Defines the amplitude of the oscillations*/
  81276. springiness?: number);
  81277. /** @hidden */
  81278. easeInCore(gradient: number): number;
  81279. }
  81280. /**
  81281. * Easing function with an exponential shape (see link below).
  81282. * @see https://easings.net/#easeInExpo
  81283. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  81284. */
  81285. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  81286. /** Defines the exponent of the function */
  81287. exponent: number;
  81288. /**
  81289. * Instantiates an exponential easing function
  81290. * @see https://easings.net/#easeInExpo
  81291. * @param exponent Defines the exponent of the function
  81292. */
  81293. constructor(
  81294. /** Defines the exponent of the function */
  81295. exponent?: number);
  81296. /** @hidden */
  81297. easeInCore(gradient: number): number;
  81298. }
  81299. /**
  81300. * Easing function with a power shape (see link below).
  81301. * @see https://easings.net/#easeInQuad
  81302. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  81303. */
  81304. export class PowerEase extends EasingFunction implements IEasingFunction {
  81305. /** Defines the power of the function */
  81306. power: number;
  81307. /**
  81308. * Instantiates an power base easing function
  81309. * @see https://easings.net/#easeInQuad
  81310. * @param power Defines the power of the function
  81311. */
  81312. constructor(
  81313. /** Defines the power of the function */
  81314. power?: number);
  81315. /** @hidden */
  81316. easeInCore(gradient: number): number;
  81317. }
  81318. /**
  81319. * Easing function with a power of 2 shape (see link below).
  81320. * @see https://easings.net/#easeInQuad
  81321. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  81322. */
  81323. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  81324. /** @hidden */
  81325. easeInCore(gradient: number): number;
  81326. }
  81327. /**
  81328. * Easing function with a power of 4 shape (see link below).
  81329. * @see https://easings.net/#easeInQuart
  81330. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  81331. */
  81332. export class QuarticEase extends EasingFunction implements IEasingFunction {
  81333. /** @hidden */
  81334. easeInCore(gradient: number): number;
  81335. }
  81336. /**
  81337. * Easing function with a power of 5 shape (see link below).
  81338. * @see https://easings.net/#easeInQuint
  81339. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  81340. */
  81341. export class QuinticEase extends EasingFunction implements IEasingFunction {
  81342. /** @hidden */
  81343. easeInCore(gradient: number): number;
  81344. }
  81345. /**
  81346. * Easing function with a sin shape (see link below).
  81347. * @see https://easings.net/#easeInSine
  81348. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  81349. */
  81350. export class SineEase extends EasingFunction implements IEasingFunction {
  81351. /** @hidden */
  81352. easeInCore(gradient: number): number;
  81353. }
  81354. /**
  81355. * Easing function with a bezier shape (see link below).
  81356. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  81357. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  81358. */
  81359. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  81360. /** Defines the x component of the start tangent in the bezier curve */
  81361. x1: number;
  81362. /** Defines the y component of the start tangent in the bezier curve */
  81363. y1: number;
  81364. /** Defines the x component of the end tangent in the bezier curve */
  81365. x2: number;
  81366. /** Defines the y component of the end tangent in the bezier curve */
  81367. y2: number;
  81368. /**
  81369. * Instantiates a bezier function
  81370. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  81371. * @param x1 Defines the x component of the start tangent in the bezier curve
  81372. * @param y1 Defines the y component of the start tangent in the bezier curve
  81373. * @param x2 Defines the x component of the end tangent in the bezier curve
  81374. * @param y2 Defines the y component of the end tangent in the bezier curve
  81375. */
  81376. constructor(
  81377. /** Defines the x component of the start tangent in the bezier curve */
  81378. x1?: number,
  81379. /** Defines the y component of the start tangent in the bezier curve */
  81380. y1?: number,
  81381. /** Defines the x component of the end tangent in the bezier curve */
  81382. x2?: number,
  81383. /** Defines the y component of the end tangent in the bezier curve */
  81384. y2?: number);
  81385. /** @hidden */
  81386. easeInCore(gradient: number): number;
  81387. }
  81388. }
  81389. declare module BABYLON {
  81390. /**
  81391. * Class used to hold a RBG color
  81392. */
  81393. export class Color3 {
  81394. /**
  81395. * Defines the red component (between 0 and 1, default is 0)
  81396. */
  81397. r: number;
  81398. /**
  81399. * Defines the green component (between 0 and 1, default is 0)
  81400. */
  81401. g: number;
  81402. /**
  81403. * Defines the blue component (between 0 and 1, default is 0)
  81404. */
  81405. b: number;
  81406. /**
  81407. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  81408. * @param r defines the red component (between 0 and 1, default is 0)
  81409. * @param g defines the green component (between 0 and 1, default is 0)
  81410. * @param b defines the blue component (between 0 and 1, default is 0)
  81411. */
  81412. constructor(
  81413. /**
  81414. * Defines the red component (between 0 and 1, default is 0)
  81415. */
  81416. r?: number,
  81417. /**
  81418. * Defines the green component (between 0 and 1, default is 0)
  81419. */
  81420. g?: number,
  81421. /**
  81422. * Defines the blue component (between 0 and 1, default is 0)
  81423. */
  81424. b?: number);
  81425. /**
  81426. * Creates a string with the Color3 current values
  81427. * @returns the string representation of the Color3 object
  81428. */
  81429. toString(): string;
  81430. /**
  81431. * Returns the string "Color3"
  81432. * @returns "Color3"
  81433. */
  81434. getClassName(): string;
  81435. /**
  81436. * Compute the Color3 hash code
  81437. * @returns an unique number that can be used to hash Color3 objects
  81438. */
  81439. getHashCode(): number;
  81440. /**
  81441. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  81442. * @param array defines the array where to store the r,g,b components
  81443. * @param index defines an optional index in the target array to define where to start storing values
  81444. * @returns the current Color3 object
  81445. */
  81446. toArray(array: FloatArray, index?: number): Color3;
  81447. /**
  81448. * Returns a new Color4 object from the current Color3 and the given alpha
  81449. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  81450. * @returns a new Color4 object
  81451. */
  81452. toColor4(alpha?: number): Color4;
  81453. /**
  81454. * Returns a new array populated with 3 numeric elements : red, green and blue values
  81455. * @returns the new array
  81456. */
  81457. asArray(): number[];
  81458. /**
  81459. * Returns the luminance value
  81460. * @returns a float value
  81461. */
  81462. toLuminance(): number;
  81463. /**
  81464. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  81465. * @param otherColor defines the second operand
  81466. * @returns the new Color3 object
  81467. */
  81468. multiply(otherColor: DeepImmutable<Color3>): Color3;
  81469. /**
  81470. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  81471. * @param otherColor defines the second operand
  81472. * @param result defines the Color3 object where to store the result
  81473. * @returns the current Color3
  81474. */
  81475. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  81476. /**
  81477. * Determines equality between Color3 objects
  81478. * @param otherColor defines the second operand
  81479. * @returns true if the rgb values are equal to the given ones
  81480. */
  81481. equals(otherColor: DeepImmutable<Color3>): boolean;
  81482. /**
  81483. * Determines equality between the current Color3 object and a set of r,b,g values
  81484. * @param r defines the red component to check
  81485. * @param g defines the green component to check
  81486. * @param b defines the blue component to check
  81487. * @returns true if the rgb values are equal to the given ones
  81488. */
  81489. equalsFloats(r: number, g: number, b: number): boolean;
  81490. /**
  81491. * Multiplies in place each rgb value by scale
  81492. * @param scale defines the scaling factor
  81493. * @returns the updated Color3
  81494. */
  81495. scale(scale: number): Color3;
  81496. /**
  81497. * Multiplies the rgb values by scale and stores the result into "result"
  81498. * @param scale defines the scaling factor
  81499. * @param result defines the Color3 object where to store the result
  81500. * @returns the unmodified current Color3
  81501. */
  81502. scaleToRef(scale: number, result: Color3): Color3;
  81503. /**
  81504. * Scale the current Color3 values by a factor and add the result to a given Color3
  81505. * @param scale defines the scale factor
  81506. * @param result defines color to store the result into
  81507. * @returns the unmodified current Color3
  81508. */
  81509. scaleAndAddToRef(scale: number, result: Color3): Color3;
  81510. /**
  81511. * Clamps the rgb values by the min and max values and stores the result into "result"
  81512. * @param min defines minimum clamping value (default is 0)
  81513. * @param max defines maximum clamping value (default is 1)
  81514. * @param result defines color to store the result into
  81515. * @returns the original Color3
  81516. */
  81517. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  81518. /**
  81519. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  81520. * @param otherColor defines the second operand
  81521. * @returns the new Color3
  81522. */
  81523. add(otherColor: DeepImmutable<Color3>): Color3;
  81524. /**
  81525. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  81526. * @param otherColor defines the second operand
  81527. * @param result defines Color3 object to store the result into
  81528. * @returns the unmodified current Color3
  81529. */
  81530. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  81531. /**
  81532. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  81533. * @param otherColor defines the second operand
  81534. * @returns the new Color3
  81535. */
  81536. subtract(otherColor: DeepImmutable<Color3>): Color3;
  81537. /**
  81538. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  81539. * @param otherColor defines the second operand
  81540. * @param result defines Color3 object to store the result into
  81541. * @returns the unmodified current Color3
  81542. */
  81543. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  81544. /**
  81545. * Copy the current object
  81546. * @returns a new Color3 copied the current one
  81547. */
  81548. clone(): Color3;
  81549. /**
  81550. * Copies the rgb values from the source in the current Color3
  81551. * @param source defines the source Color3 object
  81552. * @returns the updated Color3 object
  81553. */
  81554. copyFrom(source: DeepImmutable<Color3>): Color3;
  81555. /**
  81556. * Updates the Color3 rgb values from the given floats
  81557. * @param r defines the red component to read from
  81558. * @param g defines the green component to read from
  81559. * @param b defines the blue component to read from
  81560. * @returns the current Color3 object
  81561. */
  81562. copyFromFloats(r: number, g: number, b: number): Color3;
  81563. /**
  81564. * Updates the Color3 rgb values from the given floats
  81565. * @param r defines the red component to read from
  81566. * @param g defines the green component to read from
  81567. * @param b defines the blue component to read from
  81568. * @returns the current Color3 object
  81569. */
  81570. set(r: number, g: number, b: number): Color3;
  81571. /**
  81572. * Compute the Color3 hexadecimal code as a string
  81573. * @returns a string containing the hexadecimal representation of the Color3 object
  81574. */
  81575. toHexString(): string;
  81576. /**
  81577. * Computes a new Color3 converted from the current one to linear space
  81578. * @returns a new Color3 object
  81579. */
  81580. toLinearSpace(): Color3;
  81581. /**
  81582. * Converts current color in rgb space to HSV values
  81583. * @returns a new color3 representing the HSV values
  81584. */
  81585. toHSV(): Color3;
  81586. /**
  81587. * Converts current color in rgb space to HSV values
  81588. * @param result defines the Color3 where to store the HSV values
  81589. */
  81590. toHSVToRef(result: Color3): void;
  81591. /**
  81592. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  81593. * @param convertedColor defines the Color3 object where to store the linear space version
  81594. * @returns the unmodified Color3
  81595. */
  81596. toLinearSpaceToRef(convertedColor: Color3): Color3;
  81597. /**
  81598. * Computes a new Color3 converted from the current one to gamma space
  81599. * @returns a new Color3 object
  81600. */
  81601. toGammaSpace(): Color3;
  81602. /**
  81603. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  81604. * @param convertedColor defines the Color3 object where to store the gamma space version
  81605. * @returns the unmodified Color3
  81606. */
  81607. toGammaSpaceToRef(convertedColor: Color3): Color3;
  81608. private static _BlackReadOnly;
  81609. /**
  81610. * Convert Hue, saturation and value to a Color3 (RGB)
  81611. * @param hue defines the hue
  81612. * @param saturation defines the saturation
  81613. * @param value defines the value
  81614. * @param result defines the Color3 where to store the RGB values
  81615. */
  81616. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  81617. /**
  81618. * Creates a new Color3 from the string containing valid hexadecimal values
  81619. * @param hex defines a string containing valid hexadecimal values
  81620. * @returns a new Color3 object
  81621. */
  81622. static FromHexString(hex: string): Color3;
  81623. /**
  81624. * Creates a new Color3 from the starting index of the given array
  81625. * @param array defines the source array
  81626. * @param offset defines an offset in the source array
  81627. * @returns a new Color3 object
  81628. */
  81629. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  81630. /**
  81631. * Creates a new Color3 from integer values (< 256)
  81632. * @param r defines the red component to read from (value between 0 and 255)
  81633. * @param g defines the green component to read from (value between 0 and 255)
  81634. * @param b defines the blue component to read from (value between 0 and 255)
  81635. * @returns a new Color3 object
  81636. */
  81637. static FromInts(r: number, g: number, b: number): Color3;
  81638. /**
  81639. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  81640. * @param start defines the start Color3 value
  81641. * @param end defines the end Color3 value
  81642. * @param amount defines the gradient value between start and end
  81643. * @returns a new Color3 object
  81644. */
  81645. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  81646. /**
  81647. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  81648. * @param left defines the start value
  81649. * @param right defines the end value
  81650. * @param amount defines the gradient factor
  81651. * @param result defines the Color3 object where to store the result
  81652. */
  81653. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  81654. /**
  81655. * Returns a Color3 value containing a red color
  81656. * @returns a new Color3 object
  81657. */
  81658. static Red(): Color3;
  81659. /**
  81660. * Returns a Color3 value containing a green color
  81661. * @returns a new Color3 object
  81662. */
  81663. static Green(): Color3;
  81664. /**
  81665. * Returns a Color3 value containing a blue color
  81666. * @returns a new Color3 object
  81667. */
  81668. static Blue(): Color3;
  81669. /**
  81670. * Returns a Color3 value containing a black color
  81671. * @returns a new Color3 object
  81672. */
  81673. static Black(): Color3;
  81674. /**
  81675. * Gets a Color3 value containing a black color that must not be updated
  81676. */
  81677. static get BlackReadOnly(): DeepImmutable<Color3>;
  81678. /**
  81679. * Returns a Color3 value containing a white color
  81680. * @returns a new Color3 object
  81681. */
  81682. static White(): Color3;
  81683. /**
  81684. * Returns a Color3 value containing a purple color
  81685. * @returns a new Color3 object
  81686. */
  81687. static Purple(): Color3;
  81688. /**
  81689. * Returns a Color3 value containing a magenta color
  81690. * @returns a new Color3 object
  81691. */
  81692. static Magenta(): Color3;
  81693. /**
  81694. * Returns a Color3 value containing a yellow color
  81695. * @returns a new Color3 object
  81696. */
  81697. static Yellow(): Color3;
  81698. /**
  81699. * Returns a Color3 value containing a gray color
  81700. * @returns a new Color3 object
  81701. */
  81702. static Gray(): Color3;
  81703. /**
  81704. * Returns a Color3 value containing a teal color
  81705. * @returns a new Color3 object
  81706. */
  81707. static Teal(): Color3;
  81708. /**
  81709. * Returns a Color3 value containing a random color
  81710. * @returns a new Color3 object
  81711. */
  81712. static Random(): Color3;
  81713. }
  81714. /**
  81715. * Class used to hold a RBGA color
  81716. */
  81717. export class Color4 {
  81718. /**
  81719. * Defines the red component (between 0 and 1, default is 0)
  81720. */
  81721. r: number;
  81722. /**
  81723. * Defines the green component (between 0 and 1, default is 0)
  81724. */
  81725. g: number;
  81726. /**
  81727. * Defines the blue component (between 0 and 1, default is 0)
  81728. */
  81729. b: number;
  81730. /**
  81731. * Defines the alpha component (between 0 and 1, default is 1)
  81732. */
  81733. a: number;
  81734. /**
  81735. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  81736. * @param r defines the red component (between 0 and 1, default is 0)
  81737. * @param g defines the green component (between 0 and 1, default is 0)
  81738. * @param b defines the blue component (between 0 and 1, default is 0)
  81739. * @param a defines the alpha component (between 0 and 1, default is 1)
  81740. */
  81741. constructor(
  81742. /**
  81743. * Defines the red component (between 0 and 1, default is 0)
  81744. */
  81745. r?: number,
  81746. /**
  81747. * Defines the green component (between 0 and 1, default is 0)
  81748. */
  81749. g?: number,
  81750. /**
  81751. * Defines the blue component (between 0 and 1, default is 0)
  81752. */
  81753. b?: number,
  81754. /**
  81755. * Defines the alpha component (between 0 and 1, default is 1)
  81756. */
  81757. a?: number);
  81758. /**
  81759. * Adds in place the given Color4 values to the current Color4 object
  81760. * @param right defines the second operand
  81761. * @returns the current updated Color4 object
  81762. */
  81763. addInPlace(right: DeepImmutable<Color4>): Color4;
  81764. /**
  81765. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  81766. * @returns the new array
  81767. */
  81768. asArray(): number[];
  81769. /**
  81770. * Stores from the starting index in the given array the Color4 successive values
  81771. * @param array defines the array where to store the r,g,b components
  81772. * @param index defines an optional index in the target array to define where to start storing values
  81773. * @returns the current Color4 object
  81774. */
  81775. toArray(array: number[], index?: number): Color4;
  81776. /**
  81777. * Determines equality between Color4 objects
  81778. * @param otherColor defines the second operand
  81779. * @returns true if the rgba values are equal to the given ones
  81780. */
  81781. equals(otherColor: DeepImmutable<Color4>): boolean;
  81782. /**
  81783. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  81784. * @param right defines the second operand
  81785. * @returns a new Color4 object
  81786. */
  81787. add(right: DeepImmutable<Color4>): Color4;
  81788. /**
  81789. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  81790. * @param right defines the second operand
  81791. * @returns a new Color4 object
  81792. */
  81793. subtract(right: DeepImmutable<Color4>): Color4;
  81794. /**
  81795. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  81796. * @param right defines the second operand
  81797. * @param result defines the Color4 object where to store the result
  81798. * @returns the current Color4 object
  81799. */
  81800. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  81801. /**
  81802. * Creates a new Color4 with the current Color4 values multiplied by scale
  81803. * @param scale defines the scaling factor to apply
  81804. * @returns a new Color4 object
  81805. */
  81806. scale(scale: number): Color4;
  81807. /**
  81808. * Multiplies the current Color4 values by scale and stores the result in "result"
  81809. * @param scale defines the scaling factor to apply
  81810. * @param result defines the Color4 object where to store the result
  81811. * @returns the current unmodified Color4
  81812. */
  81813. scaleToRef(scale: number, result: Color4): Color4;
  81814. /**
  81815. * Scale the current Color4 values by a factor and add the result to a given Color4
  81816. * @param scale defines the scale factor
  81817. * @param result defines the Color4 object where to store the result
  81818. * @returns the unmodified current Color4
  81819. */
  81820. scaleAndAddToRef(scale: number, result: Color4): Color4;
  81821. /**
  81822. * Clamps the rgb values by the min and max values and stores the result into "result"
  81823. * @param min defines minimum clamping value (default is 0)
  81824. * @param max defines maximum clamping value (default is 1)
  81825. * @param result defines color to store the result into.
  81826. * @returns the cuurent Color4
  81827. */
  81828. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  81829. /**
  81830. * Multipy an Color4 value by another and return a new Color4 object
  81831. * @param color defines the Color4 value to multiply by
  81832. * @returns a new Color4 object
  81833. */
  81834. multiply(color: Color4): Color4;
  81835. /**
  81836. * Multipy a Color4 value by another and push the result in a reference value
  81837. * @param color defines the Color4 value to multiply by
  81838. * @param result defines the Color4 to fill the result in
  81839. * @returns the result Color4
  81840. */
  81841. multiplyToRef(color: Color4, result: Color4): Color4;
  81842. /**
  81843. * Creates a string with the Color4 current values
  81844. * @returns the string representation of the Color4 object
  81845. */
  81846. toString(): string;
  81847. /**
  81848. * Returns the string "Color4"
  81849. * @returns "Color4"
  81850. */
  81851. getClassName(): string;
  81852. /**
  81853. * Compute the Color4 hash code
  81854. * @returns an unique number that can be used to hash Color4 objects
  81855. */
  81856. getHashCode(): number;
  81857. /**
  81858. * Creates a new Color4 copied from the current one
  81859. * @returns a new Color4 object
  81860. */
  81861. clone(): Color4;
  81862. /**
  81863. * Copies the given Color4 values into the current one
  81864. * @param source defines the source Color4 object
  81865. * @returns the current updated Color4 object
  81866. */
  81867. copyFrom(source: Color4): Color4;
  81868. /**
  81869. * Copies the given float values into the current one
  81870. * @param r defines the red component to read from
  81871. * @param g defines the green component to read from
  81872. * @param b defines the blue component to read from
  81873. * @param a defines the alpha component to read from
  81874. * @returns the current updated Color4 object
  81875. */
  81876. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  81877. /**
  81878. * Copies the given float values into the current one
  81879. * @param r defines the red component to read from
  81880. * @param g defines the green component to read from
  81881. * @param b defines the blue component to read from
  81882. * @param a defines the alpha component to read from
  81883. * @returns the current updated Color4 object
  81884. */
  81885. set(r: number, g: number, b: number, a: number): Color4;
  81886. /**
  81887. * Compute the Color4 hexadecimal code as a string
  81888. * @param returnAsColor3 defines if the string should only contains RGB values (off by default)
  81889. * @returns a string containing the hexadecimal representation of the Color4 object
  81890. */
  81891. toHexString(returnAsColor3?: boolean): string;
  81892. /**
  81893. * Computes a new Color4 converted from the current one to linear space
  81894. * @returns a new Color4 object
  81895. */
  81896. toLinearSpace(): Color4;
  81897. /**
  81898. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  81899. * @param convertedColor defines the Color4 object where to store the linear space version
  81900. * @returns the unmodified Color4
  81901. */
  81902. toLinearSpaceToRef(convertedColor: Color4): Color4;
  81903. /**
  81904. * Computes a new Color4 converted from the current one to gamma space
  81905. * @returns a new Color4 object
  81906. */
  81907. toGammaSpace(): Color4;
  81908. /**
  81909. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  81910. * @param convertedColor defines the Color4 object where to store the gamma space version
  81911. * @returns the unmodified Color4
  81912. */
  81913. toGammaSpaceToRef(convertedColor: Color4): Color4;
  81914. /**
  81915. * Creates a new Color4 from the string containing valid hexadecimal values
  81916. * @param hex defines a string containing valid hexadecimal values
  81917. * @returns a new Color4 object
  81918. */
  81919. static FromHexString(hex: string): Color4;
  81920. /**
  81921. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  81922. * @param left defines the start value
  81923. * @param right defines the end value
  81924. * @param amount defines the gradient factor
  81925. * @returns a new Color4 object
  81926. */
  81927. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  81928. /**
  81929. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  81930. * @param left defines the start value
  81931. * @param right defines the end value
  81932. * @param amount defines the gradient factor
  81933. * @param result defines the Color4 object where to store data
  81934. */
  81935. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  81936. /**
  81937. * Creates a new Color4 from a Color3 and an alpha value
  81938. * @param color3 defines the source Color3 to read from
  81939. * @param alpha defines the alpha component (1.0 by default)
  81940. * @returns a new Color4 object
  81941. */
  81942. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  81943. /**
  81944. * Creates a new Color4 from the starting index element of the given array
  81945. * @param array defines the source array to read from
  81946. * @param offset defines the offset in the source array
  81947. * @returns a new Color4 object
  81948. */
  81949. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  81950. /**
  81951. * Creates a new Color3 from integer values (< 256)
  81952. * @param r defines the red component to read from (value between 0 and 255)
  81953. * @param g defines the green component to read from (value between 0 and 255)
  81954. * @param b defines the blue component to read from (value between 0 and 255)
  81955. * @param a defines the alpha component to read from (value between 0 and 255)
  81956. * @returns a new Color3 object
  81957. */
  81958. static FromInts(r: number, g: number, b: number, a: number): Color4;
  81959. /**
  81960. * Check the content of a given array and convert it to an array containing RGBA data
  81961. * If the original array was already containing count * 4 values then it is returned directly
  81962. * @param colors defines the array to check
  81963. * @param count defines the number of RGBA data to expect
  81964. * @returns an array containing count * 4 values (RGBA)
  81965. */
  81966. static CheckColors4(colors: number[], count: number): number[];
  81967. }
  81968. /**
  81969. * @hidden
  81970. */
  81971. export class TmpColors {
  81972. static Color3: Color3[];
  81973. static Color4: Color4[];
  81974. }
  81975. }
  81976. declare module BABYLON {
  81977. /**
  81978. * Defines an interface which represents an animation key frame
  81979. */
  81980. export interface IAnimationKey {
  81981. /**
  81982. * Frame of the key frame
  81983. */
  81984. frame: number;
  81985. /**
  81986. * Value at the specifies key frame
  81987. */
  81988. value: any;
  81989. /**
  81990. * The input tangent for the cubic hermite spline
  81991. */
  81992. inTangent?: any;
  81993. /**
  81994. * The output tangent for the cubic hermite spline
  81995. */
  81996. outTangent?: any;
  81997. /**
  81998. * The animation interpolation type
  81999. */
  82000. interpolation?: AnimationKeyInterpolation;
  82001. }
  82002. /**
  82003. * Enum for the animation key frame interpolation type
  82004. */
  82005. export enum AnimationKeyInterpolation {
  82006. /**
  82007. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  82008. */
  82009. STEP = 1
  82010. }
  82011. }
  82012. declare module BABYLON {
  82013. /**
  82014. * Represents the range of an animation
  82015. */
  82016. export class AnimationRange {
  82017. /**The name of the animation range**/
  82018. name: string;
  82019. /**The starting frame of the animation */
  82020. from: number;
  82021. /**The ending frame of the animation*/
  82022. to: number;
  82023. /**
  82024. * Initializes the range of an animation
  82025. * @param name The name of the animation range
  82026. * @param from The starting frame of the animation
  82027. * @param to The ending frame of the animation
  82028. */
  82029. constructor(
  82030. /**The name of the animation range**/
  82031. name: string,
  82032. /**The starting frame of the animation */
  82033. from: number,
  82034. /**The ending frame of the animation*/
  82035. to: number);
  82036. /**
  82037. * Makes a copy of the animation range
  82038. * @returns A copy of the animation range
  82039. */
  82040. clone(): AnimationRange;
  82041. }
  82042. }
  82043. declare module BABYLON {
  82044. /**
  82045. * Composed of a frame, and an action function
  82046. */
  82047. export class AnimationEvent {
  82048. /** The frame for which the event is triggered **/
  82049. frame: number;
  82050. /** The event to perform when triggered **/
  82051. action: (currentFrame: number) => void;
  82052. /** Specifies if the event should be triggered only once**/
  82053. onlyOnce?: boolean | undefined;
  82054. /**
  82055. * Specifies if the animation event is done
  82056. */
  82057. isDone: boolean;
  82058. /**
  82059. * Initializes the animation event
  82060. * @param frame The frame for which the event is triggered
  82061. * @param action The event to perform when triggered
  82062. * @param onlyOnce Specifies if the event should be triggered only once
  82063. */
  82064. constructor(
  82065. /** The frame for which the event is triggered **/
  82066. frame: number,
  82067. /** The event to perform when triggered **/
  82068. action: (currentFrame: number) => void,
  82069. /** Specifies if the event should be triggered only once**/
  82070. onlyOnce?: boolean | undefined);
  82071. /** @hidden */
  82072. _clone(): AnimationEvent;
  82073. }
  82074. }
  82075. declare module BABYLON {
  82076. /**
  82077. * Interface used to define a behavior
  82078. */
  82079. export interface Behavior<T> {
  82080. /** gets or sets behavior's name */
  82081. name: string;
  82082. /**
  82083. * Function called when the behavior needs to be initialized (after attaching it to a target)
  82084. */
  82085. init(): void;
  82086. /**
  82087. * Called when the behavior is attached to a target
  82088. * @param target defines the target where the behavior is attached to
  82089. */
  82090. attach(target: T): void;
  82091. /**
  82092. * Called when the behavior is detached from its target
  82093. */
  82094. detach(): void;
  82095. }
  82096. /**
  82097. * Interface implemented by classes supporting behaviors
  82098. */
  82099. export interface IBehaviorAware<T> {
  82100. /**
  82101. * Attach a behavior
  82102. * @param behavior defines the behavior to attach
  82103. * @returns the current host
  82104. */
  82105. addBehavior(behavior: Behavior<T>): T;
  82106. /**
  82107. * Remove a behavior from the current object
  82108. * @param behavior defines the behavior to detach
  82109. * @returns the current host
  82110. */
  82111. removeBehavior(behavior: Behavior<T>): T;
  82112. /**
  82113. * Gets a behavior using its name to search
  82114. * @param name defines the name to search
  82115. * @returns the behavior or null if not found
  82116. */
  82117. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  82118. }
  82119. }
  82120. declare module BABYLON {
  82121. /**
  82122. * Defines an array and its length.
  82123. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  82124. */
  82125. export interface ISmartArrayLike<T> {
  82126. /**
  82127. * The data of the array.
  82128. */
  82129. data: Array<T>;
  82130. /**
  82131. * The active length of the array.
  82132. */
  82133. length: number;
  82134. }
  82135. /**
  82136. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  82137. */
  82138. export class SmartArray<T> implements ISmartArrayLike<T> {
  82139. /**
  82140. * The full set of data from the array.
  82141. */
  82142. data: Array<T>;
  82143. /**
  82144. * The active length of the array.
  82145. */
  82146. length: number;
  82147. protected _id: number;
  82148. /**
  82149. * Instantiates a Smart Array.
  82150. * @param capacity defines the default capacity of the array.
  82151. */
  82152. constructor(capacity: number);
  82153. /**
  82154. * Pushes a value at the end of the active data.
  82155. * @param value defines the object to push in the array.
  82156. */
  82157. push(value: T): void;
  82158. /**
  82159. * Iterates over the active data and apply the lambda to them.
  82160. * @param func defines the action to apply on each value.
  82161. */
  82162. forEach(func: (content: T) => void): void;
  82163. /**
  82164. * Sorts the full sets of data.
  82165. * @param compareFn defines the comparison function to apply.
  82166. */
  82167. sort(compareFn: (a: T, b: T) => number): void;
  82168. /**
  82169. * Resets the active data to an empty array.
  82170. */
  82171. reset(): void;
  82172. /**
  82173. * Releases all the data from the array as well as the array.
  82174. */
  82175. dispose(): void;
  82176. /**
  82177. * Concats the active data with a given array.
  82178. * @param array defines the data to concatenate with.
  82179. */
  82180. concat(array: any): void;
  82181. /**
  82182. * Returns the position of a value in the active data.
  82183. * @param value defines the value to find the index for
  82184. * @returns the index if found in the active data otherwise -1
  82185. */
  82186. indexOf(value: T): number;
  82187. /**
  82188. * Returns whether an element is part of the active data.
  82189. * @param value defines the value to look for
  82190. * @returns true if found in the active data otherwise false
  82191. */
  82192. contains(value: T): boolean;
  82193. private static _GlobalId;
  82194. }
  82195. /**
  82196. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  82197. * The data in this array can only be present once
  82198. */
  82199. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  82200. private _duplicateId;
  82201. /**
  82202. * Pushes a value at the end of the active data.
  82203. * THIS DOES NOT PREVENT DUPPLICATE DATA
  82204. * @param value defines the object to push in the array.
  82205. */
  82206. push(value: T): void;
  82207. /**
  82208. * Pushes a value at the end of the active data.
  82209. * If the data is already present, it won t be added again
  82210. * @param value defines the object to push in the array.
  82211. * @returns true if added false if it was already present
  82212. */
  82213. pushNoDuplicate(value: T): boolean;
  82214. /**
  82215. * Resets the active data to an empty array.
  82216. */
  82217. reset(): void;
  82218. /**
  82219. * Concats the active data with a given array.
  82220. * This ensures no dupplicate will be present in the result.
  82221. * @param array defines the data to concatenate with.
  82222. */
  82223. concatWithNoDuplicate(array: any): void;
  82224. }
  82225. }
  82226. declare module BABYLON {
  82227. /**
  82228. * @ignore
  82229. * This is a list of all the different input types that are available in the application.
  82230. * Fo instance: ArcRotateCameraGamepadInput...
  82231. */
  82232. export var CameraInputTypes: {};
  82233. /**
  82234. * This is the contract to implement in order to create a new input class.
  82235. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  82236. */
  82237. export interface ICameraInput<TCamera extends Camera> {
  82238. /**
  82239. * Defines the camera the input is attached to.
  82240. */
  82241. camera: Nullable<TCamera>;
  82242. /**
  82243. * Gets the class name of the current intput.
  82244. * @returns the class name
  82245. */
  82246. getClassName(): string;
  82247. /**
  82248. * Get the friendly name associated with the input class.
  82249. * @returns the input friendly name
  82250. */
  82251. getSimpleName(): string;
  82252. /**
  82253. * Attach the input controls to a specific dom element to get the input from.
  82254. * @param element Defines the element the controls should be listened from
  82255. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  82256. */
  82257. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  82258. /**
  82259. * Detach the current controls from the specified dom element.
  82260. * @param element Defines the element to stop listening the inputs from
  82261. */
  82262. detachControl(element: Nullable<HTMLElement>): void;
  82263. /**
  82264. * Update the current camera state depending on the inputs that have been used this frame.
  82265. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  82266. */
  82267. checkInputs?: () => void;
  82268. }
  82269. /**
  82270. * Represents a map of input types to input instance or input index to input instance.
  82271. */
  82272. export interface CameraInputsMap<TCamera extends Camera> {
  82273. /**
  82274. * Accessor to the input by input type.
  82275. */
  82276. [name: string]: ICameraInput<TCamera>;
  82277. /**
  82278. * Accessor to the input by input index.
  82279. */
  82280. [idx: number]: ICameraInput<TCamera>;
  82281. }
  82282. /**
  82283. * This represents the input manager used within a camera.
  82284. * It helps dealing with all the different kind of input attached to a camera.
  82285. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  82286. */
  82287. export class CameraInputsManager<TCamera extends Camera> {
  82288. /**
  82289. * Defines the list of inputs attahed to the camera.
  82290. */
  82291. attached: CameraInputsMap<TCamera>;
  82292. /**
  82293. * Defines the dom element the camera is collecting inputs from.
  82294. * This is null if the controls have not been attached.
  82295. */
  82296. attachedElement: Nullable<HTMLElement>;
  82297. /**
  82298. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  82299. */
  82300. noPreventDefault: boolean;
  82301. /**
  82302. * Defined the camera the input manager belongs to.
  82303. */
  82304. camera: TCamera;
  82305. /**
  82306. * Update the current camera state depending on the inputs that have been used this frame.
  82307. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  82308. */
  82309. checkInputs: () => void;
  82310. /**
  82311. * Instantiate a new Camera Input Manager.
  82312. * @param camera Defines the camera the input manager blongs to
  82313. */
  82314. constructor(camera: TCamera);
  82315. /**
  82316. * Add an input method to a camera
  82317. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  82318. * @param input camera input method
  82319. */
  82320. add(input: ICameraInput<TCamera>): void;
  82321. /**
  82322. * Remove a specific input method from a camera
  82323. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  82324. * @param inputToRemove camera input method
  82325. */
  82326. remove(inputToRemove: ICameraInput<TCamera>): void;
  82327. /**
  82328. * Remove a specific input type from a camera
  82329. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  82330. * @param inputType the type of the input to remove
  82331. */
  82332. removeByType(inputType: string): void;
  82333. private _addCheckInputs;
  82334. /**
  82335. * Attach the input controls to the currently attached dom element to listen the events from.
  82336. * @param input Defines the input to attach
  82337. */
  82338. attachInput(input: ICameraInput<TCamera>): void;
  82339. /**
  82340. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  82341. * @param element Defines the dom element to collect the events from
  82342. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  82343. */
  82344. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  82345. /**
  82346. * Detach the current manager inputs controls from a specific dom element.
  82347. * @param element Defines the dom element to collect the events from
  82348. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  82349. */
  82350. detachElement(element: HTMLElement, disconnect?: boolean): void;
  82351. /**
  82352. * Rebuild the dynamic inputCheck function from the current list of
  82353. * defined inputs in the manager.
  82354. */
  82355. rebuildInputCheck(): void;
  82356. /**
  82357. * Remove all attached input methods from a camera
  82358. */
  82359. clear(): void;
  82360. /**
  82361. * Serialize the current input manager attached to a camera.
  82362. * This ensures than once parsed,
  82363. * the input associated to the camera will be identical to the current ones
  82364. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  82365. */
  82366. serialize(serializedCamera: any): void;
  82367. /**
  82368. * Parses an input manager serialized JSON to restore the previous list of inputs
  82369. * and states associated to a camera.
  82370. * @param parsedCamera Defines the JSON to parse
  82371. */
  82372. parse(parsedCamera: any): void;
  82373. }
  82374. }
  82375. declare module BABYLON {
  82376. /**
  82377. * Class used to store data that will be store in GPU memory
  82378. */
  82379. export class Buffer {
  82380. private _engine;
  82381. private _buffer;
  82382. /** @hidden */
  82383. _data: Nullable<DataArray>;
  82384. private _updatable;
  82385. private _instanced;
  82386. private _divisor;
  82387. /**
  82388. * Gets the byte stride.
  82389. */
  82390. readonly byteStride: number;
  82391. /**
  82392. * Constructor
  82393. * @param engine the engine
  82394. * @param data the data to use for this buffer
  82395. * @param updatable whether the data is updatable
  82396. * @param stride the stride (optional)
  82397. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  82398. * @param instanced whether the buffer is instanced (optional)
  82399. * @param useBytes set to true if the stride in in bytes (optional)
  82400. * @param divisor sets an optional divisor for instances (1 by default)
  82401. */
  82402. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  82403. /**
  82404. * Create a new VertexBuffer based on the current buffer
  82405. * @param kind defines the vertex buffer kind (position, normal, etc.)
  82406. * @param offset defines offset in the buffer (0 by default)
  82407. * @param size defines the size in floats of attributes (position is 3 for instance)
  82408. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  82409. * @param instanced defines if the vertex buffer contains indexed data
  82410. * @param useBytes defines if the offset and stride are in bytes *
  82411. * @param divisor sets an optional divisor for instances (1 by default)
  82412. * @returns the new vertex buffer
  82413. */
  82414. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  82415. /**
  82416. * Gets a boolean indicating if the Buffer is updatable?
  82417. * @returns true if the buffer is updatable
  82418. */
  82419. isUpdatable(): boolean;
  82420. /**
  82421. * Gets current buffer's data
  82422. * @returns a DataArray or null
  82423. */
  82424. getData(): Nullable<DataArray>;
  82425. /**
  82426. * Gets underlying native buffer
  82427. * @returns underlying native buffer
  82428. */
  82429. getBuffer(): Nullable<DataBuffer>;
  82430. /**
  82431. * Gets the stride in float32 units (i.e. byte stride / 4).
  82432. * May not be an integer if the byte stride is not divisible by 4.
  82433. * @returns the stride in float32 units
  82434. * @deprecated Please use byteStride instead.
  82435. */
  82436. getStrideSize(): number;
  82437. /**
  82438. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  82439. * @param data defines the data to store
  82440. */
  82441. create(data?: Nullable<DataArray>): void;
  82442. /** @hidden */
  82443. _rebuild(): void;
  82444. /**
  82445. * Update current buffer data
  82446. * @param data defines the data to store
  82447. */
  82448. update(data: DataArray): void;
  82449. /**
  82450. * Updates the data directly.
  82451. * @param data the new data
  82452. * @param offset the new offset
  82453. * @param vertexCount the vertex count (optional)
  82454. * @param useBytes set to true if the offset is in bytes
  82455. */
  82456. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  82457. /**
  82458. * Release all resources
  82459. */
  82460. dispose(): void;
  82461. }
  82462. /**
  82463. * Specialized buffer used to store vertex data
  82464. */
  82465. export class VertexBuffer {
  82466. /** @hidden */
  82467. _buffer: Buffer;
  82468. private _kind;
  82469. private _size;
  82470. private _ownsBuffer;
  82471. private _instanced;
  82472. private _instanceDivisor;
  82473. /**
  82474. * The byte type.
  82475. */
  82476. static readonly BYTE: number;
  82477. /**
  82478. * The unsigned byte type.
  82479. */
  82480. static readonly UNSIGNED_BYTE: number;
  82481. /**
  82482. * The short type.
  82483. */
  82484. static readonly SHORT: number;
  82485. /**
  82486. * The unsigned short type.
  82487. */
  82488. static readonly UNSIGNED_SHORT: number;
  82489. /**
  82490. * The integer type.
  82491. */
  82492. static readonly INT: number;
  82493. /**
  82494. * The unsigned integer type.
  82495. */
  82496. static readonly UNSIGNED_INT: number;
  82497. /**
  82498. * The float type.
  82499. */
  82500. static readonly FLOAT: number;
  82501. /**
  82502. * Gets or sets the instance divisor when in instanced mode
  82503. */
  82504. get instanceDivisor(): number;
  82505. set instanceDivisor(value: number);
  82506. /**
  82507. * Gets the byte stride.
  82508. */
  82509. readonly byteStride: number;
  82510. /**
  82511. * Gets the byte offset.
  82512. */
  82513. readonly byteOffset: number;
  82514. /**
  82515. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  82516. */
  82517. readonly normalized: boolean;
  82518. /**
  82519. * Gets the data type of each component in the array.
  82520. */
  82521. readonly type: number;
  82522. /**
  82523. * Constructor
  82524. * @param engine the engine
  82525. * @param data the data to use for this vertex buffer
  82526. * @param kind the vertex buffer kind
  82527. * @param updatable whether the data is updatable
  82528. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  82529. * @param stride the stride (optional)
  82530. * @param instanced whether the buffer is instanced (optional)
  82531. * @param offset the offset of the data (optional)
  82532. * @param size the number of components (optional)
  82533. * @param type the type of the component (optional)
  82534. * @param normalized whether the data contains normalized data (optional)
  82535. * @param useBytes set to true if stride and offset are in bytes (optional)
  82536. * @param divisor defines the instance divisor to use (1 by default)
  82537. */
  82538. 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);
  82539. /** @hidden */
  82540. _rebuild(): void;
  82541. /**
  82542. * Returns the kind of the VertexBuffer (string)
  82543. * @returns a string
  82544. */
  82545. getKind(): string;
  82546. /**
  82547. * Gets a boolean indicating if the VertexBuffer is updatable?
  82548. * @returns true if the buffer is updatable
  82549. */
  82550. isUpdatable(): boolean;
  82551. /**
  82552. * Gets current buffer's data
  82553. * @returns a DataArray or null
  82554. */
  82555. getData(): Nullable<DataArray>;
  82556. /**
  82557. * Gets underlying native buffer
  82558. * @returns underlying native buffer
  82559. */
  82560. getBuffer(): Nullable<DataBuffer>;
  82561. /**
  82562. * Gets the stride in float32 units (i.e. byte stride / 4).
  82563. * May not be an integer if the byte stride is not divisible by 4.
  82564. * @returns the stride in float32 units
  82565. * @deprecated Please use byteStride instead.
  82566. */
  82567. getStrideSize(): number;
  82568. /**
  82569. * Returns the offset as a multiple of the type byte length.
  82570. * @returns the offset in bytes
  82571. * @deprecated Please use byteOffset instead.
  82572. */
  82573. getOffset(): number;
  82574. /**
  82575. * Returns the number of components per vertex attribute (integer)
  82576. * @returns the size in float
  82577. */
  82578. getSize(): number;
  82579. /**
  82580. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  82581. * @returns true if this buffer is instanced
  82582. */
  82583. getIsInstanced(): boolean;
  82584. /**
  82585. * Returns the instancing divisor, zero for non-instanced (integer).
  82586. * @returns a number
  82587. */
  82588. getInstanceDivisor(): number;
  82589. /**
  82590. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  82591. * @param data defines the data to store
  82592. */
  82593. create(data?: DataArray): void;
  82594. /**
  82595. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  82596. * This function will create a new buffer if the current one is not updatable
  82597. * @param data defines the data to store
  82598. */
  82599. update(data: DataArray): void;
  82600. /**
  82601. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  82602. * Returns the directly updated WebGLBuffer.
  82603. * @param data the new data
  82604. * @param offset the new offset
  82605. * @param useBytes set to true if the offset is in bytes
  82606. */
  82607. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  82608. /**
  82609. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  82610. */
  82611. dispose(): void;
  82612. /**
  82613. * Enumerates each value of this vertex buffer as numbers.
  82614. * @param count the number of values to enumerate
  82615. * @param callback the callback function called for each value
  82616. */
  82617. forEach(count: number, callback: (value: number, index: number) => void): void;
  82618. /**
  82619. * Positions
  82620. */
  82621. static readonly PositionKind: string;
  82622. /**
  82623. * Normals
  82624. */
  82625. static readonly NormalKind: string;
  82626. /**
  82627. * Tangents
  82628. */
  82629. static readonly TangentKind: string;
  82630. /**
  82631. * Texture coordinates
  82632. */
  82633. static readonly UVKind: string;
  82634. /**
  82635. * Texture coordinates 2
  82636. */
  82637. static readonly UV2Kind: string;
  82638. /**
  82639. * Texture coordinates 3
  82640. */
  82641. static readonly UV3Kind: string;
  82642. /**
  82643. * Texture coordinates 4
  82644. */
  82645. static readonly UV4Kind: string;
  82646. /**
  82647. * Texture coordinates 5
  82648. */
  82649. static readonly UV5Kind: string;
  82650. /**
  82651. * Texture coordinates 6
  82652. */
  82653. static readonly UV6Kind: string;
  82654. /**
  82655. * Colors
  82656. */
  82657. static readonly ColorKind: string;
  82658. /**
  82659. * Matrix indices (for bones)
  82660. */
  82661. static readonly MatricesIndicesKind: string;
  82662. /**
  82663. * Matrix weights (for bones)
  82664. */
  82665. static readonly MatricesWeightsKind: string;
  82666. /**
  82667. * Additional matrix indices (for bones)
  82668. */
  82669. static readonly MatricesIndicesExtraKind: string;
  82670. /**
  82671. * Additional matrix weights (for bones)
  82672. */
  82673. static readonly MatricesWeightsExtraKind: string;
  82674. /**
  82675. * Deduces the stride given a kind.
  82676. * @param kind The kind string to deduce
  82677. * @returns The deduced stride
  82678. */
  82679. static DeduceStride(kind: string): number;
  82680. /**
  82681. * Gets the byte length of the given type.
  82682. * @param type the type
  82683. * @returns the number of bytes
  82684. */
  82685. static GetTypeByteLength(type: number): number;
  82686. /**
  82687. * Enumerates each value of the given parameters as numbers.
  82688. * @param data the data to enumerate
  82689. * @param byteOffset the byte offset of the data
  82690. * @param byteStride the byte stride of the data
  82691. * @param componentCount the number of components per element
  82692. * @param componentType the type of the component
  82693. * @param count the number of values to enumerate
  82694. * @param normalized whether the data is normalized
  82695. * @param callback the callback function called for each value
  82696. */
  82697. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  82698. private static _GetFloatValue;
  82699. }
  82700. }
  82701. declare module BABYLON {
  82702. /**
  82703. * @hidden
  82704. */
  82705. export class IntersectionInfo {
  82706. bu: Nullable<number>;
  82707. bv: Nullable<number>;
  82708. distance: number;
  82709. faceId: number;
  82710. subMeshId: number;
  82711. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  82712. }
  82713. }
  82714. declare module BABYLON {
  82715. /**
  82716. * Class used to store bounding sphere information
  82717. */
  82718. export class BoundingSphere {
  82719. /**
  82720. * Gets the center of the bounding sphere in local space
  82721. */
  82722. readonly center: Vector3;
  82723. /**
  82724. * Radius of the bounding sphere in local space
  82725. */
  82726. radius: number;
  82727. /**
  82728. * Gets the center of the bounding sphere in world space
  82729. */
  82730. readonly centerWorld: Vector3;
  82731. /**
  82732. * Radius of the bounding sphere in world space
  82733. */
  82734. radiusWorld: number;
  82735. /**
  82736. * Gets the minimum vector in local space
  82737. */
  82738. readonly minimum: Vector3;
  82739. /**
  82740. * Gets the maximum vector in local space
  82741. */
  82742. readonly maximum: Vector3;
  82743. private _worldMatrix;
  82744. private static readonly TmpVector3;
  82745. /**
  82746. * Creates a new bounding sphere
  82747. * @param min defines the minimum vector (in local space)
  82748. * @param max defines the maximum vector (in local space)
  82749. * @param worldMatrix defines the new world matrix
  82750. */
  82751. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  82752. /**
  82753. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  82754. * @param min defines the new minimum vector (in local space)
  82755. * @param max defines the new maximum vector (in local space)
  82756. * @param worldMatrix defines the new world matrix
  82757. */
  82758. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  82759. /**
  82760. * Scale the current bounding sphere by applying a scale factor
  82761. * @param factor defines the scale factor to apply
  82762. * @returns the current bounding box
  82763. */
  82764. scale(factor: number): BoundingSphere;
  82765. /**
  82766. * Gets the world matrix of the bounding box
  82767. * @returns a matrix
  82768. */
  82769. getWorldMatrix(): DeepImmutable<Matrix>;
  82770. /** @hidden */
  82771. _update(worldMatrix: DeepImmutable<Matrix>): void;
  82772. /**
  82773. * Tests if the bounding sphere is intersecting the frustum planes
  82774. * @param frustumPlanes defines the frustum planes to test
  82775. * @returns true if there is an intersection
  82776. */
  82777. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  82778. /**
  82779. * Tests if the bounding sphere center is in between the frustum planes.
  82780. * Used for optimistic fast inclusion.
  82781. * @param frustumPlanes defines the frustum planes to test
  82782. * @returns true if the sphere center is in between the frustum planes
  82783. */
  82784. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  82785. /**
  82786. * Tests if a point is inside the bounding sphere
  82787. * @param point defines the point to test
  82788. * @returns true if the point is inside the bounding sphere
  82789. */
  82790. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  82791. /**
  82792. * Checks if two sphere intersct
  82793. * @param sphere0 sphere 0
  82794. * @param sphere1 sphere 1
  82795. * @returns true if the speres intersect
  82796. */
  82797. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  82798. }
  82799. }
  82800. declare module BABYLON {
  82801. /**
  82802. * Class used to store bounding box information
  82803. */
  82804. export class BoundingBox implements ICullable {
  82805. /**
  82806. * Gets the 8 vectors representing the bounding box in local space
  82807. */
  82808. readonly vectors: Vector3[];
  82809. /**
  82810. * Gets the center of the bounding box in local space
  82811. */
  82812. readonly center: Vector3;
  82813. /**
  82814. * Gets the center of the bounding box in world space
  82815. */
  82816. readonly centerWorld: Vector3;
  82817. /**
  82818. * Gets the extend size in local space
  82819. */
  82820. readonly extendSize: Vector3;
  82821. /**
  82822. * Gets the extend size in world space
  82823. */
  82824. readonly extendSizeWorld: Vector3;
  82825. /**
  82826. * Gets the OBB (object bounding box) directions
  82827. */
  82828. readonly directions: Vector3[];
  82829. /**
  82830. * Gets the 8 vectors representing the bounding box in world space
  82831. */
  82832. readonly vectorsWorld: Vector3[];
  82833. /**
  82834. * Gets the minimum vector in world space
  82835. */
  82836. readonly minimumWorld: Vector3;
  82837. /**
  82838. * Gets the maximum vector in world space
  82839. */
  82840. readonly maximumWorld: Vector3;
  82841. /**
  82842. * Gets the minimum vector in local space
  82843. */
  82844. readonly minimum: Vector3;
  82845. /**
  82846. * Gets the maximum vector in local space
  82847. */
  82848. readonly maximum: Vector3;
  82849. private _worldMatrix;
  82850. private static readonly TmpVector3;
  82851. /**
  82852. * @hidden
  82853. */
  82854. _tag: number;
  82855. /**
  82856. * Creates a new bounding box
  82857. * @param min defines the minimum vector (in local space)
  82858. * @param max defines the maximum vector (in local space)
  82859. * @param worldMatrix defines the new world matrix
  82860. */
  82861. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  82862. /**
  82863. * Recreates the entire bounding box from scratch as if we call the constructor in place
  82864. * @param min defines the new minimum vector (in local space)
  82865. * @param max defines the new maximum vector (in local space)
  82866. * @param worldMatrix defines the new world matrix
  82867. */
  82868. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  82869. /**
  82870. * Scale the current bounding box by applying a scale factor
  82871. * @param factor defines the scale factor to apply
  82872. * @returns the current bounding box
  82873. */
  82874. scale(factor: number): BoundingBox;
  82875. /**
  82876. * Gets the world matrix of the bounding box
  82877. * @returns a matrix
  82878. */
  82879. getWorldMatrix(): DeepImmutable<Matrix>;
  82880. /** @hidden */
  82881. _update(world: DeepImmutable<Matrix>): void;
  82882. /**
  82883. * Tests if the bounding box is intersecting the frustum planes
  82884. * @param frustumPlanes defines the frustum planes to test
  82885. * @returns true if there is an intersection
  82886. */
  82887. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  82888. /**
  82889. * Tests if the bounding box is entirely inside the frustum planes
  82890. * @param frustumPlanes defines the frustum planes to test
  82891. * @returns true if there is an inclusion
  82892. */
  82893. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  82894. /**
  82895. * Tests if a point is inside the bounding box
  82896. * @param point defines the point to test
  82897. * @returns true if the point is inside the bounding box
  82898. */
  82899. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  82900. /**
  82901. * Tests if the bounding box intersects with a bounding sphere
  82902. * @param sphere defines the sphere to test
  82903. * @returns true if there is an intersection
  82904. */
  82905. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  82906. /**
  82907. * Tests if the bounding box intersects with a box defined by a min and max vectors
  82908. * @param min defines the min vector to use
  82909. * @param max defines the max vector to use
  82910. * @returns true if there is an intersection
  82911. */
  82912. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  82913. /**
  82914. * Tests if two bounding boxes are intersections
  82915. * @param box0 defines the first box to test
  82916. * @param box1 defines the second box to test
  82917. * @returns true if there is an intersection
  82918. */
  82919. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  82920. /**
  82921. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  82922. * @param minPoint defines the minimum vector of the bounding box
  82923. * @param maxPoint defines the maximum vector of the bounding box
  82924. * @param sphereCenter defines the sphere center
  82925. * @param sphereRadius defines the sphere radius
  82926. * @returns true if there is an intersection
  82927. */
  82928. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  82929. /**
  82930. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  82931. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  82932. * @param frustumPlanes defines the frustum planes to test
  82933. * @return true if there is an inclusion
  82934. */
  82935. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  82936. /**
  82937. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  82938. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  82939. * @param frustumPlanes defines the frustum planes to test
  82940. * @return true if there is an intersection
  82941. */
  82942. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  82943. }
  82944. }
  82945. declare module BABYLON {
  82946. /** @hidden */
  82947. export class Collider {
  82948. /** Define if a collision was found */
  82949. collisionFound: boolean;
  82950. /**
  82951. * Define last intersection point in local space
  82952. */
  82953. intersectionPoint: Vector3;
  82954. /**
  82955. * Define last collided mesh
  82956. */
  82957. collidedMesh: Nullable<AbstractMesh>;
  82958. private _collisionPoint;
  82959. private _planeIntersectionPoint;
  82960. private _tempVector;
  82961. private _tempVector2;
  82962. private _tempVector3;
  82963. private _tempVector4;
  82964. private _edge;
  82965. private _baseToVertex;
  82966. private _destinationPoint;
  82967. private _slidePlaneNormal;
  82968. private _displacementVector;
  82969. /** @hidden */
  82970. _radius: Vector3;
  82971. /** @hidden */
  82972. _retry: number;
  82973. private _velocity;
  82974. private _basePoint;
  82975. private _epsilon;
  82976. /** @hidden */
  82977. _velocityWorldLength: number;
  82978. /** @hidden */
  82979. _basePointWorld: Vector3;
  82980. private _velocityWorld;
  82981. private _normalizedVelocity;
  82982. /** @hidden */
  82983. _initialVelocity: Vector3;
  82984. /** @hidden */
  82985. _initialPosition: Vector3;
  82986. private _nearestDistance;
  82987. private _collisionMask;
  82988. get collisionMask(): number;
  82989. set collisionMask(mask: number);
  82990. /**
  82991. * Gets the plane normal used to compute the sliding response (in local space)
  82992. */
  82993. get slidePlaneNormal(): Vector3;
  82994. /** @hidden */
  82995. _initialize(source: Vector3, dir: Vector3, e: number): void;
  82996. /** @hidden */
  82997. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  82998. /** @hidden */
  82999. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  83000. /** @hidden */
  83001. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  83002. /** @hidden */
  83003. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  83004. /** @hidden */
  83005. _getResponse(pos: Vector3, vel: Vector3): void;
  83006. }
  83007. }
  83008. declare module BABYLON {
  83009. /**
  83010. * Interface for cullable objects
  83011. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  83012. */
  83013. export interface ICullable {
  83014. /**
  83015. * Checks if the object or part of the object is in the frustum
  83016. * @param frustumPlanes Camera near/planes
  83017. * @returns true if the object is in frustum otherwise false
  83018. */
  83019. isInFrustum(frustumPlanes: Plane[]): boolean;
  83020. /**
  83021. * Checks if a cullable object (mesh...) is in the camera frustum
  83022. * Unlike isInFrustum this cheks the full bounding box
  83023. * @param frustumPlanes Camera near/planes
  83024. * @returns true if the object is in frustum otherwise false
  83025. */
  83026. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  83027. }
  83028. /**
  83029. * Info for a bounding data of a mesh
  83030. */
  83031. export class BoundingInfo implements ICullable {
  83032. /**
  83033. * Bounding box for the mesh
  83034. */
  83035. readonly boundingBox: BoundingBox;
  83036. /**
  83037. * Bounding sphere for the mesh
  83038. */
  83039. readonly boundingSphere: BoundingSphere;
  83040. private _isLocked;
  83041. private static readonly TmpVector3;
  83042. /**
  83043. * Constructs bounding info
  83044. * @param minimum min vector of the bounding box/sphere
  83045. * @param maximum max vector of the bounding box/sphere
  83046. * @param worldMatrix defines the new world matrix
  83047. */
  83048. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  83049. /**
  83050. * Recreates the entire bounding info from scratch as if we call the constructor in place
  83051. * @param min defines the new minimum vector (in local space)
  83052. * @param max defines the new maximum vector (in local space)
  83053. * @param worldMatrix defines the new world matrix
  83054. */
  83055. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  83056. /**
  83057. * min vector of the bounding box/sphere
  83058. */
  83059. get minimum(): Vector3;
  83060. /**
  83061. * max vector of the bounding box/sphere
  83062. */
  83063. get maximum(): Vector3;
  83064. /**
  83065. * If the info is locked and won't be updated to avoid perf overhead
  83066. */
  83067. get isLocked(): boolean;
  83068. set isLocked(value: boolean);
  83069. /**
  83070. * Updates the bounding sphere and box
  83071. * @param world world matrix to be used to update
  83072. */
  83073. update(world: DeepImmutable<Matrix>): void;
  83074. /**
  83075. * Recreate the bounding info to be centered around a specific point given a specific extend.
  83076. * @param center New center of the bounding info
  83077. * @param extend New extend of the bounding info
  83078. * @returns the current bounding info
  83079. */
  83080. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  83081. /**
  83082. * Scale the current bounding info by applying a scale factor
  83083. * @param factor defines the scale factor to apply
  83084. * @returns the current bounding info
  83085. */
  83086. scale(factor: number): BoundingInfo;
  83087. /**
  83088. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  83089. * @param frustumPlanes defines the frustum to test
  83090. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  83091. * @returns true if the bounding info is in the frustum planes
  83092. */
  83093. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  83094. /**
  83095. * Gets the world distance between the min and max points of the bounding box
  83096. */
  83097. get diagonalLength(): number;
  83098. /**
  83099. * Checks if a cullable object (mesh...) is in the camera frustum
  83100. * Unlike isInFrustum this cheks the full bounding box
  83101. * @param frustumPlanes Camera near/planes
  83102. * @returns true if the object is in frustum otherwise false
  83103. */
  83104. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  83105. /** @hidden */
  83106. _checkCollision(collider: Collider): boolean;
  83107. /**
  83108. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  83109. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  83110. * @param point the point to check intersection with
  83111. * @returns if the point intersects
  83112. */
  83113. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  83114. /**
  83115. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  83116. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  83117. * @param boundingInfo the bounding info to check intersection with
  83118. * @param precise if the intersection should be done using OBB
  83119. * @returns if the bounding info intersects
  83120. */
  83121. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  83122. }
  83123. }
  83124. declare module BABYLON {
  83125. /**
  83126. * Extracts minimum and maximum values from a list of indexed positions
  83127. * @param positions defines the positions to use
  83128. * @param indices defines the indices to the positions
  83129. * @param indexStart defines the start index
  83130. * @param indexCount defines the end index
  83131. * @param bias defines bias value to add to the result
  83132. * @return minimum and maximum values
  83133. */
  83134. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  83135. minimum: Vector3;
  83136. maximum: Vector3;
  83137. };
  83138. /**
  83139. * Extracts minimum and maximum values from a list of positions
  83140. * @param positions defines the positions to use
  83141. * @param start defines the start index in the positions array
  83142. * @param count defines the number of positions to handle
  83143. * @param bias defines bias value to add to the result
  83144. * @param stride defines the stride size to use (distance between two positions in the positions array)
  83145. * @return minimum and maximum values
  83146. */
  83147. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  83148. minimum: Vector3;
  83149. maximum: Vector3;
  83150. };
  83151. }
  83152. declare module BABYLON {
  83153. /** @hidden */
  83154. export class WebGLDataBuffer extends DataBuffer {
  83155. private _buffer;
  83156. constructor(resource: WebGLBuffer);
  83157. get underlyingResource(): any;
  83158. }
  83159. }
  83160. declare module BABYLON {
  83161. /** @hidden */
  83162. export class WebGLPipelineContext implements IPipelineContext {
  83163. engine: ThinEngine;
  83164. program: Nullable<WebGLProgram>;
  83165. context?: WebGLRenderingContext;
  83166. vertexShader?: WebGLShader;
  83167. fragmentShader?: WebGLShader;
  83168. isParallelCompiled: boolean;
  83169. onCompiled?: () => void;
  83170. transformFeedback?: WebGLTransformFeedback | null;
  83171. vertexCompilationError: Nullable<string>;
  83172. fragmentCompilationError: Nullable<string>;
  83173. programLinkError: Nullable<string>;
  83174. programValidationError: Nullable<string>;
  83175. get isAsync(): boolean;
  83176. get isReady(): boolean;
  83177. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  83178. _getVertexShaderCode(): string | null;
  83179. _getFragmentShaderCode(): string | null;
  83180. }
  83181. }
  83182. declare module BABYLON {
  83183. interface ThinEngine {
  83184. /**
  83185. * Create an uniform buffer
  83186. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  83187. * @param elements defines the content of the uniform buffer
  83188. * @returns the webGL uniform buffer
  83189. */
  83190. createUniformBuffer(elements: FloatArray): DataBuffer;
  83191. /**
  83192. * Create a dynamic uniform buffer
  83193. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  83194. * @param elements defines the content of the uniform buffer
  83195. * @returns the webGL uniform buffer
  83196. */
  83197. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  83198. /**
  83199. * Update an existing uniform buffer
  83200. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  83201. * @param uniformBuffer defines the target uniform buffer
  83202. * @param elements defines the content to update
  83203. * @param offset defines the offset in the uniform buffer where update should start
  83204. * @param count defines the size of the data to update
  83205. */
  83206. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  83207. /**
  83208. * Bind an uniform buffer to the current webGL context
  83209. * @param buffer defines the buffer to bind
  83210. */
  83211. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  83212. /**
  83213. * Bind a buffer to the current webGL context at a given location
  83214. * @param buffer defines the buffer to bind
  83215. * @param location defines the index where to bind the buffer
  83216. */
  83217. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  83218. /**
  83219. * Bind a specific block at a given index in a specific shader program
  83220. * @param pipelineContext defines the pipeline context to use
  83221. * @param blockName defines the block name
  83222. * @param index defines the index where to bind the block
  83223. */
  83224. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  83225. }
  83226. }
  83227. declare module BABYLON {
  83228. /**
  83229. * Uniform buffer objects.
  83230. *
  83231. * Handles blocks of uniform on the GPU.
  83232. *
  83233. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  83234. *
  83235. * For more information, please refer to :
  83236. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  83237. */
  83238. export class UniformBuffer {
  83239. private _engine;
  83240. private _buffer;
  83241. private _data;
  83242. private _bufferData;
  83243. private _dynamic?;
  83244. private _uniformLocations;
  83245. private _uniformSizes;
  83246. private _uniformLocationPointer;
  83247. private _needSync;
  83248. private _noUBO;
  83249. private _currentEffect;
  83250. /** @hidden */
  83251. _alreadyBound: boolean;
  83252. private static _MAX_UNIFORM_SIZE;
  83253. private static _tempBuffer;
  83254. /**
  83255. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  83256. * This is dynamic to allow compat with webgl 1 and 2.
  83257. * You will need to pass the name of the uniform as well as the value.
  83258. */
  83259. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  83260. /**
  83261. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  83262. * This is dynamic to allow compat with webgl 1 and 2.
  83263. * You will need to pass the name of the uniform as well as the value.
  83264. */
  83265. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  83266. /**
  83267. * Lambda to Update a single float in a uniform buffer.
  83268. * This is dynamic to allow compat with webgl 1 and 2.
  83269. * You will need to pass the name of the uniform as well as the value.
  83270. */
  83271. updateFloat: (name: string, x: number) => void;
  83272. /**
  83273. * Lambda to Update a vec2 of float in a uniform buffer.
  83274. * This is dynamic to allow compat with webgl 1 and 2.
  83275. * You will need to pass the name of the uniform as well as the value.
  83276. */
  83277. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  83278. /**
  83279. * Lambda to Update a vec3 of float in a uniform buffer.
  83280. * This is dynamic to allow compat with webgl 1 and 2.
  83281. * You will need to pass the name of the uniform as well as the value.
  83282. */
  83283. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  83284. /**
  83285. * Lambda to Update a vec4 of float in a uniform buffer.
  83286. * This is dynamic to allow compat with webgl 1 and 2.
  83287. * You will need to pass the name of the uniform as well as the value.
  83288. */
  83289. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  83290. /**
  83291. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  83292. * This is dynamic to allow compat with webgl 1 and 2.
  83293. * You will need to pass the name of the uniform as well as the value.
  83294. */
  83295. updateMatrix: (name: string, mat: Matrix) => void;
  83296. /**
  83297. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  83298. * This is dynamic to allow compat with webgl 1 and 2.
  83299. * You will need to pass the name of the uniform as well as the value.
  83300. */
  83301. updateVector3: (name: string, vector: Vector3) => void;
  83302. /**
  83303. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  83304. * This is dynamic to allow compat with webgl 1 and 2.
  83305. * You will need to pass the name of the uniform as well as the value.
  83306. */
  83307. updateVector4: (name: string, vector: Vector4) => void;
  83308. /**
  83309. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  83310. * This is dynamic to allow compat with webgl 1 and 2.
  83311. * You will need to pass the name of the uniform as well as the value.
  83312. */
  83313. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  83314. /**
  83315. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  83316. * This is dynamic to allow compat with webgl 1 and 2.
  83317. * You will need to pass the name of the uniform as well as the value.
  83318. */
  83319. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  83320. /**
  83321. * Instantiates a new Uniform buffer objects.
  83322. *
  83323. * Handles blocks of uniform on the GPU.
  83324. *
  83325. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  83326. *
  83327. * For more information, please refer to :
  83328. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  83329. * @param engine Define the engine the buffer is associated with
  83330. * @param data Define the data contained in the buffer
  83331. * @param dynamic Define if the buffer is updatable
  83332. */
  83333. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  83334. /**
  83335. * Indicates if the buffer is using the WebGL2 UBO implementation,
  83336. * or just falling back on setUniformXXX calls.
  83337. */
  83338. get useUbo(): boolean;
  83339. /**
  83340. * Indicates if the WebGL underlying uniform buffer is in sync
  83341. * with the javascript cache data.
  83342. */
  83343. get isSync(): boolean;
  83344. /**
  83345. * Indicates if the WebGL underlying uniform buffer is dynamic.
  83346. * Also, a dynamic UniformBuffer will disable cache verification and always
  83347. * update the underlying WebGL uniform buffer to the GPU.
  83348. * @returns if Dynamic, otherwise false
  83349. */
  83350. isDynamic(): boolean;
  83351. /**
  83352. * The data cache on JS side.
  83353. * @returns the underlying data as a float array
  83354. */
  83355. getData(): Float32Array;
  83356. /**
  83357. * The underlying WebGL Uniform buffer.
  83358. * @returns the webgl buffer
  83359. */
  83360. getBuffer(): Nullable<DataBuffer>;
  83361. /**
  83362. * std140 layout specifies how to align data within an UBO structure.
  83363. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  83364. * for specs.
  83365. */
  83366. private _fillAlignment;
  83367. /**
  83368. * Adds an uniform in the buffer.
  83369. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  83370. * for the layout to be correct !
  83371. * @param name Name of the uniform, as used in the uniform block in the shader.
  83372. * @param size Data size, or data directly.
  83373. */
  83374. addUniform(name: string, size: number | number[]): void;
  83375. /**
  83376. * Adds a Matrix 4x4 to the uniform buffer.
  83377. * @param name Name of the uniform, as used in the uniform block in the shader.
  83378. * @param mat A 4x4 matrix.
  83379. */
  83380. addMatrix(name: string, mat: Matrix): void;
  83381. /**
  83382. * Adds a vec2 to the uniform buffer.
  83383. * @param name Name of the uniform, as used in the uniform block in the shader.
  83384. * @param x Define the x component value of the vec2
  83385. * @param y Define the y component value of the vec2
  83386. */
  83387. addFloat2(name: string, x: number, y: number): void;
  83388. /**
  83389. * Adds a vec3 to the uniform buffer.
  83390. * @param name Name of the uniform, as used in the uniform block in the shader.
  83391. * @param x Define the x component value of the vec3
  83392. * @param y Define the y component value of the vec3
  83393. * @param z Define the z component value of the vec3
  83394. */
  83395. addFloat3(name: string, x: number, y: number, z: number): void;
  83396. /**
  83397. * Adds a vec3 to the uniform buffer.
  83398. * @param name Name of the uniform, as used in the uniform block in the shader.
  83399. * @param color Define the vec3 from a Color
  83400. */
  83401. addColor3(name: string, color: Color3): void;
  83402. /**
  83403. * Adds a vec4 to the uniform buffer.
  83404. * @param name Name of the uniform, as used in the uniform block in the shader.
  83405. * @param color Define the rgb components from a Color
  83406. * @param alpha Define the a component of the vec4
  83407. */
  83408. addColor4(name: string, color: Color3, alpha: number): void;
  83409. /**
  83410. * Adds a vec3 to the uniform buffer.
  83411. * @param name Name of the uniform, as used in the uniform block in the shader.
  83412. * @param vector Define the vec3 components from a Vector
  83413. */
  83414. addVector3(name: string, vector: Vector3): void;
  83415. /**
  83416. * Adds a Matrix 3x3 to the uniform buffer.
  83417. * @param name Name of the uniform, as used in the uniform block in the shader.
  83418. */
  83419. addMatrix3x3(name: string): void;
  83420. /**
  83421. * Adds a Matrix 2x2 to the uniform buffer.
  83422. * @param name Name of the uniform, as used in the uniform block in the shader.
  83423. */
  83424. addMatrix2x2(name: string): void;
  83425. /**
  83426. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  83427. */
  83428. create(): void;
  83429. /** @hidden */
  83430. _rebuild(): void;
  83431. /**
  83432. * Updates the WebGL Uniform Buffer on the GPU.
  83433. * If the `dynamic` flag is set to true, no cache comparison is done.
  83434. * Otherwise, the buffer will be updated only if the cache differs.
  83435. */
  83436. update(): void;
  83437. /**
  83438. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  83439. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  83440. * @param data Define the flattened data
  83441. * @param size Define the size of the data.
  83442. */
  83443. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  83444. private _valueCache;
  83445. private _cacheMatrix;
  83446. private _updateMatrix3x3ForUniform;
  83447. private _updateMatrix3x3ForEffect;
  83448. private _updateMatrix2x2ForEffect;
  83449. private _updateMatrix2x2ForUniform;
  83450. private _updateFloatForEffect;
  83451. private _updateFloatForUniform;
  83452. private _updateFloat2ForEffect;
  83453. private _updateFloat2ForUniform;
  83454. private _updateFloat3ForEffect;
  83455. private _updateFloat3ForUniform;
  83456. private _updateFloat4ForEffect;
  83457. private _updateFloat4ForUniform;
  83458. private _updateMatrixForEffect;
  83459. private _updateMatrixForUniform;
  83460. private _updateVector3ForEffect;
  83461. private _updateVector3ForUniform;
  83462. private _updateVector4ForEffect;
  83463. private _updateVector4ForUniform;
  83464. private _updateColor3ForEffect;
  83465. private _updateColor3ForUniform;
  83466. private _updateColor4ForEffect;
  83467. private _updateColor4ForUniform;
  83468. /**
  83469. * Sets a sampler uniform on the effect.
  83470. * @param name Define the name of the sampler.
  83471. * @param texture Define the texture to set in the sampler
  83472. */
  83473. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  83474. /**
  83475. * Directly updates the value of the uniform in the cache AND on the GPU.
  83476. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  83477. * @param data Define the flattened data
  83478. */
  83479. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  83480. /**
  83481. * Binds this uniform buffer to an effect.
  83482. * @param effect Define the effect to bind the buffer to
  83483. * @param name Name of the uniform block in the shader.
  83484. */
  83485. bindToEffect(effect: Effect, name: string): void;
  83486. /**
  83487. * Disposes the uniform buffer.
  83488. */
  83489. dispose(): void;
  83490. }
  83491. }
  83492. declare module BABYLON {
  83493. /**
  83494. * Enum that determines the text-wrapping mode to use.
  83495. */
  83496. export enum InspectableType {
  83497. /**
  83498. * Checkbox for booleans
  83499. */
  83500. Checkbox = 0,
  83501. /**
  83502. * Sliders for numbers
  83503. */
  83504. Slider = 1,
  83505. /**
  83506. * Vector3
  83507. */
  83508. Vector3 = 2,
  83509. /**
  83510. * Quaternions
  83511. */
  83512. Quaternion = 3,
  83513. /**
  83514. * Color3
  83515. */
  83516. Color3 = 4,
  83517. /**
  83518. * String
  83519. */
  83520. String = 5
  83521. }
  83522. /**
  83523. * Interface used to define custom inspectable properties.
  83524. * This interface is used by the inspector to display custom property grids
  83525. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  83526. */
  83527. export interface IInspectable {
  83528. /**
  83529. * Gets the label to display
  83530. */
  83531. label: string;
  83532. /**
  83533. * Gets the name of the property to edit
  83534. */
  83535. propertyName: string;
  83536. /**
  83537. * Gets the type of the editor to use
  83538. */
  83539. type: InspectableType;
  83540. /**
  83541. * Gets the minimum value of the property when using in "slider" mode
  83542. */
  83543. min?: number;
  83544. /**
  83545. * Gets the maximum value of the property when using in "slider" mode
  83546. */
  83547. max?: number;
  83548. /**
  83549. * Gets the setp to use when using in "slider" mode
  83550. */
  83551. step?: number;
  83552. }
  83553. }
  83554. declare module BABYLON {
  83555. /**
  83556. * Class used to provide helper for timing
  83557. */
  83558. export class TimingTools {
  83559. /**
  83560. * Polyfill for setImmediate
  83561. * @param action defines the action to execute after the current execution block
  83562. */
  83563. static SetImmediate(action: () => void): void;
  83564. }
  83565. }
  83566. declare module BABYLON {
  83567. /**
  83568. * Class used to enable instatition of objects by class name
  83569. */
  83570. export class InstantiationTools {
  83571. /**
  83572. * Use this object to register external classes like custom textures or material
  83573. * to allow the laoders to instantiate them
  83574. */
  83575. static RegisteredExternalClasses: {
  83576. [key: string]: Object;
  83577. };
  83578. /**
  83579. * Tries to instantiate a new object from a given class name
  83580. * @param className defines the class name to instantiate
  83581. * @returns the new object or null if the system was not able to do the instantiation
  83582. */
  83583. static Instantiate(className: string): any;
  83584. }
  83585. }
  83586. declare module BABYLON {
  83587. /**
  83588. * Define options used to create a depth texture
  83589. */
  83590. export class DepthTextureCreationOptions {
  83591. /** Specifies whether or not a stencil should be allocated in the texture */
  83592. generateStencil?: boolean;
  83593. /** Specifies whether or not bilinear filtering is enable on the texture */
  83594. bilinearFiltering?: boolean;
  83595. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  83596. comparisonFunction?: number;
  83597. /** Specifies if the created texture is a cube texture */
  83598. isCube?: boolean;
  83599. }
  83600. }
  83601. declare module BABYLON {
  83602. interface ThinEngine {
  83603. /**
  83604. * Creates a depth stencil cube texture.
  83605. * This is only available in WebGL 2.
  83606. * @param size The size of face edge in the cube texture.
  83607. * @param options The options defining the cube texture.
  83608. * @returns The cube texture
  83609. */
  83610. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  83611. /**
  83612. * Creates a cube texture
  83613. * @param rootUrl defines the url where the files to load is located
  83614. * @param scene defines the current scene
  83615. * @param files defines the list of files to load (1 per face)
  83616. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  83617. * @param onLoad defines an optional callback raised when the texture is loaded
  83618. * @param onError defines an optional callback raised if there is an issue to load the texture
  83619. * @param format defines the format of the data
  83620. * @param forcedExtension defines the extension to use to pick the right loader
  83621. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  83622. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  83623. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  83624. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  83625. * @returns the cube texture as an InternalTexture
  83626. */
  83627. 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;
  83628. /**
  83629. * Creates a cube texture
  83630. * @param rootUrl defines the url where the files to load is located
  83631. * @param scene defines the current scene
  83632. * @param files defines the list of files to load (1 per face)
  83633. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  83634. * @param onLoad defines an optional callback raised when the texture is loaded
  83635. * @param onError defines an optional callback raised if there is an issue to load the texture
  83636. * @param format defines the format of the data
  83637. * @param forcedExtension defines the extension to use to pick the right loader
  83638. * @returns the cube texture as an InternalTexture
  83639. */
  83640. 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;
  83641. /**
  83642. * Creates a cube texture
  83643. * @param rootUrl defines the url where the files to load is located
  83644. * @param scene defines the current scene
  83645. * @param files defines the list of files to load (1 per face)
  83646. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  83647. * @param onLoad defines an optional callback raised when the texture is loaded
  83648. * @param onError defines an optional callback raised if there is an issue to load the texture
  83649. * @param format defines the format of the data
  83650. * @param forcedExtension defines the extension to use to pick the right loader
  83651. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  83652. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  83653. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  83654. * @returns the cube texture as an InternalTexture
  83655. */
  83656. 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;
  83657. /** @hidden */
  83658. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  83659. /** @hidden */
  83660. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  83661. /** @hidden */
  83662. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  83663. /** @hidden */
  83664. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  83665. /**
  83666. * @hidden
  83667. */
  83668. _setCubeMapTextureParams(loadMipmap: boolean): void;
  83669. }
  83670. }
  83671. declare module BABYLON {
  83672. /**
  83673. * Class for creating a cube texture
  83674. */
  83675. export class CubeTexture extends BaseTexture {
  83676. private _delayedOnLoad;
  83677. /**
  83678. * Observable triggered once the texture has been loaded.
  83679. */
  83680. onLoadObservable: Observable<CubeTexture>;
  83681. /**
  83682. * The url of the texture
  83683. */
  83684. url: string;
  83685. /**
  83686. * Gets or sets the center of the bounding box associated with the cube texture.
  83687. * It must define where the camera used to render the texture was set
  83688. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  83689. */
  83690. boundingBoxPosition: Vector3;
  83691. private _boundingBoxSize;
  83692. /**
  83693. * Gets or sets the size of the bounding box associated with the cube texture
  83694. * When defined, the cubemap will switch to local mode
  83695. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  83696. * @example https://www.babylonjs-playground.com/#RNASML
  83697. */
  83698. set boundingBoxSize(value: Vector3);
  83699. /**
  83700. * Returns the bounding box size
  83701. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  83702. */
  83703. get boundingBoxSize(): Vector3;
  83704. protected _rotationY: number;
  83705. /**
  83706. * Sets texture matrix rotation angle around Y axis in radians.
  83707. */
  83708. set rotationY(value: number);
  83709. /**
  83710. * Gets texture matrix rotation angle around Y axis radians.
  83711. */
  83712. get rotationY(): number;
  83713. /**
  83714. * Are mip maps generated for this texture or not.
  83715. */
  83716. get noMipmap(): boolean;
  83717. private _noMipmap;
  83718. private _files;
  83719. protected _forcedExtension: Nullable<string>;
  83720. private _extensions;
  83721. private _textureMatrix;
  83722. private _format;
  83723. private _createPolynomials;
  83724. /** @hidden */
  83725. _prefiltered: boolean;
  83726. /**
  83727. * Creates a cube texture from an array of image urls
  83728. * @param files defines an array of image urls
  83729. * @param scene defines the hosting scene
  83730. * @param noMipmap specifies if mip maps are not used
  83731. * @returns a cube texture
  83732. */
  83733. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  83734. /**
  83735. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  83736. * @param url defines the url of the prefiltered texture
  83737. * @param scene defines the scene the texture is attached to
  83738. * @param forcedExtension defines the extension of the file if different from the url
  83739. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  83740. * @return the prefiltered texture
  83741. */
  83742. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  83743. /**
  83744. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  83745. * as prefiltered data.
  83746. * @param rootUrl defines the url of the texture or the root name of the six images
  83747. * @param null defines the scene or engine the texture is attached to
  83748. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  83749. * @param noMipmap defines if mipmaps should be created or not
  83750. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  83751. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  83752. * @param onError defines a callback triggered in case of error during load
  83753. * @param format defines the internal format to use for the texture once loaded
  83754. * @param prefiltered defines whether or not the texture is created from prefiltered data
  83755. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  83756. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  83757. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  83758. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  83759. * @return the cube texture
  83760. */
  83761. 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);
  83762. /**
  83763. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  83764. */
  83765. get isPrefiltered(): boolean;
  83766. /**
  83767. * Get the current class name of the texture useful for serialization or dynamic coding.
  83768. * @returns "CubeTexture"
  83769. */
  83770. getClassName(): string;
  83771. /**
  83772. * Update the url (and optional buffer) of this texture if url was null during construction.
  83773. * @param url the url of the texture
  83774. * @param forcedExtension defines the extension to use
  83775. * @param onLoad callback called when the texture is loaded (defaults to null)
  83776. * @param prefiltered Defines whether the updated texture is prefiltered or not
  83777. */
  83778. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  83779. /**
  83780. * Delays loading of the cube texture
  83781. * @param forcedExtension defines the extension to use
  83782. */
  83783. delayLoad(forcedExtension?: string): void;
  83784. /**
  83785. * Returns the reflection texture matrix
  83786. * @returns the reflection texture matrix
  83787. */
  83788. getReflectionTextureMatrix(): Matrix;
  83789. /**
  83790. * Sets the reflection texture matrix
  83791. * @param value Reflection texture matrix
  83792. */
  83793. setReflectionTextureMatrix(value: Matrix): void;
  83794. /**
  83795. * Parses text to create a cube texture
  83796. * @param parsedTexture define the serialized text to read from
  83797. * @param scene defines the hosting scene
  83798. * @param rootUrl defines the root url of the cube texture
  83799. * @returns a cube texture
  83800. */
  83801. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  83802. /**
  83803. * Makes a clone, or deep copy, of the cube texture
  83804. * @returns a new cube texture
  83805. */
  83806. clone(): CubeTexture;
  83807. }
  83808. }
  83809. declare module BABYLON {
  83810. /**
  83811. * Manages the defines for the Material
  83812. */
  83813. export class MaterialDefines {
  83814. /** @hidden */
  83815. protected _keys: string[];
  83816. private _isDirty;
  83817. /** @hidden */
  83818. _renderId: number;
  83819. /** @hidden */
  83820. _areLightsDirty: boolean;
  83821. /** @hidden */
  83822. _areLightsDisposed: boolean;
  83823. /** @hidden */
  83824. _areAttributesDirty: boolean;
  83825. /** @hidden */
  83826. _areTexturesDirty: boolean;
  83827. /** @hidden */
  83828. _areFresnelDirty: boolean;
  83829. /** @hidden */
  83830. _areMiscDirty: boolean;
  83831. /** @hidden */
  83832. _areImageProcessingDirty: boolean;
  83833. /** @hidden */
  83834. _normals: boolean;
  83835. /** @hidden */
  83836. _uvs: boolean;
  83837. /** @hidden */
  83838. _needNormals: boolean;
  83839. /** @hidden */
  83840. _needUVs: boolean;
  83841. [id: string]: any;
  83842. /**
  83843. * Specifies if the material needs to be re-calculated
  83844. */
  83845. get isDirty(): boolean;
  83846. /**
  83847. * Marks the material to indicate that it has been re-calculated
  83848. */
  83849. markAsProcessed(): void;
  83850. /**
  83851. * Marks the material to indicate that it needs to be re-calculated
  83852. */
  83853. markAsUnprocessed(): void;
  83854. /**
  83855. * Marks the material to indicate all of its defines need to be re-calculated
  83856. */
  83857. markAllAsDirty(): void;
  83858. /**
  83859. * Marks the material to indicate that image processing needs to be re-calculated
  83860. */
  83861. markAsImageProcessingDirty(): void;
  83862. /**
  83863. * Marks the material to indicate the lights need to be re-calculated
  83864. * @param disposed Defines whether the light is dirty due to dispose or not
  83865. */
  83866. markAsLightDirty(disposed?: boolean): void;
  83867. /**
  83868. * Marks the attribute state as changed
  83869. */
  83870. markAsAttributesDirty(): void;
  83871. /**
  83872. * Marks the texture state as changed
  83873. */
  83874. markAsTexturesDirty(): void;
  83875. /**
  83876. * Marks the fresnel state as changed
  83877. */
  83878. markAsFresnelDirty(): void;
  83879. /**
  83880. * Marks the misc state as changed
  83881. */
  83882. markAsMiscDirty(): void;
  83883. /**
  83884. * Rebuilds the material defines
  83885. */
  83886. rebuild(): void;
  83887. /**
  83888. * Specifies if two material defines are equal
  83889. * @param other - A material define instance to compare to
  83890. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  83891. */
  83892. isEqual(other: MaterialDefines): boolean;
  83893. /**
  83894. * Clones this instance's defines to another instance
  83895. * @param other - material defines to clone values to
  83896. */
  83897. cloneTo(other: MaterialDefines): void;
  83898. /**
  83899. * Resets the material define values
  83900. */
  83901. reset(): void;
  83902. /**
  83903. * Converts the material define values to a string
  83904. * @returns - String of material define information
  83905. */
  83906. toString(): string;
  83907. }
  83908. }
  83909. declare module BABYLON {
  83910. /**
  83911. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  83912. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  83913. * 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;
  83914. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  83915. */
  83916. export class ColorCurves {
  83917. private _dirty;
  83918. private _tempColor;
  83919. private _globalCurve;
  83920. private _highlightsCurve;
  83921. private _midtonesCurve;
  83922. private _shadowsCurve;
  83923. private _positiveCurve;
  83924. private _negativeCurve;
  83925. private _globalHue;
  83926. private _globalDensity;
  83927. private _globalSaturation;
  83928. private _globalExposure;
  83929. /**
  83930. * Gets the global Hue value.
  83931. * 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).
  83932. */
  83933. get globalHue(): number;
  83934. /**
  83935. * Sets the global Hue value.
  83936. * 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).
  83937. */
  83938. set globalHue(value: number);
  83939. /**
  83940. * Gets the global Density value.
  83941. * 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.
  83942. * Values less than zero provide a filter of opposite hue.
  83943. */
  83944. get globalDensity(): number;
  83945. /**
  83946. * Sets the global Density value.
  83947. * 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.
  83948. * Values less than zero provide a filter of opposite hue.
  83949. */
  83950. set globalDensity(value: number);
  83951. /**
  83952. * Gets the global Saturation value.
  83953. * 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.
  83954. */
  83955. get globalSaturation(): number;
  83956. /**
  83957. * Sets the global Saturation value.
  83958. * 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.
  83959. */
  83960. set globalSaturation(value: number);
  83961. /**
  83962. * Gets the global Exposure value.
  83963. * 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.
  83964. */
  83965. get globalExposure(): number;
  83966. /**
  83967. * Sets the global Exposure value.
  83968. * 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.
  83969. */
  83970. set globalExposure(value: number);
  83971. private _highlightsHue;
  83972. private _highlightsDensity;
  83973. private _highlightsSaturation;
  83974. private _highlightsExposure;
  83975. /**
  83976. * Gets the highlights Hue value.
  83977. * 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).
  83978. */
  83979. get highlightsHue(): number;
  83980. /**
  83981. * Sets the highlights Hue value.
  83982. * 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).
  83983. */
  83984. set highlightsHue(value: number);
  83985. /**
  83986. * Gets the highlights Density value.
  83987. * 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.
  83988. * Values less than zero provide a filter of opposite hue.
  83989. */
  83990. get highlightsDensity(): number;
  83991. /**
  83992. * Sets the highlights Density value.
  83993. * 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.
  83994. * Values less than zero provide a filter of opposite hue.
  83995. */
  83996. set highlightsDensity(value: number);
  83997. /**
  83998. * Gets the highlights Saturation value.
  83999. * 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.
  84000. */
  84001. get highlightsSaturation(): number;
  84002. /**
  84003. * Sets the highlights Saturation value.
  84004. * 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.
  84005. */
  84006. set highlightsSaturation(value: number);
  84007. /**
  84008. * Gets the highlights Exposure value.
  84009. * 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.
  84010. */
  84011. get highlightsExposure(): number;
  84012. /**
  84013. * Sets the highlights Exposure value.
  84014. * 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.
  84015. */
  84016. set highlightsExposure(value: number);
  84017. private _midtonesHue;
  84018. private _midtonesDensity;
  84019. private _midtonesSaturation;
  84020. private _midtonesExposure;
  84021. /**
  84022. * Gets the midtones Hue value.
  84023. * 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).
  84024. */
  84025. get midtonesHue(): number;
  84026. /**
  84027. * Sets the midtones Hue value.
  84028. * 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).
  84029. */
  84030. set midtonesHue(value: number);
  84031. /**
  84032. * Gets the midtones Density value.
  84033. * 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.
  84034. * Values less than zero provide a filter of opposite hue.
  84035. */
  84036. get midtonesDensity(): number;
  84037. /**
  84038. * Sets the midtones Density value.
  84039. * 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.
  84040. * Values less than zero provide a filter of opposite hue.
  84041. */
  84042. set midtonesDensity(value: number);
  84043. /**
  84044. * Gets the midtones Saturation value.
  84045. * 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.
  84046. */
  84047. get midtonesSaturation(): number;
  84048. /**
  84049. * Sets the midtones Saturation value.
  84050. * 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.
  84051. */
  84052. set midtonesSaturation(value: number);
  84053. /**
  84054. * Gets the midtones Exposure value.
  84055. * 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.
  84056. */
  84057. get midtonesExposure(): number;
  84058. /**
  84059. * Sets the midtones Exposure value.
  84060. * 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.
  84061. */
  84062. set midtonesExposure(value: number);
  84063. private _shadowsHue;
  84064. private _shadowsDensity;
  84065. private _shadowsSaturation;
  84066. private _shadowsExposure;
  84067. /**
  84068. * Gets the shadows Hue value.
  84069. * 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).
  84070. */
  84071. get shadowsHue(): number;
  84072. /**
  84073. * Sets the shadows Hue value.
  84074. * 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).
  84075. */
  84076. set shadowsHue(value: number);
  84077. /**
  84078. * Gets the shadows Density value.
  84079. * 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.
  84080. * Values less than zero provide a filter of opposite hue.
  84081. */
  84082. get shadowsDensity(): number;
  84083. /**
  84084. * Sets the shadows Density value.
  84085. * 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.
  84086. * Values less than zero provide a filter of opposite hue.
  84087. */
  84088. set shadowsDensity(value: number);
  84089. /**
  84090. * Gets the shadows Saturation value.
  84091. * 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.
  84092. */
  84093. get shadowsSaturation(): number;
  84094. /**
  84095. * Sets the shadows Saturation value.
  84096. * 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.
  84097. */
  84098. set shadowsSaturation(value: number);
  84099. /**
  84100. * Gets the shadows Exposure value.
  84101. * 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.
  84102. */
  84103. get shadowsExposure(): number;
  84104. /**
  84105. * Sets the shadows Exposure value.
  84106. * 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.
  84107. */
  84108. set shadowsExposure(value: number);
  84109. /**
  84110. * Returns the class name
  84111. * @returns The class name
  84112. */
  84113. getClassName(): string;
  84114. /**
  84115. * Binds the color curves to the shader.
  84116. * @param colorCurves The color curve to bind
  84117. * @param effect The effect to bind to
  84118. * @param positiveUniform The positive uniform shader parameter
  84119. * @param neutralUniform The neutral uniform shader parameter
  84120. * @param negativeUniform The negative uniform shader parameter
  84121. */
  84122. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  84123. /**
  84124. * Prepare the list of uniforms associated with the ColorCurves effects.
  84125. * @param uniformsList The list of uniforms used in the effect
  84126. */
  84127. static PrepareUniforms(uniformsList: string[]): void;
  84128. /**
  84129. * Returns color grading data based on a hue, density, saturation and exposure value.
  84130. * @param filterHue The hue of the color filter.
  84131. * @param filterDensity The density of the color filter.
  84132. * @param saturation The saturation.
  84133. * @param exposure The exposure.
  84134. * @param result The result data container.
  84135. */
  84136. private getColorGradingDataToRef;
  84137. /**
  84138. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  84139. * @param value The input slider value in range [-100,100].
  84140. * @returns Adjusted value.
  84141. */
  84142. private static applyColorGradingSliderNonlinear;
  84143. /**
  84144. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  84145. * @param hue The hue (H) input.
  84146. * @param saturation The saturation (S) input.
  84147. * @param brightness The brightness (B) input.
  84148. * @result An RGBA color represented as Vector4.
  84149. */
  84150. private static fromHSBToRef;
  84151. /**
  84152. * Returns a value clamped between min and max
  84153. * @param value The value to clamp
  84154. * @param min The minimum of value
  84155. * @param max The maximum of value
  84156. * @returns The clamped value.
  84157. */
  84158. private static clamp;
  84159. /**
  84160. * Clones the current color curve instance.
  84161. * @return The cloned curves
  84162. */
  84163. clone(): ColorCurves;
  84164. /**
  84165. * Serializes the current color curve instance to a json representation.
  84166. * @return a JSON representation
  84167. */
  84168. serialize(): any;
  84169. /**
  84170. * Parses the color curve from a json representation.
  84171. * @param source the JSON source to parse
  84172. * @return The parsed curves
  84173. */
  84174. static Parse(source: any): ColorCurves;
  84175. }
  84176. }
  84177. declare module BABYLON {
  84178. /**
  84179. * Interface to follow in your material defines to integrate easily the
  84180. * Image proccessing functions.
  84181. * @hidden
  84182. */
  84183. export interface IImageProcessingConfigurationDefines {
  84184. IMAGEPROCESSING: boolean;
  84185. VIGNETTE: boolean;
  84186. VIGNETTEBLENDMODEMULTIPLY: boolean;
  84187. VIGNETTEBLENDMODEOPAQUE: boolean;
  84188. TONEMAPPING: boolean;
  84189. TONEMAPPING_ACES: boolean;
  84190. CONTRAST: boolean;
  84191. EXPOSURE: boolean;
  84192. COLORCURVES: boolean;
  84193. COLORGRADING: boolean;
  84194. COLORGRADING3D: boolean;
  84195. SAMPLER3DGREENDEPTH: boolean;
  84196. SAMPLER3DBGRMAP: boolean;
  84197. IMAGEPROCESSINGPOSTPROCESS: boolean;
  84198. }
  84199. /**
  84200. * @hidden
  84201. */
  84202. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  84203. IMAGEPROCESSING: boolean;
  84204. VIGNETTE: boolean;
  84205. VIGNETTEBLENDMODEMULTIPLY: boolean;
  84206. VIGNETTEBLENDMODEOPAQUE: boolean;
  84207. TONEMAPPING: boolean;
  84208. TONEMAPPING_ACES: boolean;
  84209. CONTRAST: boolean;
  84210. COLORCURVES: boolean;
  84211. COLORGRADING: boolean;
  84212. COLORGRADING3D: boolean;
  84213. SAMPLER3DGREENDEPTH: boolean;
  84214. SAMPLER3DBGRMAP: boolean;
  84215. IMAGEPROCESSINGPOSTPROCESS: boolean;
  84216. EXPOSURE: boolean;
  84217. constructor();
  84218. }
  84219. /**
  84220. * This groups together the common properties used for image processing either in direct forward pass
  84221. * or through post processing effect depending on the use of the image processing pipeline in your scene
  84222. * or not.
  84223. */
  84224. export class ImageProcessingConfiguration {
  84225. /**
  84226. * Default tone mapping applied in BabylonJS.
  84227. */
  84228. static readonly TONEMAPPING_STANDARD: number;
  84229. /**
  84230. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  84231. * to other engines rendering to increase portability.
  84232. */
  84233. static readonly TONEMAPPING_ACES: number;
  84234. /**
  84235. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  84236. */
  84237. colorCurves: Nullable<ColorCurves>;
  84238. private _colorCurvesEnabled;
  84239. /**
  84240. * Gets wether the color curves effect is enabled.
  84241. */
  84242. get colorCurvesEnabled(): boolean;
  84243. /**
  84244. * Sets wether the color curves effect is enabled.
  84245. */
  84246. set colorCurvesEnabled(value: boolean);
  84247. private _colorGradingTexture;
  84248. /**
  84249. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  84250. */
  84251. get colorGradingTexture(): Nullable<BaseTexture>;
  84252. /**
  84253. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  84254. */
  84255. set colorGradingTexture(value: Nullable<BaseTexture>);
  84256. private _colorGradingEnabled;
  84257. /**
  84258. * Gets wether the color grading effect is enabled.
  84259. */
  84260. get colorGradingEnabled(): boolean;
  84261. /**
  84262. * Sets wether the color grading effect is enabled.
  84263. */
  84264. set colorGradingEnabled(value: boolean);
  84265. private _colorGradingWithGreenDepth;
  84266. /**
  84267. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  84268. */
  84269. get colorGradingWithGreenDepth(): boolean;
  84270. /**
  84271. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  84272. */
  84273. set colorGradingWithGreenDepth(value: boolean);
  84274. private _colorGradingBGR;
  84275. /**
  84276. * Gets wether the color grading texture contains BGR values.
  84277. */
  84278. get colorGradingBGR(): boolean;
  84279. /**
  84280. * Sets wether the color grading texture contains BGR values.
  84281. */
  84282. set colorGradingBGR(value: boolean);
  84283. /** @hidden */
  84284. _exposure: number;
  84285. /**
  84286. * Gets the Exposure used in the effect.
  84287. */
  84288. get exposure(): number;
  84289. /**
  84290. * Sets the Exposure used in the effect.
  84291. */
  84292. set exposure(value: number);
  84293. private _toneMappingEnabled;
  84294. /**
  84295. * Gets wether the tone mapping effect is enabled.
  84296. */
  84297. get toneMappingEnabled(): boolean;
  84298. /**
  84299. * Sets wether the tone mapping effect is enabled.
  84300. */
  84301. set toneMappingEnabled(value: boolean);
  84302. private _toneMappingType;
  84303. /**
  84304. * Gets the type of tone mapping effect.
  84305. */
  84306. get toneMappingType(): number;
  84307. /**
  84308. * Sets the type of tone mapping effect used in BabylonJS.
  84309. */
  84310. set toneMappingType(value: number);
  84311. protected _contrast: number;
  84312. /**
  84313. * Gets the contrast used in the effect.
  84314. */
  84315. get contrast(): number;
  84316. /**
  84317. * Sets the contrast used in the effect.
  84318. */
  84319. set contrast(value: number);
  84320. /**
  84321. * Vignette stretch size.
  84322. */
  84323. vignetteStretch: number;
  84324. /**
  84325. * Vignette centre X Offset.
  84326. */
  84327. vignetteCentreX: number;
  84328. /**
  84329. * Vignette centre Y Offset.
  84330. */
  84331. vignetteCentreY: number;
  84332. /**
  84333. * Vignette weight or intensity of the vignette effect.
  84334. */
  84335. vignetteWeight: number;
  84336. /**
  84337. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  84338. * if vignetteEnabled is set to true.
  84339. */
  84340. vignetteColor: Color4;
  84341. /**
  84342. * Camera field of view used by the Vignette effect.
  84343. */
  84344. vignetteCameraFov: number;
  84345. private _vignetteBlendMode;
  84346. /**
  84347. * Gets the vignette blend mode allowing different kind of effect.
  84348. */
  84349. get vignetteBlendMode(): number;
  84350. /**
  84351. * Sets the vignette blend mode allowing different kind of effect.
  84352. */
  84353. set vignetteBlendMode(value: number);
  84354. private _vignetteEnabled;
  84355. /**
  84356. * Gets wether the vignette effect is enabled.
  84357. */
  84358. get vignetteEnabled(): boolean;
  84359. /**
  84360. * Sets wether the vignette effect is enabled.
  84361. */
  84362. set vignetteEnabled(value: boolean);
  84363. private _applyByPostProcess;
  84364. /**
  84365. * Gets wether the image processing is applied through a post process or not.
  84366. */
  84367. get applyByPostProcess(): boolean;
  84368. /**
  84369. * Sets wether the image processing is applied through a post process or not.
  84370. */
  84371. set applyByPostProcess(value: boolean);
  84372. private _isEnabled;
  84373. /**
  84374. * Gets wether the image processing is enabled or not.
  84375. */
  84376. get isEnabled(): boolean;
  84377. /**
  84378. * Sets wether the image processing is enabled or not.
  84379. */
  84380. set isEnabled(value: boolean);
  84381. /**
  84382. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  84383. */
  84384. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  84385. /**
  84386. * Method called each time the image processing information changes requires to recompile the effect.
  84387. */
  84388. protected _updateParameters(): void;
  84389. /**
  84390. * Gets the current class name.
  84391. * @return "ImageProcessingConfiguration"
  84392. */
  84393. getClassName(): string;
  84394. /**
  84395. * Prepare the list of uniforms associated with the Image Processing effects.
  84396. * @param uniforms The list of uniforms used in the effect
  84397. * @param defines the list of defines currently in use
  84398. */
  84399. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  84400. /**
  84401. * Prepare the list of samplers associated with the Image Processing effects.
  84402. * @param samplersList The list of uniforms used in the effect
  84403. * @param defines the list of defines currently in use
  84404. */
  84405. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  84406. /**
  84407. * Prepare the list of defines associated to the shader.
  84408. * @param defines the list of defines to complete
  84409. * @param forPostProcess Define if we are currently in post process mode or not
  84410. */
  84411. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  84412. /**
  84413. * Returns true if all the image processing information are ready.
  84414. * @returns True if ready, otherwise, false
  84415. */
  84416. isReady(): boolean;
  84417. /**
  84418. * Binds the image processing to the shader.
  84419. * @param effect The effect to bind to
  84420. * @param overrideAspectRatio Override the aspect ratio of the effect
  84421. */
  84422. bind(effect: Effect, overrideAspectRatio?: number): void;
  84423. /**
  84424. * Clones the current image processing instance.
  84425. * @return The cloned image processing
  84426. */
  84427. clone(): ImageProcessingConfiguration;
  84428. /**
  84429. * Serializes the current image processing instance to a json representation.
  84430. * @return a JSON representation
  84431. */
  84432. serialize(): any;
  84433. /**
  84434. * Parses the image processing from a json representation.
  84435. * @param source the JSON source to parse
  84436. * @return The parsed image processing
  84437. */
  84438. static Parse(source: any): ImageProcessingConfiguration;
  84439. private static _VIGNETTEMODE_MULTIPLY;
  84440. private static _VIGNETTEMODE_OPAQUE;
  84441. /**
  84442. * Used to apply the vignette as a mix with the pixel color.
  84443. */
  84444. static get VIGNETTEMODE_MULTIPLY(): number;
  84445. /**
  84446. * Used to apply the vignette as a replacement of the pixel color.
  84447. */
  84448. static get VIGNETTEMODE_OPAQUE(): number;
  84449. }
  84450. }
  84451. declare module BABYLON {
  84452. /** @hidden */
  84453. export var postprocessVertexShader: {
  84454. name: string;
  84455. shader: string;
  84456. };
  84457. }
  84458. declare module BABYLON {
  84459. interface ThinEngine {
  84460. /**
  84461. * Creates a new render target texture
  84462. * @param size defines the size of the texture
  84463. * @param options defines the options used to create the texture
  84464. * @returns a new render target texture stored in an InternalTexture
  84465. */
  84466. createRenderTargetTexture(size: number | {
  84467. width: number;
  84468. height: number;
  84469. layers?: number;
  84470. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  84471. /**
  84472. * Creates a depth stencil texture.
  84473. * This is only available in WebGL 2 or with the depth texture extension available.
  84474. * @param size The size of face edge in the texture.
  84475. * @param options The options defining the texture.
  84476. * @returns The texture
  84477. */
  84478. createDepthStencilTexture(size: number | {
  84479. width: number;
  84480. height: number;
  84481. layers?: number;
  84482. }, options: DepthTextureCreationOptions): InternalTexture;
  84483. /** @hidden */
  84484. _createDepthStencilTexture(size: number | {
  84485. width: number;
  84486. height: number;
  84487. layers?: number;
  84488. }, options: DepthTextureCreationOptions): InternalTexture;
  84489. }
  84490. }
  84491. declare module BABYLON {
  84492. /** Defines supported spaces */
  84493. export enum Space {
  84494. /** Local (object) space */
  84495. LOCAL = 0,
  84496. /** World space */
  84497. WORLD = 1,
  84498. /** Bone space */
  84499. BONE = 2
  84500. }
  84501. /** Defines the 3 main axes */
  84502. export class Axis {
  84503. /** X axis */
  84504. static X: Vector3;
  84505. /** Y axis */
  84506. static Y: Vector3;
  84507. /** Z axis */
  84508. static Z: Vector3;
  84509. }
  84510. }
  84511. declare module BABYLON {
  84512. /**
  84513. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  84514. * This is the base of the follow, arc rotate cameras and Free camera
  84515. * @see http://doc.babylonjs.com/features/cameras
  84516. */
  84517. export class TargetCamera extends Camera {
  84518. private static _RigCamTransformMatrix;
  84519. private static _TargetTransformMatrix;
  84520. private static _TargetFocalPoint;
  84521. /**
  84522. * Define the current direction the camera is moving to
  84523. */
  84524. cameraDirection: Vector3;
  84525. /**
  84526. * Define the current rotation the camera is rotating to
  84527. */
  84528. cameraRotation: Vector2;
  84529. /**
  84530. * When set, the up vector of the camera will be updated by the rotation of the camera
  84531. */
  84532. updateUpVectorFromRotation: boolean;
  84533. private _tmpQuaternion;
  84534. /**
  84535. * Define the current rotation of the camera
  84536. */
  84537. rotation: Vector3;
  84538. /**
  84539. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  84540. */
  84541. rotationQuaternion: Quaternion;
  84542. /**
  84543. * Define the current speed of the camera
  84544. */
  84545. speed: number;
  84546. /**
  84547. * Add constraint to the camera to prevent it to move freely in all directions and
  84548. * around all axis.
  84549. */
  84550. noRotationConstraint: boolean;
  84551. /**
  84552. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  84553. * panning
  84554. */
  84555. invertRotation: boolean;
  84556. /**
  84557. * Speed multiplier for inverse camera panning
  84558. */
  84559. inverseRotationSpeed: number;
  84560. /**
  84561. * Define the current target of the camera as an object or a position.
  84562. */
  84563. lockedTarget: any;
  84564. /** @hidden */
  84565. _currentTarget: Vector3;
  84566. /** @hidden */
  84567. _initialFocalDistance: number;
  84568. /** @hidden */
  84569. _viewMatrix: Matrix;
  84570. /** @hidden */
  84571. _camMatrix: Matrix;
  84572. /** @hidden */
  84573. _cameraTransformMatrix: Matrix;
  84574. /** @hidden */
  84575. _cameraRotationMatrix: Matrix;
  84576. /** @hidden */
  84577. _referencePoint: Vector3;
  84578. /** @hidden */
  84579. _transformedReferencePoint: Vector3;
  84580. protected _globalCurrentTarget: Vector3;
  84581. protected _globalCurrentUpVector: Vector3;
  84582. /** @hidden */
  84583. _reset: () => void;
  84584. private _defaultUp;
  84585. /**
  84586. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  84587. * This is the base of the follow, arc rotate cameras and Free camera
  84588. * @see http://doc.babylonjs.com/features/cameras
  84589. * @param name Defines the name of the camera in the scene
  84590. * @param position Defines the start position of the camera in the scene
  84591. * @param scene Defines the scene the camera belongs to
  84592. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  84593. */
  84594. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  84595. /**
  84596. * Gets the position in front of the camera at a given distance.
  84597. * @param distance The distance from the camera we want the position to be
  84598. * @returns the position
  84599. */
  84600. getFrontPosition(distance: number): Vector3;
  84601. /** @hidden */
  84602. _getLockedTargetPosition(): Nullable<Vector3>;
  84603. private _storedPosition;
  84604. private _storedRotation;
  84605. private _storedRotationQuaternion;
  84606. /**
  84607. * Store current camera state of the camera (fov, position, rotation, etc..)
  84608. * @returns the camera
  84609. */
  84610. storeState(): Camera;
  84611. /**
  84612. * Restored camera state. You must call storeState() first
  84613. * @returns whether it was successful or not
  84614. * @hidden
  84615. */
  84616. _restoreStateValues(): boolean;
  84617. /** @hidden */
  84618. _initCache(): void;
  84619. /** @hidden */
  84620. _updateCache(ignoreParentClass?: boolean): void;
  84621. /** @hidden */
  84622. _isSynchronizedViewMatrix(): boolean;
  84623. /** @hidden */
  84624. _computeLocalCameraSpeed(): number;
  84625. /**
  84626. * Defines the target the camera should look at.
  84627. * @param target Defines the new target as a Vector or a mesh
  84628. */
  84629. setTarget(target: Vector3): void;
  84630. /**
  84631. * Return the current target position of the camera. This value is expressed in local space.
  84632. * @returns the target position
  84633. */
  84634. getTarget(): Vector3;
  84635. /** @hidden */
  84636. _decideIfNeedsToMove(): boolean;
  84637. /** @hidden */
  84638. _updatePosition(): void;
  84639. /** @hidden */
  84640. _checkInputs(): void;
  84641. protected _updateCameraRotationMatrix(): void;
  84642. /**
  84643. * 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)
  84644. * @returns the current camera
  84645. */
  84646. private _rotateUpVectorWithCameraRotationMatrix;
  84647. private _cachedRotationZ;
  84648. private _cachedQuaternionRotationZ;
  84649. /** @hidden */
  84650. _getViewMatrix(): Matrix;
  84651. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  84652. /**
  84653. * @hidden
  84654. */
  84655. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  84656. /**
  84657. * @hidden
  84658. */
  84659. _updateRigCameras(): void;
  84660. private _getRigCamPositionAndTarget;
  84661. /**
  84662. * Gets the current object class name.
  84663. * @return the class name
  84664. */
  84665. getClassName(): string;
  84666. }
  84667. }
  84668. declare module BABYLON {
  84669. /**
  84670. * Gather the list of keyboard event types as constants.
  84671. */
  84672. export class KeyboardEventTypes {
  84673. /**
  84674. * The keydown event is fired when a key becomes active (pressed).
  84675. */
  84676. static readonly KEYDOWN: number;
  84677. /**
  84678. * The keyup event is fired when a key has been released.
  84679. */
  84680. static readonly KEYUP: number;
  84681. }
  84682. /**
  84683. * This class is used to store keyboard related info for the onKeyboardObservable event.
  84684. */
  84685. export class KeyboardInfo {
  84686. /**
  84687. * Defines the type of event (KeyboardEventTypes)
  84688. */
  84689. type: number;
  84690. /**
  84691. * Defines the related dom event
  84692. */
  84693. event: KeyboardEvent;
  84694. /**
  84695. * Instantiates a new keyboard info.
  84696. * This class is used to store keyboard related info for the onKeyboardObservable event.
  84697. * @param type Defines the type of event (KeyboardEventTypes)
  84698. * @param event Defines the related dom event
  84699. */
  84700. constructor(
  84701. /**
  84702. * Defines the type of event (KeyboardEventTypes)
  84703. */
  84704. type: number,
  84705. /**
  84706. * Defines the related dom event
  84707. */
  84708. event: KeyboardEvent);
  84709. }
  84710. /**
  84711. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  84712. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  84713. */
  84714. export class KeyboardInfoPre extends KeyboardInfo {
  84715. /**
  84716. * Defines the type of event (KeyboardEventTypes)
  84717. */
  84718. type: number;
  84719. /**
  84720. * Defines the related dom event
  84721. */
  84722. event: KeyboardEvent;
  84723. /**
  84724. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  84725. */
  84726. skipOnPointerObservable: boolean;
  84727. /**
  84728. * Instantiates a new keyboard pre info.
  84729. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  84730. * @param type Defines the type of event (KeyboardEventTypes)
  84731. * @param event Defines the related dom event
  84732. */
  84733. constructor(
  84734. /**
  84735. * Defines the type of event (KeyboardEventTypes)
  84736. */
  84737. type: number,
  84738. /**
  84739. * Defines the related dom event
  84740. */
  84741. event: KeyboardEvent);
  84742. }
  84743. }
  84744. declare module BABYLON {
  84745. /**
  84746. * Manage the keyboard inputs to control the movement of a free camera.
  84747. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  84748. */
  84749. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  84750. /**
  84751. * Defines the camera the input is attached to.
  84752. */
  84753. camera: FreeCamera;
  84754. /**
  84755. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  84756. */
  84757. keysUp: number[];
  84758. /**
  84759. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  84760. */
  84761. keysUpward: number[];
  84762. /**
  84763. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  84764. */
  84765. keysDown: number[];
  84766. /**
  84767. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  84768. */
  84769. keysDownward: number[];
  84770. /**
  84771. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  84772. */
  84773. keysLeft: number[];
  84774. /**
  84775. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  84776. */
  84777. keysRight: number[];
  84778. private _keys;
  84779. private _onCanvasBlurObserver;
  84780. private _onKeyboardObserver;
  84781. private _engine;
  84782. private _scene;
  84783. /**
  84784. * Attach the input controls to a specific dom element to get the input from.
  84785. * @param element Defines the element the controls should be listened from
  84786. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  84787. */
  84788. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  84789. /**
  84790. * Detach the current controls from the specified dom element.
  84791. * @param element Defines the element to stop listening the inputs from
  84792. */
  84793. detachControl(element: Nullable<HTMLElement>): void;
  84794. /**
  84795. * Update the current camera state depending on the inputs that have been used this frame.
  84796. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  84797. */
  84798. checkInputs(): void;
  84799. /**
  84800. * Gets the class name of the current intput.
  84801. * @returns the class name
  84802. */
  84803. getClassName(): string;
  84804. /** @hidden */
  84805. _onLostFocus(): void;
  84806. /**
  84807. * Get the friendly name associated with the input class.
  84808. * @returns the input friendly name
  84809. */
  84810. getSimpleName(): string;
  84811. }
  84812. }
  84813. declare module BABYLON {
  84814. /**
  84815. * Interface describing all the common properties and methods a shadow light needs to implement.
  84816. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  84817. * as well as binding the different shadow properties to the effects.
  84818. */
  84819. export interface IShadowLight extends Light {
  84820. /**
  84821. * The light id in the scene (used in scene.findLighById for instance)
  84822. */
  84823. id: string;
  84824. /**
  84825. * The position the shdow will be casted from.
  84826. */
  84827. position: Vector3;
  84828. /**
  84829. * In 2d mode (needCube being false), the direction used to cast the shadow.
  84830. */
  84831. direction: Vector3;
  84832. /**
  84833. * The transformed position. Position of the light in world space taking parenting in account.
  84834. */
  84835. transformedPosition: Vector3;
  84836. /**
  84837. * The transformed direction. Direction of the light in world space taking parenting in account.
  84838. */
  84839. transformedDirection: Vector3;
  84840. /**
  84841. * The friendly name of the light in the scene.
  84842. */
  84843. name: string;
  84844. /**
  84845. * Defines the shadow projection clipping minimum z value.
  84846. */
  84847. shadowMinZ: number;
  84848. /**
  84849. * Defines the shadow projection clipping maximum z value.
  84850. */
  84851. shadowMaxZ: number;
  84852. /**
  84853. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  84854. * @returns true if the information has been computed, false if it does not need to (no parenting)
  84855. */
  84856. computeTransformedInformation(): boolean;
  84857. /**
  84858. * Gets the scene the light belongs to.
  84859. * @returns The scene
  84860. */
  84861. getScene(): Scene;
  84862. /**
  84863. * Callback defining a custom Projection Matrix Builder.
  84864. * This can be used to override the default projection matrix computation.
  84865. */
  84866. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  84867. /**
  84868. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  84869. * @param matrix The materix to updated with the projection information
  84870. * @param viewMatrix The transform matrix of the light
  84871. * @param renderList The list of mesh to render in the map
  84872. * @returns The current light
  84873. */
  84874. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  84875. /**
  84876. * Gets the current depth scale used in ESM.
  84877. * @returns The scale
  84878. */
  84879. getDepthScale(): number;
  84880. /**
  84881. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  84882. * @returns true if a cube texture needs to be use
  84883. */
  84884. needCube(): boolean;
  84885. /**
  84886. * Detects if the projection matrix requires to be recomputed this frame.
  84887. * @returns true if it requires to be recomputed otherwise, false.
  84888. */
  84889. needProjectionMatrixCompute(): boolean;
  84890. /**
  84891. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  84892. */
  84893. forceProjectionMatrixCompute(): void;
  84894. /**
  84895. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  84896. * @param faceIndex The index of the face we are computed the direction to generate shadow
  84897. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  84898. */
  84899. getShadowDirection(faceIndex?: number): Vector3;
  84900. /**
  84901. * Gets the minZ used for shadow according to both the scene and the light.
  84902. * @param activeCamera The camera we are returning the min for
  84903. * @returns the depth min z
  84904. */
  84905. getDepthMinZ(activeCamera: Camera): number;
  84906. /**
  84907. * Gets the maxZ used for shadow according to both the scene and the light.
  84908. * @param activeCamera The camera we are returning the max for
  84909. * @returns the depth max z
  84910. */
  84911. getDepthMaxZ(activeCamera: Camera): number;
  84912. }
  84913. /**
  84914. * Base implementation IShadowLight
  84915. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  84916. */
  84917. export abstract class ShadowLight extends Light implements IShadowLight {
  84918. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  84919. protected _position: Vector3;
  84920. protected _setPosition(value: Vector3): void;
  84921. /**
  84922. * Sets the position the shadow will be casted from. Also use as the light position for both
  84923. * point and spot lights.
  84924. */
  84925. get position(): Vector3;
  84926. /**
  84927. * Sets the position the shadow will be casted from. Also use as the light position for both
  84928. * point and spot lights.
  84929. */
  84930. set position(value: Vector3);
  84931. protected _direction: Vector3;
  84932. protected _setDirection(value: Vector3): void;
  84933. /**
  84934. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  84935. * Also use as the light direction on spot and directional lights.
  84936. */
  84937. get direction(): Vector3;
  84938. /**
  84939. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  84940. * Also use as the light direction on spot and directional lights.
  84941. */
  84942. set direction(value: Vector3);
  84943. protected _shadowMinZ: number;
  84944. /**
  84945. * Gets the shadow projection clipping minimum z value.
  84946. */
  84947. get shadowMinZ(): number;
  84948. /**
  84949. * Sets the shadow projection clipping minimum z value.
  84950. */
  84951. set shadowMinZ(value: number);
  84952. protected _shadowMaxZ: number;
  84953. /**
  84954. * Sets the shadow projection clipping maximum z value.
  84955. */
  84956. get shadowMaxZ(): number;
  84957. /**
  84958. * Gets the shadow projection clipping maximum z value.
  84959. */
  84960. set shadowMaxZ(value: number);
  84961. /**
  84962. * Callback defining a custom Projection Matrix Builder.
  84963. * This can be used to override the default projection matrix computation.
  84964. */
  84965. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  84966. /**
  84967. * The transformed position. Position of the light in world space taking parenting in account.
  84968. */
  84969. transformedPosition: Vector3;
  84970. /**
  84971. * The transformed direction. Direction of the light in world space taking parenting in account.
  84972. */
  84973. transformedDirection: Vector3;
  84974. private _needProjectionMatrixCompute;
  84975. /**
  84976. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  84977. * @returns true if the information has been computed, false if it does not need to (no parenting)
  84978. */
  84979. computeTransformedInformation(): boolean;
  84980. /**
  84981. * Return the depth scale used for the shadow map.
  84982. * @returns the depth scale.
  84983. */
  84984. getDepthScale(): number;
  84985. /**
  84986. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  84987. * @param faceIndex The index of the face we are computed the direction to generate shadow
  84988. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  84989. */
  84990. getShadowDirection(faceIndex?: number): Vector3;
  84991. /**
  84992. * Returns the ShadowLight absolute position in the World.
  84993. * @returns the position vector in world space
  84994. */
  84995. getAbsolutePosition(): Vector3;
  84996. /**
  84997. * Sets the ShadowLight direction toward the passed target.
  84998. * @param target The point to target in local space
  84999. * @returns the updated ShadowLight direction
  85000. */
  85001. setDirectionToTarget(target: Vector3): Vector3;
  85002. /**
  85003. * Returns the light rotation in euler definition.
  85004. * @returns the x y z rotation in local space.
  85005. */
  85006. getRotation(): Vector3;
  85007. /**
  85008. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  85009. * @returns true if a cube texture needs to be use
  85010. */
  85011. needCube(): boolean;
  85012. /**
  85013. * Detects if the projection matrix requires to be recomputed this frame.
  85014. * @returns true if it requires to be recomputed otherwise, false.
  85015. */
  85016. needProjectionMatrixCompute(): boolean;
  85017. /**
  85018. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  85019. */
  85020. forceProjectionMatrixCompute(): void;
  85021. /** @hidden */
  85022. _initCache(): void;
  85023. /** @hidden */
  85024. _isSynchronized(): boolean;
  85025. /**
  85026. * Computes the world matrix of the node
  85027. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  85028. * @returns the world matrix
  85029. */
  85030. computeWorldMatrix(force?: boolean): Matrix;
  85031. /**
  85032. * Gets the minZ used for shadow according to both the scene and the light.
  85033. * @param activeCamera The camera we are returning the min for
  85034. * @returns the depth min z
  85035. */
  85036. getDepthMinZ(activeCamera: Camera): number;
  85037. /**
  85038. * Gets the maxZ used for shadow according to both the scene and the light.
  85039. * @param activeCamera The camera we are returning the max for
  85040. * @returns the depth max z
  85041. */
  85042. getDepthMaxZ(activeCamera: Camera): number;
  85043. /**
  85044. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  85045. * @param matrix The materix to updated with the projection information
  85046. * @param viewMatrix The transform matrix of the light
  85047. * @param renderList The list of mesh to render in the map
  85048. * @returns The current light
  85049. */
  85050. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  85051. }
  85052. }
  85053. declare module BABYLON {
  85054. /**
  85055. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  85056. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  85057. */
  85058. export class EffectFallbacks implements IEffectFallbacks {
  85059. private _defines;
  85060. private _currentRank;
  85061. private _maxRank;
  85062. private _mesh;
  85063. /**
  85064. * Removes the fallback from the bound mesh.
  85065. */
  85066. unBindMesh(): void;
  85067. /**
  85068. * Adds a fallback on the specified property.
  85069. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  85070. * @param define The name of the define in the shader
  85071. */
  85072. addFallback(rank: number, define: string): void;
  85073. /**
  85074. * Sets the mesh to use CPU skinning when needing to fallback.
  85075. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  85076. * @param mesh The mesh to use the fallbacks.
  85077. */
  85078. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  85079. /**
  85080. * Checks to see if more fallbacks are still availible.
  85081. */
  85082. get hasMoreFallbacks(): boolean;
  85083. /**
  85084. * Removes the defines that should be removed when falling back.
  85085. * @param currentDefines defines the current define statements for the shader.
  85086. * @param effect defines the current effect we try to compile
  85087. * @returns The resulting defines with defines of the current rank removed.
  85088. */
  85089. reduce(currentDefines: string, effect: Effect): string;
  85090. }
  85091. }
  85092. declare module BABYLON {
  85093. /**
  85094. * "Static Class" containing the most commonly used helper while dealing with material for
  85095. * rendering purpose.
  85096. *
  85097. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  85098. *
  85099. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  85100. */
  85101. export class MaterialHelper {
  85102. /**
  85103. * Bind the current view position to an effect.
  85104. * @param effect The effect to be bound
  85105. * @param scene The scene the eyes position is used from
  85106. * @param variableName name of the shader variable that will hold the eye position
  85107. */
  85108. static BindEyePosition(effect: Effect, scene: Scene, variableName?: string): void;
  85109. /**
  85110. * Helps preparing the defines values about the UVs in used in the effect.
  85111. * UVs are shared as much as we can accross channels in the shaders.
  85112. * @param texture The texture we are preparing the UVs for
  85113. * @param defines The defines to update
  85114. * @param key The channel key "diffuse", "specular"... used in the shader
  85115. */
  85116. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  85117. /**
  85118. * Binds a texture matrix value to its corrsponding uniform
  85119. * @param texture The texture to bind the matrix for
  85120. * @param uniformBuffer The uniform buffer receivin the data
  85121. * @param key The channel key "diffuse", "specular"... used in the shader
  85122. */
  85123. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  85124. /**
  85125. * Gets the current status of the fog (should it be enabled?)
  85126. * @param mesh defines the mesh to evaluate for fog support
  85127. * @param scene defines the hosting scene
  85128. * @returns true if fog must be enabled
  85129. */
  85130. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  85131. /**
  85132. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  85133. * @param mesh defines the current mesh
  85134. * @param scene defines the current scene
  85135. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  85136. * @param pointsCloud defines if point cloud rendering has to be turned on
  85137. * @param fogEnabled defines if fog has to be turned on
  85138. * @param alphaTest defines if alpha testing has to be turned on
  85139. * @param defines defines the current list of defines
  85140. */
  85141. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  85142. /**
  85143. * Helper used to prepare the list of defines associated with frame values for shader compilation
  85144. * @param scene defines the current scene
  85145. * @param engine defines the current engine
  85146. * @param defines specifies the list of active defines
  85147. * @param useInstances defines if instances have to be turned on
  85148. * @param useClipPlane defines if clip plane have to be turned on
  85149. */
  85150. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  85151. /**
  85152. * Prepares the defines for bones
  85153. * @param mesh The mesh containing the geometry data we will draw
  85154. * @param defines The defines to update
  85155. */
  85156. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  85157. /**
  85158. * Prepares the defines for morph targets
  85159. * @param mesh The mesh containing the geometry data we will draw
  85160. * @param defines The defines to update
  85161. */
  85162. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  85163. /**
  85164. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  85165. * @param mesh The mesh containing the geometry data we will draw
  85166. * @param defines The defines to update
  85167. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  85168. * @param useBones Precise whether bones should be used or not (override mesh info)
  85169. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  85170. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  85171. * @returns false if defines are considered not dirty and have not been checked
  85172. */
  85173. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  85174. /**
  85175. * Prepares the defines related to multiview
  85176. * @param scene The scene we are intending to draw
  85177. * @param defines The defines to update
  85178. */
  85179. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  85180. /**
  85181. * Prepares the defines related to the light information passed in parameter
  85182. * @param scene The scene we are intending to draw
  85183. * @param mesh The mesh the effect is compiling for
  85184. * @param light The light the effect is compiling for
  85185. * @param lightIndex The index of the light
  85186. * @param defines The defines to update
  85187. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  85188. * @param state Defines the current state regarding what is needed (normals, etc...)
  85189. */
  85190. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  85191. needNormals: boolean;
  85192. needRebuild: boolean;
  85193. shadowEnabled: boolean;
  85194. specularEnabled: boolean;
  85195. lightmapMode: boolean;
  85196. }): void;
  85197. /**
  85198. * Prepares the defines related to the light information passed in parameter
  85199. * @param scene The scene we are intending to draw
  85200. * @param mesh The mesh the effect is compiling for
  85201. * @param defines The defines to update
  85202. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  85203. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  85204. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  85205. * @returns true if normals will be required for the rest of the effect
  85206. */
  85207. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  85208. /**
  85209. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  85210. * @param lightIndex defines the light index
  85211. * @param uniformsList The uniform list
  85212. * @param samplersList The sampler list
  85213. * @param projectedLightTexture defines if projected texture must be used
  85214. * @param uniformBuffersList defines an optional list of uniform buffers
  85215. */
  85216. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  85217. /**
  85218. * Prepares the uniforms and samplers list to be used in the effect
  85219. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  85220. * @param samplersList The sampler list
  85221. * @param defines The defines helping in the list generation
  85222. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  85223. */
  85224. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  85225. /**
  85226. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  85227. * @param defines The defines to update while falling back
  85228. * @param fallbacks The authorized effect fallbacks
  85229. * @param maxSimultaneousLights The maximum number of lights allowed
  85230. * @param rank the current rank of the Effect
  85231. * @returns The newly affected rank
  85232. */
  85233. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  85234. private static _TmpMorphInfluencers;
  85235. /**
  85236. * Prepares the list of attributes required for morph targets according to the effect defines.
  85237. * @param attribs The current list of supported attribs
  85238. * @param mesh The mesh to prepare the morph targets attributes for
  85239. * @param influencers The number of influencers
  85240. */
  85241. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  85242. /**
  85243. * Prepares the list of attributes required for morph targets according to the effect defines.
  85244. * @param attribs The current list of supported attribs
  85245. * @param mesh The mesh to prepare the morph targets attributes for
  85246. * @param defines The current Defines of the effect
  85247. */
  85248. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  85249. /**
  85250. * Prepares the list of attributes required for bones according to the effect defines.
  85251. * @param attribs The current list of supported attribs
  85252. * @param mesh The mesh to prepare the bones attributes for
  85253. * @param defines The current Defines of the effect
  85254. * @param fallbacks The current efffect fallback strategy
  85255. */
  85256. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  85257. /**
  85258. * Check and prepare the list of attributes required for instances according to the effect defines.
  85259. * @param attribs The current list of supported attribs
  85260. * @param defines The current MaterialDefines of the effect
  85261. */
  85262. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  85263. /**
  85264. * Add the list of attributes required for instances to the attribs array.
  85265. * @param attribs The current list of supported attribs
  85266. */
  85267. static PushAttributesForInstances(attribs: string[]): void;
  85268. /**
  85269. * Binds the light information to the effect.
  85270. * @param light The light containing the generator
  85271. * @param effect The effect we are binding the data to
  85272. * @param lightIndex The light index in the effect used to render
  85273. */
  85274. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  85275. /**
  85276. * Binds the lights information from the scene to the effect for the given mesh.
  85277. * @param light Light to bind
  85278. * @param lightIndex Light index
  85279. * @param scene The scene where the light belongs to
  85280. * @param effect The effect we are binding the data to
  85281. * @param useSpecular Defines if specular is supported
  85282. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  85283. */
  85284. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  85285. /**
  85286. * Binds the lights information from the scene to the effect for the given mesh.
  85287. * @param scene The scene the lights belongs to
  85288. * @param mesh The mesh we are binding the information to render
  85289. * @param effect The effect we are binding the data to
  85290. * @param defines The generated defines for the effect
  85291. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  85292. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  85293. */
  85294. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  85295. private static _tempFogColor;
  85296. /**
  85297. * Binds the fog information from the scene to the effect for the given mesh.
  85298. * @param scene The scene the lights belongs to
  85299. * @param mesh The mesh we are binding the information to render
  85300. * @param effect The effect we are binding the data to
  85301. * @param linearSpace Defines if the fog effect is applied in linear space
  85302. */
  85303. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  85304. /**
  85305. * Binds the bones information from the mesh to the effect.
  85306. * @param mesh The mesh we are binding the information to render
  85307. * @param effect The effect we are binding the data to
  85308. */
  85309. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  85310. /**
  85311. * Binds the morph targets information from the mesh to the effect.
  85312. * @param abstractMesh The mesh we are binding the information to render
  85313. * @param effect The effect we are binding the data to
  85314. */
  85315. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  85316. /**
  85317. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  85318. * @param defines The generated defines used in the effect
  85319. * @param effect The effect we are binding the data to
  85320. * @param scene The scene we are willing to render with logarithmic scale for
  85321. */
  85322. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  85323. /**
  85324. * Binds the clip plane information from the scene to the effect.
  85325. * @param scene The scene the clip plane information are extracted from
  85326. * @param effect The effect we are binding the data to
  85327. */
  85328. static BindClipPlane(effect: Effect, scene: Scene): void;
  85329. }
  85330. }
  85331. declare module BABYLON {
  85332. /** @hidden */
  85333. export var packingFunctions: {
  85334. name: string;
  85335. shader: string;
  85336. };
  85337. }
  85338. declare module BABYLON {
  85339. /** @hidden */
  85340. export var bayerDitherFunctions: {
  85341. name: string;
  85342. shader: string;
  85343. };
  85344. }
  85345. declare module BABYLON {
  85346. /** @hidden */
  85347. export var shadowMapFragmentDeclaration: {
  85348. name: string;
  85349. shader: string;
  85350. };
  85351. }
  85352. declare module BABYLON {
  85353. /** @hidden */
  85354. export var clipPlaneFragmentDeclaration: {
  85355. name: string;
  85356. shader: string;
  85357. };
  85358. }
  85359. declare module BABYLON {
  85360. /** @hidden */
  85361. export var clipPlaneFragment: {
  85362. name: string;
  85363. shader: string;
  85364. };
  85365. }
  85366. declare module BABYLON {
  85367. /** @hidden */
  85368. export var shadowMapFragment: {
  85369. name: string;
  85370. shader: string;
  85371. };
  85372. }
  85373. declare module BABYLON {
  85374. /** @hidden */
  85375. export var shadowMapPixelShader: {
  85376. name: string;
  85377. shader: string;
  85378. };
  85379. }
  85380. declare module BABYLON {
  85381. /** @hidden */
  85382. export var bonesDeclaration: {
  85383. name: string;
  85384. shader: string;
  85385. };
  85386. }
  85387. declare module BABYLON {
  85388. /** @hidden */
  85389. export var morphTargetsVertexGlobalDeclaration: {
  85390. name: string;
  85391. shader: string;
  85392. };
  85393. }
  85394. declare module BABYLON {
  85395. /** @hidden */
  85396. export var morphTargetsVertexDeclaration: {
  85397. name: string;
  85398. shader: string;
  85399. };
  85400. }
  85401. declare module BABYLON {
  85402. /** @hidden */
  85403. export var instancesDeclaration: {
  85404. name: string;
  85405. shader: string;
  85406. };
  85407. }
  85408. declare module BABYLON {
  85409. /** @hidden */
  85410. export var helperFunctions: {
  85411. name: string;
  85412. shader: string;
  85413. };
  85414. }
  85415. declare module BABYLON {
  85416. /** @hidden */
  85417. export var shadowMapVertexDeclaration: {
  85418. name: string;
  85419. shader: string;
  85420. };
  85421. }
  85422. declare module BABYLON {
  85423. /** @hidden */
  85424. export var clipPlaneVertexDeclaration: {
  85425. name: string;
  85426. shader: string;
  85427. };
  85428. }
  85429. declare module BABYLON {
  85430. /** @hidden */
  85431. export var morphTargetsVertex: {
  85432. name: string;
  85433. shader: string;
  85434. };
  85435. }
  85436. declare module BABYLON {
  85437. /** @hidden */
  85438. export var instancesVertex: {
  85439. name: string;
  85440. shader: string;
  85441. };
  85442. }
  85443. declare module BABYLON {
  85444. /** @hidden */
  85445. export var bonesVertex: {
  85446. name: string;
  85447. shader: string;
  85448. };
  85449. }
  85450. declare module BABYLON {
  85451. /** @hidden */
  85452. export var shadowMapVertexNormalBias: {
  85453. name: string;
  85454. shader: string;
  85455. };
  85456. }
  85457. declare module BABYLON {
  85458. /** @hidden */
  85459. export var shadowMapVertexMetric: {
  85460. name: string;
  85461. shader: string;
  85462. };
  85463. }
  85464. declare module BABYLON {
  85465. /** @hidden */
  85466. export var clipPlaneVertex: {
  85467. name: string;
  85468. shader: string;
  85469. };
  85470. }
  85471. declare module BABYLON {
  85472. /** @hidden */
  85473. export var shadowMapVertexShader: {
  85474. name: string;
  85475. shader: string;
  85476. };
  85477. }
  85478. declare module BABYLON {
  85479. /** @hidden */
  85480. export var depthBoxBlurPixelShader: {
  85481. name: string;
  85482. shader: string;
  85483. };
  85484. }
  85485. declare module BABYLON {
  85486. /** @hidden */
  85487. export var shadowMapFragmentSoftTransparentShadow: {
  85488. name: string;
  85489. shader: string;
  85490. };
  85491. }
  85492. declare module BABYLON {
  85493. /**
  85494. * Class representing a ray with position and direction
  85495. */
  85496. export class Ray {
  85497. /** origin point */
  85498. origin: Vector3;
  85499. /** direction */
  85500. direction: Vector3;
  85501. /** length of the ray */
  85502. length: number;
  85503. private static readonly TmpVector3;
  85504. private _tmpRay;
  85505. /**
  85506. * Creates a new ray
  85507. * @param origin origin point
  85508. * @param direction direction
  85509. * @param length length of the ray
  85510. */
  85511. constructor(
  85512. /** origin point */
  85513. origin: Vector3,
  85514. /** direction */
  85515. direction: Vector3,
  85516. /** length of the ray */
  85517. length?: number);
  85518. /**
  85519. * Checks if the ray intersects a box
  85520. * This does not account for the ray lenght by design to improve perfs.
  85521. * @param minimum bound of the box
  85522. * @param maximum bound of the box
  85523. * @param intersectionTreshold extra extend to be added to the box in all direction
  85524. * @returns if the box was hit
  85525. */
  85526. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  85527. /**
  85528. * Checks if the ray intersects a box
  85529. * This does not account for the ray lenght by design to improve perfs.
  85530. * @param box the bounding box to check
  85531. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  85532. * @returns if the box was hit
  85533. */
  85534. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  85535. /**
  85536. * If the ray hits a sphere
  85537. * @param sphere the bounding sphere to check
  85538. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  85539. * @returns true if it hits the sphere
  85540. */
  85541. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  85542. /**
  85543. * If the ray hits a triange
  85544. * @param vertex0 triangle vertex
  85545. * @param vertex1 triangle vertex
  85546. * @param vertex2 triangle vertex
  85547. * @returns intersection information if hit
  85548. */
  85549. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  85550. /**
  85551. * Checks if ray intersects a plane
  85552. * @param plane the plane to check
  85553. * @returns the distance away it was hit
  85554. */
  85555. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  85556. /**
  85557. * Calculate the intercept of a ray on a given axis
  85558. * @param axis to check 'x' | 'y' | 'z'
  85559. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  85560. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  85561. */
  85562. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  85563. /**
  85564. * Checks if ray intersects a mesh
  85565. * @param mesh the mesh to check
  85566. * @param fastCheck defines if the first intersection will be used (and not the closest)
  85567. * @returns picking info of the intersecton
  85568. */
  85569. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  85570. /**
  85571. * Checks if ray intersects a mesh
  85572. * @param meshes the meshes to check
  85573. * @param fastCheck defines if the first intersection will be used (and not the closest)
  85574. * @param results array to store result in
  85575. * @returns Array of picking infos
  85576. */
  85577. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  85578. private _comparePickingInfo;
  85579. private static smallnum;
  85580. private static rayl;
  85581. /**
  85582. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  85583. * @param sega the first point of the segment to test the intersection against
  85584. * @param segb the second point of the segment to test the intersection against
  85585. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  85586. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  85587. */
  85588. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  85589. /**
  85590. * Update the ray from viewport position
  85591. * @param x position
  85592. * @param y y position
  85593. * @param viewportWidth viewport width
  85594. * @param viewportHeight viewport height
  85595. * @param world world matrix
  85596. * @param view view matrix
  85597. * @param projection projection matrix
  85598. * @returns this ray updated
  85599. */
  85600. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  85601. /**
  85602. * Creates a ray with origin and direction of 0,0,0
  85603. * @returns the new ray
  85604. */
  85605. static Zero(): Ray;
  85606. /**
  85607. * Creates a new ray from screen space and viewport
  85608. * @param x position
  85609. * @param y y position
  85610. * @param viewportWidth viewport width
  85611. * @param viewportHeight viewport height
  85612. * @param world world matrix
  85613. * @param view view matrix
  85614. * @param projection projection matrix
  85615. * @returns new ray
  85616. */
  85617. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  85618. /**
  85619. * 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
  85620. * transformed to the given world matrix.
  85621. * @param origin The origin point
  85622. * @param end The end point
  85623. * @param world a matrix to transform the ray to. Default is the identity matrix.
  85624. * @returns the new ray
  85625. */
  85626. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  85627. /**
  85628. * Transforms a ray by a matrix
  85629. * @param ray ray to transform
  85630. * @param matrix matrix to apply
  85631. * @returns the resulting new ray
  85632. */
  85633. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  85634. /**
  85635. * Transforms a ray by a matrix
  85636. * @param ray ray to transform
  85637. * @param matrix matrix to apply
  85638. * @param result ray to store result in
  85639. */
  85640. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  85641. /**
  85642. * Unproject a ray from screen space to object space
  85643. * @param sourceX defines the screen space x coordinate to use
  85644. * @param sourceY defines the screen space y coordinate to use
  85645. * @param viewportWidth defines the current width of the viewport
  85646. * @param viewportHeight defines the current height of the viewport
  85647. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  85648. * @param view defines the view matrix to use
  85649. * @param projection defines the projection matrix to use
  85650. */
  85651. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  85652. }
  85653. /**
  85654. * Type used to define predicate used to select faces when a mesh intersection is detected
  85655. */
  85656. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  85657. interface Scene {
  85658. /** @hidden */
  85659. _tempPickingRay: Nullable<Ray>;
  85660. /** @hidden */
  85661. _cachedRayForTransform: Ray;
  85662. /** @hidden */
  85663. _pickWithRayInverseMatrix: Matrix;
  85664. /** @hidden */
  85665. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  85666. /** @hidden */
  85667. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  85668. }
  85669. }
  85670. declare module BABYLON {
  85671. /**
  85672. * Groups all the scene component constants in one place to ease maintenance.
  85673. * @hidden
  85674. */
  85675. export class SceneComponentConstants {
  85676. static readonly NAME_EFFECTLAYER: string;
  85677. static readonly NAME_LAYER: string;
  85678. static readonly NAME_LENSFLARESYSTEM: string;
  85679. static readonly NAME_BOUNDINGBOXRENDERER: string;
  85680. static readonly NAME_PARTICLESYSTEM: string;
  85681. static readonly NAME_GAMEPAD: string;
  85682. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  85683. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  85684. static readonly NAME_DEPTHRENDERER: string;
  85685. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  85686. static readonly NAME_SPRITE: string;
  85687. static readonly NAME_OUTLINERENDERER: string;
  85688. static readonly NAME_PROCEDURALTEXTURE: string;
  85689. static readonly NAME_SHADOWGENERATOR: string;
  85690. static readonly NAME_OCTREE: string;
  85691. static readonly NAME_PHYSICSENGINE: string;
  85692. static readonly NAME_AUDIO: string;
  85693. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  85694. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  85695. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  85696. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  85697. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  85698. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  85699. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  85700. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  85701. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  85702. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  85703. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  85704. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  85705. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  85706. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  85707. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  85708. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  85709. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  85710. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  85711. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  85712. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  85713. static readonly STEP_AFTERRENDER_AUDIO: number;
  85714. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  85715. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  85716. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  85717. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  85718. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  85719. static readonly STEP_POINTERMOVE_SPRITE: number;
  85720. static readonly STEP_POINTERDOWN_SPRITE: number;
  85721. static readonly STEP_POINTERUP_SPRITE: number;
  85722. }
  85723. /**
  85724. * This represents a scene component.
  85725. *
  85726. * This is used to decouple the dependency the scene is having on the different workloads like
  85727. * layers, post processes...
  85728. */
  85729. export interface ISceneComponent {
  85730. /**
  85731. * The name of the component. Each component must have a unique name.
  85732. */
  85733. name: string;
  85734. /**
  85735. * The scene the component belongs to.
  85736. */
  85737. scene: Scene;
  85738. /**
  85739. * Register the component to one instance of a scene.
  85740. */
  85741. register(): void;
  85742. /**
  85743. * Rebuilds the elements related to this component in case of
  85744. * context lost for instance.
  85745. */
  85746. rebuild(): void;
  85747. /**
  85748. * Disposes the component and the associated ressources.
  85749. */
  85750. dispose(): void;
  85751. }
  85752. /**
  85753. * This represents a SERIALIZABLE scene component.
  85754. *
  85755. * This extends Scene Component to add Serialization methods on top.
  85756. */
  85757. export interface ISceneSerializableComponent extends ISceneComponent {
  85758. /**
  85759. * Adds all the elements from the container to the scene
  85760. * @param container the container holding the elements
  85761. */
  85762. addFromContainer(container: AbstractScene): void;
  85763. /**
  85764. * Removes all the elements in the container from the scene
  85765. * @param container contains the elements to remove
  85766. * @param dispose if the removed element should be disposed (default: false)
  85767. */
  85768. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  85769. /**
  85770. * Serializes the component data to the specified json object
  85771. * @param serializationObject The object to serialize to
  85772. */
  85773. serialize(serializationObject: any): void;
  85774. }
  85775. /**
  85776. * Strong typing of a Mesh related stage step action
  85777. */
  85778. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  85779. /**
  85780. * Strong typing of a Evaluate Sub Mesh related stage step action
  85781. */
  85782. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  85783. /**
  85784. * Strong typing of a Active Mesh related stage step action
  85785. */
  85786. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  85787. /**
  85788. * Strong typing of a Camera related stage step action
  85789. */
  85790. export type CameraStageAction = (camera: Camera) => void;
  85791. /**
  85792. * Strong typing of a Camera Frame buffer related stage step action
  85793. */
  85794. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  85795. /**
  85796. * Strong typing of a Render Target related stage step action
  85797. */
  85798. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  85799. /**
  85800. * Strong typing of a RenderingGroup related stage step action
  85801. */
  85802. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  85803. /**
  85804. * Strong typing of a Mesh Render related stage step action
  85805. */
  85806. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  85807. /**
  85808. * Strong typing of a simple stage step action
  85809. */
  85810. export type SimpleStageAction = () => void;
  85811. /**
  85812. * Strong typing of a render target action.
  85813. */
  85814. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  85815. /**
  85816. * Strong typing of a pointer move action.
  85817. */
  85818. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  85819. /**
  85820. * Strong typing of a pointer up/down action.
  85821. */
  85822. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  85823. /**
  85824. * Representation of a stage in the scene (Basically a list of ordered steps)
  85825. * @hidden
  85826. */
  85827. export class Stage<T extends Function> extends Array<{
  85828. index: number;
  85829. component: ISceneComponent;
  85830. action: T;
  85831. }> {
  85832. /**
  85833. * Hide ctor from the rest of the world.
  85834. * @param items The items to add.
  85835. */
  85836. private constructor();
  85837. /**
  85838. * Creates a new Stage.
  85839. * @returns A new instance of a Stage
  85840. */
  85841. static Create<T extends Function>(): Stage<T>;
  85842. /**
  85843. * Registers a step in an ordered way in the targeted stage.
  85844. * @param index Defines the position to register the step in
  85845. * @param component Defines the component attached to the step
  85846. * @param action Defines the action to launch during the step
  85847. */
  85848. registerStep(index: number, component: ISceneComponent, action: T): void;
  85849. /**
  85850. * Clears all the steps from the stage.
  85851. */
  85852. clear(): void;
  85853. }
  85854. }
  85855. declare module BABYLON {
  85856. interface Scene {
  85857. /** @hidden */
  85858. _pointerOverSprite: Nullable<Sprite>;
  85859. /** @hidden */
  85860. _pickedDownSprite: Nullable<Sprite>;
  85861. /** @hidden */
  85862. _tempSpritePickingRay: Nullable<Ray>;
  85863. /**
  85864. * All of the sprite managers added to this scene
  85865. * @see http://doc.babylonjs.com/babylon101/sprites
  85866. */
  85867. spriteManagers: Array<ISpriteManager>;
  85868. /**
  85869. * An event triggered when sprites rendering is about to start
  85870. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  85871. */
  85872. onBeforeSpritesRenderingObservable: Observable<Scene>;
  85873. /**
  85874. * An event triggered when sprites rendering is done
  85875. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  85876. */
  85877. onAfterSpritesRenderingObservable: Observable<Scene>;
  85878. /** @hidden */
  85879. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  85880. /** Launch a ray to try to pick a sprite in the scene
  85881. * @param x position on screen
  85882. * @param y position on screen
  85883. * @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
  85884. * @param fastCheck defines if the first intersection will be used (and not the closest)
  85885. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  85886. * @returns a PickingInfo
  85887. */
  85888. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  85889. /** Use the given ray to pick a sprite in the scene
  85890. * @param ray The ray (in world space) to use to pick meshes
  85891. * @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
  85892. * @param fastCheck defines if the first intersection will be used (and not the closest)
  85893. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  85894. * @returns a PickingInfo
  85895. */
  85896. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  85897. /** @hidden */
  85898. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  85899. /** Launch a ray to try to pick sprites in the scene
  85900. * @param x position on screen
  85901. * @param y position on screen
  85902. * @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
  85903. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  85904. * @returns a PickingInfo array
  85905. */
  85906. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  85907. /** Use the given ray to pick sprites in the scene
  85908. * @param ray The ray (in world space) to use to pick meshes
  85909. * @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
  85910. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  85911. * @returns a PickingInfo array
  85912. */
  85913. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  85914. /**
  85915. * Force the sprite under the pointer
  85916. * @param sprite defines the sprite to use
  85917. */
  85918. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  85919. /**
  85920. * Gets the sprite under the pointer
  85921. * @returns a Sprite or null if no sprite is under the pointer
  85922. */
  85923. getPointerOverSprite(): Nullable<Sprite>;
  85924. }
  85925. /**
  85926. * Defines the sprite scene component responsible to manage sprites
  85927. * in a given scene.
  85928. */
  85929. export class SpriteSceneComponent implements ISceneComponent {
  85930. /**
  85931. * The component name helpfull to identify the component in the list of scene components.
  85932. */
  85933. readonly name: string;
  85934. /**
  85935. * The scene the component belongs to.
  85936. */
  85937. scene: Scene;
  85938. /** @hidden */
  85939. private _spritePredicate;
  85940. /**
  85941. * Creates a new instance of the component for the given scene
  85942. * @param scene Defines the scene to register the component in
  85943. */
  85944. constructor(scene: Scene);
  85945. /**
  85946. * Registers the component in a given scene
  85947. */
  85948. register(): void;
  85949. /**
  85950. * Rebuilds the elements related to this component in case of
  85951. * context lost for instance.
  85952. */
  85953. rebuild(): void;
  85954. /**
  85955. * Disposes the component and the associated ressources.
  85956. */
  85957. dispose(): void;
  85958. private _pickSpriteButKeepRay;
  85959. private _pointerMove;
  85960. private _pointerDown;
  85961. private _pointerUp;
  85962. }
  85963. }
  85964. declare module BABYLON {
  85965. /** @hidden */
  85966. export var fogFragmentDeclaration: {
  85967. name: string;
  85968. shader: string;
  85969. };
  85970. }
  85971. declare module BABYLON {
  85972. /** @hidden */
  85973. export var fogFragment: {
  85974. name: string;
  85975. shader: string;
  85976. };
  85977. }
  85978. declare module BABYLON {
  85979. /** @hidden */
  85980. export var spritesPixelShader: {
  85981. name: string;
  85982. shader: string;
  85983. };
  85984. }
  85985. declare module BABYLON {
  85986. /** @hidden */
  85987. export var fogVertexDeclaration: {
  85988. name: string;
  85989. shader: string;
  85990. };
  85991. }
  85992. declare module BABYLON {
  85993. /** @hidden */
  85994. export var spritesVertexShader: {
  85995. name: string;
  85996. shader: string;
  85997. };
  85998. }
  85999. declare module BABYLON {
  86000. /**
  86001. * Defines the minimum interface to fullfil in order to be a sprite manager.
  86002. */
  86003. export interface ISpriteManager extends IDisposable {
  86004. /**
  86005. * Restricts the camera to viewing objects with the same layerMask.
  86006. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  86007. */
  86008. layerMask: number;
  86009. /**
  86010. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  86011. */
  86012. isPickable: boolean;
  86013. /**
  86014. * Specifies the rendering group id for this mesh (0 by default)
  86015. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  86016. */
  86017. renderingGroupId: number;
  86018. /**
  86019. * Defines the list of sprites managed by the manager.
  86020. */
  86021. sprites: Array<Sprite>;
  86022. /**
  86023. * Tests the intersection of a sprite with a specific ray.
  86024. * @param ray The ray we are sending to test the collision
  86025. * @param camera The camera space we are sending rays in
  86026. * @param predicate A predicate allowing excluding sprites from the list of object to test
  86027. * @param fastCheck defines if the first intersection will be used (and not the closest)
  86028. * @returns picking info or null.
  86029. */
  86030. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  86031. /**
  86032. * Intersects the sprites with a ray
  86033. * @param ray defines the ray to intersect with
  86034. * @param camera defines the current active camera
  86035. * @param predicate defines a predicate used to select candidate sprites
  86036. * @returns null if no hit or a PickingInfo array
  86037. */
  86038. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  86039. /**
  86040. * Renders the list of sprites on screen.
  86041. */
  86042. render(): void;
  86043. }
  86044. /**
  86045. * Class used to manage multiple sprites on the same spritesheet
  86046. * @see http://doc.babylonjs.com/babylon101/sprites
  86047. */
  86048. export class SpriteManager implements ISpriteManager {
  86049. /** defines the manager's name */
  86050. name: string;
  86051. /** Gets the list of sprites */
  86052. sprites: Sprite[];
  86053. /** Gets or sets the rendering group id (0 by default) */
  86054. renderingGroupId: number;
  86055. /** Gets or sets camera layer mask */
  86056. layerMask: number;
  86057. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  86058. fogEnabled: boolean;
  86059. /** Gets or sets a boolean indicating if the sprites are pickable */
  86060. isPickable: boolean;
  86061. /** Defines the default width of a cell in the spritesheet */
  86062. cellWidth: number;
  86063. /** Defines the default height of a cell in the spritesheet */
  86064. cellHeight: number;
  86065. /** Associative array from JSON sprite data file */
  86066. private _cellData;
  86067. /** Array of sprite names from JSON sprite data file */
  86068. private _spriteMap;
  86069. /** True when packed cell data from JSON file is ready*/
  86070. private _packedAndReady;
  86071. private _textureContent;
  86072. /**
  86073. * An event triggered when the manager is disposed.
  86074. */
  86075. onDisposeObservable: Observable<SpriteManager>;
  86076. private _onDisposeObserver;
  86077. /**
  86078. * Callback called when the manager is disposed
  86079. */
  86080. set onDispose(callback: () => void);
  86081. private _capacity;
  86082. private _fromPacked;
  86083. private _spriteTexture;
  86084. private _epsilon;
  86085. private _scene;
  86086. private _vertexData;
  86087. private _buffer;
  86088. private _vertexBuffers;
  86089. private _indexBuffer;
  86090. private _effectBase;
  86091. private _effectFog;
  86092. /**
  86093. * Gets or sets the spritesheet texture
  86094. */
  86095. get texture(): Texture;
  86096. set texture(value: Texture);
  86097. private _blendMode;
  86098. /**
  86099. * Blend mode use to render the particle, it can be any of
  86100. * the static Constants.ALPHA_x properties provided in this class.
  86101. * Default value is Constants.ALPHA_COMBINE
  86102. */
  86103. get blendMode(): number;
  86104. set blendMode(blendMode: number);
  86105. /** Disables writing to the depth buffer when rendering the sprites.
  86106. * It can be handy to disable depth writing when using textures without alpha channel
  86107. * and setting some specific blend modes.
  86108. */
  86109. disableDepthWrite: boolean;
  86110. /**
  86111. * Creates a new sprite manager
  86112. * @param name defines the manager's name
  86113. * @param imgUrl defines the sprite sheet url
  86114. * @param capacity defines the maximum allowed number of sprites
  86115. * @param cellSize defines the size of a sprite cell
  86116. * @param scene defines the hosting scene
  86117. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  86118. * @param samplingMode defines the smapling mode to use with spritesheet
  86119. * @param fromPacked set to false; do not alter
  86120. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  86121. */
  86122. constructor(
  86123. /** defines the manager's name */
  86124. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  86125. private _makePacked;
  86126. private _appendSpriteVertex;
  86127. private _checkTextureAlpha;
  86128. /**
  86129. * Intersects the sprites with a ray
  86130. * @param ray defines the ray to intersect with
  86131. * @param camera defines the current active camera
  86132. * @param predicate defines a predicate used to select candidate sprites
  86133. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  86134. * @returns null if no hit or a PickingInfo
  86135. */
  86136. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  86137. /**
  86138. * Intersects the sprites with a ray
  86139. * @param ray defines the ray to intersect with
  86140. * @param camera defines the current active camera
  86141. * @param predicate defines a predicate used to select candidate sprites
  86142. * @returns null if no hit or a PickingInfo array
  86143. */
  86144. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  86145. /**
  86146. * Render all child sprites
  86147. */
  86148. render(): void;
  86149. /**
  86150. * Release associated resources
  86151. */
  86152. dispose(): void;
  86153. }
  86154. }
  86155. declare module BABYLON {
  86156. /** Interface used by value gradients (color, factor, ...) */
  86157. export interface IValueGradient {
  86158. /**
  86159. * Gets or sets the gradient value (between 0 and 1)
  86160. */
  86161. gradient: number;
  86162. }
  86163. /** Class used to store color4 gradient */
  86164. export class ColorGradient implements IValueGradient {
  86165. /**
  86166. * Gets or sets the gradient value (between 0 and 1)
  86167. */
  86168. gradient: number;
  86169. /**
  86170. * Gets or sets first associated color
  86171. */
  86172. color1: Color4;
  86173. /**
  86174. * Gets or sets second associated color
  86175. */
  86176. color2?: Color4 | undefined;
  86177. /**
  86178. * Creates a new color4 gradient
  86179. * @param gradient gets or sets the gradient value (between 0 and 1)
  86180. * @param color1 gets or sets first associated color
  86181. * @param color2 gets or sets first second color
  86182. */
  86183. constructor(
  86184. /**
  86185. * Gets or sets the gradient value (between 0 and 1)
  86186. */
  86187. gradient: number,
  86188. /**
  86189. * Gets or sets first associated color
  86190. */
  86191. color1: Color4,
  86192. /**
  86193. * Gets or sets second associated color
  86194. */
  86195. color2?: Color4 | undefined);
  86196. /**
  86197. * Will get a color picked randomly between color1 and color2.
  86198. * If color2 is undefined then color1 will be used
  86199. * @param result defines the target Color4 to store the result in
  86200. */
  86201. getColorToRef(result: Color4): void;
  86202. }
  86203. /** Class used to store color 3 gradient */
  86204. export class Color3Gradient implements IValueGradient {
  86205. /**
  86206. * Gets or sets the gradient value (between 0 and 1)
  86207. */
  86208. gradient: number;
  86209. /**
  86210. * Gets or sets the associated color
  86211. */
  86212. color: Color3;
  86213. /**
  86214. * Creates a new color3 gradient
  86215. * @param gradient gets or sets the gradient value (between 0 and 1)
  86216. * @param color gets or sets associated color
  86217. */
  86218. constructor(
  86219. /**
  86220. * Gets or sets the gradient value (between 0 and 1)
  86221. */
  86222. gradient: number,
  86223. /**
  86224. * Gets or sets the associated color
  86225. */
  86226. color: Color3);
  86227. }
  86228. /** Class used to store factor gradient */
  86229. export class FactorGradient implements IValueGradient {
  86230. /**
  86231. * Gets or sets the gradient value (between 0 and 1)
  86232. */
  86233. gradient: number;
  86234. /**
  86235. * Gets or sets first associated factor
  86236. */
  86237. factor1: number;
  86238. /**
  86239. * Gets or sets second associated factor
  86240. */
  86241. factor2?: number | undefined;
  86242. /**
  86243. * Creates a new factor gradient
  86244. * @param gradient gets or sets the gradient value (between 0 and 1)
  86245. * @param factor1 gets or sets first associated factor
  86246. * @param factor2 gets or sets second associated factor
  86247. */
  86248. constructor(
  86249. /**
  86250. * Gets or sets the gradient value (between 0 and 1)
  86251. */
  86252. gradient: number,
  86253. /**
  86254. * Gets or sets first associated factor
  86255. */
  86256. factor1: number,
  86257. /**
  86258. * Gets or sets second associated factor
  86259. */
  86260. factor2?: number | undefined);
  86261. /**
  86262. * Will get a number picked randomly between factor1 and factor2.
  86263. * If factor2 is undefined then factor1 will be used
  86264. * @returns the picked number
  86265. */
  86266. getFactor(): number;
  86267. }
  86268. /**
  86269. * Helper used to simplify some generic gradient tasks
  86270. */
  86271. export class GradientHelper {
  86272. /**
  86273. * Gets the current gradient from an array of IValueGradient
  86274. * @param ratio defines the current ratio to get
  86275. * @param gradients defines the array of IValueGradient
  86276. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  86277. */
  86278. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  86279. }
  86280. }
  86281. declare module BABYLON {
  86282. /**
  86283. * Interface for the size containing width and height
  86284. */
  86285. export interface ISize {
  86286. /**
  86287. * Width
  86288. */
  86289. width: number;
  86290. /**
  86291. * Heighht
  86292. */
  86293. height: number;
  86294. }
  86295. /**
  86296. * Size containing widht and height
  86297. */
  86298. export class Size implements ISize {
  86299. /**
  86300. * Width
  86301. */
  86302. width: number;
  86303. /**
  86304. * Height
  86305. */
  86306. height: number;
  86307. /**
  86308. * Creates a Size object from the given width and height (floats).
  86309. * @param width width of the new size
  86310. * @param height height of the new size
  86311. */
  86312. constructor(width: number, height: number);
  86313. /**
  86314. * Returns a string with the Size width and height
  86315. * @returns a string with the Size width and height
  86316. */
  86317. toString(): string;
  86318. /**
  86319. * "Size"
  86320. * @returns the string "Size"
  86321. */
  86322. getClassName(): string;
  86323. /**
  86324. * Returns the Size hash code.
  86325. * @returns a hash code for a unique width and height
  86326. */
  86327. getHashCode(): number;
  86328. /**
  86329. * Updates the current size from the given one.
  86330. * @param src the given size
  86331. */
  86332. copyFrom(src: Size): void;
  86333. /**
  86334. * Updates in place the current Size from the given floats.
  86335. * @param width width of the new size
  86336. * @param height height of the new size
  86337. * @returns the updated Size.
  86338. */
  86339. copyFromFloats(width: number, height: number): Size;
  86340. /**
  86341. * Updates in place the current Size from the given floats.
  86342. * @param width width to set
  86343. * @param height height to set
  86344. * @returns the updated Size.
  86345. */
  86346. set(width: number, height: number): Size;
  86347. /**
  86348. * Multiplies the width and height by numbers
  86349. * @param w factor to multiple the width by
  86350. * @param h factor to multiple the height by
  86351. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  86352. */
  86353. multiplyByFloats(w: number, h: number): Size;
  86354. /**
  86355. * Clones the size
  86356. * @returns a new Size copied from the given one.
  86357. */
  86358. clone(): Size;
  86359. /**
  86360. * True if the current Size and the given one width and height are strictly equal.
  86361. * @param other the other size to compare against
  86362. * @returns True if the current Size and the given one width and height are strictly equal.
  86363. */
  86364. equals(other: Size): boolean;
  86365. /**
  86366. * The surface of the Size : width * height (float).
  86367. */
  86368. get surface(): number;
  86369. /**
  86370. * Create a new size of zero
  86371. * @returns a new Size set to (0.0, 0.0)
  86372. */
  86373. static Zero(): Size;
  86374. /**
  86375. * Sums the width and height of two sizes
  86376. * @param otherSize size to add to this size
  86377. * @returns a new Size set as the addition result of the current Size and the given one.
  86378. */
  86379. add(otherSize: Size): Size;
  86380. /**
  86381. * Subtracts the width and height of two
  86382. * @param otherSize size to subtract to this size
  86383. * @returns a new Size set as the subtraction result of the given one from the current Size.
  86384. */
  86385. subtract(otherSize: Size): Size;
  86386. /**
  86387. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  86388. * @param start starting size to lerp between
  86389. * @param end end size to lerp between
  86390. * @param amount amount to lerp between the start and end values
  86391. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  86392. */
  86393. static Lerp(start: Size, end: Size, amount: number): Size;
  86394. }
  86395. }
  86396. declare module BABYLON {
  86397. interface ThinEngine {
  86398. /**
  86399. * Creates a dynamic texture
  86400. * @param width defines the width of the texture
  86401. * @param height defines the height of the texture
  86402. * @param generateMipMaps defines if the engine should generate the mip levels
  86403. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  86404. * @returns the dynamic texture inside an InternalTexture
  86405. */
  86406. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  86407. /**
  86408. * Update the content of a dynamic texture
  86409. * @param texture defines the texture to update
  86410. * @param canvas defines the canvas containing the source
  86411. * @param invertY defines if data must be stored with Y axis inverted
  86412. * @param premulAlpha defines if alpha is stored as premultiplied
  86413. * @param format defines the format of the data
  86414. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  86415. */
  86416. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  86417. }
  86418. }
  86419. declare module BABYLON {
  86420. /**
  86421. * Helper class used to generate a canvas to manipulate images
  86422. */
  86423. export class CanvasGenerator {
  86424. /**
  86425. * Create a new canvas (or offscreen canvas depending on the context)
  86426. * @param width defines the expected width
  86427. * @param height defines the expected height
  86428. * @return a new canvas or offscreen canvas
  86429. */
  86430. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  86431. }
  86432. }
  86433. declare module BABYLON {
  86434. /**
  86435. * A class extending Texture allowing drawing on a texture
  86436. * @see http://doc.babylonjs.com/how_to/dynamictexture
  86437. */
  86438. export class DynamicTexture extends Texture {
  86439. private _generateMipMaps;
  86440. private _canvas;
  86441. private _context;
  86442. /**
  86443. * Creates a DynamicTexture
  86444. * @param name defines the name of the texture
  86445. * @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
  86446. * @param scene defines the scene where you want the texture
  86447. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  86448. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  86449. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  86450. */
  86451. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  86452. /**
  86453. * Get the current class name of the texture useful for serialization or dynamic coding.
  86454. * @returns "DynamicTexture"
  86455. */
  86456. getClassName(): string;
  86457. /**
  86458. * Gets the current state of canRescale
  86459. */
  86460. get canRescale(): boolean;
  86461. private _recreate;
  86462. /**
  86463. * Scales the texture
  86464. * @param ratio the scale factor to apply to both width and height
  86465. */
  86466. scale(ratio: number): void;
  86467. /**
  86468. * Resizes the texture
  86469. * @param width the new width
  86470. * @param height the new height
  86471. */
  86472. scaleTo(width: number, height: number): void;
  86473. /**
  86474. * Gets the context of the canvas used by the texture
  86475. * @returns the canvas context of the dynamic texture
  86476. */
  86477. getContext(): CanvasRenderingContext2D;
  86478. /**
  86479. * Clears the texture
  86480. */
  86481. clear(): void;
  86482. /**
  86483. * Updates the texture
  86484. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  86485. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  86486. */
  86487. update(invertY?: boolean, premulAlpha?: boolean): void;
  86488. /**
  86489. * Draws text onto the texture
  86490. * @param text defines the text to be drawn
  86491. * @param x defines the placement of the text from the left
  86492. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  86493. * @param font defines the font to be used with font-style, font-size, font-name
  86494. * @param color defines the color used for the text
  86495. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  86496. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  86497. * @param update defines whether texture is immediately update (default is true)
  86498. */
  86499. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, clearColor: string, invertY?: boolean, update?: boolean): void;
  86500. /**
  86501. * Clones the texture
  86502. * @returns the clone of the texture.
  86503. */
  86504. clone(): DynamicTexture;
  86505. /**
  86506. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  86507. * @returns a serialized dynamic texture object
  86508. */
  86509. serialize(): any;
  86510. /** @hidden */
  86511. _rebuild(): void;
  86512. }
  86513. }
  86514. declare module BABYLON {
  86515. interface ThinEngine {
  86516. /**
  86517. * Creates a raw texture
  86518. * @param data defines the data to store in the texture
  86519. * @param width defines the width of the texture
  86520. * @param height defines the height of the texture
  86521. * @param format defines the format of the data
  86522. * @param generateMipMaps defines if the engine should generate the mip levels
  86523. * @param invertY defines if data must be stored with Y axis inverted
  86524. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  86525. * @param compression defines the compression used (null by default)
  86526. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  86527. * @returns the raw texture inside an InternalTexture
  86528. */
  86529. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  86530. /**
  86531. * Update a raw texture
  86532. * @param texture defines the texture to update
  86533. * @param data defines the data to store in the texture
  86534. * @param format defines the format of the data
  86535. * @param invertY defines if data must be stored with Y axis inverted
  86536. */
  86537. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  86538. /**
  86539. * Update a raw texture
  86540. * @param texture defines the texture to update
  86541. * @param data defines the data to store in the texture
  86542. * @param format defines the format of the data
  86543. * @param invertY defines if data must be stored with Y axis inverted
  86544. * @param compression defines the compression used (null by default)
  86545. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  86546. */
  86547. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  86548. /**
  86549. * Creates a new raw cube texture
  86550. * @param data defines the array of data to use to create each face
  86551. * @param size defines the size of the textures
  86552. * @param format defines the format of the data
  86553. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  86554. * @param generateMipMaps defines if the engine should generate the mip levels
  86555. * @param invertY defines if data must be stored with Y axis inverted
  86556. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  86557. * @param compression defines the compression used (null by default)
  86558. * @returns the cube texture as an InternalTexture
  86559. */
  86560. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  86561. /**
  86562. * Update a raw cube texture
  86563. * @param texture defines the texture to udpdate
  86564. * @param data defines the data to store
  86565. * @param format defines the data format
  86566. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  86567. * @param invertY defines if data must be stored with Y axis inverted
  86568. */
  86569. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  86570. /**
  86571. * Update a raw cube texture
  86572. * @param texture defines the texture to udpdate
  86573. * @param data defines the data to store
  86574. * @param format defines the data format
  86575. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  86576. * @param invertY defines if data must be stored with Y axis inverted
  86577. * @param compression defines the compression used (null by default)
  86578. */
  86579. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  86580. /**
  86581. * Update a raw cube texture
  86582. * @param texture defines the texture to udpdate
  86583. * @param data defines the data to store
  86584. * @param format defines the data format
  86585. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  86586. * @param invertY defines if data must be stored with Y axis inverted
  86587. * @param compression defines the compression used (null by default)
  86588. * @param level defines which level of the texture to update
  86589. */
  86590. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  86591. /**
  86592. * Creates a new raw cube texture from a specified url
  86593. * @param url defines the url where the data is located
  86594. * @param scene defines the current scene
  86595. * @param size defines the size of the textures
  86596. * @param format defines the format of the data
  86597. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  86598. * @param noMipmap defines if the engine should avoid generating the mip levels
  86599. * @param callback defines a callback used to extract texture data from loaded data
  86600. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  86601. * @param onLoad defines a callback called when texture is loaded
  86602. * @param onError defines a callback called if there is an error
  86603. * @returns the cube texture as an InternalTexture
  86604. */
  86605. 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;
  86606. /**
  86607. * Creates a new raw cube texture from a specified url
  86608. * @param url defines the url where the data is located
  86609. * @param scene defines the current scene
  86610. * @param size defines the size of the textures
  86611. * @param format defines the format of the data
  86612. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  86613. * @param noMipmap defines if the engine should avoid generating the mip levels
  86614. * @param callback defines a callback used to extract texture data from loaded data
  86615. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  86616. * @param onLoad defines a callback called when texture is loaded
  86617. * @param onError defines a callback called if there is an error
  86618. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  86619. * @param invertY defines if data must be stored with Y axis inverted
  86620. * @returns the cube texture as an InternalTexture
  86621. */
  86622. 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;
  86623. /**
  86624. * Creates a new raw 3D texture
  86625. * @param data defines the data used to create the texture
  86626. * @param width defines the width of the texture
  86627. * @param height defines the height of the texture
  86628. * @param depth defines the depth of the texture
  86629. * @param format defines the format of the texture
  86630. * @param generateMipMaps defines if the engine must generate mip levels
  86631. * @param invertY defines if data must be stored with Y axis inverted
  86632. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  86633. * @param compression defines the compressed used (can be null)
  86634. * @param textureType defines the compressed used (can be null)
  86635. * @returns a new raw 3D texture (stored in an InternalTexture)
  86636. */
  86637. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  86638. /**
  86639. * Update a raw 3D texture
  86640. * @param texture defines the texture to update
  86641. * @param data defines the data to store
  86642. * @param format defines the data format
  86643. * @param invertY defines if data must be stored with Y axis inverted
  86644. */
  86645. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  86646. /**
  86647. * Update a raw 3D texture
  86648. * @param texture defines the texture to update
  86649. * @param data defines the data to store
  86650. * @param format defines the data format
  86651. * @param invertY defines if data must be stored with Y axis inverted
  86652. * @param compression defines the used compression (can be null)
  86653. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  86654. */
  86655. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  86656. /**
  86657. * Creates a new raw 2D array texture
  86658. * @param data defines the data used to create the texture
  86659. * @param width defines the width of the texture
  86660. * @param height defines the height of the texture
  86661. * @param depth defines the number of layers of the texture
  86662. * @param format defines the format of the texture
  86663. * @param generateMipMaps defines if the engine must generate mip levels
  86664. * @param invertY defines if data must be stored with Y axis inverted
  86665. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  86666. * @param compression defines the compressed used (can be null)
  86667. * @param textureType defines the compressed used (can be null)
  86668. * @returns a new raw 2D array texture (stored in an InternalTexture)
  86669. */
  86670. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  86671. /**
  86672. * Update a raw 2D array texture
  86673. * @param texture defines the texture to update
  86674. * @param data defines the data to store
  86675. * @param format defines the data format
  86676. * @param invertY defines if data must be stored with Y axis inverted
  86677. */
  86678. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  86679. /**
  86680. * Update a raw 2D array texture
  86681. * @param texture defines the texture to update
  86682. * @param data defines the data to store
  86683. * @param format defines the data format
  86684. * @param invertY defines if data must be stored with Y axis inverted
  86685. * @param compression defines the used compression (can be null)
  86686. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  86687. */
  86688. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  86689. }
  86690. }
  86691. declare module BABYLON {
  86692. /**
  86693. * Raw texture can help creating a texture directly from an array of data.
  86694. * This can be super useful if you either get the data from an uncompressed source or
  86695. * if you wish to create your texture pixel by pixel.
  86696. */
  86697. export class RawTexture extends Texture {
  86698. /**
  86699. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  86700. */
  86701. format: number;
  86702. /**
  86703. * Instantiates a new RawTexture.
  86704. * Raw texture can help creating a texture directly from an array of data.
  86705. * This can be super useful if you either get the data from an uncompressed source or
  86706. * if you wish to create your texture pixel by pixel.
  86707. * @param data define the array of data to use to create the texture
  86708. * @param width define the width of the texture
  86709. * @param height define the height of the texture
  86710. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  86711. * @param scene define the scene the texture belongs to
  86712. * @param generateMipMaps define whether mip maps should be generated or not
  86713. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  86714. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  86715. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  86716. */
  86717. constructor(data: ArrayBufferView, width: number, height: number,
  86718. /**
  86719. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  86720. */
  86721. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  86722. /**
  86723. * Updates the texture underlying data.
  86724. * @param data Define the new data of the texture
  86725. */
  86726. update(data: ArrayBufferView): void;
  86727. /**
  86728. * Creates a luminance texture from some data.
  86729. * @param data Define the texture data
  86730. * @param width Define the width of the texture
  86731. * @param height Define the height of the texture
  86732. * @param scene Define the scene the texture belongs to
  86733. * @param generateMipMaps Define whether or not to create mip maps for the texture
  86734. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  86735. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  86736. * @returns the luminance texture
  86737. */
  86738. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  86739. /**
  86740. * Creates a luminance alpha texture from some data.
  86741. * @param data Define the texture data
  86742. * @param width Define the width of the texture
  86743. * @param height Define the height of the texture
  86744. * @param scene Define the scene the texture belongs to
  86745. * @param generateMipMaps Define whether or not to create mip maps for the texture
  86746. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  86747. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  86748. * @returns the luminance alpha texture
  86749. */
  86750. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  86751. /**
  86752. * Creates an alpha texture from some data.
  86753. * @param data Define the texture data
  86754. * @param width Define the width of the texture
  86755. * @param height Define the height of the texture
  86756. * @param scene Define the scene the texture belongs to
  86757. * @param generateMipMaps Define whether or not to create mip maps for the texture
  86758. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  86759. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  86760. * @returns the alpha texture
  86761. */
  86762. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  86763. /**
  86764. * Creates a RGB texture from some data.
  86765. * @param data Define the texture data
  86766. * @param width Define the width of the texture
  86767. * @param height Define the height of the texture
  86768. * @param scene Define the scene the texture belongs to
  86769. * @param generateMipMaps Define whether or not to create mip maps for the texture
  86770. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  86771. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  86772. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  86773. * @returns the RGB alpha texture
  86774. */
  86775. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  86776. /**
  86777. * Creates a RGBA texture from some data.
  86778. * @param data Define the texture data
  86779. * @param width Define the width of the texture
  86780. * @param height Define the height of the texture
  86781. * @param scene Define the scene the texture belongs to
  86782. * @param generateMipMaps Define whether or not to create mip maps for the texture
  86783. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  86784. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  86785. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  86786. * @returns the RGBA texture
  86787. */
  86788. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  86789. /**
  86790. * Creates a R texture from some data.
  86791. * @param data Define the texture data
  86792. * @param width Define the width of the texture
  86793. * @param height Define the height of the texture
  86794. * @param scene Define the scene the texture belongs to
  86795. * @param generateMipMaps Define whether or not to create mip maps for the texture
  86796. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  86797. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  86798. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  86799. * @returns the R texture
  86800. */
  86801. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  86802. }
  86803. }
  86804. declare module BABYLON {
  86805. interface AbstractScene {
  86806. /**
  86807. * The list of procedural textures added to the scene
  86808. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  86809. */
  86810. proceduralTextures: Array<ProceduralTexture>;
  86811. }
  86812. /**
  86813. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  86814. * in a given scene.
  86815. */
  86816. export class ProceduralTextureSceneComponent implements ISceneComponent {
  86817. /**
  86818. * The component name helpfull to identify the component in the list of scene components.
  86819. */
  86820. readonly name: string;
  86821. /**
  86822. * The scene the component belongs to.
  86823. */
  86824. scene: Scene;
  86825. /**
  86826. * Creates a new instance of the component for the given scene
  86827. * @param scene Defines the scene to register the component in
  86828. */
  86829. constructor(scene: Scene);
  86830. /**
  86831. * Registers the component in a given scene
  86832. */
  86833. register(): void;
  86834. /**
  86835. * Rebuilds the elements related to this component in case of
  86836. * context lost for instance.
  86837. */
  86838. rebuild(): void;
  86839. /**
  86840. * Disposes the component and the associated ressources.
  86841. */
  86842. dispose(): void;
  86843. private _beforeClear;
  86844. }
  86845. }
  86846. declare module BABYLON {
  86847. interface ThinEngine {
  86848. /**
  86849. * Creates a new render target cube texture
  86850. * @param size defines the size of the texture
  86851. * @param options defines the options used to create the texture
  86852. * @returns a new render target cube texture stored in an InternalTexture
  86853. */
  86854. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  86855. }
  86856. }
  86857. declare module BABYLON {
  86858. /** @hidden */
  86859. export var proceduralVertexShader: {
  86860. name: string;
  86861. shader: string;
  86862. };
  86863. }
  86864. declare module BABYLON {
  86865. /**
  86866. * 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.
  86867. * This is the base class of any Procedural texture and contains most of the shareable code.
  86868. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  86869. */
  86870. export class ProceduralTexture extends Texture {
  86871. isCube: boolean;
  86872. /**
  86873. * Define if the texture is enabled or not (disabled texture will not render)
  86874. */
  86875. isEnabled: boolean;
  86876. /**
  86877. * Define if the texture must be cleared before rendering (default is true)
  86878. */
  86879. autoClear: boolean;
  86880. /**
  86881. * Callback called when the texture is generated
  86882. */
  86883. onGenerated: () => void;
  86884. /**
  86885. * Event raised when the texture is generated
  86886. */
  86887. onGeneratedObservable: Observable<ProceduralTexture>;
  86888. /** @hidden */
  86889. _generateMipMaps: boolean;
  86890. /** @hidden **/
  86891. _effect: Effect;
  86892. /** @hidden */
  86893. _textures: {
  86894. [key: string]: Texture;
  86895. };
  86896. /** @hidden */
  86897. protected _fallbackTexture: Nullable<Texture>;
  86898. private _size;
  86899. private _currentRefreshId;
  86900. private _frameId;
  86901. private _refreshRate;
  86902. private _vertexBuffers;
  86903. private _indexBuffer;
  86904. private _uniforms;
  86905. private _samplers;
  86906. private _fragment;
  86907. private _floats;
  86908. private _ints;
  86909. private _floatsArrays;
  86910. private _colors3;
  86911. private _colors4;
  86912. private _vectors2;
  86913. private _vectors3;
  86914. private _matrices;
  86915. private _fallbackTextureUsed;
  86916. private _fullEngine;
  86917. private _cachedDefines;
  86918. private _contentUpdateId;
  86919. private _contentData;
  86920. /**
  86921. * Instantiates a new procedural texture.
  86922. * 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.
  86923. * This is the base class of any Procedural texture and contains most of the shareable code.
  86924. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  86925. * @param name Define the name of the texture
  86926. * @param size Define the size of the texture to create
  86927. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  86928. * @param scene Define the scene the texture belongs to
  86929. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  86930. * @param generateMipMaps Define if the texture should creates mip maps or not
  86931. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  86932. */
  86933. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  86934. /**
  86935. * The effect that is created when initializing the post process.
  86936. * @returns The created effect corresponding the the postprocess.
  86937. */
  86938. getEffect(): Effect;
  86939. /**
  86940. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  86941. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  86942. */
  86943. getContent(): Nullable<ArrayBufferView>;
  86944. private _createIndexBuffer;
  86945. /** @hidden */
  86946. _rebuild(): void;
  86947. /**
  86948. * Resets the texture in order to recreate its associated resources.
  86949. * This can be called in case of context loss
  86950. */
  86951. reset(): void;
  86952. protected _getDefines(): string;
  86953. /**
  86954. * Is the texture ready to be used ? (rendered at least once)
  86955. * @returns true if ready, otherwise, false.
  86956. */
  86957. isReady(): boolean;
  86958. /**
  86959. * Resets the refresh counter of the texture and start bak from scratch.
  86960. * Could be useful to regenerate the texture if it is setup to render only once.
  86961. */
  86962. resetRefreshCounter(): void;
  86963. /**
  86964. * Set the fragment shader to use in order to render the texture.
  86965. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  86966. */
  86967. setFragment(fragment: any): void;
  86968. /**
  86969. * Define the refresh rate of the texture or the rendering frequency.
  86970. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  86971. */
  86972. get refreshRate(): number;
  86973. set refreshRate(value: number);
  86974. /** @hidden */
  86975. _shouldRender(): boolean;
  86976. /**
  86977. * Get the size the texture is rendering at.
  86978. * @returns the size (texture is always squared)
  86979. */
  86980. getRenderSize(): number;
  86981. /**
  86982. * Resize the texture to new value.
  86983. * @param size Define the new size the texture should have
  86984. * @param generateMipMaps Define whether the new texture should create mip maps
  86985. */
  86986. resize(size: number, generateMipMaps: boolean): void;
  86987. private _checkUniform;
  86988. /**
  86989. * Set a texture in the shader program used to render.
  86990. * @param name Define the name of the uniform samplers as defined in the shader
  86991. * @param texture Define the texture to bind to this sampler
  86992. * @return the texture itself allowing "fluent" like uniform updates
  86993. */
  86994. setTexture(name: string, texture: Texture): ProceduralTexture;
  86995. /**
  86996. * Set a float in the shader.
  86997. * @param name Define the name of the uniform as defined in the shader
  86998. * @param value Define the value to give to the uniform
  86999. * @return the texture itself allowing "fluent" like uniform updates
  87000. */
  87001. setFloat(name: string, value: number): ProceduralTexture;
  87002. /**
  87003. * Set a int in the shader.
  87004. * @param name Define the name of the uniform as defined in the shader
  87005. * @param value Define the value to give to the uniform
  87006. * @return the texture itself allowing "fluent" like uniform updates
  87007. */
  87008. setInt(name: string, value: number): ProceduralTexture;
  87009. /**
  87010. * Set an array of floats in the shader.
  87011. * @param name Define the name of the uniform as defined in the shader
  87012. * @param value Define the value to give to the uniform
  87013. * @return the texture itself allowing "fluent" like uniform updates
  87014. */
  87015. setFloats(name: string, value: number[]): ProceduralTexture;
  87016. /**
  87017. * Set a vec3 in the shader from a Color3.
  87018. * @param name Define the name of the uniform as defined in the shader
  87019. * @param value Define the value to give to the uniform
  87020. * @return the texture itself allowing "fluent" like uniform updates
  87021. */
  87022. setColor3(name: string, value: Color3): ProceduralTexture;
  87023. /**
  87024. * Set a vec4 in the shader from a Color4.
  87025. * @param name Define the name of the uniform as defined in the shader
  87026. * @param value Define the value to give to the uniform
  87027. * @return the texture itself allowing "fluent" like uniform updates
  87028. */
  87029. setColor4(name: string, value: Color4): ProceduralTexture;
  87030. /**
  87031. * Set a vec2 in the shader from a Vector2.
  87032. * @param name Define the name of the uniform as defined in the shader
  87033. * @param value Define the value to give to the uniform
  87034. * @return the texture itself allowing "fluent" like uniform updates
  87035. */
  87036. setVector2(name: string, value: Vector2): ProceduralTexture;
  87037. /**
  87038. * Set a vec3 in the shader from a Vector3.
  87039. * @param name Define the name of the uniform as defined in the shader
  87040. * @param value Define the value to give to the uniform
  87041. * @return the texture itself allowing "fluent" like uniform updates
  87042. */
  87043. setVector3(name: string, value: Vector3): ProceduralTexture;
  87044. /**
  87045. * Set a mat4 in the shader from a MAtrix.
  87046. * @param name Define the name of the uniform as defined in the shader
  87047. * @param value Define the value to give to the uniform
  87048. * @return the texture itself allowing "fluent" like uniform updates
  87049. */
  87050. setMatrix(name: string, value: Matrix): ProceduralTexture;
  87051. /**
  87052. * Render the texture to its associated render target.
  87053. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  87054. */
  87055. render(useCameraPostProcess?: boolean): void;
  87056. /**
  87057. * Clone the texture.
  87058. * @returns the cloned texture
  87059. */
  87060. clone(): ProceduralTexture;
  87061. /**
  87062. * Dispose the texture and release its asoociated resources.
  87063. */
  87064. dispose(): void;
  87065. }
  87066. }
  87067. declare module BABYLON {
  87068. /**
  87069. * This represents the base class for particle system in Babylon.
  87070. * 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.
  87071. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  87072. * @example https://doc.babylonjs.com/babylon101/particles
  87073. */
  87074. export class BaseParticleSystem {
  87075. /**
  87076. * Source color is added to the destination color without alpha affecting the result
  87077. */
  87078. static BLENDMODE_ONEONE: number;
  87079. /**
  87080. * Blend current color and particle color using particle’s alpha
  87081. */
  87082. static BLENDMODE_STANDARD: number;
  87083. /**
  87084. * Add current color and particle color multiplied by particle’s alpha
  87085. */
  87086. static BLENDMODE_ADD: number;
  87087. /**
  87088. * Multiply current color with particle color
  87089. */
  87090. static BLENDMODE_MULTIPLY: number;
  87091. /**
  87092. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  87093. */
  87094. static BLENDMODE_MULTIPLYADD: number;
  87095. /**
  87096. * List of animations used by the particle system.
  87097. */
  87098. animations: Animation[];
  87099. /**
  87100. * Gets or sets the unique id of the particle system
  87101. */
  87102. uniqueId: number;
  87103. /**
  87104. * The id of the Particle system.
  87105. */
  87106. id: string;
  87107. /**
  87108. * The friendly name of the Particle system.
  87109. */
  87110. name: string;
  87111. /**
  87112. * Snippet ID if the particle system was created from the snippet server
  87113. */
  87114. snippetId: string;
  87115. /**
  87116. * The rendering group used by the Particle system to chose when to render.
  87117. */
  87118. renderingGroupId: number;
  87119. /**
  87120. * The emitter represents the Mesh or position we are attaching the particle system to.
  87121. */
  87122. emitter: Nullable<AbstractMesh | Vector3>;
  87123. /**
  87124. * The maximum number of particles to emit per frame
  87125. */
  87126. emitRate: number;
  87127. /**
  87128. * If you want to launch only a few particles at once, that can be done, as well.
  87129. */
  87130. manualEmitCount: number;
  87131. /**
  87132. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  87133. */
  87134. updateSpeed: number;
  87135. /**
  87136. * The amount of time the particle system is running (depends of the overall update speed).
  87137. */
  87138. targetStopDuration: number;
  87139. /**
  87140. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  87141. */
  87142. disposeOnStop: boolean;
  87143. /**
  87144. * Minimum power of emitting particles.
  87145. */
  87146. minEmitPower: number;
  87147. /**
  87148. * Maximum power of emitting particles.
  87149. */
  87150. maxEmitPower: number;
  87151. /**
  87152. * Minimum life time of emitting particles.
  87153. */
  87154. minLifeTime: number;
  87155. /**
  87156. * Maximum life time of emitting particles.
  87157. */
  87158. maxLifeTime: number;
  87159. /**
  87160. * Minimum Size of emitting particles.
  87161. */
  87162. minSize: number;
  87163. /**
  87164. * Maximum Size of emitting particles.
  87165. */
  87166. maxSize: number;
  87167. /**
  87168. * Minimum scale of emitting particles on X axis.
  87169. */
  87170. minScaleX: number;
  87171. /**
  87172. * Maximum scale of emitting particles on X axis.
  87173. */
  87174. maxScaleX: number;
  87175. /**
  87176. * Minimum scale of emitting particles on Y axis.
  87177. */
  87178. minScaleY: number;
  87179. /**
  87180. * Maximum scale of emitting particles on Y axis.
  87181. */
  87182. maxScaleY: number;
  87183. /**
  87184. * Gets or sets the minimal initial rotation in radians.
  87185. */
  87186. minInitialRotation: number;
  87187. /**
  87188. * Gets or sets the maximal initial rotation in radians.
  87189. */
  87190. maxInitialRotation: number;
  87191. /**
  87192. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  87193. */
  87194. minAngularSpeed: number;
  87195. /**
  87196. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  87197. */
  87198. maxAngularSpeed: number;
  87199. /**
  87200. * The texture used to render each particle. (this can be a spritesheet)
  87201. */
  87202. particleTexture: Nullable<Texture>;
  87203. /**
  87204. * The layer mask we are rendering the particles through.
  87205. */
  87206. layerMask: number;
  87207. /**
  87208. * This can help using your own shader to render the particle system.
  87209. * The according effect will be created
  87210. */
  87211. customShader: any;
  87212. /**
  87213. * By default particle system starts as soon as they are created. This prevents the
  87214. * automatic start to happen and let you decide when to start emitting particles.
  87215. */
  87216. preventAutoStart: boolean;
  87217. private _noiseTexture;
  87218. /**
  87219. * Gets or sets a texture used to add random noise to particle positions
  87220. */
  87221. get noiseTexture(): Nullable<ProceduralTexture>;
  87222. set noiseTexture(value: Nullable<ProceduralTexture>);
  87223. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  87224. noiseStrength: Vector3;
  87225. /**
  87226. * Callback triggered when the particle animation is ending.
  87227. */
  87228. onAnimationEnd: Nullable<() => void>;
  87229. /**
  87230. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  87231. */
  87232. blendMode: number;
  87233. /**
  87234. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  87235. * to override the particles.
  87236. */
  87237. forceDepthWrite: boolean;
  87238. /** 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 */
  87239. preWarmCycles: number;
  87240. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  87241. preWarmStepOffset: number;
  87242. /**
  87243. * 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)
  87244. */
  87245. spriteCellChangeSpeed: number;
  87246. /**
  87247. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  87248. */
  87249. startSpriteCellID: number;
  87250. /**
  87251. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  87252. */
  87253. endSpriteCellID: number;
  87254. /**
  87255. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  87256. */
  87257. spriteCellWidth: number;
  87258. /**
  87259. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  87260. */
  87261. spriteCellHeight: number;
  87262. /**
  87263. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  87264. */
  87265. spriteRandomStartCell: boolean;
  87266. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  87267. translationPivot: Vector2;
  87268. /** @hidden */
  87269. protected _isAnimationSheetEnabled: boolean;
  87270. /**
  87271. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  87272. */
  87273. beginAnimationOnStart: boolean;
  87274. /**
  87275. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  87276. */
  87277. beginAnimationFrom: number;
  87278. /**
  87279. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  87280. */
  87281. beginAnimationTo: number;
  87282. /**
  87283. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  87284. */
  87285. beginAnimationLoop: boolean;
  87286. /**
  87287. * Gets or sets a world offset applied to all particles
  87288. */
  87289. worldOffset: Vector3;
  87290. /**
  87291. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  87292. */
  87293. get isAnimationSheetEnabled(): boolean;
  87294. set isAnimationSheetEnabled(value: boolean);
  87295. /**
  87296. * Get hosting scene
  87297. * @returns the scene
  87298. */
  87299. getScene(): Scene;
  87300. /**
  87301. * You can use gravity if you want to give an orientation to your particles.
  87302. */
  87303. gravity: Vector3;
  87304. protected _colorGradients: Nullable<Array<ColorGradient>>;
  87305. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  87306. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  87307. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  87308. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  87309. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  87310. protected _dragGradients: Nullable<Array<FactorGradient>>;
  87311. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  87312. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  87313. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  87314. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  87315. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  87316. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  87317. /**
  87318. * Defines the delay in milliseconds before starting the system (0 by default)
  87319. */
  87320. startDelay: number;
  87321. /**
  87322. * Gets the current list of drag gradients.
  87323. * You must use addDragGradient and removeDragGradient to udpate this list
  87324. * @returns the list of drag gradients
  87325. */
  87326. getDragGradients(): Nullable<Array<FactorGradient>>;
  87327. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  87328. limitVelocityDamping: number;
  87329. /**
  87330. * Gets the current list of limit velocity gradients.
  87331. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  87332. * @returns the list of limit velocity gradients
  87333. */
  87334. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  87335. /**
  87336. * Gets the current list of color gradients.
  87337. * You must use addColorGradient and removeColorGradient to udpate this list
  87338. * @returns the list of color gradients
  87339. */
  87340. getColorGradients(): Nullable<Array<ColorGradient>>;
  87341. /**
  87342. * Gets the current list of size gradients.
  87343. * You must use addSizeGradient and removeSizeGradient to udpate this list
  87344. * @returns the list of size gradients
  87345. */
  87346. getSizeGradients(): Nullable<Array<FactorGradient>>;
  87347. /**
  87348. * Gets the current list of color remap gradients.
  87349. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  87350. * @returns the list of color remap gradients
  87351. */
  87352. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  87353. /**
  87354. * Gets the current list of alpha remap gradients.
  87355. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  87356. * @returns the list of alpha remap gradients
  87357. */
  87358. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  87359. /**
  87360. * Gets the current list of life time gradients.
  87361. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  87362. * @returns the list of life time gradients
  87363. */
  87364. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  87365. /**
  87366. * Gets the current list of angular speed gradients.
  87367. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  87368. * @returns the list of angular speed gradients
  87369. */
  87370. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  87371. /**
  87372. * Gets the current list of velocity gradients.
  87373. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  87374. * @returns the list of velocity gradients
  87375. */
  87376. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  87377. /**
  87378. * Gets the current list of start size gradients.
  87379. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  87380. * @returns the list of start size gradients
  87381. */
  87382. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  87383. /**
  87384. * Gets the current list of emit rate gradients.
  87385. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  87386. * @returns the list of emit rate gradients
  87387. */
  87388. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  87389. /**
  87390. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  87391. * This only works when particleEmitterTyps is a BoxParticleEmitter
  87392. */
  87393. get direction1(): Vector3;
  87394. set direction1(value: Vector3);
  87395. /**
  87396. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  87397. * This only works when particleEmitterTyps is a BoxParticleEmitter
  87398. */
  87399. get direction2(): Vector3;
  87400. set direction2(value: Vector3);
  87401. /**
  87402. * 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.
  87403. * This only works when particleEmitterTyps is a BoxParticleEmitter
  87404. */
  87405. get minEmitBox(): Vector3;
  87406. set minEmitBox(value: Vector3);
  87407. /**
  87408. * 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.
  87409. * This only works when particleEmitterTyps is a BoxParticleEmitter
  87410. */
  87411. get maxEmitBox(): Vector3;
  87412. set maxEmitBox(value: Vector3);
  87413. /**
  87414. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  87415. */
  87416. color1: Color4;
  87417. /**
  87418. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  87419. */
  87420. color2: Color4;
  87421. /**
  87422. * Color the particle will have at the end of its lifetime
  87423. */
  87424. colorDead: Color4;
  87425. /**
  87426. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  87427. */
  87428. textureMask: Color4;
  87429. /**
  87430. * The particle emitter type defines the emitter used by the particle system.
  87431. * It can be for example box, sphere, or cone...
  87432. */
  87433. particleEmitterType: IParticleEmitterType;
  87434. /** @hidden */
  87435. _isSubEmitter: boolean;
  87436. /**
  87437. * Gets or sets the billboard mode to use when isBillboardBased = true.
  87438. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  87439. */
  87440. billboardMode: number;
  87441. protected _isBillboardBased: boolean;
  87442. /**
  87443. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  87444. */
  87445. get isBillboardBased(): boolean;
  87446. set isBillboardBased(value: boolean);
  87447. /**
  87448. * The scene the particle system belongs to.
  87449. */
  87450. protected _scene: Scene;
  87451. /**
  87452. * Local cache of defines for image processing.
  87453. */
  87454. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  87455. /**
  87456. * Default configuration related to image processing available in the standard Material.
  87457. */
  87458. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  87459. /**
  87460. * Gets the image processing configuration used either in this material.
  87461. */
  87462. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  87463. /**
  87464. * Sets the Default image processing configuration used either in the this material.
  87465. *
  87466. * If sets to null, the scene one is in use.
  87467. */
  87468. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  87469. /**
  87470. * Attaches a new image processing configuration to the Standard Material.
  87471. * @param configuration
  87472. */
  87473. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  87474. /** @hidden */
  87475. protected _reset(): void;
  87476. /** @hidden */
  87477. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  87478. /**
  87479. * Instantiates a particle system.
  87480. * 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.
  87481. * @param name The name of the particle system
  87482. */
  87483. constructor(name: string);
  87484. /**
  87485. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  87486. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  87487. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  87488. * @returns the emitter
  87489. */
  87490. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  87491. /**
  87492. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  87493. * @param radius The radius of the hemisphere to emit from
  87494. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  87495. * @returns the emitter
  87496. */
  87497. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  87498. /**
  87499. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  87500. * @param radius The radius of the sphere to emit from
  87501. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  87502. * @returns the emitter
  87503. */
  87504. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  87505. /**
  87506. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  87507. * @param radius The radius of the sphere to emit from
  87508. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  87509. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  87510. * @returns the emitter
  87511. */
  87512. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  87513. /**
  87514. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  87515. * @param radius The radius of the emission cylinder
  87516. * @param height The height of the emission cylinder
  87517. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  87518. * @param directionRandomizer How much to randomize the particle direction [0-1]
  87519. * @returns the emitter
  87520. */
  87521. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  87522. /**
  87523. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  87524. * @param radius The radius of the cylinder to emit from
  87525. * @param height The height of the emission cylinder
  87526. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  87527. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  87528. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  87529. * @returns the emitter
  87530. */
  87531. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  87532. /**
  87533. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  87534. * @param radius The radius of the cone to emit from
  87535. * @param angle The base angle of the cone
  87536. * @returns the emitter
  87537. */
  87538. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  87539. /**
  87540. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  87541. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  87542. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  87543. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  87544. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  87545. * @returns the emitter
  87546. */
  87547. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  87548. }
  87549. }
  87550. declare module BABYLON {
  87551. /**
  87552. * Type of sub emitter
  87553. */
  87554. export enum SubEmitterType {
  87555. /**
  87556. * Attached to the particle over it's lifetime
  87557. */
  87558. ATTACHED = 0,
  87559. /**
  87560. * Created when the particle dies
  87561. */
  87562. END = 1
  87563. }
  87564. /**
  87565. * Sub emitter class used to emit particles from an existing particle
  87566. */
  87567. export class SubEmitter {
  87568. /**
  87569. * the particle system to be used by the sub emitter
  87570. */
  87571. particleSystem: ParticleSystem;
  87572. /**
  87573. * Type of the submitter (Default: END)
  87574. */
  87575. type: SubEmitterType;
  87576. /**
  87577. * 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)
  87578. * Note: This only is supported when using an emitter of type Mesh
  87579. */
  87580. inheritDirection: boolean;
  87581. /**
  87582. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  87583. */
  87584. inheritedVelocityAmount: number;
  87585. /**
  87586. * Creates a sub emitter
  87587. * @param particleSystem the particle system to be used by the sub emitter
  87588. */
  87589. constructor(
  87590. /**
  87591. * the particle system to be used by the sub emitter
  87592. */
  87593. particleSystem: ParticleSystem);
  87594. /**
  87595. * Clones the sub emitter
  87596. * @returns the cloned sub emitter
  87597. */
  87598. clone(): SubEmitter;
  87599. /**
  87600. * Serialize current object to a JSON object
  87601. * @returns the serialized object
  87602. */
  87603. serialize(): any;
  87604. /** @hidden */
  87605. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  87606. /**
  87607. * Creates a new SubEmitter from a serialized JSON version
  87608. * @param serializationObject defines the JSON object to read from
  87609. * @param scene defines the hosting scene
  87610. * @param rootUrl defines the rootUrl for data loading
  87611. * @returns a new SubEmitter
  87612. */
  87613. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  87614. /** Release associated resources */
  87615. dispose(): void;
  87616. }
  87617. }
  87618. declare module BABYLON {
  87619. /** @hidden */
  87620. export var imageProcessingDeclaration: {
  87621. name: string;
  87622. shader: string;
  87623. };
  87624. }
  87625. declare module BABYLON {
  87626. /** @hidden */
  87627. export var imageProcessingFunctions: {
  87628. name: string;
  87629. shader: string;
  87630. };
  87631. }
  87632. declare module BABYLON {
  87633. /** @hidden */
  87634. export var particlesPixelShader: {
  87635. name: string;
  87636. shader: string;
  87637. };
  87638. }
  87639. declare module BABYLON {
  87640. /** @hidden */
  87641. export var particlesVertexShader: {
  87642. name: string;
  87643. shader: string;
  87644. };
  87645. }
  87646. declare module BABYLON {
  87647. /**
  87648. * This represents a particle system in Babylon.
  87649. * 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.
  87650. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  87651. * @example https://doc.babylonjs.com/babylon101/particles
  87652. */
  87653. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  87654. /**
  87655. * Billboard mode will only apply to Y axis
  87656. */
  87657. static readonly BILLBOARDMODE_Y: number;
  87658. /**
  87659. * Billboard mode will apply to all axes
  87660. */
  87661. static readonly BILLBOARDMODE_ALL: number;
  87662. /**
  87663. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  87664. */
  87665. static readonly BILLBOARDMODE_STRETCHED: number;
  87666. /**
  87667. * This function can be defined to provide custom update for active particles.
  87668. * This function will be called instead of regular update (age, position, color, etc.).
  87669. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  87670. */
  87671. updateFunction: (particles: Particle[]) => void;
  87672. private _emitterWorldMatrix;
  87673. /**
  87674. * This function can be defined to specify initial direction for every new particle.
  87675. * It by default use the emitterType defined function
  87676. */
  87677. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  87678. /**
  87679. * This function can be defined to specify initial position for every new particle.
  87680. * It by default use the emitterType defined function
  87681. */
  87682. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  87683. /**
  87684. * @hidden
  87685. */
  87686. _inheritedVelocityOffset: Vector3;
  87687. /**
  87688. * An event triggered when the system is disposed
  87689. */
  87690. onDisposeObservable: Observable<ParticleSystem>;
  87691. private _onDisposeObserver;
  87692. /**
  87693. * Sets a callback that will be triggered when the system is disposed
  87694. */
  87695. set onDispose(callback: () => void);
  87696. private _particles;
  87697. private _epsilon;
  87698. private _capacity;
  87699. private _stockParticles;
  87700. private _newPartsExcess;
  87701. private _vertexData;
  87702. private _vertexBuffer;
  87703. private _vertexBuffers;
  87704. private _spriteBuffer;
  87705. private _indexBuffer;
  87706. private _effect;
  87707. private _customEffect;
  87708. private _cachedDefines;
  87709. private _scaledColorStep;
  87710. private _colorDiff;
  87711. private _scaledDirection;
  87712. private _scaledGravity;
  87713. private _currentRenderId;
  87714. private _alive;
  87715. private _useInstancing;
  87716. private _started;
  87717. private _stopped;
  87718. private _actualFrame;
  87719. private _scaledUpdateSpeed;
  87720. private _vertexBufferSize;
  87721. /** @hidden */
  87722. _currentEmitRateGradient: Nullable<FactorGradient>;
  87723. /** @hidden */
  87724. _currentEmitRate1: number;
  87725. /** @hidden */
  87726. _currentEmitRate2: number;
  87727. /** @hidden */
  87728. _currentStartSizeGradient: Nullable<FactorGradient>;
  87729. /** @hidden */
  87730. _currentStartSize1: number;
  87731. /** @hidden */
  87732. _currentStartSize2: number;
  87733. private readonly _rawTextureWidth;
  87734. private _rampGradientsTexture;
  87735. private _useRampGradients;
  87736. /** Gets or sets a boolean indicating that ramp gradients must be used
  87737. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  87738. */
  87739. get useRampGradients(): boolean;
  87740. set useRampGradients(value: boolean);
  87741. /**
  87742. * 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.
  87743. * 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: [])
  87744. */
  87745. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  87746. private _subEmitters;
  87747. /**
  87748. * @hidden
  87749. * If the particle systems emitter should be disposed when the particle system is disposed
  87750. */
  87751. _disposeEmitterOnDispose: boolean;
  87752. /**
  87753. * The current active Sub-systems, this property is used by the root particle system only.
  87754. */
  87755. activeSubSystems: Array<ParticleSystem>;
  87756. /**
  87757. * Specifies if the particles are updated in emitter local space or world space
  87758. */
  87759. isLocal: boolean;
  87760. private _rootParticleSystem;
  87761. /**
  87762. * Gets the current list of active particles
  87763. */
  87764. get particles(): Particle[];
  87765. /**
  87766. * Gets the number of particles active at the same time.
  87767. * @returns The number of active particles.
  87768. */
  87769. getActiveCount(): number;
  87770. /**
  87771. * Returns the string "ParticleSystem"
  87772. * @returns a string containing the class name
  87773. */
  87774. getClassName(): string;
  87775. /**
  87776. * Gets a boolean indicating that the system is stopping
  87777. * @returns true if the system is currently stopping
  87778. */
  87779. isStopping(): boolean;
  87780. /**
  87781. * Instantiates a particle system.
  87782. * 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.
  87783. * @param name The name of the particle system
  87784. * @param capacity The max number of particles alive at the same time
  87785. * @param scene The scene the particle system belongs to
  87786. * @param customEffect a custom effect used to change the way particles are rendered by default
  87787. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  87788. * @param epsilon Offset used to render the particles
  87789. */
  87790. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  87791. private _addFactorGradient;
  87792. private _removeFactorGradient;
  87793. /**
  87794. * Adds a new life time gradient
  87795. * @param gradient defines the gradient to use (between 0 and 1)
  87796. * @param factor defines the life time factor to affect to the specified gradient
  87797. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  87798. * @returns the current particle system
  87799. */
  87800. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  87801. /**
  87802. * Remove a specific life time gradient
  87803. * @param gradient defines the gradient to remove
  87804. * @returns the current particle system
  87805. */
  87806. removeLifeTimeGradient(gradient: number): IParticleSystem;
  87807. /**
  87808. * Adds a new size gradient
  87809. * @param gradient defines the gradient to use (between 0 and 1)
  87810. * @param factor defines the size factor to affect to the specified gradient
  87811. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  87812. * @returns the current particle system
  87813. */
  87814. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  87815. /**
  87816. * Remove a specific size gradient
  87817. * @param gradient defines the gradient to remove
  87818. * @returns the current particle system
  87819. */
  87820. removeSizeGradient(gradient: number): IParticleSystem;
  87821. /**
  87822. * Adds a new color remap gradient
  87823. * @param gradient defines the gradient to use (between 0 and 1)
  87824. * @param min defines the color remap minimal range
  87825. * @param max defines the color remap maximal range
  87826. * @returns the current particle system
  87827. */
  87828. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  87829. /**
  87830. * Remove a specific color remap gradient
  87831. * @param gradient defines the gradient to remove
  87832. * @returns the current particle system
  87833. */
  87834. removeColorRemapGradient(gradient: number): IParticleSystem;
  87835. /**
  87836. * Adds a new alpha remap gradient
  87837. * @param gradient defines the gradient to use (between 0 and 1)
  87838. * @param min defines the alpha remap minimal range
  87839. * @param max defines the alpha remap maximal range
  87840. * @returns the current particle system
  87841. */
  87842. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  87843. /**
  87844. * Remove a specific alpha remap gradient
  87845. * @param gradient defines the gradient to remove
  87846. * @returns the current particle system
  87847. */
  87848. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  87849. /**
  87850. * Adds a new angular speed gradient
  87851. * @param gradient defines the gradient to use (between 0 and 1)
  87852. * @param factor defines the angular speed to affect to the specified gradient
  87853. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  87854. * @returns the current particle system
  87855. */
  87856. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  87857. /**
  87858. * Remove a specific angular speed gradient
  87859. * @param gradient defines the gradient to remove
  87860. * @returns the current particle system
  87861. */
  87862. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  87863. /**
  87864. * Adds a new velocity gradient
  87865. * @param gradient defines the gradient to use (between 0 and 1)
  87866. * @param factor defines the velocity to affect to the specified gradient
  87867. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  87868. * @returns the current particle system
  87869. */
  87870. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  87871. /**
  87872. * Remove a specific velocity gradient
  87873. * @param gradient defines the gradient to remove
  87874. * @returns the current particle system
  87875. */
  87876. removeVelocityGradient(gradient: number): IParticleSystem;
  87877. /**
  87878. * Adds a new limit velocity gradient
  87879. * @param gradient defines the gradient to use (between 0 and 1)
  87880. * @param factor defines the limit velocity value to affect to the specified gradient
  87881. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  87882. * @returns the current particle system
  87883. */
  87884. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  87885. /**
  87886. * Remove a specific limit velocity gradient
  87887. * @param gradient defines the gradient to remove
  87888. * @returns the current particle system
  87889. */
  87890. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  87891. /**
  87892. * Adds a new drag gradient
  87893. * @param gradient defines the gradient to use (between 0 and 1)
  87894. * @param factor defines the drag value to affect to the specified gradient
  87895. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  87896. * @returns the current particle system
  87897. */
  87898. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  87899. /**
  87900. * Remove a specific drag gradient
  87901. * @param gradient defines the gradient to remove
  87902. * @returns the current particle system
  87903. */
  87904. removeDragGradient(gradient: number): IParticleSystem;
  87905. /**
  87906. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  87907. * @param gradient defines the gradient to use (between 0 and 1)
  87908. * @param factor defines the emit rate value to affect to the specified gradient
  87909. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  87910. * @returns the current particle system
  87911. */
  87912. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  87913. /**
  87914. * Remove a specific emit rate gradient
  87915. * @param gradient defines the gradient to remove
  87916. * @returns the current particle system
  87917. */
  87918. removeEmitRateGradient(gradient: number): IParticleSystem;
  87919. /**
  87920. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  87921. * @param gradient defines the gradient to use (between 0 and 1)
  87922. * @param factor defines the start size value to affect to the specified gradient
  87923. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  87924. * @returns the current particle system
  87925. */
  87926. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  87927. /**
  87928. * Remove a specific start size gradient
  87929. * @param gradient defines the gradient to remove
  87930. * @returns the current particle system
  87931. */
  87932. removeStartSizeGradient(gradient: number): IParticleSystem;
  87933. private _createRampGradientTexture;
  87934. /**
  87935. * Gets the current list of ramp gradients.
  87936. * You must use addRampGradient and removeRampGradient to udpate this list
  87937. * @returns the list of ramp gradients
  87938. */
  87939. getRampGradients(): Nullable<Array<Color3Gradient>>;
  87940. /** Force the system to rebuild all gradients that need to be resync */
  87941. forceRefreshGradients(): void;
  87942. private _syncRampGradientTexture;
  87943. /**
  87944. * Adds a new ramp gradient used to remap particle colors
  87945. * @param gradient defines the gradient to use (between 0 and 1)
  87946. * @param color defines the color to affect to the specified gradient
  87947. * @returns the current particle system
  87948. */
  87949. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  87950. /**
  87951. * Remove a specific ramp gradient
  87952. * @param gradient defines the gradient to remove
  87953. * @returns the current particle system
  87954. */
  87955. removeRampGradient(gradient: number): ParticleSystem;
  87956. /**
  87957. * Adds a new color gradient
  87958. * @param gradient defines the gradient to use (between 0 and 1)
  87959. * @param color1 defines the color to affect to the specified gradient
  87960. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  87961. * @returns this particle system
  87962. */
  87963. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  87964. /**
  87965. * Remove a specific color gradient
  87966. * @param gradient defines the gradient to remove
  87967. * @returns this particle system
  87968. */
  87969. removeColorGradient(gradient: number): IParticleSystem;
  87970. private _fetchR;
  87971. protected _reset(): void;
  87972. private _resetEffect;
  87973. private _createVertexBuffers;
  87974. private _createIndexBuffer;
  87975. /**
  87976. * Gets the maximum number of particles active at the same time.
  87977. * @returns The max number of active particles.
  87978. */
  87979. getCapacity(): number;
  87980. /**
  87981. * Gets whether there are still active particles in the system.
  87982. * @returns True if it is alive, otherwise false.
  87983. */
  87984. isAlive(): boolean;
  87985. /**
  87986. * Gets if the system has been started. (Note: this will still be true after stop is called)
  87987. * @returns True if it has been started, otherwise false.
  87988. */
  87989. isStarted(): boolean;
  87990. private _prepareSubEmitterInternalArray;
  87991. /**
  87992. * Starts the particle system and begins to emit
  87993. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  87994. */
  87995. start(delay?: number): void;
  87996. /**
  87997. * Stops the particle system.
  87998. * @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.
  87999. */
  88000. stop(stopSubEmitters?: boolean): void;
  88001. /**
  88002. * Remove all active particles
  88003. */
  88004. reset(): void;
  88005. /**
  88006. * @hidden (for internal use only)
  88007. */
  88008. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  88009. /**
  88010. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  88011. * Its lifetime will start back at 0.
  88012. */
  88013. recycleParticle: (particle: Particle) => void;
  88014. private _stopSubEmitters;
  88015. private _createParticle;
  88016. private _removeFromRoot;
  88017. private _emitFromParticle;
  88018. private _update;
  88019. /** @hidden */
  88020. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  88021. /** @hidden */
  88022. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  88023. /** @hidden */
  88024. private _getEffect;
  88025. /**
  88026. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  88027. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  88028. */
  88029. animate(preWarmOnly?: boolean): void;
  88030. private _appendParticleVertices;
  88031. /**
  88032. * Rebuilds the particle system.
  88033. */
  88034. rebuild(): void;
  88035. /**
  88036. * Is this system ready to be used/rendered
  88037. * @return true if the system is ready
  88038. */
  88039. isReady(): boolean;
  88040. private _render;
  88041. /**
  88042. * Renders the particle system in its current state.
  88043. * @returns the current number of particles
  88044. */
  88045. render(): number;
  88046. /**
  88047. * Disposes the particle system and free the associated resources
  88048. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  88049. */
  88050. dispose(disposeTexture?: boolean): void;
  88051. /**
  88052. * Clones the particle system.
  88053. * @param name The name of the cloned object
  88054. * @param newEmitter The new emitter to use
  88055. * @returns the cloned particle system
  88056. */
  88057. clone(name: string, newEmitter: any): ParticleSystem;
  88058. /**
  88059. * Serializes the particle system to a JSON object
  88060. * @param serializeTexture defines if the texture must be serialized as well
  88061. * @returns the JSON object
  88062. */
  88063. serialize(serializeTexture?: boolean): any;
  88064. /** @hidden */
  88065. static _Serialize(serializationObject: any, particleSystem: IParticleSystem, serializeTexture: boolean): void;
  88066. /** @hidden */
  88067. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  88068. /**
  88069. * Parses a JSON object to create a particle system.
  88070. * @param parsedParticleSystem The JSON object to parse
  88071. * @param scene The scene to create the particle system in
  88072. * @param rootUrl The root url to use to load external dependencies like texture
  88073. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  88074. * @returns the Parsed particle system
  88075. */
  88076. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  88077. }
  88078. }
  88079. declare module BABYLON {
  88080. /**
  88081. * A particle represents one of the element emitted by a particle system.
  88082. * This is mainly define by its coordinates, direction, velocity and age.
  88083. */
  88084. export class Particle {
  88085. /**
  88086. * The particle system the particle belongs to.
  88087. */
  88088. particleSystem: ParticleSystem;
  88089. private static _Count;
  88090. /**
  88091. * Unique ID of the particle
  88092. */
  88093. id: number;
  88094. /**
  88095. * The world position of the particle in the scene.
  88096. */
  88097. position: Vector3;
  88098. /**
  88099. * The world direction of the particle in the scene.
  88100. */
  88101. direction: Vector3;
  88102. /**
  88103. * The color of the particle.
  88104. */
  88105. color: Color4;
  88106. /**
  88107. * The color change of the particle per step.
  88108. */
  88109. colorStep: Color4;
  88110. /**
  88111. * Defines how long will the life of the particle be.
  88112. */
  88113. lifeTime: number;
  88114. /**
  88115. * The current age of the particle.
  88116. */
  88117. age: number;
  88118. /**
  88119. * The current size of the particle.
  88120. */
  88121. size: number;
  88122. /**
  88123. * The current scale of the particle.
  88124. */
  88125. scale: Vector2;
  88126. /**
  88127. * The current angle of the particle.
  88128. */
  88129. angle: number;
  88130. /**
  88131. * Defines how fast is the angle changing.
  88132. */
  88133. angularSpeed: number;
  88134. /**
  88135. * Defines the cell index used by the particle to be rendered from a sprite.
  88136. */
  88137. cellIndex: number;
  88138. /**
  88139. * The information required to support color remapping
  88140. */
  88141. remapData: Vector4;
  88142. /** @hidden */
  88143. _randomCellOffset?: number;
  88144. /** @hidden */
  88145. _initialDirection: Nullable<Vector3>;
  88146. /** @hidden */
  88147. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  88148. /** @hidden */
  88149. _initialStartSpriteCellID: number;
  88150. /** @hidden */
  88151. _initialEndSpriteCellID: number;
  88152. /** @hidden */
  88153. _currentColorGradient: Nullable<ColorGradient>;
  88154. /** @hidden */
  88155. _currentColor1: Color4;
  88156. /** @hidden */
  88157. _currentColor2: Color4;
  88158. /** @hidden */
  88159. _currentSizeGradient: Nullable<FactorGradient>;
  88160. /** @hidden */
  88161. _currentSize1: number;
  88162. /** @hidden */
  88163. _currentSize2: number;
  88164. /** @hidden */
  88165. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  88166. /** @hidden */
  88167. _currentAngularSpeed1: number;
  88168. /** @hidden */
  88169. _currentAngularSpeed2: number;
  88170. /** @hidden */
  88171. _currentVelocityGradient: Nullable<FactorGradient>;
  88172. /** @hidden */
  88173. _currentVelocity1: number;
  88174. /** @hidden */
  88175. _currentVelocity2: number;
  88176. /** @hidden */
  88177. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  88178. /** @hidden */
  88179. _currentLimitVelocity1: number;
  88180. /** @hidden */
  88181. _currentLimitVelocity2: number;
  88182. /** @hidden */
  88183. _currentDragGradient: Nullable<FactorGradient>;
  88184. /** @hidden */
  88185. _currentDrag1: number;
  88186. /** @hidden */
  88187. _currentDrag2: number;
  88188. /** @hidden */
  88189. _randomNoiseCoordinates1: Vector3;
  88190. /** @hidden */
  88191. _randomNoiseCoordinates2: Vector3;
  88192. /** @hidden */
  88193. _localPosition?: Vector3;
  88194. /**
  88195. * Creates a new instance Particle
  88196. * @param particleSystem the particle system the particle belongs to
  88197. */
  88198. constructor(
  88199. /**
  88200. * The particle system the particle belongs to.
  88201. */
  88202. particleSystem: ParticleSystem);
  88203. private updateCellInfoFromSystem;
  88204. /**
  88205. * Defines how the sprite cell index is updated for the particle
  88206. */
  88207. updateCellIndex(): void;
  88208. /** @hidden */
  88209. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  88210. /** @hidden */
  88211. _inheritParticleInfoToSubEmitters(): void;
  88212. /** @hidden */
  88213. _reset(): void;
  88214. /**
  88215. * Copy the properties of particle to another one.
  88216. * @param other the particle to copy the information to.
  88217. */
  88218. copyTo(other: Particle): void;
  88219. }
  88220. }
  88221. declare module BABYLON {
  88222. /**
  88223. * Particle emitter represents a volume emitting particles.
  88224. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  88225. */
  88226. export interface IParticleEmitterType {
  88227. /**
  88228. * Called by the particle System when the direction is computed for the created particle.
  88229. * @param worldMatrix is the world matrix of the particle system
  88230. * @param directionToUpdate is the direction vector to update with the result
  88231. * @param particle is the particle we are computed the direction for
  88232. * @param isLocal defines if the direction should be set in local space
  88233. */
  88234. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  88235. /**
  88236. * Called by the particle System when the position is computed for the created particle.
  88237. * @param worldMatrix is the world matrix of the particle system
  88238. * @param positionToUpdate is the position vector to update with the result
  88239. * @param particle is the particle we are computed the position for
  88240. * @param isLocal defines if the position should be set in local space
  88241. */
  88242. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  88243. /**
  88244. * Clones the current emitter and returns a copy of it
  88245. * @returns the new emitter
  88246. */
  88247. clone(): IParticleEmitterType;
  88248. /**
  88249. * Called by the GPUParticleSystem to setup the update shader
  88250. * @param effect defines the update shader
  88251. */
  88252. applyToShader(effect: Effect): void;
  88253. /**
  88254. * Returns a string to use to update the GPU particles update shader
  88255. * @returns the effect defines string
  88256. */
  88257. getEffectDefines(): string;
  88258. /**
  88259. * Returns a string representing the class name
  88260. * @returns a string containing the class name
  88261. */
  88262. getClassName(): string;
  88263. /**
  88264. * Serializes the particle system to a JSON object.
  88265. * @returns the JSON object
  88266. */
  88267. serialize(): any;
  88268. /**
  88269. * Parse properties from a JSON object
  88270. * @param serializationObject defines the JSON object
  88271. * @param scene defines the hosting scene
  88272. */
  88273. parse(serializationObject: any, scene: Scene): void;
  88274. }
  88275. }
  88276. declare module BABYLON {
  88277. /**
  88278. * Particle emitter emitting particles from the inside of a box.
  88279. * It emits the particles randomly between 2 given directions.
  88280. */
  88281. export class BoxParticleEmitter implements IParticleEmitterType {
  88282. /**
  88283. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  88284. */
  88285. direction1: Vector3;
  88286. /**
  88287. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  88288. */
  88289. direction2: Vector3;
  88290. /**
  88291. * 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.
  88292. */
  88293. minEmitBox: Vector3;
  88294. /**
  88295. * 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.
  88296. */
  88297. maxEmitBox: Vector3;
  88298. /**
  88299. * Creates a new instance BoxParticleEmitter
  88300. */
  88301. constructor();
  88302. /**
  88303. * Called by the particle System when the direction is computed for the created particle.
  88304. * @param worldMatrix is the world matrix of the particle system
  88305. * @param directionToUpdate is the direction vector to update with the result
  88306. * @param particle is the particle we are computed the direction for
  88307. * @param isLocal defines if the direction should be set in local space
  88308. */
  88309. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  88310. /**
  88311. * Called by the particle System when the position is computed for the created particle.
  88312. * @param worldMatrix is the world matrix of the particle system
  88313. * @param positionToUpdate is the position vector to update with the result
  88314. * @param particle is the particle we are computed the position for
  88315. * @param isLocal defines if the position should be set in local space
  88316. */
  88317. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  88318. /**
  88319. * Clones the current emitter and returns a copy of it
  88320. * @returns the new emitter
  88321. */
  88322. clone(): BoxParticleEmitter;
  88323. /**
  88324. * Called by the GPUParticleSystem to setup the update shader
  88325. * @param effect defines the update shader
  88326. */
  88327. applyToShader(effect: Effect): void;
  88328. /**
  88329. * Returns a string to use to update the GPU particles update shader
  88330. * @returns a string containng the defines string
  88331. */
  88332. getEffectDefines(): string;
  88333. /**
  88334. * Returns the string "BoxParticleEmitter"
  88335. * @returns a string containing the class name
  88336. */
  88337. getClassName(): string;
  88338. /**
  88339. * Serializes the particle system to a JSON object.
  88340. * @returns the JSON object
  88341. */
  88342. serialize(): any;
  88343. /**
  88344. * Parse properties from a JSON object
  88345. * @param serializationObject defines the JSON object
  88346. */
  88347. parse(serializationObject: any): void;
  88348. }
  88349. }
  88350. declare module BABYLON {
  88351. /**
  88352. * Particle emitter emitting particles from the inside of a cone.
  88353. * It emits the particles alongside the cone volume from the base to the particle.
  88354. * The emission direction might be randomized.
  88355. */
  88356. export class ConeParticleEmitter implements IParticleEmitterType {
  88357. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  88358. directionRandomizer: number;
  88359. private _radius;
  88360. private _angle;
  88361. private _height;
  88362. /**
  88363. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  88364. */
  88365. radiusRange: number;
  88366. /**
  88367. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  88368. */
  88369. heightRange: number;
  88370. /**
  88371. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  88372. */
  88373. emitFromSpawnPointOnly: boolean;
  88374. /**
  88375. * Gets or sets the radius of the emission cone
  88376. */
  88377. get radius(): number;
  88378. set radius(value: number);
  88379. /**
  88380. * Gets or sets the angle of the emission cone
  88381. */
  88382. get angle(): number;
  88383. set angle(value: number);
  88384. private _buildHeight;
  88385. /**
  88386. * Creates a new instance ConeParticleEmitter
  88387. * @param radius the radius of the emission cone (1 by default)
  88388. * @param angle the cone base angle (PI by default)
  88389. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  88390. */
  88391. constructor(radius?: number, angle?: number,
  88392. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  88393. directionRandomizer?: number);
  88394. /**
  88395. * Called by the particle System when the direction is computed for the created particle.
  88396. * @param worldMatrix is the world matrix of the particle system
  88397. * @param directionToUpdate is the direction vector to update with the result
  88398. * @param particle is the particle we are computed the direction for
  88399. * @param isLocal defines if the direction should be set in local space
  88400. */
  88401. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  88402. /**
  88403. * Called by the particle System when the position is computed for the created particle.
  88404. * @param worldMatrix is the world matrix of the particle system
  88405. * @param positionToUpdate is the position vector to update with the result
  88406. * @param particle is the particle we are computed the position for
  88407. * @param isLocal defines if the position should be set in local space
  88408. */
  88409. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  88410. /**
  88411. * Clones the current emitter and returns a copy of it
  88412. * @returns the new emitter
  88413. */
  88414. clone(): ConeParticleEmitter;
  88415. /**
  88416. * Called by the GPUParticleSystem to setup the update shader
  88417. * @param effect defines the update shader
  88418. */
  88419. applyToShader(effect: Effect): void;
  88420. /**
  88421. * Returns a string to use to update the GPU particles update shader
  88422. * @returns a string containng the defines string
  88423. */
  88424. getEffectDefines(): string;
  88425. /**
  88426. * Returns the string "ConeParticleEmitter"
  88427. * @returns a string containing the class name
  88428. */
  88429. getClassName(): string;
  88430. /**
  88431. * Serializes the particle system to a JSON object.
  88432. * @returns the JSON object
  88433. */
  88434. serialize(): any;
  88435. /**
  88436. * Parse properties from a JSON object
  88437. * @param serializationObject defines the JSON object
  88438. */
  88439. parse(serializationObject: any): void;
  88440. }
  88441. }
  88442. declare module BABYLON {
  88443. /**
  88444. * Particle emitter emitting particles from the inside of a cylinder.
  88445. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  88446. */
  88447. export class CylinderParticleEmitter implements IParticleEmitterType {
  88448. /**
  88449. * The radius of the emission cylinder.
  88450. */
  88451. radius: number;
  88452. /**
  88453. * The height of the emission cylinder.
  88454. */
  88455. height: number;
  88456. /**
  88457. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  88458. */
  88459. radiusRange: number;
  88460. /**
  88461. * How much to randomize the particle direction [0-1].
  88462. */
  88463. directionRandomizer: number;
  88464. /**
  88465. * Creates a new instance CylinderParticleEmitter
  88466. * @param radius the radius of the emission cylinder (1 by default)
  88467. * @param height the height of the emission cylinder (1 by default)
  88468. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  88469. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  88470. */
  88471. constructor(
  88472. /**
  88473. * The radius of the emission cylinder.
  88474. */
  88475. radius?: number,
  88476. /**
  88477. * The height of the emission cylinder.
  88478. */
  88479. height?: number,
  88480. /**
  88481. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  88482. */
  88483. radiusRange?: number,
  88484. /**
  88485. * How much to randomize the particle direction [0-1].
  88486. */
  88487. directionRandomizer?: number);
  88488. /**
  88489. * Called by the particle System when the direction is computed for the created particle.
  88490. * @param worldMatrix is the world matrix of the particle system
  88491. * @param directionToUpdate is the direction vector to update with the result
  88492. * @param particle is the particle we are computed the direction for
  88493. * @param isLocal defines if the direction should be set in local space
  88494. */
  88495. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  88496. /**
  88497. * Called by the particle System when the position is computed for the created particle.
  88498. * @param worldMatrix is the world matrix of the particle system
  88499. * @param positionToUpdate is the position vector to update with the result
  88500. * @param particle is the particle we are computed the position for
  88501. * @param isLocal defines if the position should be set in local space
  88502. */
  88503. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  88504. /**
  88505. * Clones the current emitter and returns a copy of it
  88506. * @returns the new emitter
  88507. */
  88508. clone(): CylinderParticleEmitter;
  88509. /**
  88510. * Called by the GPUParticleSystem to setup the update shader
  88511. * @param effect defines the update shader
  88512. */
  88513. applyToShader(effect: Effect): void;
  88514. /**
  88515. * Returns a string to use to update the GPU particles update shader
  88516. * @returns a string containng the defines string
  88517. */
  88518. getEffectDefines(): string;
  88519. /**
  88520. * Returns the string "CylinderParticleEmitter"
  88521. * @returns a string containing the class name
  88522. */
  88523. getClassName(): string;
  88524. /**
  88525. * Serializes the particle system to a JSON object.
  88526. * @returns the JSON object
  88527. */
  88528. serialize(): any;
  88529. /**
  88530. * Parse properties from a JSON object
  88531. * @param serializationObject defines the JSON object
  88532. */
  88533. parse(serializationObject: any): void;
  88534. }
  88535. /**
  88536. * Particle emitter emitting particles from the inside of a cylinder.
  88537. * It emits the particles randomly between two vectors.
  88538. */
  88539. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  88540. /**
  88541. * The min limit of the emission direction.
  88542. */
  88543. direction1: Vector3;
  88544. /**
  88545. * The max limit of the emission direction.
  88546. */
  88547. direction2: Vector3;
  88548. /**
  88549. * Creates a new instance CylinderDirectedParticleEmitter
  88550. * @param radius the radius of the emission cylinder (1 by default)
  88551. * @param height the height of the emission cylinder (1 by default)
  88552. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  88553. * @param direction1 the min limit of the emission direction (up vector by default)
  88554. * @param direction2 the max limit of the emission direction (up vector by default)
  88555. */
  88556. constructor(radius?: number, height?: number, radiusRange?: number,
  88557. /**
  88558. * The min limit of the emission direction.
  88559. */
  88560. direction1?: Vector3,
  88561. /**
  88562. * The max limit of the emission direction.
  88563. */
  88564. direction2?: Vector3);
  88565. /**
  88566. * Called by the particle System when the direction is computed for the created particle.
  88567. * @param worldMatrix is the world matrix of the particle system
  88568. * @param directionToUpdate is the direction vector to update with the result
  88569. * @param particle is the particle we are computed the direction for
  88570. */
  88571. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  88572. /**
  88573. * Clones the current emitter and returns a copy of it
  88574. * @returns the new emitter
  88575. */
  88576. clone(): CylinderDirectedParticleEmitter;
  88577. /**
  88578. * Called by the GPUParticleSystem to setup the update shader
  88579. * @param effect defines the update shader
  88580. */
  88581. applyToShader(effect: Effect): void;
  88582. /**
  88583. * Returns a string to use to update the GPU particles update shader
  88584. * @returns a string containng the defines string
  88585. */
  88586. getEffectDefines(): string;
  88587. /**
  88588. * Returns the string "CylinderDirectedParticleEmitter"
  88589. * @returns a string containing the class name
  88590. */
  88591. getClassName(): string;
  88592. /**
  88593. * Serializes the particle system to a JSON object.
  88594. * @returns the JSON object
  88595. */
  88596. serialize(): any;
  88597. /**
  88598. * Parse properties from a JSON object
  88599. * @param serializationObject defines the JSON object
  88600. */
  88601. parse(serializationObject: any): void;
  88602. }
  88603. }
  88604. declare module BABYLON {
  88605. /**
  88606. * Particle emitter emitting particles from the inside of a hemisphere.
  88607. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  88608. */
  88609. export class HemisphericParticleEmitter implements IParticleEmitterType {
  88610. /**
  88611. * The radius of the emission hemisphere.
  88612. */
  88613. radius: number;
  88614. /**
  88615. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  88616. */
  88617. radiusRange: number;
  88618. /**
  88619. * How much to randomize the particle direction [0-1].
  88620. */
  88621. directionRandomizer: number;
  88622. /**
  88623. * Creates a new instance HemisphericParticleEmitter
  88624. * @param radius the radius of the emission hemisphere (1 by default)
  88625. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  88626. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  88627. */
  88628. constructor(
  88629. /**
  88630. * The radius of the emission hemisphere.
  88631. */
  88632. radius?: number,
  88633. /**
  88634. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  88635. */
  88636. radiusRange?: number,
  88637. /**
  88638. * How much to randomize the particle direction [0-1].
  88639. */
  88640. directionRandomizer?: number);
  88641. /**
  88642. * Called by the particle System when the direction is computed for the created particle.
  88643. * @param worldMatrix is the world matrix of the particle system
  88644. * @param directionToUpdate is the direction vector to update with the result
  88645. * @param particle is the particle we are computed the direction for
  88646. * @param isLocal defines if the direction should be set in local space
  88647. */
  88648. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  88649. /**
  88650. * Called by the particle System when the position is computed for the created particle.
  88651. * @param worldMatrix is the world matrix of the particle system
  88652. * @param positionToUpdate is the position vector to update with the result
  88653. * @param particle is the particle we are computed the position for
  88654. * @param isLocal defines if the position should be set in local space
  88655. */
  88656. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  88657. /**
  88658. * Clones the current emitter and returns a copy of it
  88659. * @returns the new emitter
  88660. */
  88661. clone(): HemisphericParticleEmitter;
  88662. /**
  88663. * Called by the GPUParticleSystem to setup the update shader
  88664. * @param effect defines the update shader
  88665. */
  88666. applyToShader(effect: Effect): void;
  88667. /**
  88668. * Returns a string to use to update the GPU particles update shader
  88669. * @returns a string containng the defines string
  88670. */
  88671. getEffectDefines(): string;
  88672. /**
  88673. * Returns the string "HemisphericParticleEmitter"
  88674. * @returns a string containing the class name
  88675. */
  88676. getClassName(): string;
  88677. /**
  88678. * Serializes the particle system to a JSON object.
  88679. * @returns the JSON object
  88680. */
  88681. serialize(): any;
  88682. /**
  88683. * Parse properties from a JSON object
  88684. * @param serializationObject defines the JSON object
  88685. */
  88686. parse(serializationObject: any): void;
  88687. }
  88688. }
  88689. declare module BABYLON {
  88690. /**
  88691. * Particle emitter emitting particles from a point.
  88692. * It emits the particles randomly between 2 given directions.
  88693. */
  88694. export class PointParticleEmitter implements IParticleEmitterType {
  88695. /**
  88696. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  88697. */
  88698. direction1: Vector3;
  88699. /**
  88700. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  88701. */
  88702. direction2: Vector3;
  88703. /**
  88704. * Creates a new instance PointParticleEmitter
  88705. */
  88706. constructor();
  88707. /**
  88708. * Called by the particle System when the direction is computed for the created particle.
  88709. * @param worldMatrix is the world matrix of the particle system
  88710. * @param directionToUpdate is the direction vector to update with the result
  88711. * @param particle is the particle we are computed the direction for
  88712. * @param isLocal defines if the direction should be set in local space
  88713. */
  88714. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  88715. /**
  88716. * Called by the particle System when the position is computed for the created particle.
  88717. * @param worldMatrix is the world matrix of the particle system
  88718. * @param positionToUpdate is the position vector to update with the result
  88719. * @param particle is the particle we are computed the position for
  88720. * @param isLocal defines if the position should be set in local space
  88721. */
  88722. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  88723. /**
  88724. * Clones the current emitter and returns a copy of it
  88725. * @returns the new emitter
  88726. */
  88727. clone(): PointParticleEmitter;
  88728. /**
  88729. * Called by the GPUParticleSystem to setup the update shader
  88730. * @param effect defines the update shader
  88731. */
  88732. applyToShader(effect: Effect): void;
  88733. /**
  88734. * Returns a string to use to update the GPU particles update shader
  88735. * @returns a string containng the defines string
  88736. */
  88737. getEffectDefines(): string;
  88738. /**
  88739. * Returns the string "PointParticleEmitter"
  88740. * @returns a string containing the class name
  88741. */
  88742. getClassName(): string;
  88743. /**
  88744. * Serializes the particle system to a JSON object.
  88745. * @returns the JSON object
  88746. */
  88747. serialize(): any;
  88748. /**
  88749. * Parse properties from a JSON object
  88750. * @param serializationObject defines the JSON object
  88751. */
  88752. parse(serializationObject: any): void;
  88753. }
  88754. }
  88755. declare module BABYLON {
  88756. /**
  88757. * Particle emitter emitting particles from the inside of a sphere.
  88758. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  88759. */
  88760. export class SphereParticleEmitter implements IParticleEmitterType {
  88761. /**
  88762. * The radius of the emission sphere.
  88763. */
  88764. radius: number;
  88765. /**
  88766. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  88767. */
  88768. radiusRange: number;
  88769. /**
  88770. * How much to randomize the particle direction [0-1].
  88771. */
  88772. directionRandomizer: number;
  88773. /**
  88774. * Creates a new instance SphereParticleEmitter
  88775. * @param radius the radius of the emission sphere (1 by default)
  88776. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  88777. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  88778. */
  88779. constructor(
  88780. /**
  88781. * The radius of the emission sphere.
  88782. */
  88783. radius?: number,
  88784. /**
  88785. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  88786. */
  88787. radiusRange?: number,
  88788. /**
  88789. * How much to randomize the particle direction [0-1].
  88790. */
  88791. directionRandomizer?: number);
  88792. /**
  88793. * Called by the particle System when the direction is computed for the created particle.
  88794. * @param worldMatrix is the world matrix of the particle system
  88795. * @param directionToUpdate is the direction vector to update with the result
  88796. * @param particle is the particle we are computed the direction for
  88797. * @param isLocal defines if the direction should be set in local space
  88798. */
  88799. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  88800. /**
  88801. * Called by the particle System when the position is computed for the created particle.
  88802. * @param worldMatrix is the world matrix of the particle system
  88803. * @param positionToUpdate is the position vector to update with the result
  88804. * @param particle is the particle we are computed the position for
  88805. * @param isLocal defines if the position should be set in local space
  88806. */
  88807. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  88808. /**
  88809. * Clones the current emitter and returns a copy of it
  88810. * @returns the new emitter
  88811. */
  88812. clone(): SphereParticleEmitter;
  88813. /**
  88814. * Called by the GPUParticleSystem to setup the update shader
  88815. * @param effect defines the update shader
  88816. */
  88817. applyToShader(effect: Effect): void;
  88818. /**
  88819. * Returns a string to use to update the GPU particles update shader
  88820. * @returns a string containng the defines string
  88821. */
  88822. getEffectDefines(): string;
  88823. /**
  88824. * Returns the string "SphereParticleEmitter"
  88825. * @returns a string containing the class name
  88826. */
  88827. getClassName(): string;
  88828. /**
  88829. * Serializes the particle system to a JSON object.
  88830. * @returns the JSON object
  88831. */
  88832. serialize(): any;
  88833. /**
  88834. * Parse properties from a JSON object
  88835. * @param serializationObject defines the JSON object
  88836. */
  88837. parse(serializationObject: any): void;
  88838. }
  88839. /**
  88840. * Particle emitter emitting particles from the inside of a sphere.
  88841. * It emits the particles randomly between two vectors.
  88842. */
  88843. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  88844. /**
  88845. * The min limit of the emission direction.
  88846. */
  88847. direction1: Vector3;
  88848. /**
  88849. * The max limit of the emission direction.
  88850. */
  88851. direction2: Vector3;
  88852. /**
  88853. * Creates a new instance SphereDirectedParticleEmitter
  88854. * @param radius the radius of the emission sphere (1 by default)
  88855. * @param direction1 the min limit of the emission direction (up vector by default)
  88856. * @param direction2 the max limit of the emission direction (up vector by default)
  88857. */
  88858. constructor(radius?: number,
  88859. /**
  88860. * The min limit of the emission direction.
  88861. */
  88862. direction1?: Vector3,
  88863. /**
  88864. * The max limit of the emission direction.
  88865. */
  88866. direction2?: Vector3);
  88867. /**
  88868. * Called by the particle System when the direction is computed for the created particle.
  88869. * @param worldMatrix is the world matrix of the particle system
  88870. * @param directionToUpdate is the direction vector to update with the result
  88871. * @param particle is the particle we are computed the direction for
  88872. */
  88873. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  88874. /**
  88875. * Clones the current emitter and returns a copy of it
  88876. * @returns the new emitter
  88877. */
  88878. clone(): SphereDirectedParticleEmitter;
  88879. /**
  88880. * Called by the GPUParticleSystem to setup the update shader
  88881. * @param effect defines the update shader
  88882. */
  88883. applyToShader(effect: Effect): void;
  88884. /**
  88885. * Returns a string to use to update the GPU particles update shader
  88886. * @returns a string containng the defines string
  88887. */
  88888. getEffectDefines(): string;
  88889. /**
  88890. * Returns the string "SphereDirectedParticleEmitter"
  88891. * @returns a string containing the class name
  88892. */
  88893. getClassName(): string;
  88894. /**
  88895. * Serializes the particle system to a JSON object.
  88896. * @returns the JSON object
  88897. */
  88898. serialize(): any;
  88899. /**
  88900. * Parse properties from a JSON object
  88901. * @param serializationObject defines the JSON object
  88902. */
  88903. parse(serializationObject: any): void;
  88904. }
  88905. }
  88906. declare module BABYLON {
  88907. /**
  88908. * Particle emitter emitting particles from a custom list of positions.
  88909. */
  88910. export class CustomParticleEmitter implements IParticleEmitterType {
  88911. /**
  88912. * Gets or sets the position generator that will create the inital position of each particle.
  88913. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  88914. */
  88915. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  88916. /**
  88917. * Gets or sets the destination generator that will create the final destination of each particle.
  88918. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  88919. */
  88920. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  88921. /**
  88922. * Creates a new instance CustomParticleEmitter
  88923. */
  88924. constructor();
  88925. /**
  88926. * Called by the particle System when the direction is computed for the created particle.
  88927. * @param worldMatrix is the world matrix of the particle system
  88928. * @param directionToUpdate is the direction vector to update with the result
  88929. * @param particle is the particle we are computed the direction for
  88930. * @param isLocal defines if the direction should be set in local space
  88931. */
  88932. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  88933. /**
  88934. * Called by the particle System when the position is computed for the created particle.
  88935. * @param worldMatrix is the world matrix of the particle system
  88936. * @param positionToUpdate is the position vector to update with the result
  88937. * @param particle is the particle we are computed the position for
  88938. * @param isLocal defines if the position should be set in local space
  88939. */
  88940. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  88941. /**
  88942. * Clones the current emitter and returns a copy of it
  88943. * @returns the new emitter
  88944. */
  88945. clone(): CustomParticleEmitter;
  88946. /**
  88947. * Called by the GPUParticleSystem to setup the update shader
  88948. * @param effect defines the update shader
  88949. */
  88950. applyToShader(effect: Effect): void;
  88951. /**
  88952. * Returns a string to use to update the GPU particles update shader
  88953. * @returns a string containng the defines string
  88954. */
  88955. getEffectDefines(): string;
  88956. /**
  88957. * Returns the string "PointParticleEmitter"
  88958. * @returns a string containing the class name
  88959. */
  88960. getClassName(): string;
  88961. /**
  88962. * Serializes the particle system to a JSON object.
  88963. * @returns the JSON object
  88964. */
  88965. serialize(): any;
  88966. /**
  88967. * Parse properties from a JSON object
  88968. * @param serializationObject defines the JSON object
  88969. */
  88970. parse(serializationObject: any): void;
  88971. }
  88972. }
  88973. declare module BABYLON {
  88974. /**
  88975. * Particle emitter emitting particles from the inside of a box.
  88976. * It emits the particles randomly between 2 given directions.
  88977. */
  88978. export class MeshParticleEmitter implements IParticleEmitterType {
  88979. private _indices;
  88980. private _positions;
  88981. private _normals;
  88982. private _storedNormal;
  88983. private _mesh;
  88984. /**
  88985. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  88986. */
  88987. direction1: Vector3;
  88988. /**
  88989. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  88990. */
  88991. direction2: Vector3;
  88992. /**
  88993. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  88994. */
  88995. useMeshNormalsForDirection: boolean;
  88996. /** Defines the mesh to use as source */
  88997. get mesh(): Nullable<AbstractMesh>;
  88998. set mesh(value: Nullable<AbstractMesh>);
  88999. /**
  89000. * Creates a new instance MeshParticleEmitter
  89001. * @param mesh defines the mesh to use as source
  89002. */
  89003. constructor(mesh?: Nullable<AbstractMesh>);
  89004. /**
  89005. * Called by the particle System when the direction is computed for the created particle.
  89006. * @param worldMatrix is the world matrix of the particle system
  89007. * @param directionToUpdate is the direction vector to update with the result
  89008. * @param particle is the particle we are computed the direction for
  89009. * @param isLocal defines if the direction should be set in local space
  89010. */
  89011. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  89012. /**
  89013. * Called by the particle System when the position is computed for the created particle.
  89014. * @param worldMatrix is the world matrix of the particle system
  89015. * @param positionToUpdate is the position vector to update with the result
  89016. * @param particle is the particle we are computed the position for
  89017. * @param isLocal defines if the position should be set in local space
  89018. */
  89019. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  89020. /**
  89021. * Clones the current emitter and returns a copy of it
  89022. * @returns the new emitter
  89023. */
  89024. clone(): MeshParticleEmitter;
  89025. /**
  89026. * Called by the GPUParticleSystem to setup the update shader
  89027. * @param effect defines the update shader
  89028. */
  89029. applyToShader(effect: Effect): void;
  89030. /**
  89031. * Returns a string to use to update the GPU particles update shader
  89032. * @returns a string containng the defines string
  89033. */
  89034. getEffectDefines(): string;
  89035. /**
  89036. * Returns the string "BoxParticleEmitter"
  89037. * @returns a string containing the class name
  89038. */
  89039. getClassName(): string;
  89040. /**
  89041. * Serializes the particle system to a JSON object.
  89042. * @returns the JSON object
  89043. */
  89044. serialize(): any;
  89045. /**
  89046. * Parse properties from a JSON object
  89047. * @param serializationObject defines the JSON object
  89048. * @param scene defines the hosting scene
  89049. */
  89050. parse(serializationObject: any, scene: Scene): void;
  89051. }
  89052. }
  89053. declare module BABYLON {
  89054. /**
  89055. * Interface representing a particle system in Babylon.js.
  89056. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  89057. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  89058. */
  89059. export interface IParticleSystem {
  89060. /**
  89061. * List of animations used by the particle system.
  89062. */
  89063. animations: Animation[];
  89064. /**
  89065. * The id of the Particle system.
  89066. */
  89067. id: string;
  89068. /**
  89069. * The name of the Particle system.
  89070. */
  89071. name: string;
  89072. /**
  89073. * The emitter represents the Mesh or position we are attaching the particle system to.
  89074. */
  89075. emitter: Nullable<AbstractMesh | Vector3>;
  89076. /**
  89077. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  89078. */
  89079. isBillboardBased: boolean;
  89080. /**
  89081. * The rendering group used by the Particle system to chose when to render.
  89082. */
  89083. renderingGroupId: number;
  89084. /**
  89085. * The layer mask we are rendering the particles through.
  89086. */
  89087. layerMask: number;
  89088. /**
  89089. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  89090. */
  89091. updateSpeed: number;
  89092. /**
  89093. * The amount of time the particle system is running (depends of the overall update speed).
  89094. */
  89095. targetStopDuration: number;
  89096. /**
  89097. * The texture used to render each particle. (this can be a spritesheet)
  89098. */
  89099. particleTexture: Nullable<Texture>;
  89100. /**
  89101. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  89102. */
  89103. blendMode: number;
  89104. /**
  89105. * Minimum life time of emitting particles.
  89106. */
  89107. minLifeTime: number;
  89108. /**
  89109. * Maximum life time of emitting particles.
  89110. */
  89111. maxLifeTime: number;
  89112. /**
  89113. * Minimum Size of emitting particles.
  89114. */
  89115. minSize: number;
  89116. /**
  89117. * Maximum Size of emitting particles.
  89118. */
  89119. maxSize: number;
  89120. /**
  89121. * Minimum scale of emitting particles on X axis.
  89122. */
  89123. minScaleX: number;
  89124. /**
  89125. * Maximum scale of emitting particles on X axis.
  89126. */
  89127. maxScaleX: number;
  89128. /**
  89129. * Minimum scale of emitting particles on Y axis.
  89130. */
  89131. minScaleY: number;
  89132. /**
  89133. * Maximum scale of emitting particles on Y axis.
  89134. */
  89135. maxScaleY: number;
  89136. /**
  89137. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  89138. */
  89139. color1: Color4;
  89140. /**
  89141. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  89142. */
  89143. color2: Color4;
  89144. /**
  89145. * Color the particle will have at the end of its lifetime.
  89146. */
  89147. colorDead: Color4;
  89148. /**
  89149. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  89150. */
  89151. emitRate: number;
  89152. /**
  89153. * You can use gravity if you want to give an orientation to your particles.
  89154. */
  89155. gravity: Vector3;
  89156. /**
  89157. * Minimum power of emitting particles.
  89158. */
  89159. minEmitPower: number;
  89160. /**
  89161. * Maximum power of emitting particles.
  89162. */
  89163. maxEmitPower: number;
  89164. /**
  89165. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  89166. */
  89167. minAngularSpeed: number;
  89168. /**
  89169. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  89170. */
  89171. maxAngularSpeed: number;
  89172. /**
  89173. * Gets or sets the minimal initial rotation in radians.
  89174. */
  89175. minInitialRotation: number;
  89176. /**
  89177. * Gets or sets the maximal initial rotation in radians.
  89178. */
  89179. maxInitialRotation: number;
  89180. /**
  89181. * The particle emitter type defines the emitter used by the particle system.
  89182. * It can be for example box, sphere, or cone...
  89183. */
  89184. particleEmitterType: Nullable<IParticleEmitterType>;
  89185. /**
  89186. * Defines the delay in milliseconds before starting the system (0 by default)
  89187. */
  89188. startDelay: number;
  89189. /**
  89190. * 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
  89191. */
  89192. preWarmCycles: number;
  89193. /**
  89194. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  89195. */
  89196. preWarmStepOffset: number;
  89197. /**
  89198. * 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)
  89199. */
  89200. spriteCellChangeSpeed: number;
  89201. /**
  89202. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  89203. */
  89204. startSpriteCellID: number;
  89205. /**
  89206. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  89207. */
  89208. endSpriteCellID: number;
  89209. /**
  89210. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  89211. */
  89212. spriteCellWidth: number;
  89213. /**
  89214. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  89215. */
  89216. spriteCellHeight: number;
  89217. /**
  89218. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  89219. */
  89220. spriteRandomStartCell: boolean;
  89221. /**
  89222. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  89223. */
  89224. isAnimationSheetEnabled: boolean;
  89225. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  89226. translationPivot: Vector2;
  89227. /**
  89228. * Gets or sets a texture used to add random noise to particle positions
  89229. */
  89230. noiseTexture: Nullable<BaseTexture>;
  89231. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  89232. noiseStrength: Vector3;
  89233. /**
  89234. * Gets or sets the billboard mode to use when isBillboardBased = true.
  89235. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  89236. */
  89237. billboardMode: number;
  89238. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  89239. limitVelocityDamping: number;
  89240. /**
  89241. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  89242. */
  89243. beginAnimationOnStart: boolean;
  89244. /**
  89245. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  89246. */
  89247. beginAnimationFrom: number;
  89248. /**
  89249. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  89250. */
  89251. beginAnimationTo: number;
  89252. /**
  89253. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  89254. */
  89255. beginAnimationLoop: boolean;
  89256. /**
  89257. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  89258. */
  89259. disposeOnStop: boolean;
  89260. /**
  89261. * Specifies if the particles are updated in emitter local space or world space
  89262. */
  89263. isLocal: boolean;
  89264. /** Snippet ID if the particle system was created from the snippet server */
  89265. snippetId: string;
  89266. /**
  89267. * Gets the maximum number of particles active at the same time.
  89268. * @returns The max number of active particles.
  89269. */
  89270. getCapacity(): number;
  89271. /**
  89272. * Gets the number of particles active at the same time.
  89273. * @returns The number of active particles.
  89274. */
  89275. getActiveCount(): number;
  89276. /**
  89277. * Gets if the system has been started. (Note: this will still be true after stop is called)
  89278. * @returns True if it has been started, otherwise false.
  89279. */
  89280. isStarted(): boolean;
  89281. /**
  89282. * Animates the particle system for this frame.
  89283. */
  89284. animate(): void;
  89285. /**
  89286. * Renders the particle system in its current state.
  89287. * @returns the current number of particles
  89288. */
  89289. render(): number;
  89290. /**
  89291. * Dispose the particle system and frees its associated resources.
  89292. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  89293. */
  89294. dispose(disposeTexture?: boolean): void;
  89295. /**
  89296. * Clones the particle system.
  89297. * @param name The name of the cloned object
  89298. * @param newEmitter The new emitter to use
  89299. * @returns the cloned particle system
  89300. */
  89301. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  89302. /**
  89303. * Serializes the particle system to a JSON object
  89304. * @param serializeTexture defines if the texture must be serialized as well
  89305. * @returns the JSON object
  89306. */
  89307. serialize(serializeTexture: boolean): any;
  89308. /**
  89309. * Rebuild the particle system
  89310. */
  89311. rebuild(): void;
  89312. /** Force the system to rebuild all gradients that need to be resync */
  89313. forceRefreshGradients(): void;
  89314. /**
  89315. * Starts the particle system and begins to emit
  89316. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  89317. */
  89318. start(delay?: number): void;
  89319. /**
  89320. * Stops the particle system.
  89321. */
  89322. stop(): void;
  89323. /**
  89324. * Remove all active particles
  89325. */
  89326. reset(): void;
  89327. /**
  89328. * Gets a boolean indicating that the system is stopping
  89329. * @returns true if the system is currently stopping
  89330. */
  89331. isStopping(): boolean;
  89332. /**
  89333. * Is this system ready to be used/rendered
  89334. * @return true if the system is ready
  89335. */
  89336. isReady(): boolean;
  89337. /**
  89338. * Returns the string "ParticleSystem"
  89339. * @returns a string containing the class name
  89340. */
  89341. getClassName(): string;
  89342. /**
  89343. * Adds a new color gradient
  89344. * @param gradient defines the gradient to use (between 0 and 1)
  89345. * @param color1 defines the color to affect to the specified gradient
  89346. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  89347. * @returns the current particle system
  89348. */
  89349. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  89350. /**
  89351. * Remove a specific color gradient
  89352. * @param gradient defines the gradient to remove
  89353. * @returns the current particle system
  89354. */
  89355. removeColorGradient(gradient: number): IParticleSystem;
  89356. /**
  89357. * Adds a new size gradient
  89358. * @param gradient defines the gradient to use (between 0 and 1)
  89359. * @param factor defines the size factor to affect to the specified gradient
  89360. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  89361. * @returns the current particle system
  89362. */
  89363. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  89364. /**
  89365. * Remove a specific size gradient
  89366. * @param gradient defines the gradient to remove
  89367. * @returns the current particle system
  89368. */
  89369. removeSizeGradient(gradient: number): IParticleSystem;
  89370. /**
  89371. * Gets the current list of color gradients.
  89372. * You must use addColorGradient and removeColorGradient to udpate this list
  89373. * @returns the list of color gradients
  89374. */
  89375. getColorGradients(): Nullable<Array<ColorGradient>>;
  89376. /**
  89377. * Gets the current list of size gradients.
  89378. * You must use addSizeGradient and removeSizeGradient to udpate this list
  89379. * @returns the list of size gradients
  89380. */
  89381. getSizeGradients(): Nullable<Array<FactorGradient>>;
  89382. /**
  89383. * Gets the current list of angular speed gradients.
  89384. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  89385. * @returns the list of angular speed gradients
  89386. */
  89387. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  89388. /**
  89389. * Adds a new angular speed gradient
  89390. * @param gradient defines the gradient to use (between 0 and 1)
  89391. * @param factor defines the angular speed to affect to the specified gradient
  89392. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  89393. * @returns the current particle system
  89394. */
  89395. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  89396. /**
  89397. * Remove a specific angular speed gradient
  89398. * @param gradient defines the gradient to remove
  89399. * @returns the current particle system
  89400. */
  89401. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  89402. /**
  89403. * Gets the current list of velocity gradients.
  89404. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  89405. * @returns the list of velocity gradients
  89406. */
  89407. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  89408. /**
  89409. * Adds a new velocity gradient
  89410. * @param gradient defines the gradient to use (between 0 and 1)
  89411. * @param factor defines the velocity to affect to the specified gradient
  89412. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  89413. * @returns the current particle system
  89414. */
  89415. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  89416. /**
  89417. * Remove a specific velocity gradient
  89418. * @param gradient defines the gradient to remove
  89419. * @returns the current particle system
  89420. */
  89421. removeVelocityGradient(gradient: number): IParticleSystem;
  89422. /**
  89423. * Gets the current list of limit velocity gradients.
  89424. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  89425. * @returns the list of limit velocity gradients
  89426. */
  89427. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  89428. /**
  89429. * Adds a new limit velocity gradient
  89430. * @param gradient defines the gradient to use (between 0 and 1)
  89431. * @param factor defines the limit velocity to affect to the specified gradient
  89432. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  89433. * @returns the current particle system
  89434. */
  89435. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  89436. /**
  89437. * Remove a specific limit velocity gradient
  89438. * @param gradient defines the gradient to remove
  89439. * @returns the current particle system
  89440. */
  89441. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  89442. /**
  89443. * Adds a new drag gradient
  89444. * @param gradient defines the gradient to use (between 0 and 1)
  89445. * @param factor defines the drag to affect to the specified gradient
  89446. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  89447. * @returns the current particle system
  89448. */
  89449. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  89450. /**
  89451. * Remove a specific drag gradient
  89452. * @param gradient defines the gradient to remove
  89453. * @returns the current particle system
  89454. */
  89455. removeDragGradient(gradient: number): IParticleSystem;
  89456. /**
  89457. * Gets the current list of drag gradients.
  89458. * You must use addDragGradient and removeDragGradient to udpate this list
  89459. * @returns the list of drag gradients
  89460. */
  89461. getDragGradients(): Nullable<Array<FactorGradient>>;
  89462. /**
  89463. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  89464. * @param gradient defines the gradient to use (between 0 and 1)
  89465. * @param factor defines the emit rate to affect to the specified gradient
  89466. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  89467. * @returns the current particle system
  89468. */
  89469. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  89470. /**
  89471. * Remove a specific emit rate gradient
  89472. * @param gradient defines the gradient to remove
  89473. * @returns the current particle system
  89474. */
  89475. removeEmitRateGradient(gradient: number): IParticleSystem;
  89476. /**
  89477. * Gets the current list of emit rate gradients.
  89478. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  89479. * @returns the list of emit rate gradients
  89480. */
  89481. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  89482. /**
  89483. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  89484. * @param gradient defines the gradient to use (between 0 and 1)
  89485. * @param factor defines the start size to affect to the specified gradient
  89486. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  89487. * @returns the current particle system
  89488. */
  89489. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  89490. /**
  89491. * Remove a specific start size gradient
  89492. * @param gradient defines the gradient to remove
  89493. * @returns the current particle system
  89494. */
  89495. removeStartSizeGradient(gradient: number): IParticleSystem;
  89496. /**
  89497. * Gets the current list of start size gradients.
  89498. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  89499. * @returns the list of start size gradients
  89500. */
  89501. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  89502. /**
  89503. * Adds a new life time gradient
  89504. * @param gradient defines the gradient to use (between 0 and 1)
  89505. * @param factor defines the life time factor to affect to the specified gradient
  89506. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  89507. * @returns the current particle system
  89508. */
  89509. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  89510. /**
  89511. * Remove a specific life time gradient
  89512. * @param gradient defines the gradient to remove
  89513. * @returns the current particle system
  89514. */
  89515. removeLifeTimeGradient(gradient: number): IParticleSystem;
  89516. /**
  89517. * Gets the current list of life time gradients.
  89518. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  89519. * @returns the list of life time gradients
  89520. */
  89521. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  89522. /**
  89523. * Gets the current list of color gradients.
  89524. * You must use addColorGradient and removeColorGradient to udpate this list
  89525. * @returns the list of color gradients
  89526. */
  89527. getColorGradients(): Nullable<Array<ColorGradient>>;
  89528. /**
  89529. * Adds a new ramp gradient used to remap particle colors
  89530. * @param gradient defines the gradient to use (between 0 and 1)
  89531. * @param color defines the color to affect to the specified gradient
  89532. * @returns the current particle system
  89533. */
  89534. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  89535. /**
  89536. * Gets the current list of ramp gradients.
  89537. * You must use addRampGradient and removeRampGradient to udpate this list
  89538. * @returns the list of ramp gradients
  89539. */
  89540. getRampGradients(): Nullable<Array<Color3Gradient>>;
  89541. /** Gets or sets a boolean indicating that ramp gradients must be used
  89542. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  89543. */
  89544. useRampGradients: boolean;
  89545. /**
  89546. * Adds a new color remap gradient
  89547. * @param gradient defines the gradient to use (between 0 and 1)
  89548. * @param min defines the color remap minimal range
  89549. * @param max defines the color remap maximal range
  89550. * @returns the current particle system
  89551. */
  89552. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  89553. /**
  89554. * Gets the current list of color remap gradients.
  89555. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  89556. * @returns the list of color remap gradients
  89557. */
  89558. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  89559. /**
  89560. * Adds a new alpha remap gradient
  89561. * @param gradient defines the gradient to use (between 0 and 1)
  89562. * @param min defines the alpha remap minimal range
  89563. * @param max defines the alpha remap maximal range
  89564. * @returns the current particle system
  89565. */
  89566. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  89567. /**
  89568. * Gets the current list of alpha remap gradients.
  89569. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  89570. * @returns the list of alpha remap gradients
  89571. */
  89572. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  89573. /**
  89574. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  89575. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  89576. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  89577. * @returns the emitter
  89578. */
  89579. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  89580. /**
  89581. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  89582. * @param radius The radius of the hemisphere to emit from
  89583. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  89584. * @returns the emitter
  89585. */
  89586. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  89587. /**
  89588. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  89589. * @param radius The radius of the sphere to emit from
  89590. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  89591. * @returns the emitter
  89592. */
  89593. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  89594. /**
  89595. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  89596. * @param radius The radius of the sphere to emit from
  89597. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  89598. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  89599. * @returns the emitter
  89600. */
  89601. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  89602. /**
  89603. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  89604. * @param radius The radius of the emission cylinder
  89605. * @param height The height of the emission cylinder
  89606. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  89607. * @param directionRandomizer How much to randomize the particle direction [0-1]
  89608. * @returns the emitter
  89609. */
  89610. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  89611. /**
  89612. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  89613. * @param radius The radius of the cylinder to emit from
  89614. * @param height The height of the emission cylinder
  89615. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  89616. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  89617. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  89618. * @returns the emitter
  89619. */
  89620. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  89621. /**
  89622. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  89623. * @param radius The radius of the cone to emit from
  89624. * @param angle The base angle of the cone
  89625. * @returns the emitter
  89626. */
  89627. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  89628. /**
  89629. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  89630. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  89631. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  89632. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  89633. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  89634. * @returns the emitter
  89635. */
  89636. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  89637. /**
  89638. * Get hosting scene
  89639. * @returns the scene
  89640. */
  89641. getScene(): Scene;
  89642. }
  89643. }
  89644. declare module BABYLON {
  89645. /**
  89646. * 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.
  89647. * @see https://doc.babylonjs.com/how_to/transformnode
  89648. */
  89649. export class TransformNode extends Node {
  89650. /**
  89651. * Object will not rotate to face the camera
  89652. */
  89653. static BILLBOARDMODE_NONE: number;
  89654. /**
  89655. * Object will rotate to face the camera but only on the x axis
  89656. */
  89657. static BILLBOARDMODE_X: number;
  89658. /**
  89659. * Object will rotate to face the camera but only on the y axis
  89660. */
  89661. static BILLBOARDMODE_Y: number;
  89662. /**
  89663. * Object will rotate to face the camera but only on the z axis
  89664. */
  89665. static BILLBOARDMODE_Z: number;
  89666. /**
  89667. * Object will rotate to face the camera
  89668. */
  89669. static BILLBOARDMODE_ALL: number;
  89670. /**
  89671. * Object will rotate to face the camera's position instead of orientation
  89672. */
  89673. static BILLBOARDMODE_USE_POSITION: number;
  89674. private _forward;
  89675. private _forwardInverted;
  89676. private _up;
  89677. private _right;
  89678. private _rightInverted;
  89679. private _position;
  89680. private _rotation;
  89681. private _rotationQuaternion;
  89682. protected _scaling: Vector3;
  89683. protected _isDirty: boolean;
  89684. private _transformToBoneReferal;
  89685. private _isAbsoluteSynced;
  89686. private _billboardMode;
  89687. /**
  89688. * Gets or sets the billboard mode. Default is 0.
  89689. *
  89690. * | Value | Type | Description |
  89691. * | --- | --- | --- |
  89692. * | 0 | BILLBOARDMODE_NONE | |
  89693. * | 1 | BILLBOARDMODE_X | |
  89694. * | 2 | BILLBOARDMODE_Y | |
  89695. * | 4 | BILLBOARDMODE_Z | |
  89696. * | 7 | BILLBOARDMODE_ALL | |
  89697. *
  89698. */
  89699. get billboardMode(): number;
  89700. set billboardMode(value: number);
  89701. private _preserveParentRotationForBillboard;
  89702. /**
  89703. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  89704. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  89705. */
  89706. get preserveParentRotationForBillboard(): boolean;
  89707. set preserveParentRotationForBillboard(value: boolean);
  89708. /**
  89709. * 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
  89710. */
  89711. scalingDeterminant: number;
  89712. private _infiniteDistance;
  89713. /**
  89714. * Gets or sets the distance of the object to max, often used by skybox
  89715. */
  89716. get infiniteDistance(): boolean;
  89717. set infiniteDistance(value: boolean);
  89718. /**
  89719. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  89720. * By default the system will update normals to compensate
  89721. */
  89722. ignoreNonUniformScaling: boolean;
  89723. /**
  89724. * 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
  89725. */
  89726. reIntegrateRotationIntoRotationQuaternion: boolean;
  89727. /** @hidden */
  89728. _poseMatrix: Nullable<Matrix>;
  89729. /** @hidden */
  89730. _localMatrix: Matrix;
  89731. private _usePivotMatrix;
  89732. private _absolutePosition;
  89733. private _absoluteScaling;
  89734. private _absoluteRotationQuaternion;
  89735. private _pivotMatrix;
  89736. private _pivotMatrixInverse;
  89737. protected _postMultiplyPivotMatrix: boolean;
  89738. protected _isWorldMatrixFrozen: boolean;
  89739. /** @hidden */
  89740. _indexInSceneTransformNodesArray: number;
  89741. /**
  89742. * An event triggered after the world matrix is updated
  89743. */
  89744. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  89745. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  89746. /**
  89747. * Gets a string identifying the name of the class
  89748. * @returns "TransformNode" string
  89749. */
  89750. getClassName(): string;
  89751. /**
  89752. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  89753. */
  89754. get position(): Vector3;
  89755. set position(newPosition: Vector3);
  89756. /**
  89757. * 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)).
  89758. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  89759. */
  89760. get rotation(): Vector3;
  89761. set rotation(newRotation: Vector3);
  89762. /**
  89763. * 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)).
  89764. */
  89765. get scaling(): Vector3;
  89766. set scaling(newScaling: Vector3);
  89767. /**
  89768. * 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).
  89769. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  89770. */
  89771. get rotationQuaternion(): Nullable<Quaternion>;
  89772. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  89773. /**
  89774. * The forward direction of that transform in world space.
  89775. */
  89776. get forward(): Vector3;
  89777. /**
  89778. * The up direction of that transform in world space.
  89779. */
  89780. get up(): Vector3;
  89781. /**
  89782. * The right direction of that transform in world space.
  89783. */
  89784. get right(): Vector3;
  89785. /**
  89786. * Copies the parameter passed Matrix into the mesh Pose matrix.
  89787. * @param matrix the matrix to copy the pose from
  89788. * @returns this TransformNode.
  89789. */
  89790. updatePoseMatrix(matrix: Matrix): TransformNode;
  89791. /**
  89792. * Returns the mesh Pose matrix.
  89793. * @returns the pose matrix
  89794. */
  89795. getPoseMatrix(): Matrix;
  89796. /** @hidden */
  89797. _isSynchronized(): boolean;
  89798. /** @hidden */
  89799. _initCache(): void;
  89800. /**
  89801. * Flag the transform node as dirty (Forcing it to update everything)
  89802. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  89803. * @returns this transform node
  89804. */
  89805. markAsDirty(property: string): TransformNode;
  89806. /**
  89807. * Returns the current mesh absolute position.
  89808. * Returns a Vector3.
  89809. */
  89810. get absolutePosition(): Vector3;
  89811. /**
  89812. * Returns the current mesh absolute scaling.
  89813. * Returns a Vector3.
  89814. */
  89815. get absoluteScaling(): Vector3;
  89816. /**
  89817. * Returns the current mesh absolute rotation.
  89818. * Returns a Quaternion.
  89819. */
  89820. get absoluteRotationQuaternion(): Quaternion;
  89821. /**
  89822. * Sets a new matrix to apply before all other transformation
  89823. * @param matrix defines the transform matrix
  89824. * @returns the current TransformNode
  89825. */
  89826. setPreTransformMatrix(matrix: Matrix): TransformNode;
  89827. /**
  89828. * Sets a new pivot matrix to the current node
  89829. * @param matrix defines the new pivot matrix to use
  89830. * @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
  89831. * @returns the current TransformNode
  89832. */
  89833. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  89834. /**
  89835. * Returns the mesh pivot matrix.
  89836. * Default : Identity.
  89837. * @returns the matrix
  89838. */
  89839. getPivotMatrix(): Matrix;
  89840. /**
  89841. * Instantiate (when possible) or clone that node with its hierarchy
  89842. * @param newParent defines the new parent to use for the instance (or clone)
  89843. * @param options defines options to configure how copy is done
  89844. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  89845. * @returns an instance (or a clone) of the current node with its hiearchy
  89846. */
  89847. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  89848. doNotInstantiate: boolean;
  89849. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  89850. /**
  89851. * Prevents the World matrix to be computed any longer
  89852. * @param newWorldMatrix defines an optional matrix to use as world matrix
  89853. * @returns the TransformNode.
  89854. */
  89855. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  89856. /**
  89857. * Allows back the World matrix computation.
  89858. * @returns the TransformNode.
  89859. */
  89860. unfreezeWorldMatrix(): this;
  89861. /**
  89862. * True if the World matrix has been frozen.
  89863. */
  89864. get isWorldMatrixFrozen(): boolean;
  89865. /**
  89866. * Retuns the mesh absolute position in the World.
  89867. * @returns a Vector3.
  89868. */
  89869. getAbsolutePosition(): Vector3;
  89870. /**
  89871. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  89872. * @param absolutePosition the absolute position to set
  89873. * @returns the TransformNode.
  89874. */
  89875. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  89876. /**
  89877. * Sets the mesh position in its local space.
  89878. * @param vector3 the position to set in localspace
  89879. * @returns the TransformNode.
  89880. */
  89881. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  89882. /**
  89883. * Returns the mesh position in the local space from the current World matrix values.
  89884. * @returns a new Vector3.
  89885. */
  89886. getPositionExpressedInLocalSpace(): Vector3;
  89887. /**
  89888. * Translates the mesh along the passed Vector3 in its local space.
  89889. * @param vector3 the distance to translate in localspace
  89890. * @returns the TransformNode.
  89891. */
  89892. locallyTranslate(vector3: Vector3): TransformNode;
  89893. private static _lookAtVectorCache;
  89894. /**
  89895. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  89896. * @param targetPoint the position (must be in same space as current mesh) to look at
  89897. * @param yawCor optional yaw (y-axis) correction in radians
  89898. * @param pitchCor optional pitch (x-axis) correction in radians
  89899. * @param rollCor optional roll (z-axis) correction in radians
  89900. * @param space the choosen space of the target
  89901. * @returns the TransformNode.
  89902. */
  89903. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  89904. /**
  89905. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  89906. * This Vector3 is expressed in the World space.
  89907. * @param localAxis axis to rotate
  89908. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  89909. */
  89910. getDirection(localAxis: Vector3): Vector3;
  89911. /**
  89912. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  89913. * localAxis is expressed in the mesh local space.
  89914. * result is computed in the Wordl space from the mesh World matrix.
  89915. * @param localAxis axis to rotate
  89916. * @param result the resulting transformnode
  89917. * @returns this TransformNode.
  89918. */
  89919. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  89920. /**
  89921. * Sets this transform node rotation to the given local axis.
  89922. * @param localAxis the axis in local space
  89923. * @param yawCor optional yaw (y-axis) correction in radians
  89924. * @param pitchCor optional pitch (x-axis) correction in radians
  89925. * @param rollCor optional roll (z-axis) correction in radians
  89926. * @returns this TransformNode
  89927. */
  89928. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  89929. /**
  89930. * Sets a new pivot point to the current node
  89931. * @param point defines the new pivot point to use
  89932. * @param space defines if the point is in world or local space (local by default)
  89933. * @returns the current TransformNode
  89934. */
  89935. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  89936. /**
  89937. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  89938. * @returns the pivot point
  89939. */
  89940. getPivotPoint(): Vector3;
  89941. /**
  89942. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  89943. * @param result the vector3 to store the result
  89944. * @returns this TransformNode.
  89945. */
  89946. getPivotPointToRef(result: Vector3): TransformNode;
  89947. /**
  89948. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  89949. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  89950. */
  89951. getAbsolutePivotPoint(): Vector3;
  89952. /**
  89953. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  89954. * @param result vector3 to store the result
  89955. * @returns this TransformNode.
  89956. */
  89957. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  89958. /**
  89959. * Defines the passed node as the parent of the current node.
  89960. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  89961. * @see https://doc.babylonjs.com/how_to/parenting
  89962. * @param node the node ot set as the parent
  89963. * @returns this TransformNode.
  89964. */
  89965. setParent(node: Nullable<Node>): TransformNode;
  89966. private _nonUniformScaling;
  89967. /**
  89968. * True if the scaling property of this object is non uniform eg. (1,2,1)
  89969. */
  89970. get nonUniformScaling(): boolean;
  89971. /** @hidden */
  89972. _updateNonUniformScalingState(value: boolean): boolean;
  89973. /**
  89974. * Attach the current TransformNode to another TransformNode associated with a bone
  89975. * @param bone Bone affecting the TransformNode
  89976. * @param affectedTransformNode TransformNode associated with the bone
  89977. * @returns this object
  89978. */
  89979. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  89980. /**
  89981. * Detach the transform node if its associated with a bone
  89982. * @returns this object
  89983. */
  89984. detachFromBone(): TransformNode;
  89985. private static _rotationAxisCache;
  89986. /**
  89987. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  89988. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  89989. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  89990. * The passed axis is also normalized.
  89991. * @param axis the axis to rotate around
  89992. * @param amount the amount to rotate in radians
  89993. * @param space Space to rotate in (Default: local)
  89994. * @returns the TransformNode.
  89995. */
  89996. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  89997. /**
  89998. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  89999. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  90000. * The passed axis is also normalized. .
  90001. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  90002. * @param point the point to rotate around
  90003. * @param axis the axis to rotate around
  90004. * @param amount the amount to rotate in radians
  90005. * @returns the TransformNode
  90006. */
  90007. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  90008. /**
  90009. * Translates the mesh along the axis vector for the passed distance in the given space.
  90010. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  90011. * @param axis the axis to translate in
  90012. * @param distance the distance to translate
  90013. * @param space Space to rotate in (Default: local)
  90014. * @returns the TransformNode.
  90015. */
  90016. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  90017. /**
  90018. * Adds a rotation step to the mesh current rotation.
  90019. * x, y, z are Euler angles expressed in radians.
  90020. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  90021. * This means this rotation is made in the mesh local space only.
  90022. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  90023. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  90024. * ```javascript
  90025. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  90026. * ```
  90027. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  90028. * 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.
  90029. * @param x Rotation to add
  90030. * @param y Rotation to add
  90031. * @param z Rotation to add
  90032. * @returns the TransformNode.
  90033. */
  90034. addRotation(x: number, y: number, z: number): TransformNode;
  90035. /**
  90036. * @hidden
  90037. */
  90038. protected _getEffectiveParent(): Nullable<Node>;
  90039. /**
  90040. * Computes the world matrix of the node
  90041. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  90042. * @returns the world matrix
  90043. */
  90044. computeWorldMatrix(force?: boolean): Matrix;
  90045. /**
  90046. * Resets this nodeTransform's local matrix to Matrix.Identity().
  90047. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  90048. */
  90049. resetLocalMatrix(independentOfChildren?: boolean): void;
  90050. protected _afterComputeWorldMatrix(): void;
  90051. /**
  90052. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  90053. * @param func callback function to add
  90054. *
  90055. * @returns the TransformNode.
  90056. */
  90057. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  90058. /**
  90059. * Removes a registered callback function.
  90060. * @param func callback function to remove
  90061. * @returns the TransformNode.
  90062. */
  90063. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  90064. /**
  90065. * Gets the position of the current mesh in camera space
  90066. * @param camera defines the camera to use
  90067. * @returns a position
  90068. */
  90069. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  90070. /**
  90071. * Returns the distance from the mesh to the active camera
  90072. * @param camera defines the camera to use
  90073. * @returns the distance
  90074. */
  90075. getDistanceToCamera(camera?: Nullable<Camera>): number;
  90076. /**
  90077. * Clone the current transform node
  90078. * @param name Name of the new clone
  90079. * @param newParent New parent for the clone
  90080. * @param doNotCloneChildren Do not clone children hierarchy
  90081. * @returns the new transform node
  90082. */
  90083. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  90084. /**
  90085. * Serializes the objects information.
  90086. * @param currentSerializationObject defines the object to serialize in
  90087. * @returns the serialized object
  90088. */
  90089. serialize(currentSerializationObject?: any): any;
  90090. /**
  90091. * Returns a new TransformNode object parsed from the source provided.
  90092. * @param parsedTransformNode is the source.
  90093. * @param scene the scne the object belongs to
  90094. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  90095. * @returns a new TransformNode object parsed from the source provided.
  90096. */
  90097. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  90098. /**
  90099. * Get all child-transformNodes of this node
  90100. * @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
  90101. * @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
  90102. * @returns an array of TransformNode
  90103. */
  90104. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  90105. /**
  90106. * Releases resources associated with this transform node.
  90107. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  90108. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  90109. */
  90110. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  90111. /**
  90112. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  90113. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  90114. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  90115. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  90116. * @returns the current mesh
  90117. */
  90118. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  90119. private _syncAbsoluteScalingAndRotation;
  90120. }
  90121. }
  90122. declare module BABYLON {
  90123. /**
  90124. * Class used to override all child animations of a given target
  90125. */
  90126. export class AnimationPropertiesOverride {
  90127. /**
  90128. * Gets or sets a value indicating if animation blending must be used
  90129. */
  90130. enableBlending: boolean;
  90131. /**
  90132. * Gets or sets the blending speed to use when enableBlending is true
  90133. */
  90134. blendingSpeed: number;
  90135. /**
  90136. * Gets or sets the default loop mode to use
  90137. */
  90138. loopMode: number;
  90139. }
  90140. }
  90141. declare module BABYLON {
  90142. /**
  90143. * Class used to store bone information
  90144. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  90145. */
  90146. export class Bone extends Node {
  90147. /**
  90148. * defines the bone name
  90149. */
  90150. name: string;
  90151. private static _tmpVecs;
  90152. private static _tmpQuat;
  90153. private static _tmpMats;
  90154. /**
  90155. * Gets the list of child bones
  90156. */
  90157. children: Bone[];
  90158. /** Gets the animations associated with this bone */
  90159. animations: Animation[];
  90160. /**
  90161. * Gets or sets bone length
  90162. */
  90163. length: number;
  90164. /**
  90165. * @hidden Internal only
  90166. * Set this value to map this bone to a different index in the transform matrices
  90167. * Set this value to -1 to exclude the bone from the transform matrices
  90168. */
  90169. _index: Nullable<number>;
  90170. private _skeleton;
  90171. private _localMatrix;
  90172. private _restPose;
  90173. private _baseMatrix;
  90174. private _absoluteTransform;
  90175. private _invertedAbsoluteTransform;
  90176. private _parent;
  90177. private _scalingDeterminant;
  90178. private _worldTransform;
  90179. private _localScaling;
  90180. private _localRotation;
  90181. private _localPosition;
  90182. private _needToDecompose;
  90183. private _needToCompose;
  90184. /** @hidden */
  90185. _linkedTransformNode: Nullable<TransformNode>;
  90186. /** @hidden */
  90187. _waitingTransformNodeId: Nullable<string>;
  90188. /** @hidden */
  90189. get _matrix(): Matrix;
  90190. /** @hidden */
  90191. set _matrix(value: Matrix);
  90192. /**
  90193. * Create a new bone
  90194. * @param name defines the bone name
  90195. * @param skeleton defines the parent skeleton
  90196. * @param parentBone defines the parent (can be null if the bone is the root)
  90197. * @param localMatrix defines the local matrix
  90198. * @param restPose defines the rest pose matrix
  90199. * @param baseMatrix defines the base matrix
  90200. * @param index defines index of the bone in the hiearchy
  90201. */
  90202. constructor(
  90203. /**
  90204. * defines the bone name
  90205. */
  90206. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  90207. /**
  90208. * Gets the current object class name.
  90209. * @return the class name
  90210. */
  90211. getClassName(): string;
  90212. /**
  90213. * Gets the parent skeleton
  90214. * @returns a skeleton
  90215. */
  90216. getSkeleton(): Skeleton;
  90217. /**
  90218. * Gets parent bone
  90219. * @returns a bone or null if the bone is the root of the bone hierarchy
  90220. */
  90221. getParent(): Nullable<Bone>;
  90222. /**
  90223. * Returns an array containing the root bones
  90224. * @returns an array containing the root bones
  90225. */
  90226. getChildren(): Array<Bone>;
  90227. /**
  90228. * Gets the node index in matrix array generated for rendering
  90229. * @returns the node index
  90230. */
  90231. getIndex(): number;
  90232. /**
  90233. * Sets the parent bone
  90234. * @param parent defines the parent (can be null if the bone is the root)
  90235. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  90236. */
  90237. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  90238. /**
  90239. * Gets the local matrix
  90240. * @returns a matrix
  90241. */
  90242. getLocalMatrix(): Matrix;
  90243. /**
  90244. * Gets the base matrix (initial matrix which remains unchanged)
  90245. * @returns a matrix
  90246. */
  90247. getBaseMatrix(): Matrix;
  90248. /**
  90249. * Gets the rest pose matrix
  90250. * @returns a matrix
  90251. */
  90252. getRestPose(): Matrix;
  90253. /**
  90254. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  90255. */
  90256. getWorldMatrix(): Matrix;
  90257. /**
  90258. * Sets the local matrix to rest pose matrix
  90259. */
  90260. returnToRest(): void;
  90261. /**
  90262. * Gets the inverse of the absolute transform matrix.
  90263. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  90264. * @returns a matrix
  90265. */
  90266. getInvertedAbsoluteTransform(): Matrix;
  90267. /**
  90268. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  90269. * @returns a matrix
  90270. */
  90271. getAbsoluteTransform(): Matrix;
  90272. /**
  90273. * Links with the given transform node.
  90274. * The local matrix of this bone is copied from the transform node every frame.
  90275. * @param transformNode defines the transform node to link to
  90276. */
  90277. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  90278. /**
  90279. * Gets the node used to drive the bone's transformation
  90280. * @returns a transform node or null
  90281. */
  90282. getTransformNode(): Nullable<TransformNode>;
  90283. /** Gets or sets current position (in local space) */
  90284. get position(): Vector3;
  90285. set position(newPosition: Vector3);
  90286. /** Gets or sets current rotation (in local space) */
  90287. get rotation(): Vector3;
  90288. set rotation(newRotation: Vector3);
  90289. /** Gets or sets current rotation quaternion (in local space) */
  90290. get rotationQuaternion(): Quaternion;
  90291. set rotationQuaternion(newRotation: Quaternion);
  90292. /** Gets or sets current scaling (in local space) */
  90293. get scaling(): Vector3;
  90294. set scaling(newScaling: Vector3);
  90295. /**
  90296. * Gets the animation properties override
  90297. */
  90298. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  90299. private _decompose;
  90300. private _compose;
  90301. /**
  90302. * Update the base and local matrices
  90303. * @param matrix defines the new base or local matrix
  90304. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  90305. * @param updateLocalMatrix defines if the local matrix should be updated
  90306. */
  90307. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  90308. /** @hidden */
  90309. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  90310. /**
  90311. * Flag the bone as dirty (Forcing it to update everything)
  90312. */
  90313. markAsDirty(): void;
  90314. /** @hidden */
  90315. _markAsDirtyAndCompose(): void;
  90316. private _markAsDirtyAndDecompose;
  90317. /**
  90318. * Translate the bone in local or world space
  90319. * @param vec The amount to translate the bone
  90320. * @param space The space that the translation is in
  90321. * @param mesh The mesh that this bone is attached to. This is only used in world space
  90322. */
  90323. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  90324. /**
  90325. * Set the postion of the bone in local or world space
  90326. * @param position The position to set the bone
  90327. * @param space The space that the position is in
  90328. * @param mesh The mesh that this bone is attached to. This is only used in world space
  90329. */
  90330. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  90331. /**
  90332. * Set the absolute position of the bone (world space)
  90333. * @param position The position to set the bone
  90334. * @param mesh The mesh that this bone is attached to
  90335. */
  90336. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  90337. /**
  90338. * Scale the bone on the x, y and z axes (in local space)
  90339. * @param x The amount to scale the bone on the x axis
  90340. * @param y The amount to scale the bone on the y axis
  90341. * @param z The amount to scale the bone on the z axis
  90342. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  90343. */
  90344. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  90345. /**
  90346. * Set the bone scaling in local space
  90347. * @param scale defines the scaling vector
  90348. */
  90349. setScale(scale: Vector3): void;
  90350. /**
  90351. * Gets the current scaling in local space
  90352. * @returns the current scaling vector
  90353. */
  90354. getScale(): Vector3;
  90355. /**
  90356. * Gets the current scaling in local space and stores it in a target vector
  90357. * @param result defines the target vector
  90358. */
  90359. getScaleToRef(result: Vector3): void;
  90360. /**
  90361. * Set the yaw, pitch, and roll of the bone in local or world space
  90362. * @param yaw The rotation of the bone on the y axis
  90363. * @param pitch The rotation of the bone on the x axis
  90364. * @param roll The rotation of the bone on the z axis
  90365. * @param space The space that the axes of rotation are in
  90366. * @param mesh The mesh that this bone is attached to. This is only used in world space
  90367. */
  90368. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  90369. /**
  90370. * Add a rotation to the bone on an axis in local or world space
  90371. * @param axis The axis to rotate the bone on
  90372. * @param amount The amount to rotate the bone
  90373. * @param space The space that the axis is in
  90374. * @param mesh The mesh that this bone is attached to. This is only used in world space
  90375. */
  90376. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  90377. /**
  90378. * Set the rotation of the bone to a particular axis angle in local or world space
  90379. * @param axis The axis to rotate the bone on
  90380. * @param angle The angle that the bone should be rotated to
  90381. * @param space The space that the axis is in
  90382. * @param mesh The mesh that this bone is attached to. This is only used in world space
  90383. */
  90384. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  90385. /**
  90386. * Set the euler rotation of the bone in local of world space
  90387. * @param rotation The euler rotation that the bone should be set to
  90388. * @param space The space that the rotation is in
  90389. * @param mesh The mesh that this bone is attached to. This is only used in world space
  90390. */
  90391. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  90392. /**
  90393. * Set the quaternion rotation of the bone in local of world space
  90394. * @param quat The quaternion rotation that the bone should be set to
  90395. * @param space The space that the rotation is in
  90396. * @param mesh The mesh that this bone is attached to. This is only used in world space
  90397. */
  90398. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  90399. /**
  90400. * Set the rotation matrix of the bone in local of world space
  90401. * @param rotMat The rotation matrix that the bone should be set to
  90402. * @param space The space that the rotation is in
  90403. * @param mesh The mesh that this bone is attached to. This is only used in world space
  90404. */
  90405. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  90406. private _rotateWithMatrix;
  90407. private _getNegativeRotationToRef;
  90408. /**
  90409. * Get the position of the bone in local or world space
  90410. * @param space The space that the returned position is in
  90411. * @param mesh The mesh that this bone is attached to. This is only used in world space
  90412. * @returns The position of the bone
  90413. */
  90414. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  90415. /**
  90416. * Copy the position of the bone to a vector3 in local or world space
  90417. * @param space The space that the returned position is in
  90418. * @param mesh The mesh that this bone is attached to. This is only used in world space
  90419. * @param result The vector3 to copy the position to
  90420. */
  90421. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  90422. /**
  90423. * Get the absolute position of the bone (world space)
  90424. * @param mesh The mesh that this bone is attached to
  90425. * @returns The absolute position of the bone
  90426. */
  90427. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  90428. /**
  90429. * Copy the absolute position of the bone (world space) to the result param
  90430. * @param mesh The mesh that this bone is attached to
  90431. * @param result The vector3 to copy the absolute position to
  90432. */
  90433. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  90434. /**
  90435. * Compute the absolute transforms of this bone and its children
  90436. */
  90437. computeAbsoluteTransforms(): void;
  90438. /**
  90439. * Get the world direction from an axis that is in the local space of the bone
  90440. * @param localAxis The local direction that is used to compute the world direction
  90441. * @param mesh The mesh that this bone is attached to
  90442. * @returns The world direction
  90443. */
  90444. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  90445. /**
  90446. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  90447. * @param localAxis The local direction that is used to compute the world direction
  90448. * @param mesh The mesh that this bone is attached to
  90449. * @param result The vector3 that the world direction will be copied to
  90450. */
  90451. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  90452. /**
  90453. * Get the euler rotation of the bone in local or world space
  90454. * @param space The space that the rotation should be in
  90455. * @param mesh The mesh that this bone is attached to. This is only used in world space
  90456. * @returns The euler rotation
  90457. */
  90458. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  90459. /**
  90460. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  90461. * @param space The space that the rotation should be in
  90462. * @param mesh The mesh that this bone is attached to. This is only used in world space
  90463. * @param result The vector3 that the rotation should be copied to
  90464. */
  90465. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  90466. /**
  90467. * Get the quaternion rotation of the bone in either local or world space
  90468. * @param space The space that the rotation should be in
  90469. * @param mesh The mesh that this bone is attached to. This is only used in world space
  90470. * @returns The quaternion rotation
  90471. */
  90472. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  90473. /**
  90474. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  90475. * @param space The space that the rotation should be in
  90476. * @param mesh The mesh that this bone is attached to. This is only used in world space
  90477. * @param result The quaternion that the rotation should be copied to
  90478. */
  90479. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  90480. /**
  90481. * Get the rotation matrix of the bone in local or world space
  90482. * @param space The space that the rotation should be in
  90483. * @param mesh The mesh that this bone is attached to. This is only used in world space
  90484. * @returns The rotation matrix
  90485. */
  90486. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  90487. /**
  90488. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  90489. * @param space The space that the rotation should be in
  90490. * @param mesh The mesh that this bone is attached to. This is only used in world space
  90491. * @param result The quaternion that the rotation should be copied to
  90492. */
  90493. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  90494. /**
  90495. * Get the world position of a point that is in the local space of the bone
  90496. * @param position The local position
  90497. * @param mesh The mesh that this bone is attached to
  90498. * @returns The world position
  90499. */
  90500. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  90501. /**
  90502. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  90503. * @param position The local position
  90504. * @param mesh The mesh that this bone is attached to
  90505. * @param result The vector3 that the world position should be copied to
  90506. */
  90507. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  90508. /**
  90509. * Get the local position of a point that is in world space
  90510. * @param position The world position
  90511. * @param mesh The mesh that this bone is attached to
  90512. * @returns The local position
  90513. */
  90514. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  90515. /**
  90516. * Get the local position of a point that is in world space and copy it to the result param
  90517. * @param position The world position
  90518. * @param mesh The mesh that this bone is attached to
  90519. * @param result The vector3 that the local position should be copied to
  90520. */
  90521. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  90522. }
  90523. }
  90524. declare module BABYLON {
  90525. /**
  90526. * Defines a runtime animation
  90527. */
  90528. export class RuntimeAnimation {
  90529. private _events;
  90530. /**
  90531. * The current frame of the runtime animation
  90532. */
  90533. private _currentFrame;
  90534. /**
  90535. * The animation used by the runtime animation
  90536. */
  90537. private _animation;
  90538. /**
  90539. * The target of the runtime animation
  90540. */
  90541. private _target;
  90542. /**
  90543. * The initiating animatable
  90544. */
  90545. private _host;
  90546. /**
  90547. * The original value of the runtime animation
  90548. */
  90549. private _originalValue;
  90550. /**
  90551. * The original blend value of the runtime animation
  90552. */
  90553. private _originalBlendValue;
  90554. /**
  90555. * The offsets cache of the runtime animation
  90556. */
  90557. private _offsetsCache;
  90558. /**
  90559. * The high limits cache of the runtime animation
  90560. */
  90561. private _highLimitsCache;
  90562. /**
  90563. * Specifies if the runtime animation has been stopped
  90564. */
  90565. private _stopped;
  90566. /**
  90567. * The blending factor of the runtime animation
  90568. */
  90569. private _blendingFactor;
  90570. /**
  90571. * The BabylonJS scene
  90572. */
  90573. private _scene;
  90574. /**
  90575. * The current value of the runtime animation
  90576. */
  90577. private _currentValue;
  90578. /** @hidden */
  90579. _animationState: _IAnimationState;
  90580. /**
  90581. * The active target of the runtime animation
  90582. */
  90583. private _activeTargets;
  90584. private _currentActiveTarget;
  90585. private _directTarget;
  90586. /**
  90587. * The target path of the runtime animation
  90588. */
  90589. private _targetPath;
  90590. /**
  90591. * The weight of the runtime animation
  90592. */
  90593. private _weight;
  90594. /**
  90595. * The ratio offset of the runtime animation
  90596. */
  90597. private _ratioOffset;
  90598. /**
  90599. * The previous delay of the runtime animation
  90600. */
  90601. private _previousDelay;
  90602. /**
  90603. * The previous ratio of the runtime animation
  90604. */
  90605. private _previousRatio;
  90606. private _enableBlending;
  90607. private _keys;
  90608. private _minFrame;
  90609. private _maxFrame;
  90610. private _minValue;
  90611. private _maxValue;
  90612. private _targetIsArray;
  90613. /**
  90614. * Gets the current frame of the runtime animation
  90615. */
  90616. get currentFrame(): number;
  90617. /**
  90618. * Gets the weight of the runtime animation
  90619. */
  90620. get weight(): number;
  90621. /**
  90622. * Gets the current value of the runtime animation
  90623. */
  90624. get currentValue(): any;
  90625. /**
  90626. * Gets the target path of the runtime animation
  90627. */
  90628. get targetPath(): string;
  90629. /**
  90630. * Gets the actual target of the runtime animation
  90631. */
  90632. get target(): any;
  90633. /**
  90634. * Gets the additive state of the runtime animation
  90635. */
  90636. get isAdditive(): boolean;
  90637. /** @hidden */
  90638. _onLoop: () => void;
  90639. /**
  90640. * Create a new RuntimeAnimation object
  90641. * @param target defines the target of the animation
  90642. * @param animation defines the source animation object
  90643. * @param scene defines the hosting scene
  90644. * @param host defines the initiating Animatable
  90645. */
  90646. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  90647. private _preparePath;
  90648. /**
  90649. * Gets the animation from the runtime animation
  90650. */
  90651. get animation(): Animation;
  90652. /**
  90653. * Resets the runtime animation to the beginning
  90654. * @param restoreOriginal defines whether to restore the target property to the original value
  90655. */
  90656. reset(restoreOriginal?: boolean): void;
  90657. /**
  90658. * Specifies if the runtime animation is stopped
  90659. * @returns Boolean specifying if the runtime animation is stopped
  90660. */
  90661. isStopped(): boolean;
  90662. /**
  90663. * Disposes of the runtime animation
  90664. */
  90665. dispose(): void;
  90666. /**
  90667. * Apply the interpolated value to the target
  90668. * @param currentValue defines the value computed by the animation
  90669. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  90670. */
  90671. setValue(currentValue: any, weight: number): void;
  90672. private _getOriginalValues;
  90673. private _setValue;
  90674. /**
  90675. * Gets the loop pmode of the runtime animation
  90676. * @returns Loop Mode
  90677. */
  90678. private _getCorrectLoopMode;
  90679. /**
  90680. * Move the current animation to a given frame
  90681. * @param frame defines the frame to move to
  90682. */
  90683. goToFrame(frame: number): void;
  90684. /**
  90685. * @hidden Internal use only
  90686. */
  90687. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  90688. /**
  90689. * Execute the current animation
  90690. * @param delay defines the delay to add to the current frame
  90691. * @param from defines the lower bound of the animation range
  90692. * @param to defines the upper bound of the animation range
  90693. * @param loop defines if the current animation must loop
  90694. * @param speedRatio defines the current speed ratio
  90695. * @param weight defines the weight of the animation (default is -1 so no weight)
  90696. * @param onLoop optional callback called when animation loops
  90697. * @returns a boolean indicating if the animation is running
  90698. */
  90699. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  90700. }
  90701. }
  90702. declare module BABYLON {
  90703. /**
  90704. * Class used to store an actual running animation
  90705. */
  90706. export class Animatable {
  90707. /** defines the target object */
  90708. target: any;
  90709. /** defines the starting frame number (default is 0) */
  90710. fromFrame: number;
  90711. /** defines the ending frame number (default is 100) */
  90712. toFrame: number;
  90713. /** defines if the animation must loop (default is false) */
  90714. loopAnimation: boolean;
  90715. /** defines a callback to call when animation ends if it is not looping */
  90716. onAnimationEnd?: (() => void) | null | undefined;
  90717. /** defines a callback to call when animation loops */
  90718. onAnimationLoop?: (() => void) | null | undefined;
  90719. /** defines whether the animation should be evaluated additively */
  90720. isAdditive: boolean;
  90721. private _localDelayOffset;
  90722. private _pausedDelay;
  90723. private _runtimeAnimations;
  90724. private _paused;
  90725. private _scene;
  90726. private _speedRatio;
  90727. private _weight;
  90728. private _syncRoot;
  90729. /**
  90730. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  90731. * This will only apply for non looping animation (default is true)
  90732. */
  90733. disposeOnEnd: boolean;
  90734. /**
  90735. * Gets a boolean indicating if the animation has started
  90736. */
  90737. animationStarted: boolean;
  90738. /**
  90739. * Observer raised when the animation ends
  90740. */
  90741. onAnimationEndObservable: Observable<Animatable>;
  90742. /**
  90743. * Observer raised when the animation loops
  90744. */
  90745. onAnimationLoopObservable: Observable<Animatable>;
  90746. /**
  90747. * Gets the root Animatable used to synchronize and normalize animations
  90748. */
  90749. get syncRoot(): Nullable<Animatable>;
  90750. /**
  90751. * Gets the current frame of the first RuntimeAnimation
  90752. * Used to synchronize Animatables
  90753. */
  90754. get masterFrame(): number;
  90755. /**
  90756. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  90757. */
  90758. get weight(): number;
  90759. set weight(value: number);
  90760. /**
  90761. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  90762. */
  90763. get speedRatio(): number;
  90764. set speedRatio(value: number);
  90765. /**
  90766. * Creates a new Animatable
  90767. * @param scene defines the hosting scene
  90768. * @param target defines the target object
  90769. * @param fromFrame defines the starting frame number (default is 0)
  90770. * @param toFrame defines the ending frame number (default is 100)
  90771. * @param loopAnimation defines if the animation must loop (default is false)
  90772. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  90773. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  90774. * @param animations defines a group of animation to add to the new Animatable
  90775. * @param onAnimationLoop defines a callback to call when animation loops
  90776. * @param isAdditive defines whether the animation should be evaluated additively
  90777. */
  90778. constructor(scene: Scene,
  90779. /** defines the target object */
  90780. target: any,
  90781. /** defines the starting frame number (default is 0) */
  90782. fromFrame?: number,
  90783. /** defines the ending frame number (default is 100) */
  90784. toFrame?: number,
  90785. /** defines if the animation must loop (default is false) */
  90786. loopAnimation?: boolean, speedRatio?: number,
  90787. /** defines a callback to call when animation ends if it is not looping */
  90788. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  90789. /** defines a callback to call when animation loops */
  90790. onAnimationLoop?: (() => void) | null | undefined,
  90791. /** defines whether the animation should be evaluated additively */
  90792. isAdditive?: boolean);
  90793. /**
  90794. * Synchronize and normalize current Animatable with a source Animatable
  90795. * This is useful when using animation weights and when animations are not of the same length
  90796. * @param root defines the root Animatable to synchronize with
  90797. * @returns the current Animatable
  90798. */
  90799. syncWith(root: Animatable): Animatable;
  90800. /**
  90801. * Gets the list of runtime animations
  90802. * @returns an array of RuntimeAnimation
  90803. */
  90804. getAnimations(): RuntimeAnimation[];
  90805. /**
  90806. * Adds more animations to the current animatable
  90807. * @param target defines the target of the animations
  90808. * @param animations defines the new animations to add
  90809. */
  90810. appendAnimations(target: any, animations: Animation[]): void;
  90811. /**
  90812. * Gets the source animation for a specific property
  90813. * @param property defines the propertyu to look for
  90814. * @returns null or the source animation for the given property
  90815. */
  90816. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  90817. /**
  90818. * Gets the runtime animation for a specific property
  90819. * @param property defines the propertyu to look for
  90820. * @returns null or the runtime animation for the given property
  90821. */
  90822. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  90823. /**
  90824. * Resets the animatable to its original state
  90825. */
  90826. reset(): void;
  90827. /**
  90828. * Allows the animatable to blend with current running animations
  90829. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  90830. * @param blendingSpeed defines the blending speed to use
  90831. */
  90832. enableBlending(blendingSpeed: number): void;
  90833. /**
  90834. * Disable animation blending
  90835. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  90836. */
  90837. disableBlending(): void;
  90838. /**
  90839. * Jump directly to a given frame
  90840. * @param frame defines the frame to jump to
  90841. */
  90842. goToFrame(frame: number): void;
  90843. /**
  90844. * Pause the animation
  90845. */
  90846. pause(): void;
  90847. /**
  90848. * Restart the animation
  90849. */
  90850. restart(): void;
  90851. private _raiseOnAnimationEnd;
  90852. /**
  90853. * Stop and delete the current animation
  90854. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  90855. * @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)
  90856. */
  90857. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  90858. /**
  90859. * Wait asynchronously for the animation to end
  90860. * @returns a promise which will be fullfilled when the animation ends
  90861. */
  90862. waitAsync(): Promise<Animatable>;
  90863. /** @hidden */
  90864. _animate(delay: number): boolean;
  90865. }
  90866. interface Scene {
  90867. /** @hidden */
  90868. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  90869. /** @hidden */
  90870. _processLateAnimationBindingsForMatrices(holder: {
  90871. totalWeight: number;
  90872. totalAdditiveWeight: number;
  90873. animations: RuntimeAnimation[];
  90874. additiveAnimations: RuntimeAnimation[];
  90875. originalValue: Matrix;
  90876. }): any;
  90877. /** @hidden */
  90878. _processLateAnimationBindingsForQuaternions(holder: {
  90879. totalWeight: number;
  90880. totalAdditiveWeight: number;
  90881. animations: RuntimeAnimation[];
  90882. additiveAnimations: RuntimeAnimation[];
  90883. originalValue: Quaternion;
  90884. }, refQuaternion: Quaternion): Quaternion;
  90885. /** @hidden */
  90886. _processLateAnimationBindings(): void;
  90887. /**
  90888. * Will start the animation sequence of a given target
  90889. * @param target defines the target
  90890. * @param from defines from which frame should animation start
  90891. * @param to defines until which frame should animation run.
  90892. * @param weight defines the weight to apply to the animation (1.0 by default)
  90893. * @param loop defines if the animation loops
  90894. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  90895. * @param onAnimationEnd defines the function to be executed when the animation ends
  90896. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  90897. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  90898. * @param onAnimationLoop defines the callback to call when an animation loops
  90899. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  90900. * @returns the animatable object created for this animation
  90901. */
  90902. 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;
  90903. /**
  90904. * Will start the animation sequence of a given target
  90905. * @param target defines the target
  90906. * @param from defines from which frame should animation start
  90907. * @param to defines until which frame should animation run.
  90908. * @param loop defines if the animation loops
  90909. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  90910. * @param onAnimationEnd defines the function to be executed when the animation ends
  90911. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  90912. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  90913. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  90914. * @param onAnimationLoop defines the callback to call when an animation loops
  90915. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  90916. * @returns the animatable object created for this animation
  90917. */
  90918. 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;
  90919. /**
  90920. * Will start the animation sequence of a given target and its hierarchy
  90921. * @param target defines the target
  90922. * @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.
  90923. * @param from defines from which frame should animation start
  90924. * @param to defines until which frame should animation run.
  90925. * @param loop defines if the animation loops
  90926. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  90927. * @param onAnimationEnd defines the function to be executed when the animation ends
  90928. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  90929. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  90930. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  90931. * @param onAnimationLoop defines the callback to call when an animation loops
  90932. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  90933. * @returns the list of created animatables
  90934. */
  90935. 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[];
  90936. /**
  90937. * Begin a new animation on a given node
  90938. * @param target defines the target where the animation will take place
  90939. * @param animations defines the list of animations to start
  90940. * @param from defines the initial value
  90941. * @param to defines the final value
  90942. * @param loop defines if you want animation to loop (off by default)
  90943. * @param speedRatio defines the speed ratio to apply to all animations
  90944. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  90945. * @param onAnimationLoop defines the callback to call when an animation loops
  90946. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  90947. * @returns the list of created animatables
  90948. */
  90949. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  90950. /**
  90951. * Begin a new animation on a given node and its hierarchy
  90952. * @param target defines the root node where the animation will take place
  90953. * @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.
  90954. * @param animations defines the list of animations to start
  90955. * @param from defines the initial value
  90956. * @param to defines the final value
  90957. * @param loop defines if you want animation to loop (off by default)
  90958. * @param speedRatio defines the speed ratio to apply to all animations
  90959. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  90960. * @param onAnimationLoop defines the callback to call when an animation loops
  90961. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  90962. * @returns the list of animatables created for all nodes
  90963. */
  90964. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  90965. /**
  90966. * Gets the animatable associated with a specific target
  90967. * @param target defines the target of the animatable
  90968. * @returns the required animatable if found
  90969. */
  90970. getAnimatableByTarget(target: any): Nullable<Animatable>;
  90971. /**
  90972. * Gets all animatables associated with a given target
  90973. * @param target defines the target to look animatables for
  90974. * @returns an array of Animatables
  90975. */
  90976. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  90977. /**
  90978. * Stops and removes all animations that have been applied to the scene
  90979. */
  90980. stopAllAnimations(): void;
  90981. /**
  90982. * Gets the current delta time used by animation engine
  90983. */
  90984. deltaTime: number;
  90985. }
  90986. interface Bone {
  90987. /**
  90988. * Copy an animation range from another bone
  90989. * @param source defines the source bone
  90990. * @param rangeName defines the range name to copy
  90991. * @param frameOffset defines the frame offset
  90992. * @param rescaleAsRequired defines if rescaling must be applied if required
  90993. * @param skelDimensionsRatio defines the scaling ratio
  90994. * @returns true if operation was successful
  90995. */
  90996. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  90997. }
  90998. }
  90999. declare module BABYLON {
  91000. /**
  91001. * Class used to handle skinning animations
  91002. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  91003. */
  91004. export class Skeleton implements IAnimatable {
  91005. /** defines the skeleton name */
  91006. name: string;
  91007. /** defines the skeleton Id */
  91008. id: string;
  91009. /**
  91010. * Defines the list of child bones
  91011. */
  91012. bones: Bone[];
  91013. /**
  91014. * Defines an estimate of the dimension of the skeleton at rest
  91015. */
  91016. dimensionsAtRest: Vector3;
  91017. /**
  91018. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  91019. */
  91020. needInitialSkinMatrix: boolean;
  91021. /**
  91022. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  91023. */
  91024. overrideMesh: Nullable<AbstractMesh>;
  91025. /**
  91026. * Gets the list of animations attached to this skeleton
  91027. */
  91028. animations: Array<Animation>;
  91029. private _scene;
  91030. private _isDirty;
  91031. private _transformMatrices;
  91032. private _transformMatrixTexture;
  91033. private _meshesWithPoseMatrix;
  91034. private _animatables;
  91035. private _identity;
  91036. private _synchronizedWithMesh;
  91037. private _ranges;
  91038. private _lastAbsoluteTransformsUpdateId;
  91039. private _canUseTextureForBones;
  91040. private _uniqueId;
  91041. /** @hidden */
  91042. _numBonesWithLinkedTransformNode: number;
  91043. /** @hidden */
  91044. _hasWaitingData: Nullable<boolean>;
  91045. /**
  91046. * Specifies if the skeleton should be serialized
  91047. */
  91048. doNotSerialize: boolean;
  91049. private _useTextureToStoreBoneMatrices;
  91050. /**
  91051. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  91052. * Please note that this option is not available if the hardware does not support it
  91053. */
  91054. get useTextureToStoreBoneMatrices(): boolean;
  91055. set useTextureToStoreBoneMatrices(value: boolean);
  91056. private _animationPropertiesOverride;
  91057. /**
  91058. * Gets or sets the animation properties override
  91059. */
  91060. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  91061. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  91062. /**
  91063. * List of inspectable custom properties (used by the Inspector)
  91064. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  91065. */
  91066. inspectableCustomProperties: IInspectable[];
  91067. /**
  91068. * An observable triggered before computing the skeleton's matrices
  91069. */
  91070. onBeforeComputeObservable: Observable<Skeleton>;
  91071. /**
  91072. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  91073. */
  91074. get isUsingTextureForMatrices(): boolean;
  91075. /**
  91076. * Gets the unique ID of this skeleton
  91077. */
  91078. get uniqueId(): number;
  91079. /**
  91080. * Creates a new skeleton
  91081. * @param name defines the skeleton name
  91082. * @param id defines the skeleton Id
  91083. * @param scene defines the hosting scene
  91084. */
  91085. constructor(
  91086. /** defines the skeleton name */
  91087. name: string,
  91088. /** defines the skeleton Id */
  91089. id: string, scene: Scene);
  91090. /**
  91091. * Gets the current object class name.
  91092. * @return the class name
  91093. */
  91094. getClassName(): string;
  91095. /**
  91096. * Returns an array containing the root bones
  91097. * @returns an array containing the root bones
  91098. */
  91099. getChildren(): Array<Bone>;
  91100. /**
  91101. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  91102. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  91103. * @returns a Float32Array containing matrices data
  91104. */
  91105. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  91106. /**
  91107. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  91108. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  91109. * @returns a raw texture containing the data
  91110. */
  91111. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  91112. /**
  91113. * Gets the current hosting scene
  91114. * @returns a scene object
  91115. */
  91116. getScene(): Scene;
  91117. /**
  91118. * Gets a string representing the current skeleton data
  91119. * @param fullDetails defines a boolean indicating if we want a verbose version
  91120. * @returns a string representing the current skeleton data
  91121. */
  91122. toString(fullDetails?: boolean): string;
  91123. /**
  91124. * Get bone's index searching by name
  91125. * @param name defines bone's name to search for
  91126. * @return the indice of the bone. Returns -1 if not found
  91127. */
  91128. getBoneIndexByName(name: string): number;
  91129. /**
  91130. * Creater a new animation range
  91131. * @param name defines the name of the range
  91132. * @param from defines the start key
  91133. * @param to defines the end key
  91134. */
  91135. createAnimationRange(name: string, from: number, to: number): void;
  91136. /**
  91137. * Delete a specific animation range
  91138. * @param name defines the name of the range
  91139. * @param deleteFrames defines if frames must be removed as well
  91140. */
  91141. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  91142. /**
  91143. * Gets a specific animation range
  91144. * @param name defines the name of the range to look for
  91145. * @returns the requested animation range or null if not found
  91146. */
  91147. getAnimationRange(name: string): Nullable<AnimationRange>;
  91148. /**
  91149. * Gets the list of all animation ranges defined on this skeleton
  91150. * @returns an array
  91151. */
  91152. getAnimationRanges(): Nullable<AnimationRange>[];
  91153. /**
  91154. * Copy animation range from a source skeleton.
  91155. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  91156. * @param source defines the source skeleton
  91157. * @param name defines the name of the range to copy
  91158. * @param rescaleAsRequired defines if rescaling must be applied if required
  91159. * @returns true if operation was successful
  91160. */
  91161. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  91162. /**
  91163. * Forces the skeleton to go to rest pose
  91164. */
  91165. returnToRest(): void;
  91166. private _getHighestAnimationFrame;
  91167. /**
  91168. * Begin a specific animation range
  91169. * @param name defines the name of the range to start
  91170. * @param loop defines if looping must be turned on (false by default)
  91171. * @param speedRatio defines the speed ratio to apply (1 by default)
  91172. * @param onAnimationEnd defines a callback which will be called when animation will end
  91173. * @returns a new animatable
  91174. */
  91175. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  91176. /**
  91177. * Convert the keyframes for a range of animation on a skeleton to be relative to a given reference frame.
  91178. * @param skeleton defines the Skeleton containing the animation range to convert
  91179. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  91180. * @param range defines the name of the AnimationRange belonging to the Skeleton to convert
  91181. * @returns the original skeleton
  91182. */
  91183. static MakeAnimationAdditive(skeleton: Skeleton, referenceFrame: number | undefined, range: string): Nullable<Skeleton>;
  91184. /** @hidden */
  91185. _markAsDirty(): void;
  91186. /** @hidden */
  91187. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  91188. /** @hidden */
  91189. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  91190. private _computeTransformMatrices;
  91191. /**
  91192. * Build all resources required to render a skeleton
  91193. */
  91194. prepare(): void;
  91195. /**
  91196. * Gets the list of animatables currently running for this skeleton
  91197. * @returns an array of animatables
  91198. */
  91199. getAnimatables(): IAnimatable[];
  91200. /**
  91201. * Clone the current skeleton
  91202. * @param name defines the name of the new skeleton
  91203. * @param id defines the id of the new skeleton
  91204. * @returns the new skeleton
  91205. */
  91206. clone(name: string, id?: string): Skeleton;
  91207. /**
  91208. * Enable animation blending for this skeleton
  91209. * @param blendingSpeed defines the blending speed to apply
  91210. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  91211. */
  91212. enableBlending(blendingSpeed?: number): void;
  91213. /**
  91214. * Releases all resources associated with the current skeleton
  91215. */
  91216. dispose(): void;
  91217. /**
  91218. * Serialize the skeleton in a JSON object
  91219. * @returns a JSON object
  91220. */
  91221. serialize(): any;
  91222. /**
  91223. * Creates a new skeleton from serialized data
  91224. * @param parsedSkeleton defines the serialized data
  91225. * @param scene defines the hosting scene
  91226. * @returns a new skeleton
  91227. */
  91228. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  91229. /**
  91230. * Compute all node absolute transforms
  91231. * @param forceUpdate defines if computation must be done even if cache is up to date
  91232. */
  91233. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  91234. /**
  91235. * Gets the root pose matrix
  91236. * @returns a matrix
  91237. */
  91238. getPoseMatrix(): Nullable<Matrix>;
  91239. /**
  91240. * Sorts bones per internal index
  91241. */
  91242. sortBones(): void;
  91243. private _sortBones;
  91244. }
  91245. }
  91246. declare module BABYLON {
  91247. /**
  91248. * Creates an instance based on a source mesh.
  91249. */
  91250. export class InstancedMesh extends AbstractMesh {
  91251. private _sourceMesh;
  91252. private _currentLOD;
  91253. /** @hidden */
  91254. _indexInSourceMeshInstanceArray: number;
  91255. constructor(name: string, source: Mesh);
  91256. /**
  91257. * Returns the string "InstancedMesh".
  91258. */
  91259. getClassName(): string;
  91260. /** Gets the list of lights affecting that mesh */
  91261. get lightSources(): Light[];
  91262. _resyncLightSources(): void;
  91263. _resyncLightSource(light: Light): void;
  91264. _removeLightSource(light: Light, dispose: boolean): void;
  91265. /**
  91266. * If the source mesh receives shadows
  91267. */
  91268. get receiveShadows(): boolean;
  91269. /**
  91270. * The material of the source mesh
  91271. */
  91272. get material(): Nullable<Material>;
  91273. /**
  91274. * Visibility of the source mesh
  91275. */
  91276. get visibility(): number;
  91277. /**
  91278. * Skeleton of the source mesh
  91279. */
  91280. get skeleton(): Nullable<Skeleton>;
  91281. /**
  91282. * Rendering ground id of the source mesh
  91283. */
  91284. get renderingGroupId(): number;
  91285. set renderingGroupId(value: number);
  91286. /**
  91287. * Returns the total number of vertices (integer).
  91288. */
  91289. getTotalVertices(): number;
  91290. /**
  91291. * Returns a positive integer : the total number of indices in this mesh geometry.
  91292. * @returns the numner of indices or zero if the mesh has no geometry.
  91293. */
  91294. getTotalIndices(): number;
  91295. /**
  91296. * The source mesh of the instance
  91297. */
  91298. get sourceMesh(): Mesh;
  91299. /**
  91300. * Is this node ready to be used/rendered
  91301. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  91302. * @return {boolean} is it ready
  91303. */
  91304. isReady(completeCheck?: boolean): boolean;
  91305. /**
  91306. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  91307. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  91308. * @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.
  91309. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  91310. */
  91311. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  91312. /**
  91313. * Sets the vertex data of the mesh geometry for the requested `kind`.
  91314. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  91315. * The `data` are either a numeric array either a Float32Array.
  91316. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  91317. * 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).
  91318. * Note that a new underlying VertexBuffer object is created each call.
  91319. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  91320. *
  91321. * Possible `kind` values :
  91322. * - VertexBuffer.PositionKind
  91323. * - VertexBuffer.UVKind
  91324. * - VertexBuffer.UV2Kind
  91325. * - VertexBuffer.UV3Kind
  91326. * - VertexBuffer.UV4Kind
  91327. * - VertexBuffer.UV5Kind
  91328. * - VertexBuffer.UV6Kind
  91329. * - VertexBuffer.ColorKind
  91330. * - VertexBuffer.MatricesIndicesKind
  91331. * - VertexBuffer.MatricesIndicesExtraKind
  91332. * - VertexBuffer.MatricesWeightsKind
  91333. * - VertexBuffer.MatricesWeightsExtraKind
  91334. *
  91335. * Returns the Mesh.
  91336. */
  91337. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  91338. /**
  91339. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  91340. * If the mesh has no geometry, it is simply returned as it is.
  91341. * The `data` are either a numeric array either a Float32Array.
  91342. * No new underlying VertexBuffer object is created.
  91343. * 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.
  91344. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  91345. *
  91346. * Possible `kind` values :
  91347. * - VertexBuffer.PositionKind
  91348. * - VertexBuffer.UVKind
  91349. * - VertexBuffer.UV2Kind
  91350. * - VertexBuffer.UV3Kind
  91351. * - VertexBuffer.UV4Kind
  91352. * - VertexBuffer.UV5Kind
  91353. * - VertexBuffer.UV6Kind
  91354. * - VertexBuffer.ColorKind
  91355. * - VertexBuffer.MatricesIndicesKind
  91356. * - VertexBuffer.MatricesIndicesExtraKind
  91357. * - VertexBuffer.MatricesWeightsKind
  91358. * - VertexBuffer.MatricesWeightsExtraKind
  91359. *
  91360. * Returns the Mesh.
  91361. */
  91362. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  91363. /**
  91364. * Sets the mesh indices.
  91365. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  91366. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  91367. * This method creates a new index buffer each call.
  91368. * Returns the Mesh.
  91369. */
  91370. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  91371. /**
  91372. * Boolean : True if the mesh owns the requested kind of data.
  91373. */
  91374. isVerticesDataPresent(kind: string): boolean;
  91375. /**
  91376. * Returns an array of indices (IndicesArray).
  91377. */
  91378. getIndices(): Nullable<IndicesArray>;
  91379. get _positions(): Nullable<Vector3[]>;
  91380. /**
  91381. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  91382. * This means the mesh underlying bounding box and sphere are recomputed.
  91383. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  91384. * @returns the current mesh
  91385. */
  91386. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  91387. /** @hidden */
  91388. _preActivate(): InstancedMesh;
  91389. /** @hidden */
  91390. _activate(renderId: number, intermediateRendering: boolean): boolean;
  91391. /** @hidden */
  91392. _postActivate(): void;
  91393. getWorldMatrix(): Matrix;
  91394. get isAnInstance(): boolean;
  91395. /**
  91396. * Returns the current associated LOD AbstractMesh.
  91397. */
  91398. getLOD(camera: Camera): AbstractMesh;
  91399. /** @hidden */
  91400. _preActivateForIntermediateRendering(renderId: number): Mesh;
  91401. /** @hidden */
  91402. _syncSubMeshes(): InstancedMesh;
  91403. /** @hidden */
  91404. _generatePointsArray(): boolean;
  91405. /**
  91406. * Creates a new InstancedMesh from the current mesh.
  91407. * - name (string) : the cloned mesh name
  91408. * - newParent (optional Node) : the optional Node to parent the clone to.
  91409. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  91410. *
  91411. * Returns the clone.
  91412. */
  91413. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  91414. /**
  91415. * Disposes the InstancedMesh.
  91416. * Returns nothing.
  91417. */
  91418. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  91419. }
  91420. interface Mesh {
  91421. /**
  91422. * Register a custom buffer that will be instanced
  91423. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  91424. * @param kind defines the buffer kind
  91425. * @param stride defines the stride in floats
  91426. */
  91427. registerInstancedBuffer(kind: string, stride: number): void;
  91428. /** @hidden */
  91429. _userInstancedBuffersStorage: {
  91430. data: {
  91431. [key: string]: Float32Array;
  91432. };
  91433. sizes: {
  91434. [key: string]: number;
  91435. };
  91436. vertexBuffers: {
  91437. [key: string]: Nullable<VertexBuffer>;
  91438. };
  91439. strides: {
  91440. [key: string]: number;
  91441. };
  91442. };
  91443. }
  91444. interface AbstractMesh {
  91445. /**
  91446. * Object used to store instanced buffers defined by user
  91447. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  91448. */
  91449. instancedBuffers: {
  91450. [key: string]: any;
  91451. };
  91452. }
  91453. }
  91454. declare module BABYLON {
  91455. /**
  91456. * Defines the options associated with the creation of a shader material.
  91457. */
  91458. export interface IShaderMaterialOptions {
  91459. /**
  91460. * Does the material work in alpha blend mode
  91461. */
  91462. needAlphaBlending: boolean;
  91463. /**
  91464. * Does the material work in alpha test mode
  91465. */
  91466. needAlphaTesting: boolean;
  91467. /**
  91468. * The list of attribute names used in the shader
  91469. */
  91470. attributes: string[];
  91471. /**
  91472. * The list of unifrom names used in the shader
  91473. */
  91474. uniforms: string[];
  91475. /**
  91476. * The list of UBO names used in the shader
  91477. */
  91478. uniformBuffers: string[];
  91479. /**
  91480. * The list of sampler names used in the shader
  91481. */
  91482. samplers: string[];
  91483. /**
  91484. * The list of defines used in the shader
  91485. */
  91486. defines: string[];
  91487. }
  91488. /**
  91489. * 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.
  91490. *
  91491. * This returned material effects how the mesh will look based on the code in the shaders.
  91492. *
  91493. * @see http://doc.babylonjs.com/how_to/shader_material
  91494. */
  91495. export class ShaderMaterial extends Material {
  91496. private _shaderPath;
  91497. private _options;
  91498. private _textures;
  91499. private _textureArrays;
  91500. private _floats;
  91501. private _ints;
  91502. private _floatsArrays;
  91503. private _colors3;
  91504. private _colors3Arrays;
  91505. private _colors4;
  91506. private _colors4Arrays;
  91507. private _vectors2;
  91508. private _vectors3;
  91509. private _vectors4;
  91510. private _matrices;
  91511. private _matrixArrays;
  91512. private _matrices3x3;
  91513. private _matrices2x2;
  91514. private _vectors2Arrays;
  91515. private _vectors3Arrays;
  91516. private _vectors4Arrays;
  91517. private _cachedWorldViewMatrix;
  91518. private _cachedWorldViewProjectionMatrix;
  91519. private _renderId;
  91520. private _multiview;
  91521. private _cachedDefines;
  91522. /**
  91523. * Instantiate a new shader material.
  91524. * 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.
  91525. * This returned material effects how the mesh will look based on the code in the shaders.
  91526. * @see http://doc.babylonjs.com/how_to/shader_material
  91527. * @param name Define the name of the material in the scene
  91528. * @param scene Define the scene the material belongs to
  91529. * @param shaderPath Defines the route to the shader code in one of three ways:
  91530. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  91531. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  91532. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  91533. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  91534. * @param options Define the options used to create the shader
  91535. */
  91536. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  91537. /**
  91538. * Gets the shader path used to define the shader code
  91539. * It can be modified to trigger a new compilation
  91540. */
  91541. get shaderPath(): any;
  91542. /**
  91543. * Sets the shader path used to define the shader code
  91544. * It can be modified to trigger a new compilation
  91545. */
  91546. set shaderPath(shaderPath: any);
  91547. /**
  91548. * Gets the options used to compile the shader.
  91549. * They can be modified to trigger a new compilation
  91550. */
  91551. get options(): IShaderMaterialOptions;
  91552. /**
  91553. * Gets the current class name of the material e.g. "ShaderMaterial"
  91554. * Mainly use in serialization.
  91555. * @returns the class name
  91556. */
  91557. getClassName(): string;
  91558. /**
  91559. * Specifies if the material will require alpha blending
  91560. * @returns a boolean specifying if alpha blending is needed
  91561. */
  91562. needAlphaBlending(): boolean;
  91563. /**
  91564. * Specifies if this material should be rendered in alpha test mode
  91565. * @returns a boolean specifying if an alpha test is needed.
  91566. */
  91567. needAlphaTesting(): boolean;
  91568. private _checkUniform;
  91569. /**
  91570. * Set a texture in the shader.
  91571. * @param name Define the name of the uniform samplers as defined in the shader
  91572. * @param texture Define the texture to bind to this sampler
  91573. * @return the material itself allowing "fluent" like uniform updates
  91574. */
  91575. setTexture(name: string, texture: BaseTexture): ShaderMaterial;
  91576. /**
  91577. * Set a texture array in the shader.
  91578. * @param name Define the name of the uniform sampler array as defined in the shader
  91579. * @param textures Define the list of textures to bind to this sampler
  91580. * @return the material itself allowing "fluent" like uniform updates
  91581. */
  91582. setTextureArray(name: string, textures: BaseTexture[]): ShaderMaterial;
  91583. /**
  91584. * Set a float in the shader.
  91585. * @param name Define the name of the uniform as defined in the shader
  91586. * @param value Define the value to give to the uniform
  91587. * @return the material itself allowing "fluent" like uniform updates
  91588. */
  91589. setFloat(name: string, value: number): ShaderMaterial;
  91590. /**
  91591. * Set a int in the shader.
  91592. * @param name Define the name of the uniform as defined in the shader
  91593. * @param value Define the value to give to the uniform
  91594. * @return the material itself allowing "fluent" like uniform updates
  91595. */
  91596. setInt(name: string, value: number): ShaderMaterial;
  91597. /**
  91598. * Set an array of floats in the shader.
  91599. * @param name Define the name of the uniform as defined in the shader
  91600. * @param value Define the value to give to the uniform
  91601. * @return the material itself allowing "fluent" like uniform updates
  91602. */
  91603. setFloats(name: string, value: number[]): ShaderMaterial;
  91604. /**
  91605. * Set a vec3 in the shader from a Color3.
  91606. * @param name Define the name of the uniform as defined in the shader
  91607. * @param value Define the value to give to the uniform
  91608. * @return the material itself allowing "fluent" like uniform updates
  91609. */
  91610. setColor3(name: string, value: Color3): ShaderMaterial;
  91611. /**
  91612. * Set a vec3 array in the shader from a Color3 array.
  91613. * @param name Define the name of the uniform as defined in the shader
  91614. * @param value Define the value to give to the uniform
  91615. * @return the material itself allowing "fluent" like uniform updates
  91616. */
  91617. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  91618. /**
  91619. * Set a vec4 in the shader from a Color4.
  91620. * @param name Define the name of the uniform as defined in the shader
  91621. * @param value Define the value to give to the uniform
  91622. * @return the material itself allowing "fluent" like uniform updates
  91623. */
  91624. setColor4(name: string, value: Color4): ShaderMaterial;
  91625. /**
  91626. * Set a vec4 array in the shader from a Color4 array.
  91627. * @param name Define the name of the uniform as defined in the shader
  91628. * @param value Define the value to give to the uniform
  91629. * @return the material itself allowing "fluent" like uniform updates
  91630. */
  91631. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  91632. /**
  91633. * Set a vec2 in the shader from a Vector2.
  91634. * @param name Define the name of the uniform as defined in the shader
  91635. * @param value Define the value to give to the uniform
  91636. * @return the material itself allowing "fluent" like uniform updates
  91637. */
  91638. setVector2(name: string, value: Vector2): ShaderMaterial;
  91639. /**
  91640. * Set a vec3 in the shader from a Vector3.
  91641. * @param name Define the name of the uniform as defined in the shader
  91642. * @param value Define the value to give to the uniform
  91643. * @return the material itself allowing "fluent" like uniform updates
  91644. */
  91645. setVector3(name: string, value: Vector3): ShaderMaterial;
  91646. /**
  91647. * Set a vec4 in the shader from a Vector4.
  91648. * @param name Define the name of the uniform as defined in the shader
  91649. * @param value Define the value to give to the uniform
  91650. * @return the material itself allowing "fluent" like uniform updates
  91651. */
  91652. setVector4(name: string, value: Vector4): ShaderMaterial;
  91653. /**
  91654. * Set a mat4 in the shader from a Matrix.
  91655. * @param name Define the name of the uniform as defined in the shader
  91656. * @param value Define the value to give to the uniform
  91657. * @return the material itself allowing "fluent" like uniform updates
  91658. */
  91659. setMatrix(name: string, value: Matrix): ShaderMaterial;
  91660. /**
  91661. * Set a float32Array in the shader from a matrix array.
  91662. * @param name Define the name of the uniform as defined in the shader
  91663. * @param value Define the value to give to the uniform
  91664. * @return the material itself allowing "fluent" like uniform updates
  91665. */
  91666. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  91667. /**
  91668. * Set a mat3 in the shader from a Float32Array.
  91669. * @param name Define the name of the uniform as defined in the shader
  91670. * @param value Define the value to give to the uniform
  91671. * @return the material itself allowing "fluent" like uniform updates
  91672. */
  91673. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  91674. /**
  91675. * Set a mat2 in the shader from a Float32Array.
  91676. * @param name Define the name of the uniform as defined in the shader
  91677. * @param value Define the value to give to the uniform
  91678. * @return the material itself allowing "fluent" like uniform updates
  91679. */
  91680. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  91681. /**
  91682. * Set a vec2 array in the shader from a number array.
  91683. * @param name Define the name of the uniform as defined in the shader
  91684. * @param value Define the value to give to the uniform
  91685. * @return the material itself allowing "fluent" like uniform updates
  91686. */
  91687. setArray2(name: string, value: number[]): ShaderMaterial;
  91688. /**
  91689. * Set a vec3 array in the shader from a number array.
  91690. * @param name Define the name of the uniform as defined in the shader
  91691. * @param value Define the value to give to the uniform
  91692. * @return the material itself allowing "fluent" like uniform updates
  91693. */
  91694. setArray3(name: string, value: number[]): ShaderMaterial;
  91695. /**
  91696. * Set a vec4 array in the shader from a number array.
  91697. * @param name Define the name of the uniform as defined in the shader
  91698. * @param value Define the value to give to the uniform
  91699. * @return the material itself allowing "fluent" like uniform updates
  91700. */
  91701. setArray4(name: string, value: number[]): ShaderMaterial;
  91702. private _checkCache;
  91703. /**
  91704. * Specifies that the submesh is ready to be used
  91705. * @param mesh defines the mesh to check
  91706. * @param subMesh defines which submesh to check
  91707. * @param useInstances specifies that instances should be used
  91708. * @returns a boolean indicating that the submesh is ready or not
  91709. */
  91710. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  91711. /**
  91712. * Checks if the material is ready to render the requested mesh
  91713. * @param mesh Define the mesh to render
  91714. * @param useInstances Define whether or not the material is used with instances
  91715. * @returns true if ready, otherwise false
  91716. */
  91717. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  91718. /**
  91719. * Binds the world matrix to the material
  91720. * @param world defines the world transformation matrix
  91721. * @param effectOverride - If provided, use this effect instead of internal effect
  91722. */
  91723. bindOnlyWorldMatrix(world: Matrix, effectOverride?: Nullable<Effect>): void;
  91724. /**
  91725. * Binds the submesh to this material by preparing the effect and shader to draw
  91726. * @param world defines the world transformation matrix
  91727. * @param mesh defines the mesh containing the submesh
  91728. * @param subMesh defines the submesh to bind the material to
  91729. */
  91730. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  91731. /**
  91732. * Binds the material to the mesh
  91733. * @param world defines the world transformation matrix
  91734. * @param mesh defines the mesh to bind the material to
  91735. * @param effectOverride - If provided, use this effect instead of internal effect
  91736. */
  91737. bind(world: Matrix, mesh?: Mesh, effectOverride?: Nullable<Effect>): void;
  91738. protected _afterBind(mesh?: Mesh): void;
  91739. /**
  91740. * Gets the active textures from the material
  91741. * @returns an array of textures
  91742. */
  91743. getActiveTextures(): BaseTexture[];
  91744. /**
  91745. * Specifies if the material uses a texture
  91746. * @param texture defines the texture to check against the material
  91747. * @returns a boolean specifying if the material uses the texture
  91748. */
  91749. hasTexture(texture: BaseTexture): boolean;
  91750. /**
  91751. * Makes a duplicate of the material, and gives it a new name
  91752. * @param name defines the new name for the duplicated material
  91753. * @returns the cloned material
  91754. */
  91755. clone(name: string): ShaderMaterial;
  91756. /**
  91757. * Disposes the material
  91758. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  91759. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  91760. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  91761. */
  91762. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  91763. /**
  91764. * Serializes this material in a JSON representation
  91765. * @returns the serialized material object
  91766. */
  91767. serialize(): any;
  91768. /**
  91769. * Creates a shader material from parsed shader material data
  91770. * @param source defines the JSON represnetation of the material
  91771. * @param scene defines the hosting scene
  91772. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  91773. * @returns a new material
  91774. */
  91775. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  91776. }
  91777. }
  91778. declare module BABYLON {
  91779. /** @hidden */
  91780. export var colorPixelShader: {
  91781. name: string;
  91782. shader: string;
  91783. };
  91784. }
  91785. declare module BABYLON {
  91786. /** @hidden */
  91787. export var colorVertexShader: {
  91788. name: string;
  91789. shader: string;
  91790. };
  91791. }
  91792. declare module BABYLON {
  91793. /**
  91794. * Line mesh
  91795. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  91796. */
  91797. export class LinesMesh extends Mesh {
  91798. /**
  91799. * If vertex color should be applied to the mesh
  91800. */
  91801. readonly useVertexColor?: boolean | undefined;
  91802. /**
  91803. * If vertex alpha should be applied to the mesh
  91804. */
  91805. readonly useVertexAlpha?: boolean | undefined;
  91806. /**
  91807. * Color of the line (Default: White)
  91808. */
  91809. color: Color3;
  91810. /**
  91811. * Alpha of the line (Default: 1)
  91812. */
  91813. alpha: number;
  91814. /**
  91815. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  91816. * This margin is expressed in world space coordinates, so its value may vary.
  91817. * Default value is 0.1
  91818. */
  91819. intersectionThreshold: number;
  91820. private _colorShader;
  91821. private color4;
  91822. /**
  91823. * Creates a new LinesMesh
  91824. * @param name defines the name
  91825. * @param scene defines the hosting scene
  91826. * @param parent defines the parent mesh if any
  91827. * @param source defines the optional source LinesMesh used to clone data from
  91828. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  91829. * When false, achieved by calling a clone(), also passing False.
  91830. * This will make creation of children, recursive.
  91831. * @param useVertexColor defines if this LinesMesh supports vertex color
  91832. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  91833. */
  91834. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  91835. /**
  91836. * If vertex color should be applied to the mesh
  91837. */
  91838. useVertexColor?: boolean | undefined,
  91839. /**
  91840. * If vertex alpha should be applied to the mesh
  91841. */
  91842. useVertexAlpha?: boolean | undefined);
  91843. private _addClipPlaneDefine;
  91844. private _removeClipPlaneDefine;
  91845. isReady(): boolean;
  91846. /**
  91847. * Returns the string "LineMesh"
  91848. */
  91849. getClassName(): string;
  91850. /**
  91851. * @hidden
  91852. */
  91853. get material(): Material;
  91854. /**
  91855. * @hidden
  91856. */
  91857. set material(value: Material);
  91858. /**
  91859. * @hidden
  91860. */
  91861. get checkCollisions(): boolean;
  91862. /** @hidden */
  91863. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  91864. /** @hidden */
  91865. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  91866. /**
  91867. * Disposes of the line mesh
  91868. * @param doNotRecurse If children should be disposed
  91869. */
  91870. dispose(doNotRecurse?: boolean): void;
  91871. /**
  91872. * Returns a new LineMesh object cloned from the current one.
  91873. */
  91874. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  91875. /**
  91876. * Creates a new InstancedLinesMesh object from the mesh model.
  91877. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  91878. * @param name defines the name of the new instance
  91879. * @returns a new InstancedLinesMesh
  91880. */
  91881. createInstance(name: string): InstancedLinesMesh;
  91882. }
  91883. /**
  91884. * Creates an instance based on a source LinesMesh
  91885. */
  91886. export class InstancedLinesMesh extends InstancedMesh {
  91887. /**
  91888. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  91889. * This margin is expressed in world space coordinates, so its value may vary.
  91890. * Initilized with the intersectionThreshold value of the source LinesMesh
  91891. */
  91892. intersectionThreshold: number;
  91893. constructor(name: string, source: LinesMesh);
  91894. /**
  91895. * Returns the string "InstancedLinesMesh".
  91896. */
  91897. getClassName(): string;
  91898. }
  91899. }
  91900. declare module BABYLON {
  91901. /** @hidden */
  91902. export var linePixelShader: {
  91903. name: string;
  91904. shader: string;
  91905. };
  91906. }
  91907. declare module BABYLON {
  91908. /** @hidden */
  91909. export var lineVertexShader: {
  91910. name: string;
  91911. shader: string;
  91912. };
  91913. }
  91914. declare module BABYLON {
  91915. interface AbstractMesh {
  91916. /**
  91917. * Gets the edgesRenderer associated with the mesh
  91918. */
  91919. edgesRenderer: Nullable<EdgesRenderer>;
  91920. }
  91921. interface LinesMesh {
  91922. /**
  91923. * Enables the edge rendering mode on the mesh.
  91924. * This mode makes the mesh edges visible
  91925. * @param epsilon defines the maximal distance between two angles to detect a face
  91926. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  91927. * @returns the currentAbstractMesh
  91928. * @see https://www.babylonjs-playground.com/#19O9TU#0
  91929. */
  91930. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  91931. }
  91932. interface InstancedLinesMesh {
  91933. /**
  91934. * Enables the edge rendering mode on the mesh.
  91935. * This mode makes the mesh edges visible
  91936. * @param epsilon defines the maximal distance between two angles to detect a face
  91937. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  91938. * @returns the current InstancedLinesMesh
  91939. * @see https://www.babylonjs-playground.com/#19O9TU#0
  91940. */
  91941. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  91942. }
  91943. /**
  91944. * Defines the minimum contract an Edges renderer should follow.
  91945. */
  91946. export interface IEdgesRenderer extends IDisposable {
  91947. /**
  91948. * Gets or sets a boolean indicating if the edgesRenderer is active
  91949. */
  91950. isEnabled: boolean;
  91951. /**
  91952. * Renders the edges of the attached mesh,
  91953. */
  91954. render(): void;
  91955. /**
  91956. * Checks wether or not the edges renderer is ready to render.
  91957. * @return true if ready, otherwise false.
  91958. */
  91959. isReady(): boolean;
  91960. }
  91961. /**
  91962. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  91963. */
  91964. export class EdgesRenderer implements IEdgesRenderer {
  91965. /**
  91966. * Define the size of the edges with an orthographic camera
  91967. */
  91968. edgesWidthScalerForOrthographic: number;
  91969. /**
  91970. * Define the size of the edges with a perspective camera
  91971. */
  91972. edgesWidthScalerForPerspective: number;
  91973. protected _source: AbstractMesh;
  91974. protected _linesPositions: number[];
  91975. protected _linesNormals: number[];
  91976. protected _linesIndices: number[];
  91977. protected _epsilon: number;
  91978. protected _indicesCount: number;
  91979. protected _lineShader: ShaderMaterial;
  91980. protected _ib: DataBuffer;
  91981. protected _buffers: {
  91982. [key: string]: Nullable<VertexBuffer>;
  91983. };
  91984. protected _checkVerticesInsteadOfIndices: boolean;
  91985. private _meshRebuildObserver;
  91986. private _meshDisposeObserver;
  91987. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  91988. isEnabled: boolean;
  91989. /**
  91990. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  91991. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  91992. * @param source Mesh used to create edges
  91993. * @param epsilon sum of angles in adjacency to check for edge
  91994. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  91995. * @param generateEdgesLines - should generate Lines or only prepare resources.
  91996. */
  91997. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  91998. protected _prepareRessources(): void;
  91999. /** @hidden */
  92000. _rebuild(): void;
  92001. /**
  92002. * Releases the required resources for the edges renderer
  92003. */
  92004. dispose(): void;
  92005. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  92006. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  92007. /**
  92008. * Checks if the pair of p0 and p1 is en edge
  92009. * @param faceIndex
  92010. * @param edge
  92011. * @param faceNormals
  92012. * @param p0
  92013. * @param p1
  92014. * @private
  92015. */
  92016. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  92017. /**
  92018. * push line into the position, normal and index buffer
  92019. * @protected
  92020. */
  92021. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  92022. /**
  92023. * Generates lines edges from adjacencjes
  92024. * @private
  92025. */
  92026. _generateEdgesLines(): void;
  92027. /**
  92028. * Checks wether or not the edges renderer is ready to render.
  92029. * @return true if ready, otherwise false.
  92030. */
  92031. isReady(): boolean;
  92032. /**
  92033. * Renders the edges of the attached mesh,
  92034. */
  92035. render(): void;
  92036. }
  92037. /**
  92038. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  92039. */
  92040. export class LineEdgesRenderer extends EdgesRenderer {
  92041. /**
  92042. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  92043. * @param source LineMesh used to generate edges
  92044. * @param epsilon not important (specified angle for edge detection)
  92045. * @param checkVerticesInsteadOfIndices not important for LineMesh
  92046. */
  92047. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  92048. /**
  92049. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  92050. */
  92051. _generateEdgesLines(): void;
  92052. }
  92053. }
  92054. declare module BABYLON {
  92055. /**
  92056. * This represents the object necessary to create a rendering group.
  92057. * This is exclusively used and created by the rendering manager.
  92058. * To modify the behavior, you use the available helpers in your scene or meshes.
  92059. * @hidden
  92060. */
  92061. export class RenderingGroup {
  92062. index: number;
  92063. private static _zeroVector;
  92064. private _scene;
  92065. private _opaqueSubMeshes;
  92066. private _transparentSubMeshes;
  92067. private _alphaTestSubMeshes;
  92068. private _depthOnlySubMeshes;
  92069. private _particleSystems;
  92070. private _spriteManagers;
  92071. private _opaqueSortCompareFn;
  92072. private _alphaTestSortCompareFn;
  92073. private _transparentSortCompareFn;
  92074. private _renderOpaque;
  92075. private _renderAlphaTest;
  92076. private _renderTransparent;
  92077. /** @hidden */
  92078. _edgesRenderers: SmartArray<IEdgesRenderer>;
  92079. onBeforeTransparentRendering: () => void;
  92080. /**
  92081. * Set the opaque sort comparison function.
  92082. * If null the sub meshes will be render in the order they were created
  92083. */
  92084. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  92085. /**
  92086. * Set the alpha test sort comparison function.
  92087. * If null the sub meshes will be render in the order they were created
  92088. */
  92089. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  92090. /**
  92091. * Set the transparent sort comparison function.
  92092. * If null the sub meshes will be render in the order they were created
  92093. */
  92094. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  92095. /**
  92096. * Creates a new rendering group.
  92097. * @param index The rendering group index
  92098. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  92099. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  92100. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  92101. */
  92102. 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>);
  92103. /**
  92104. * Render all the sub meshes contained in the group.
  92105. * @param customRenderFunction Used to override the default render behaviour of the group.
  92106. * @returns true if rendered some submeshes.
  92107. */
  92108. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  92109. /**
  92110. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  92111. * @param subMeshes The submeshes to render
  92112. */
  92113. private renderOpaqueSorted;
  92114. /**
  92115. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  92116. * @param subMeshes The submeshes to render
  92117. */
  92118. private renderAlphaTestSorted;
  92119. /**
  92120. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  92121. * @param subMeshes The submeshes to render
  92122. */
  92123. private renderTransparentSorted;
  92124. /**
  92125. * Renders the submeshes in a specified order.
  92126. * @param subMeshes The submeshes to sort before render
  92127. * @param sortCompareFn The comparison function use to sort
  92128. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  92129. * @param transparent Specifies to activate blending if true
  92130. */
  92131. private static renderSorted;
  92132. /**
  92133. * Renders the submeshes in the order they were dispatched (no sort applied).
  92134. * @param subMeshes The submeshes to render
  92135. */
  92136. private static renderUnsorted;
  92137. /**
  92138. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  92139. * are rendered back to front if in the same alpha index.
  92140. *
  92141. * @param a The first submesh
  92142. * @param b The second submesh
  92143. * @returns The result of the comparison
  92144. */
  92145. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  92146. /**
  92147. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  92148. * are rendered back to front.
  92149. *
  92150. * @param a The first submesh
  92151. * @param b The second submesh
  92152. * @returns The result of the comparison
  92153. */
  92154. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  92155. /**
  92156. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  92157. * are rendered front to back (prevent overdraw).
  92158. *
  92159. * @param a The first submesh
  92160. * @param b The second submesh
  92161. * @returns The result of the comparison
  92162. */
  92163. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  92164. /**
  92165. * Resets the different lists of submeshes to prepare a new frame.
  92166. */
  92167. prepare(): void;
  92168. dispose(): void;
  92169. /**
  92170. * Inserts the submesh in its correct queue depending on its material.
  92171. * @param subMesh The submesh to dispatch
  92172. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  92173. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  92174. */
  92175. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  92176. dispatchSprites(spriteManager: ISpriteManager): void;
  92177. dispatchParticles(particleSystem: IParticleSystem): void;
  92178. private _renderParticles;
  92179. private _renderSprites;
  92180. }
  92181. }
  92182. declare module BABYLON {
  92183. /**
  92184. * Interface describing the different options available in the rendering manager
  92185. * regarding Auto Clear between groups.
  92186. */
  92187. export interface IRenderingManagerAutoClearSetup {
  92188. /**
  92189. * Defines whether or not autoclear is enable.
  92190. */
  92191. autoClear: boolean;
  92192. /**
  92193. * Defines whether or not to autoclear the depth buffer.
  92194. */
  92195. depth: boolean;
  92196. /**
  92197. * Defines whether or not to autoclear the stencil buffer.
  92198. */
  92199. stencil: boolean;
  92200. }
  92201. /**
  92202. * This class is used by the onRenderingGroupObservable
  92203. */
  92204. export class RenderingGroupInfo {
  92205. /**
  92206. * The Scene that being rendered
  92207. */
  92208. scene: Scene;
  92209. /**
  92210. * The camera currently used for the rendering pass
  92211. */
  92212. camera: Nullable<Camera>;
  92213. /**
  92214. * The ID of the renderingGroup being processed
  92215. */
  92216. renderingGroupId: number;
  92217. }
  92218. /**
  92219. * This is the manager responsible of all the rendering for meshes sprites and particles.
  92220. * It is enable to manage the different groups as well as the different necessary sort functions.
  92221. * This should not be used directly aside of the few static configurations
  92222. */
  92223. export class RenderingManager {
  92224. /**
  92225. * The max id used for rendering groups (not included)
  92226. */
  92227. static MAX_RENDERINGGROUPS: number;
  92228. /**
  92229. * The min id used for rendering groups (included)
  92230. */
  92231. static MIN_RENDERINGGROUPS: number;
  92232. /**
  92233. * Used to globally prevent autoclearing scenes.
  92234. */
  92235. static AUTOCLEAR: boolean;
  92236. /**
  92237. * @hidden
  92238. */
  92239. _useSceneAutoClearSetup: boolean;
  92240. private _scene;
  92241. private _renderingGroups;
  92242. private _depthStencilBufferAlreadyCleaned;
  92243. private _autoClearDepthStencil;
  92244. private _customOpaqueSortCompareFn;
  92245. private _customAlphaTestSortCompareFn;
  92246. private _customTransparentSortCompareFn;
  92247. private _renderingGroupInfo;
  92248. /**
  92249. * Instantiates a new rendering group for a particular scene
  92250. * @param scene Defines the scene the groups belongs to
  92251. */
  92252. constructor(scene: Scene);
  92253. private _clearDepthStencilBuffer;
  92254. /**
  92255. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  92256. * @hidden
  92257. */
  92258. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  92259. /**
  92260. * Resets the different information of the group to prepare a new frame
  92261. * @hidden
  92262. */
  92263. reset(): void;
  92264. /**
  92265. * Dispose and release the group and its associated resources.
  92266. * @hidden
  92267. */
  92268. dispose(): void;
  92269. /**
  92270. * Clear the info related to rendering groups preventing retention points during dispose.
  92271. */
  92272. freeRenderingGroups(): void;
  92273. private _prepareRenderingGroup;
  92274. /**
  92275. * Add a sprite manager to the rendering manager in order to render it this frame.
  92276. * @param spriteManager Define the sprite manager to render
  92277. */
  92278. dispatchSprites(spriteManager: ISpriteManager): void;
  92279. /**
  92280. * Add a particle system to the rendering manager in order to render it this frame.
  92281. * @param particleSystem Define the particle system to render
  92282. */
  92283. dispatchParticles(particleSystem: IParticleSystem): void;
  92284. /**
  92285. * Add a submesh to the manager in order to render it this frame
  92286. * @param subMesh The submesh to dispatch
  92287. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  92288. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  92289. */
  92290. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  92291. /**
  92292. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  92293. * This allowed control for front to back rendering or reversly depending of the special needs.
  92294. *
  92295. * @param renderingGroupId The rendering group id corresponding to its index
  92296. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  92297. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  92298. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  92299. */
  92300. 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;
  92301. /**
  92302. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  92303. *
  92304. * @param renderingGroupId The rendering group id corresponding to its index
  92305. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  92306. * @param depth Automatically clears depth between groups if true and autoClear is true.
  92307. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  92308. */
  92309. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  92310. /**
  92311. * Gets the current auto clear configuration for one rendering group of the rendering
  92312. * manager.
  92313. * @param index the rendering group index to get the information for
  92314. * @returns The auto clear setup for the requested rendering group
  92315. */
  92316. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  92317. }
  92318. }
  92319. declare module BABYLON {
  92320. /**
  92321. * Defines the options associated with the creation of a custom shader for a shadow generator.
  92322. */
  92323. export interface ICustomShaderOptions {
  92324. /**
  92325. * Gets or sets the custom shader name to use
  92326. */
  92327. shaderName: string;
  92328. /**
  92329. * The list of attribute names used in the shader
  92330. */
  92331. attributes?: string[];
  92332. /**
  92333. * The list of unifrom names used in the shader
  92334. */
  92335. uniforms?: string[];
  92336. /**
  92337. * The list of sampler names used in the shader
  92338. */
  92339. samplers?: string[];
  92340. /**
  92341. * The list of defines used in the shader
  92342. */
  92343. defines?: string[];
  92344. }
  92345. /**
  92346. * Interface to implement to create a shadow generator compatible with BJS.
  92347. */
  92348. export interface IShadowGenerator {
  92349. /**
  92350. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  92351. * @returns The render target texture if present otherwise, null
  92352. */
  92353. getShadowMap(): Nullable<RenderTargetTexture>;
  92354. /**
  92355. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  92356. * @param subMesh The submesh we want to render in the shadow map
  92357. * @param useInstances Defines wether will draw in the map using instances
  92358. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  92359. * @returns true if ready otherwise, false
  92360. */
  92361. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  92362. /**
  92363. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  92364. * @param defines Defines of the material we want to update
  92365. * @param lightIndex Index of the light in the enabled light list of the material
  92366. */
  92367. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  92368. /**
  92369. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  92370. * defined in the generator but impacting the effect).
  92371. * It implies the unifroms available on the materials are the standard BJS ones.
  92372. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  92373. * @param effect The effect we are binfing the information for
  92374. */
  92375. bindShadowLight(lightIndex: string, effect: Effect): void;
  92376. /**
  92377. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  92378. * (eq to shadow prjection matrix * light transform matrix)
  92379. * @returns The transform matrix used to create the shadow map
  92380. */
  92381. getTransformMatrix(): Matrix;
  92382. /**
  92383. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  92384. * Cube and 2D textures for instance.
  92385. */
  92386. recreateShadowMap(): void;
  92387. /**
  92388. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  92389. * @param onCompiled Callback triggered at the and of the effects compilation
  92390. * @param options Sets of optional options forcing the compilation with different modes
  92391. */
  92392. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  92393. useInstances: boolean;
  92394. }>): void;
  92395. /**
  92396. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  92397. * @param options Sets of optional options forcing the compilation with different modes
  92398. * @returns A promise that resolves when the compilation completes
  92399. */
  92400. forceCompilationAsync(options?: Partial<{
  92401. useInstances: boolean;
  92402. }>): Promise<void>;
  92403. /**
  92404. * Serializes the shadow generator setup to a json object.
  92405. * @returns The serialized JSON object
  92406. */
  92407. serialize(): any;
  92408. /**
  92409. * Disposes the Shadow map and related Textures and effects.
  92410. */
  92411. dispose(): void;
  92412. }
  92413. /**
  92414. * Default implementation IShadowGenerator.
  92415. * This is the main object responsible of generating shadows in the framework.
  92416. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  92417. */
  92418. export class ShadowGenerator implements IShadowGenerator {
  92419. /**
  92420. * Name of the shadow generator class
  92421. */
  92422. static CLASSNAME: string;
  92423. /**
  92424. * Shadow generator mode None: no filtering applied.
  92425. */
  92426. static readonly FILTER_NONE: number;
  92427. /**
  92428. * Shadow generator mode ESM: Exponential Shadow Mapping.
  92429. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  92430. */
  92431. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  92432. /**
  92433. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  92434. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  92435. */
  92436. static readonly FILTER_POISSONSAMPLING: number;
  92437. /**
  92438. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  92439. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  92440. */
  92441. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  92442. /**
  92443. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  92444. * edge artifacts on steep falloff.
  92445. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  92446. */
  92447. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  92448. /**
  92449. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  92450. * edge artifacts on steep falloff.
  92451. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  92452. */
  92453. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  92454. /**
  92455. * Shadow generator mode PCF: Percentage Closer Filtering
  92456. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  92457. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  92458. */
  92459. static readonly FILTER_PCF: number;
  92460. /**
  92461. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  92462. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  92463. * Contact Hardening
  92464. */
  92465. static readonly FILTER_PCSS: number;
  92466. /**
  92467. * Reserved for PCF and PCSS
  92468. * Highest Quality.
  92469. *
  92470. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  92471. *
  92472. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  92473. */
  92474. static readonly QUALITY_HIGH: number;
  92475. /**
  92476. * Reserved for PCF and PCSS
  92477. * Good tradeoff for quality/perf cross devices
  92478. *
  92479. * Execute PCF on a 3*3 kernel.
  92480. *
  92481. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  92482. */
  92483. static readonly QUALITY_MEDIUM: number;
  92484. /**
  92485. * Reserved for PCF and PCSS
  92486. * The lowest quality but the fastest.
  92487. *
  92488. * Execute PCF on a 1*1 kernel.
  92489. *
  92490. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  92491. */
  92492. static readonly QUALITY_LOW: number;
  92493. /** Gets or sets the custom shader name to use */
  92494. customShaderOptions: ICustomShaderOptions;
  92495. /**
  92496. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  92497. */
  92498. onBeforeShadowMapRenderObservable: Observable<Effect>;
  92499. /**
  92500. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  92501. */
  92502. onAfterShadowMapRenderObservable: Observable<Effect>;
  92503. /**
  92504. * Observable triggered before a mesh is rendered in the shadow map.
  92505. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  92506. */
  92507. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  92508. /**
  92509. * Observable triggered after a mesh is rendered in the shadow map.
  92510. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  92511. */
  92512. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  92513. protected _bias: number;
  92514. /**
  92515. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  92516. */
  92517. get bias(): number;
  92518. /**
  92519. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  92520. */
  92521. set bias(bias: number);
  92522. protected _normalBias: number;
  92523. /**
  92524. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  92525. */
  92526. get normalBias(): number;
  92527. /**
  92528. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  92529. */
  92530. set normalBias(normalBias: number);
  92531. protected _blurBoxOffset: number;
  92532. /**
  92533. * Gets the blur box offset: offset applied during the blur pass.
  92534. * Only useful if useKernelBlur = false
  92535. */
  92536. get blurBoxOffset(): number;
  92537. /**
  92538. * Sets the blur box offset: offset applied during the blur pass.
  92539. * Only useful if useKernelBlur = false
  92540. */
  92541. set blurBoxOffset(value: number);
  92542. protected _blurScale: number;
  92543. /**
  92544. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  92545. * 2 means half of the size.
  92546. */
  92547. get blurScale(): number;
  92548. /**
  92549. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  92550. * 2 means half of the size.
  92551. */
  92552. set blurScale(value: number);
  92553. protected _blurKernel: number;
  92554. /**
  92555. * Gets the blur kernel: kernel size of the blur pass.
  92556. * Only useful if useKernelBlur = true
  92557. */
  92558. get blurKernel(): number;
  92559. /**
  92560. * Sets the blur kernel: kernel size of the blur pass.
  92561. * Only useful if useKernelBlur = true
  92562. */
  92563. set blurKernel(value: number);
  92564. protected _useKernelBlur: boolean;
  92565. /**
  92566. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  92567. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  92568. */
  92569. get useKernelBlur(): boolean;
  92570. /**
  92571. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  92572. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  92573. */
  92574. set useKernelBlur(value: boolean);
  92575. protected _depthScale: number;
  92576. /**
  92577. * Gets the depth scale used in ESM mode.
  92578. */
  92579. get depthScale(): number;
  92580. /**
  92581. * Sets the depth scale used in ESM mode.
  92582. * This can override the scale stored on the light.
  92583. */
  92584. set depthScale(value: number);
  92585. protected _validateFilter(filter: number): number;
  92586. protected _filter: number;
  92587. /**
  92588. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  92589. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  92590. */
  92591. get filter(): number;
  92592. /**
  92593. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  92594. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  92595. */
  92596. set filter(value: number);
  92597. /**
  92598. * Gets if the current filter is set to Poisson Sampling.
  92599. */
  92600. get usePoissonSampling(): boolean;
  92601. /**
  92602. * Sets the current filter to Poisson Sampling.
  92603. */
  92604. set usePoissonSampling(value: boolean);
  92605. /**
  92606. * Gets if the current filter is set to ESM.
  92607. */
  92608. get useExponentialShadowMap(): boolean;
  92609. /**
  92610. * Sets the current filter is to ESM.
  92611. */
  92612. set useExponentialShadowMap(value: boolean);
  92613. /**
  92614. * Gets if the current filter is set to filtered ESM.
  92615. */
  92616. get useBlurExponentialShadowMap(): boolean;
  92617. /**
  92618. * Gets if the current filter is set to filtered ESM.
  92619. */
  92620. set useBlurExponentialShadowMap(value: boolean);
  92621. /**
  92622. * Gets if the current filter is set to "close ESM" (using the inverse of the
  92623. * exponential to prevent steep falloff artifacts).
  92624. */
  92625. get useCloseExponentialShadowMap(): boolean;
  92626. /**
  92627. * Sets the current filter to "close ESM" (using the inverse of the
  92628. * exponential to prevent steep falloff artifacts).
  92629. */
  92630. set useCloseExponentialShadowMap(value: boolean);
  92631. /**
  92632. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  92633. * exponential to prevent steep falloff artifacts).
  92634. */
  92635. get useBlurCloseExponentialShadowMap(): boolean;
  92636. /**
  92637. * Sets the current filter to filtered "close ESM" (using the inverse of the
  92638. * exponential to prevent steep falloff artifacts).
  92639. */
  92640. set useBlurCloseExponentialShadowMap(value: boolean);
  92641. /**
  92642. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  92643. */
  92644. get usePercentageCloserFiltering(): boolean;
  92645. /**
  92646. * Sets the current filter to "PCF" (percentage closer filtering).
  92647. */
  92648. set usePercentageCloserFiltering(value: boolean);
  92649. protected _filteringQuality: number;
  92650. /**
  92651. * Gets the PCF or PCSS Quality.
  92652. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  92653. */
  92654. get filteringQuality(): number;
  92655. /**
  92656. * Sets the PCF or PCSS Quality.
  92657. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  92658. */
  92659. set filteringQuality(filteringQuality: number);
  92660. /**
  92661. * Gets if the current filter is set to "PCSS" (contact hardening).
  92662. */
  92663. get useContactHardeningShadow(): boolean;
  92664. /**
  92665. * Sets the current filter to "PCSS" (contact hardening).
  92666. */
  92667. set useContactHardeningShadow(value: boolean);
  92668. protected _contactHardeningLightSizeUVRatio: number;
  92669. /**
  92670. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  92671. * Using a ratio helps keeping shape stability independently of the map size.
  92672. *
  92673. * It does not account for the light projection as it was having too much
  92674. * instability during the light setup or during light position changes.
  92675. *
  92676. * Only valid if useContactHardeningShadow is true.
  92677. */
  92678. get contactHardeningLightSizeUVRatio(): number;
  92679. /**
  92680. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  92681. * Using a ratio helps keeping shape stability independently of the map size.
  92682. *
  92683. * It does not account for the light projection as it was having too much
  92684. * instability during the light setup or during light position changes.
  92685. *
  92686. * Only valid if useContactHardeningShadow is true.
  92687. */
  92688. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  92689. protected _darkness: number;
  92690. /** Gets or sets the actual darkness of a shadow */
  92691. get darkness(): number;
  92692. set darkness(value: number);
  92693. /**
  92694. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  92695. * 0 means strongest and 1 would means no shadow.
  92696. * @returns the darkness.
  92697. */
  92698. getDarkness(): number;
  92699. /**
  92700. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  92701. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  92702. * @returns the shadow generator allowing fluent coding.
  92703. */
  92704. setDarkness(darkness: number): ShadowGenerator;
  92705. protected _transparencyShadow: boolean;
  92706. /** Gets or sets the ability to have transparent shadow */
  92707. get transparencyShadow(): boolean;
  92708. set transparencyShadow(value: boolean);
  92709. /**
  92710. * Sets the ability to have transparent shadow (boolean).
  92711. * @param transparent True if transparent else False
  92712. * @returns the shadow generator allowing fluent coding
  92713. */
  92714. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  92715. /**
  92716. * Enables or disables shadows with varying strength based on the transparency
  92717. * When it is enabled, the strength of the shadow is taken equal to mesh.visibility
  92718. * If you enabled an alpha texture on your material, the alpha value red from the texture is also combined to compute the strength:
  92719. * mesh.visibility * alphaTexture.a
  92720. * Note that by definition transparencyShadow must be set to true for enableSoftTransparentShadow to work!
  92721. */
  92722. enableSoftTransparentShadow: boolean;
  92723. protected _shadowMap: Nullable<RenderTargetTexture>;
  92724. protected _shadowMap2: Nullable<RenderTargetTexture>;
  92725. /**
  92726. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  92727. * @returns The render target texture if present otherwise, null
  92728. */
  92729. getShadowMap(): Nullable<RenderTargetTexture>;
  92730. /**
  92731. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  92732. * @returns The render target texture if the shadow map is present otherwise, null
  92733. */
  92734. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  92735. /**
  92736. * Gets the class name of that object
  92737. * @returns "ShadowGenerator"
  92738. */
  92739. getClassName(): string;
  92740. /**
  92741. * Helper function to add a mesh and its descendants to the list of shadow casters.
  92742. * @param mesh Mesh to add
  92743. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  92744. * @returns the Shadow Generator itself
  92745. */
  92746. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  92747. /**
  92748. * Helper function to remove a mesh and its descendants from the list of shadow casters
  92749. * @param mesh Mesh to remove
  92750. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  92751. * @returns the Shadow Generator itself
  92752. */
  92753. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  92754. /**
  92755. * Controls the extent to which the shadows fade out at the edge of the frustum
  92756. */
  92757. frustumEdgeFalloff: number;
  92758. protected _light: IShadowLight;
  92759. /**
  92760. * Returns the associated light object.
  92761. * @returns the light generating the shadow
  92762. */
  92763. getLight(): IShadowLight;
  92764. /**
  92765. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  92766. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  92767. * It might on the other hand introduce peter panning.
  92768. */
  92769. forceBackFacesOnly: boolean;
  92770. protected _scene: Scene;
  92771. protected _lightDirection: Vector3;
  92772. protected _effect: Effect;
  92773. protected _viewMatrix: Matrix;
  92774. protected _projectionMatrix: Matrix;
  92775. protected _transformMatrix: Matrix;
  92776. protected _cachedPosition: Vector3;
  92777. protected _cachedDirection: Vector3;
  92778. protected _cachedDefines: string;
  92779. protected _currentRenderID: number;
  92780. protected _boxBlurPostprocess: Nullable<PostProcess>;
  92781. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  92782. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  92783. protected _blurPostProcesses: PostProcess[];
  92784. protected _mapSize: number;
  92785. protected _currentFaceIndex: number;
  92786. protected _currentFaceIndexCache: number;
  92787. protected _textureType: number;
  92788. protected _defaultTextureMatrix: Matrix;
  92789. protected _storedUniqueId: Nullable<number>;
  92790. /** @hidden */
  92791. static _SceneComponentInitialization: (scene: Scene) => void;
  92792. /**
  92793. * Creates a ShadowGenerator object.
  92794. * A ShadowGenerator is the required tool to use the shadows.
  92795. * Each light casting shadows needs to use its own ShadowGenerator.
  92796. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  92797. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  92798. * @param light The light object generating the shadows.
  92799. * @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.
  92800. */
  92801. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  92802. protected _initializeGenerator(): void;
  92803. protected _createTargetRenderTexture(): void;
  92804. protected _initializeShadowMap(): void;
  92805. protected _initializeBlurRTTAndPostProcesses(): void;
  92806. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  92807. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  92808. protected _renderSubMeshForShadowMap(subMesh: SubMesh, isTransparent?: boolean): void;
  92809. protected _applyFilterValues(): void;
  92810. /**
  92811. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  92812. * @param onCompiled Callback triggered at the and of the effects compilation
  92813. * @param options Sets of optional options forcing the compilation with different modes
  92814. */
  92815. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  92816. useInstances: boolean;
  92817. }>): void;
  92818. /**
  92819. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  92820. * @param options Sets of optional options forcing the compilation with different modes
  92821. * @returns A promise that resolves when the compilation completes
  92822. */
  92823. forceCompilationAsync(options?: Partial<{
  92824. useInstances: boolean;
  92825. }>): Promise<void>;
  92826. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  92827. private _prepareShadowDefines;
  92828. /**
  92829. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  92830. * @param subMesh The submesh we want to render in the shadow map
  92831. * @param useInstances Defines wether will draw in the map using instances
  92832. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  92833. * @returns true if ready otherwise, false
  92834. */
  92835. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  92836. /**
  92837. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  92838. * @param defines Defines of the material we want to update
  92839. * @param lightIndex Index of the light in the enabled light list of the material
  92840. */
  92841. prepareDefines(defines: any, lightIndex: number): void;
  92842. /**
  92843. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  92844. * defined in the generator but impacting the effect).
  92845. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  92846. * @param effect The effect we are binfing the information for
  92847. */
  92848. bindShadowLight(lightIndex: string, effect: Effect): void;
  92849. /**
  92850. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  92851. * (eq to shadow prjection matrix * light transform matrix)
  92852. * @returns The transform matrix used to create the shadow map
  92853. */
  92854. getTransformMatrix(): Matrix;
  92855. /**
  92856. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  92857. * Cube and 2D textures for instance.
  92858. */
  92859. recreateShadowMap(): void;
  92860. protected _disposeBlurPostProcesses(): void;
  92861. protected _disposeRTTandPostProcesses(): void;
  92862. /**
  92863. * Disposes the ShadowGenerator.
  92864. * Returns nothing.
  92865. */
  92866. dispose(): void;
  92867. /**
  92868. * Serializes the shadow generator setup to a json object.
  92869. * @returns The serialized JSON object
  92870. */
  92871. serialize(): any;
  92872. /**
  92873. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  92874. * @param parsedShadowGenerator The JSON object to parse
  92875. * @param scene The scene to create the shadow map for
  92876. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  92877. * @returns The parsed shadow generator
  92878. */
  92879. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  92880. }
  92881. }
  92882. declare module BABYLON {
  92883. /**
  92884. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  92885. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  92886. * 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.
  92887. */
  92888. export abstract class Light extends Node {
  92889. /**
  92890. * Falloff Default: light is falling off following the material specification:
  92891. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  92892. */
  92893. static readonly FALLOFF_DEFAULT: number;
  92894. /**
  92895. * Falloff Physical: light is falling off following the inverse squared distance law.
  92896. */
  92897. static readonly FALLOFF_PHYSICAL: number;
  92898. /**
  92899. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  92900. * to enhance interoperability with other engines.
  92901. */
  92902. static readonly FALLOFF_GLTF: number;
  92903. /**
  92904. * Falloff Standard: light is falling off like in the standard material
  92905. * to enhance interoperability with other materials.
  92906. */
  92907. static readonly FALLOFF_STANDARD: number;
  92908. /**
  92909. * If every light affecting the material is in this lightmapMode,
  92910. * material.lightmapTexture adds or multiplies
  92911. * (depends on material.useLightmapAsShadowmap)
  92912. * after every other light calculations.
  92913. */
  92914. static readonly LIGHTMAP_DEFAULT: number;
  92915. /**
  92916. * material.lightmapTexture as only diffuse lighting from this light
  92917. * adds only specular lighting from this light
  92918. * adds dynamic shadows
  92919. */
  92920. static readonly LIGHTMAP_SPECULAR: number;
  92921. /**
  92922. * material.lightmapTexture as only lighting
  92923. * no light calculation from this light
  92924. * only adds dynamic shadows from this light
  92925. */
  92926. static readonly LIGHTMAP_SHADOWSONLY: number;
  92927. /**
  92928. * Each light type uses the default quantity according to its type:
  92929. * point/spot lights use luminous intensity
  92930. * directional lights use illuminance
  92931. */
  92932. static readonly INTENSITYMODE_AUTOMATIC: number;
  92933. /**
  92934. * lumen (lm)
  92935. */
  92936. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  92937. /**
  92938. * candela (lm/sr)
  92939. */
  92940. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  92941. /**
  92942. * lux (lm/m^2)
  92943. */
  92944. static readonly INTENSITYMODE_ILLUMINANCE: number;
  92945. /**
  92946. * nit (cd/m^2)
  92947. */
  92948. static readonly INTENSITYMODE_LUMINANCE: number;
  92949. /**
  92950. * Light type const id of the point light.
  92951. */
  92952. static readonly LIGHTTYPEID_POINTLIGHT: number;
  92953. /**
  92954. * Light type const id of the directional light.
  92955. */
  92956. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  92957. /**
  92958. * Light type const id of the spot light.
  92959. */
  92960. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  92961. /**
  92962. * Light type const id of the hemispheric light.
  92963. */
  92964. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  92965. /**
  92966. * Diffuse gives the basic color to an object.
  92967. */
  92968. diffuse: Color3;
  92969. /**
  92970. * Specular produces a highlight color on an object.
  92971. * Note: This is note affecting PBR materials.
  92972. */
  92973. specular: Color3;
  92974. /**
  92975. * Defines the falloff type for this light. This lets overrriding how punctual light are
  92976. * falling off base on range or angle.
  92977. * This can be set to any values in Light.FALLOFF_x.
  92978. *
  92979. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  92980. * other types of materials.
  92981. */
  92982. falloffType: number;
  92983. /**
  92984. * Strength of the light.
  92985. * Note: By default it is define in the framework own unit.
  92986. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  92987. */
  92988. intensity: number;
  92989. private _range;
  92990. protected _inverseSquaredRange: number;
  92991. /**
  92992. * Defines how far from the source the light is impacting in scene units.
  92993. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  92994. */
  92995. get range(): number;
  92996. /**
  92997. * Defines how far from the source the light is impacting in scene units.
  92998. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  92999. */
  93000. set range(value: number);
  93001. /**
  93002. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  93003. * of light.
  93004. */
  93005. private _photometricScale;
  93006. private _intensityMode;
  93007. /**
  93008. * Gets the photometric scale used to interpret the intensity.
  93009. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  93010. */
  93011. get intensityMode(): number;
  93012. /**
  93013. * Sets the photometric scale used to interpret the intensity.
  93014. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  93015. */
  93016. set intensityMode(value: number);
  93017. private _radius;
  93018. /**
  93019. * Gets the light radius used by PBR Materials to simulate soft area lights.
  93020. */
  93021. get radius(): number;
  93022. /**
  93023. * sets the light radius used by PBR Materials to simulate soft area lights.
  93024. */
  93025. set radius(value: number);
  93026. private _renderPriority;
  93027. /**
  93028. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  93029. * exceeding the number allowed of the materials.
  93030. */
  93031. renderPriority: number;
  93032. private _shadowEnabled;
  93033. /**
  93034. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  93035. * the current shadow generator.
  93036. */
  93037. get shadowEnabled(): boolean;
  93038. /**
  93039. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  93040. * the current shadow generator.
  93041. */
  93042. set shadowEnabled(value: boolean);
  93043. private _includedOnlyMeshes;
  93044. /**
  93045. * Gets the only meshes impacted by this light.
  93046. */
  93047. get includedOnlyMeshes(): AbstractMesh[];
  93048. /**
  93049. * Sets the only meshes impacted by this light.
  93050. */
  93051. set includedOnlyMeshes(value: AbstractMesh[]);
  93052. private _excludedMeshes;
  93053. /**
  93054. * Gets the meshes not impacted by this light.
  93055. */
  93056. get excludedMeshes(): AbstractMesh[];
  93057. /**
  93058. * Sets the meshes not impacted by this light.
  93059. */
  93060. set excludedMeshes(value: AbstractMesh[]);
  93061. private _excludeWithLayerMask;
  93062. /**
  93063. * Gets the layer id use to find what meshes are not impacted by the light.
  93064. * Inactive if 0
  93065. */
  93066. get excludeWithLayerMask(): number;
  93067. /**
  93068. * Sets the layer id use to find what meshes are not impacted by the light.
  93069. * Inactive if 0
  93070. */
  93071. set excludeWithLayerMask(value: number);
  93072. private _includeOnlyWithLayerMask;
  93073. /**
  93074. * Gets the layer id use to find what meshes are impacted by the light.
  93075. * Inactive if 0
  93076. */
  93077. get includeOnlyWithLayerMask(): number;
  93078. /**
  93079. * Sets the layer id use to find what meshes are impacted by the light.
  93080. * Inactive if 0
  93081. */
  93082. set includeOnlyWithLayerMask(value: number);
  93083. private _lightmapMode;
  93084. /**
  93085. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  93086. */
  93087. get lightmapMode(): number;
  93088. /**
  93089. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  93090. */
  93091. set lightmapMode(value: number);
  93092. /**
  93093. * Shadow generator associted to the light.
  93094. * @hidden Internal use only.
  93095. */
  93096. _shadowGenerator: Nullable<IShadowGenerator>;
  93097. /**
  93098. * @hidden Internal use only.
  93099. */
  93100. _excludedMeshesIds: string[];
  93101. /**
  93102. * @hidden Internal use only.
  93103. */
  93104. _includedOnlyMeshesIds: string[];
  93105. /**
  93106. * The current light unifom buffer.
  93107. * @hidden Internal use only.
  93108. */
  93109. _uniformBuffer: UniformBuffer;
  93110. /** @hidden */
  93111. _renderId: number;
  93112. /**
  93113. * Creates a Light object in the scene.
  93114. * Documentation : https://doc.babylonjs.com/babylon101/lights
  93115. * @param name The firendly name of the light
  93116. * @param scene The scene the light belongs too
  93117. */
  93118. constructor(name: string, scene: Scene);
  93119. protected abstract _buildUniformLayout(): void;
  93120. /**
  93121. * Sets the passed Effect "effect" with the Light information.
  93122. * @param effect The effect to update
  93123. * @param lightIndex The index of the light in the effect to update
  93124. * @returns The light
  93125. */
  93126. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  93127. /**
  93128. * Sets the passed Effect "effect" with the Light textures.
  93129. * @param effect The effect to update
  93130. * @param lightIndex The index of the light in the effect to update
  93131. * @returns The light
  93132. */
  93133. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  93134. /**
  93135. * Binds the lights information from the scene to the effect for the given mesh.
  93136. * @param lightIndex Light index
  93137. * @param scene The scene where the light belongs to
  93138. * @param effect The effect we are binding the data to
  93139. * @param useSpecular Defines if specular is supported
  93140. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  93141. */
  93142. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  93143. /**
  93144. * Sets the passed Effect "effect" with the Light information.
  93145. * @param effect The effect to update
  93146. * @param lightDataUniformName The uniform used to store light data (position or direction)
  93147. * @returns The light
  93148. */
  93149. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  93150. /**
  93151. * Returns the string "Light".
  93152. * @returns the class name
  93153. */
  93154. getClassName(): string;
  93155. /** @hidden */
  93156. readonly _isLight: boolean;
  93157. /**
  93158. * Converts the light information to a readable string for debug purpose.
  93159. * @param fullDetails Supports for multiple levels of logging within scene loading
  93160. * @returns the human readable light info
  93161. */
  93162. toString(fullDetails?: boolean): string;
  93163. /** @hidden */
  93164. protected _syncParentEnabledState(): void;
  93165. /**
  93166. * Set the enabled state of this node.
  93167. * @param value - the new enabled state
  93168. */
  93169. setEnabled(value: boolean): void;
  93170. /**
  93171. * Returns the Light associated shadow generator if any.
  93172. * @return the associated shadow generator.
  93173. */
  93174. getShadowGenerator(): Nullable<IShadowGenerator>;
  93175. /**
  93176. * Returns a Vector3, the absolute light position in the World.
  93177. * @returns the world space position of the light
  93178. */
  93179. getAbsolutePosition(): Vector3;
  93180. /**
  93181. * Specifies if the light will affect the passed mesh.
  93182. * @param mesh The mesh to test against the light
  93183. * @return true the mesh is affected otherwise, false.
  93184. */
  93185. canAffectMesh(mesh: AbstractMesh): boolean;
  93186. /**
  93187. * Sort function to order lights for rendering.
  93188. * @param a First Light object to compare to second.
  93189. * @param b Second Light object to compare first.
  93190. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  93191. */
  93192. static CompareLightsPriority(a: Light, b: Light): number;
  93193. /**
  93194. * Releases resources associated with this node.
  93195. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  93196. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  93197. */
  93198. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  93199. /**
  93200. * Returns the light type ID (integer).
  93201. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  93202. */
  93203. getTypeID(): number;
  93204. /**
  93205. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  93206. * @returns the scaled intensity in intensity mode unit
  93207. */
  93208. getScaledIntensity(): number;
  93209. /**
  93210. * Returns a new Light object, named "name", from the current one.
  93211. * @param name The name of the cloned light
  93212. * @param newParent The parent of this light, if it has one
  93213. * @returns the new created light
  93214. */
  93215. clone(name: string, newParent?: Nullable<Node>): Nullable<Light>;
  93216. /**
  93217. * Serializes the current light into a Serialization object.
  93218. * @returns the serialized object.
  93219. */
  93220. serialize(): any;
  93221. /**
  93222. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  93223. * This new light is named "name" and added to the passed scene.
  93224. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  93225. * @param name The friendly name of the light
  93226. * @param scene The scene the new light will belong to
  93227. * @returns the constructor function
  93228. */
  93229. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  93230. /**
  93231. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  93232. * @param parsedLight The JSON representation of the light
  93233. * @param scene The scene to create the parsed light in
  93234. * @returns the created light after parsing
  93235. */
  93236. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  93237. private _hookArrayForExcluded;
  93238. private _hookArrayForIncludedOnly;
  93239. private _resyncMeshes;
  93240. /**
  93241. * Forces the meshes to update their light related information in their rendering used effects
  93242. * @hidden Internal Use Only
  93243. */
  93244. _markMeshesAsLightDirty(): void;
  93245. /**
  93246. * Recomputes the cached photometric scale if needed.
  93247. */
  93248. private _computePhotometricScale;
  93249. /**
  93250. * Returns the Photometric Scale according to the light type and intensity mode.
  93251. */
  93252. private _getPhotometricScale;
  93253. /**
  93254. * Reorder the light in the scene according to their defined priority.
  93255. * @hidden Internal Use Only
  93256. */
  93257. _reorderLightsInScene(): void;
  93258. /**
  93259. * Prepares the list of defines specific to the light type.
  93260. * @param defines the list of defines
  93261. * @param lightIndex defines the index of the light for the effect
  93262. */
  93263. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  93264. }
  93265. }
  93266. declare module BABYLON {
  93267. /**
  93268. * Interface used to define Action
  93269. */
  93270. export interface IAction {
  93271. /**
  93272. * Trigger for the action
  93273. */
  93274. trigger: number;
  93275. /** Options of the trigger */
  93276. triggerOptions: any;
  93277. /**
  93278. * Gets the trigger parameters
  93279. * @returns the trigger parameters
  93280. */
  93281. getTriggerParameter(): any;
  93282. /**
  93283. * Internal only - executes current action event
  93284. * @hidden
  93285. */
  93286. _executeCurrent(evt?: ActionEvent): void;
  93287. /**
  93288. * Serialize placeholder for child classes
  93289. * @param parent of child
  93290. * @returns the serialized object
  93291. */
  93292. serialize(parent: any): any;
  93293. /**
  93294. * Internal only
  93295. * @hidden
  93296. */
  93297. _prepare(): void;
  93298. /**
  93299. * Internal only - manager for action
  93300. * @hidden
  93301. */
  93302. _actionManager: AbstractActionManager;
  93303. /**
  93304. * Adds action to chain of actions, may be a DoNothingAction
  93305. * @param action defines the next action to execute
  93306. * @returns The action passed in
  93307. * @see https://www.babylonjs-playground.com/#1T30HR#0
  93308. */
  93309. then(action: IAction): IAction;
  93310. }
  93311. /**
  93312. * The action to be carried out following a trigger
  93313. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  93314. */
  93315. export class Action implements IAction {
  93316. /** the trigger, with or without parameters, for the action */
  93317. triggerOptions: any;
  93318. /**
  93319. * Trigger for the action
  93320. */
  93321. trigger: number;
  93322. /**
  93323. * Internal only - manager for action
  93324. * @hidden
  93325. */
  93326. _actionManager: ActionManager;
  93327. private _nextActiveAction;
  93328. private _child;
  93329. private _condition?;
  93330. private _triggerParameter;
  93331. /**
  93332. * An event triggered prior to action being executed.
  93333. */
  93334. onBeforeExecuteObservable: Observable<Action>;
  93335. /**
  93336. * Creates a new Action
  93337. * @param triggerOptions the trigger, with or without parameters, for the action
  93338. * @param condition an optional determinant of action
  93339. */
  93340. constructor(
  93341. /** the trigger, with or without parameters, for the action */
  93342. triggerOptions: any, condition?: Condition);
  93343. /**
  93344. * Internal only
  93345. * @hidden
  93346. */
  93347. _prepare(): void;
  93348. /**
  93349. * Gets the trigger parameters
  93350. * @returns the trigger parameters
  93351. */
  93352. getTriggerParameter(): any;
  93353. /**
  93354. * Internal only - executes current action event
  93355. * @hidden
  93356. */
  93357. _executeCurrent(evt?: ActionEvent): void;
  93358. /**
  93359. * Execute placeholder for child classes
  93360. * @param evt optional action event
  93361. */
  93362. execute(evt?: ActionEvent): void;
  93363. /**
  93364. * Skips to next active action
  93365. */
  93366. skipToNextActiveAction(): void;
  93367. /**
  93368. * Adds action to chain of actions, may be a DoNothingAction
  93369. * @param action defines the next action to execute
  93370. * @returns The action passed in
  93371. * @see https://www.babylonjs-playground.com/#1T30HR#0
  93372. */
  93373. then(action: Action): Action;
  93374. /**
  93375. * Internal only
  93376. * @hidden
  93377. */
  93378. _getProperty(propertyPath: string): string;
  93379. /**
  93380. * Internal only
  93381. * @hidden
  93382. */
  93383. _getEffectiveTarget(target: any, propertyPath: string): any;
  93384. /**
  93385. * Serialize placeholder for child classes
  93386. * @param parent of child
  93387. * @returns the serialized object
  93388. */
  93389. serialize(parent: any): any;
  93390. /**
  93391. * Internal only called by serialize
  93392. * @hidden
  93393. */
  93394. protected _serialize(serializedAction: any, parent?: any): any;
  93395. /**
  93396. * Internal only
  93397. * @hidden
  93398. */
  93399. static _SerializeValueAsString: (value: any) => string;
  93400. /**
  93401. * Internal only
  93402. * @hidden
  93403. */
  93404. static _GetTargetProperty: (target: Node | Scene) => {
  93405. name: string;
  93406. targetType: string;
  93407. value: string;
  93408. };
  93409. }
  93410. }
  93411. declare module BABYLON {
  93412. /**
  93413. * A Condition applied to an Action
  93414. */
  93415. export class Condition {
  93416. /**
  93417. * Internal only - manager for action
  93418. * @hidden
  93419. */
  93420. _actionManager: ActionManager;
  93421. /**
  93422. * Internal only
  93423. * @hidden
  93424. */
  93425. _evaluationId: number;
  93426. /**
  93427. * Internal only
  93428. * @hidden
  93429. */
  93430. _currentResult: boolean;
  93431. /**
  93432. * Creates a new Condition
  93433. * @param actionManager the manager of the action the condition is applied to
  93434. */
  93435. constructor(actionManager: ActionManager);
  93436. /**
  93437. * Check if the current condition is valid
  93438. * @returns a boolean
  93439. */
  93440. isValid(): boolean;
  93441. /**
  93442. * Internal only
  93443. * @hidden
  93444. */
  93445. _getProperty(propertyPath: string): string;
  93446. /**
  93447. * Internal only
  93448. * @hidden
  93449. */
  93450. _getEffectiveTarget(target: any, propertyPath: string): any;
  93451. /**
  93452. * Serialize placeholder for child classes
  93453. * @returns the serialized object
  93454. */
  93455. serialize(): any;
  93456. /**
  93457. * Internal only
  93458. * @hidden
  93459. */
  93460. protected _serialize(serializedCondition: any): any;
  93461. }
  93462. /**
  93463. * Defines specific conditional operators as extensions of Condition
  93464. */
  93465. export class ValueCondition extends Condition {
  93466. /** path to specify the property of the target the conditional operator uses */
  93467. propertyPath: string;
  93468. /** the value compared by the conditional operator against the current value of the property */
  93469. value: any;
  93470. /** the conditional operator, default ValueCondition.IsEqual */
  93471. operator: number;
  93472. /**
  93473. * Internal only
  93474. * @hidden
  93475. */
  93476. private static _IsEqual;
  93477. /**
  93478. * Internal only
  93479. * @hidden
  93480. */
  93481. private static _IsDifferent;
  93482. /**
  93483. * Internal only
  93484. * @hidden
  93485. */
  93486. private static _IsGreater;
  93487. /**
  93488. * Internal only
  93489. * @hidden
  93490. */
  93491. private static _IsLesser;
  93492. /**
  93493. * returns the number for IsEqual
  93494. */
  93495. static get IsEqual(): number;
  93496. /**
  93497. * Returns the number for IsDifferent
  93498. */
  93499. static get IsDifferent(): number;
  93500. /**
  93501. * Returns the number for IsGreater
  93502. */
  93503. static get IsGreater(): number;
  93504. /**
  93505. * Returns the number for IsLesser
  93506. */
  93507. static get IsLesser(): number;
  93508. /**
  93509. * Internal only The action manager for the condition
  93510. * @hidden
  93511. */
  93512. _actionManager: ActionManager;
  93513. /**
  93514. * Internal only
  93515. * @hidden
  93516. */
  93517. private _target;
  93518. /**
  93519. * Internal only
  93520. * @hidden
  93521. */
  93522. private _effectiveTarget;
  93523. /**
  93524. * Internal only
  93525. * @hidden
  93526. */
  93527. private _property;
  93528. /**
  93529. * Creates a new ValueCondition
  93530. * @param actionManager manager for the action the condition applies to
  93531. * @param target for the action
  93532. * @param propertyPath path to specify the property of the target the conditional operator uses
  93533. * @param value the value compared by the conditional operator against the current value of the property
  93534. * @param operator the conditional operator, default ValueCondition.IsEqual
  93535. */
  93536. constructor(actionManager: ActionManager, target: any,
  93537. /** path to specify the property of the target the conditional operator uses */
  93538. propertyPath: string,
  93539. /** the value compared by the conditional operator against the current value of the property */
  93540. value: any,
  93541. /** the conditional operator, default ValueCondition.IsEqual */
  93542. operator?: number);
  93543. /**
  93544. * Compares the given value with the property value for the specified conditional operator
  93545. * @returns the result of the comparison
  93546. */
  93547. isValid(): boolean;
  93548. /**
  93549. * Serialize the ValueCondition into a JSON compatible object
  93550. * @returns serialization object
  93551. */
  93552. serialize(): any;
  93553. /**
  93554. * Gets the name of the conditional operator for the ValueCondition
  93555. * @param operator the conditional operator
  93556. * @returns the name
  93557. */
  93558. static GetOperatorName(operator: number): string;
  93559. }
  93560. /**
  93561. * Defines a predicate condition as an extension of Condition
  93562. */
  93563. export class PredicateCondition extends Condition {
  93564. /** defines the predicate function used to validate the condition */
  93565. predicate: () => boolean;
  93566. /**
  93567. * Internal only - manager for action
  93568. * @hidden
  93569. */
  93570. _actionManager: ActionManager;
  93571. /**
  93572. * Creates a new PredicateCondition
  93573. * @param actionManager manager for the action the condition applies to
  93574. * @param predicate defines the predicate function used to validate the condition
  93575. */
  93576. constructor(actionManager: ActionManager,
  93577. /** defines the predicate function used to validate the condition */
  93578. predicate: () => boolean);
  93579. /**
  93580. * @returns the validity of the predicate condition
  93581. */
  93582. isValid(): boolean;
  93583. }
  93584. /**
  93585. * Defines a state condition as an extension of Condition
  93586. */
  93587. export class StateCondition extends Condition {
  93588. /** Value to compare with target state */
  93589. value: string;
  93590. /**
  93591. * Internal only - manager for action
  93592. * @hidden
  93593. */
  93594. _actionManager: ActionManager;
  93595. /**
  93596. * Internal only
  93597. * @hidden
  93598. */
  93599. private _target;
  93600. /**
  93601. * Creates a new StateCondition
  93602. * @param actionManager manager for the action the condition applies to
  93603. * @param target of the condition
  93604. * @param value to compare with target state
  93605. */
  93606. constructor(actionManager: ActionManager, target: any,
  93607. /** Value to compare with target state */
  93608. value: string);
  93609. /**
  93610. * Gets a boolean indicating if the current condition is met
  93611. * @returns the validity of the state
  93612. */
  93613. isValid(): boolean;
  93614. /**
  93615. * Serialize the StateCondition into a JSON compatible object
  93616. * @returns serialization object
  93617. */
  93618. serialize(): any;
  93619. }
  93620. }
  93621. declare module BABYLON {
  93622. /**
  93623. * This defines an action responsible to toggle a boolean once triggered.
  93624. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  93625. */
  93626. export class SwitchBooleanAction extends Action {
  93627. /**
  93628. * The path to the boolean property in the target object
  93629. */
  93630. propertyPath: string;
  93631. private _target;
  93632. private _effectiveTarget;
  93633. private _property;
  93634. /**
  93635. * Instantiate the action
  93636. * @param triggerOptions defines the trigger options
  93637. * @param target defines the object containing the boolean
  93638. * @param propertyPath defines the path to the boolean property in the target object
  93639. * @param condition defines the trigger related conditions
  93640. */
  93641. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  93642. /** @hidden */
  93643. _prepare(): void;
  93644. /**
  93645. * Execute the action toggle the boolean value.
  93646. */
  93647. execute(): void;
  93648. /**
  93649. * Serializes the actions and its related information.
  93650. * @param parent defines the object to serialize in
  93651. * @returns the serialized object
  93652. */
  93653. serialize(parent: any): any;
  93654. }
  93655. /**
  93656. * This defines an action responsible to set a the state field of the target
  93657. * to a desired value once triggered.
  93658. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  93659. */
  93660. export class SetStateAction extends Action {
  93661. /**
  93662. * The value to store in the state field.
  93663. */
  93664. value: string;
  93665. private _target;
  93666. /**
  93667. * Instantiate the action
  93668. * @param triggerOptions defines the trigger options
  93669. * @param target defines the object containing the state property
  93670. * @param value defines the value to store in the state field
  93671. * @param condition defines the trigger related conditions
  93672. */
  93673. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  93674. /**
  93675. * Execute the action and store the value on the target state property.
  93676. */
  93677. execute(): void;
  93678. /**
  93679. * Serializes the actions and its related information.
  93680. * @param parent defines the object to serialize in
  93681. * @returns the serialized object
  93682. */
  93683. serialize(parent: any): any;
  93684. }
  93685. /**
  93686. * This defines an action responsible to set a property of the target
  93687. * to a desired value once triggered.
  93688. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  93689. */
  93690. export class SetValueAction extends Action {
  93691. /**
  93692. * The path of the property to set in the target.
  93693. */
  93694. propertyPath: string;
  93695. /**
  93696. * The value to set in the property
  93697. */
  93698. value: any;
  93699. private _target;
  93700. private _effectiveTarget;
  93701. private _property;
  93702. /**
  93703. * Instantiate the action
  93704. * @param triggerOptions defines the trigger options
  93705. * @param target defines the object containing the property
  93706. * @param propertyPath defines the path of the property to set in the target
  93707. * @param value defines the value to set in the property
  93708. * @param condition defines the trigger related conditions
  93709. */
  93710. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  93711. /** @hidden */
  93712. _prepare(): void;
  93713. /**
  93714. * Execute the action and set the targetted property to the desired value.
  93715. */
  93716. execute(): void;
  93717. /**
  93718. * Serializes the actions and its related information.
  93719. * @param parent defines the object to serialize in
  93720. * @returns the serialized object
  93721. */
  93722. serialize(parent: any): any;
  93723. }
  93724. /**
  93725. * This defines an action responsible to increment the target value
  93726. * to a desired value once triggered.
  93727. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  93728. */
  93729. export class IncrementValueAction extends Action {
  93730. /**
  93731. * The path of the property to increment in the target.
  93732. */
  93733. propertyPath: string;
  93734. /**
  93735. * The value we should increment the property by.
  93736. */
  93737. value: any;
  93738. private _target;
  93739. private _effectiveTarget;
  93740. private _property;
  93741. /**
  93742. * Instantiate the action
  93743. * @param triggerOptions defines the trigger options
  93744. * @param target defines the object containing the property
  93745. * @param propertyPath defines the path of the property to increment in the target
  93746. * @param value defines the value value we should increment the property by
  93747. * @param condition defines the trigger related conditions
  93748. */
  93749. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  93750. /** @hidden */
  93751. _prepare(): void;
  93752. /**
  93753. * Execute the action and increment the target of the value amount.
  93754. */
  93755. execute(): void;
  93756. /**
  93757. * Serializes the actions and its related information.
  93758. * @param parent defines the object to serialize in
  93759. * @returns the serialized object
  93760. */
  93761. serialize(parent: any): any;
  93762. }
  93763. /**
  93764. * This defines an action responsible to start an animation once triggered.
  93765. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  93766. */
  93767. export class PlayAnimationAction extends Action {
  93768. /**
  93769. * Where the animation should start (animation frame)
  93770. */
  93771. from: number;
  93772. /**
  93773. * Where the animation should stop (animation frame)
  93774. */
  93775. to: number;
  93776. /**
  93777. * Define if the animation should loop or stop after the first play.
  93778. */
  93779. loop?: boolean;
  93780. private _target;
  93781. /**
  93782. * Instantiate the action
  93783. * @param triggerOptions defines the trigger options
  93784. * @param target defines the target animation or animation name
  93785. * @param from defines from where the animation should start (animation frame)
  93786. * @param end defines where the animation should stop (animation frame)
  93787. * @param loop defines if the animation should loop or stop after the first play
  93788. * @param condition defines the trigger related conditions
  93789. */
  93790. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  93791. /** @hidden */
  93792. _prepare(): void;
  93793. /**
  93794. * Execute the action and play the animation.
  93795. */
  93796. execute(): void;
  93797. /**
  93798. * Serializes the actions and its related information.
  93799. * @param parent defines the object to serialize in
  93800. * @returns the serialized object
  93801. */
  93802. serialize(parent: any): any;
  93803. }
  93804. /**
  93805. * This defines an action responsible to stop an animation once triggered.
  93806. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  93807. */
  93808. export class StopAnimationAction extends Action {
  93809. private _target;
  93810. /**
  93811. * Instantiate the action
  93812. * @param triggerOptions defines the trigger options
  93813. * @param target defines the target animation or animation name
  93814. * @param condition defines the trigger related conditions
  93815. */
  93816. constructor(triggerOptions: any, target: any, condition?: Condition);
  93817. /** @hidden */
  93818. _prepare(): void;
  93819. /**
  93820. * Execute the action and stop the animation.
  93821. */
  93822. execute(): void;
  93823. /**
  93824. * Serializes the actions and its related information.
  93825. * @param parent defines the object to serialize in
  93826. * @returns the serialized object
  93827. */
  93828. serialize(parent: any): any;
  93829. }
  93830. /**
  93831. * This defines an action responsible that does nothing once triggered.
  93832. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  93833. */
  93834. export class DoNothingAction extends Action {
  93835. /**
  93836. * Instantiate the action
  93837. * @param triggerOptions defines the trigger options
  93838. * @param condition defines the trigger related conditions
  93839. */
  93840. constructor(triggerOptions?: any, condition?: Condition);
  93841. /**
  93842. * Execute the action and do nothing.
  93843. */
  93844. execute(): void;
  93845. /**
  93846. * Serializes the actions and its related information.
  93847. * @param parent defines the object to serialize in
  93848. * @returns the serialized object
  93849. */
  93850. serialize(parent: any): any;
  93851. }
  93852. /**
  93853. * This defines an action responsible to trigger several actions once triggered.
  93854. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  93855. */
  93856. export class CombineAction extends Action {
  93857. /**
  93858. * The list of aggregated animations to run.
  93859. */
  93860. children: Action[];
  93861. /**
  93862. * Instantiate the action
  93863. * @param triggerOptions defines the trigger options
  93864. * @param children defines the list of aggregated animations to run
  93865. * @param condition defines the trigger related conditions
  93866. */
  93867. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  93868. /** @hidden */
  93869. _prepare(): void;
  93870. /**
  93871. * Execute the action and executes all the aggregated actions.
  93872. */
  93873. execute(evt: ActionEvent): void;
  93874. /**
  93875. * Serializes the actions and its related information.
  93876. * @param parent defines the object to serialize in
  93877. * @returns the serialized object
  93878. */
  93879. serialize(parent: any): any;
  93880. }
  93881. /**
  93882. * This defines an action responsible to run code (external event) once triggered.
  93883. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  93884. */
  93885. export class ExecuteCodeAction extends Action {
  93886. /**
  93887. * The callback function to run.
  93888. */
  93889. func: (evt: ActionEvent) => void;
  93890. /**
  93891. * Instantiate the action
  93892. * @param triggerOptions defines the trigger options
  93893. * @param func defines the callback function to run
  93894. * @param condition defines the trigger related conditions
  93895. */
  93896. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  93897. /**
  93898. * Execute the action and run the attached code.
  93899. */
  93900. execute(evt: ActionEvent): void;
  93901. }
  93902. /**
  93903. * This defines an action responsible to set the parent property of the target once triggered.
  93904. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  93905. */
  93906. export class SetParentAction extends Action {
  93907. private _parent;
  93908. private _target;
  93909. /**
  93910. * Instantiate the action
  93911. * @param triggerOptions defines the trigger options
  93912. * @param target defines the target containing the parent property
  93913. * @param parent defines from where the animation should start (animation frame)
  93914. * @param condition defines the trigger related conditions
  93915. */
  93916. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  93917. /** @hidden */
  93918. _prepare(): void;
  93919. /**
  93920. * Execute the action and set the parent property.
  93921. */
  93922. execute(): void;
  93923. /**
  93924. * Serializes the actions and its related information.
  93925. * @param parent defines the object to serialize in
  93926. * @returns the serialized object
  93927. */
  93928. serialize(parent: any): any;
  93929. }
  93930. }
  93931. declare module BABYLON {
  93932. /**
  93933. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  93934. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  93935. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  93936. */
  93937. export class ActionManager extends AbstractActionManager {
  93938. /**
  93939. * Nothing
  93940. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  93941. */
  93942. static readonly NothingTrigger: number;
  93943. /**
  93944. * On pick
  93945. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  93946. */
  93947. static readonly OnPickTrigger: number;
  93948. /**
  93949. * On left pick
  93950. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  93951. */
  93952. static readonly OnLeftPickTrigger: number;
  93953. /**
  93954. * On right pick
  93955. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  93956. */
  93957. static readonly OnRightPickTrigger: number;
  93958. /**
  93959. * On center pick
  93960. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  93961. */
  93962. static readonly OnCenterPickTrigger: number;
  93963. /**
  93964. * On pick down
  93965. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  93966. */
  93967. static readonly OnPickDownTrigger: number;
  93968. /**
  93969. * On double pick
  93970. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  93971. */
  93972. static readonly OnDoublePickTrigger: number;
  93973. /**
  93974. * On pick up
  93975. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  93976. */
  93977. static readonly OnPickUpTrigger: number;
  93978. /**
  93979. * On pick out.
  93980. * This trigger will only be raised if you also declared a OnPickDown
  93981. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  93982. */
  93983. static readonly OnPickOutTrigger: number;
  93984. /**
  93985. * On long press
  93986. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  93987. */
  93988. static readonly OnLongPressTrigger: number;
  93989. /**
  93990. * On pointer over
  93991. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  93992. */
  93993. static readonly OnPointerOverTrigger: number;
  93994. /**
  93995. * On pointer out
  93996. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  93997. */
  93998. static readonly OnPointerOutTrigger: number;
  93999. /**
  94000. * On every frame
  94001. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  94002. */
  94003. static readonly OnEveryFrameTrigger: number;
  94004. /**
  94005. * On intersection enter
  94006. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  94007. */
  94008. static readonly OnIntersectionEnterTrigger: number;
  94009. /**
  94010. * On intersection exit
  94011. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  94012. */
  94013. static readonly OnIntersectionExitTrigger: number;
  94014. /**
  94015. * On key down
  94016. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  94017. */
  94018. static readonly OnKeyDownTrigger: number;
  94019. /**
  94020. * On key up
  94021. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  94022. */
  94023. static readonly OnKeyUpTrigger: number;
  94024. private _scene;
  94025. /**
  94026. * Creates a new action manager
  94027. * @param scene defines the hosting scene
  94028. */
  94029. constructor(scene: Scene);
  94030. /**
  94031. * Releases all associated resources
  94032. */
  94033. dispose(): void;
  94034. /**
  94035. * Gets hosting scene
  94036. * @returns the hosting scene
  94037. */
  94038. getScene(): Scene;
  94039. /**
  94040. * Does this action manager handles actions of any of the given triggers
  94041. * @param triggers defines the triggers to be tested
  94042. * @return a boolean indicating whether one (or more) of the triggers is handled
  94043. */
  94044. hasSpecificTriggers(triggers: number[]): boolean;
  94045. /**
  94046. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  94047. * speed.
  94048. * @param triggerA defines the trigger to be tested
  94049. * @param triggerB defines the trigger to be tested
  94050. * @return a boolean indicating whether one (or more) of the triggers is handled
  94051. */
  94052. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  94053. /**
  94054. * Does this action manager handles actions of a given trigger
  94055. * @param trigger defines the trigger to be tested
  94056. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  94057. * @return whether the trigger is handled
  94058. */
  94059. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  94060. /**
  94061. * Does this action manager has pointer triggers
  94062. */
  94063. get hasPointerTriggers(): boolean;
  94064. /**
  94065. * Does this action manager has pick triggers
  94066. */
  94067. get hasPickTriggers(): boolean;
  94068. /**
  94069. * Registers an action to this action manager
  94070. * @param action defines the action to be registered
  94071. * @return the action amended (prepared) after registration
  94072. */
  94073. registerAction(action: IAction): Nullable<IAction>;
  94074. /**
  94075. * Unregisters an action to this action manager
  94076. * @param action defines the action to be unregistered
  94077. * @return a boolean indicating whether the action has been unregistered
  94078. */
  94079. unregisterAction(action: IAction): Boolean;
  94080. /**
  94081. * Process a specific trigger
  94082. * @param trigger defines the trigger to process
  94083. * @param evt defines the event details to be processed
  94084. */
  94085. processTrigger(trigger: number, evt?: IActionEvent): void;
  94086. /** @hidden */
  94087. _getEffectiveTarget(target: any, propertyPath: string): any;
  94088. /** @hidden */
  94089. _getProperty(propertyPath: string): string;
  94090. /**
  94091. * Serialize this manager to a JSON object
  94092. * @param name defines the property name to store this manager
  94093. * @returns a JSON representation of this manager
  94094. */
  94095. serialize(name: string): any;
  94096. /**
  94097. * Creates a new ActionManager from a JSON data
  94098. * @param parsedActions defines the JSON data to read from
  94099. * @param object defines the hosting mesh
  94100. * @param scene defines the hosting scene
  94101. */
  94102. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  94103. /**
  94104. * Get a trigger name by index
  94105. * @param trigger defines the trigger index
  94106. * @returns a trigger name
  94107. */
  94108. static GetTriggerName(trigger: number): string;
  94109. }
  94110. }
  94111. declare module BABYLON {
  94112. /**
  94113. * Class used to represent a sprite
  94114. * @see http://doc.babylonjs.com/babylon101/sprites
  94115. */
  94116. export class Sprite {
  94117. /** defines the name */
  94118. name: string;
  94119. /** Gets or sets the current world position */
  94120. position: Vector3;
  94121. /** Gets or sets the main color */
  94122. color: Color4;
  94123. /** Gets or sets the width */
  94124. width: number;
  94125. /** Gets or sets the height */
  94126. height: number;
  94127. /** Gets or sets rotation angle */
  94128. angle: number;
  94129. /** Gets or sets the cell index in the sprite sheet */
  94130. cellIndex: number;
  94131. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  94132. cellRef: string;
  94133. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  94134. invertU: number;
  94135. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  94136. invertV: number;
  94137. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  94138. disposeWhenFinishedAnimating: boolean;
  94139. /** Gets the list of attached animations */
  94140. animations: Animation[];
  94141. /** Gets or sets a boolean indicating if the sprite can be picked */
  94142. isPickable: boolean;
  94143. /** Gets or sets a boolean indicating that sprite texture alpha will be used for precise picking (false by default) */
  94144. useAlphaForPicking: boolean;
  94145. /** @hidden */
  94146. _xOffset: number;
  94147. /** @hidden */
  94148. _yOffset: number;
  94149. /** @hidden */
  94150. _xSize: number;
  94151. /** @hidden */
  94152. _ySize: number;
  94153. /**
  94154. * Gets or sets the associated action manager
  94155. */
  94156. actionManager: Nullable<ActionManager>;
  94157. /**
  94158. * An event triggered when the control has been disposed
  94159. */
  94160. onDisposeObservable: Observable<Sprite>;
  94161. private _animationStarted;
  94162. private _loopAnimation;
  94163. private _fromIndex;
  94164. private _toIndex;
  94165. private _delay;
  94166. private _direction;
  94167. private _manager;
  94168. private _time;
  94169. private _onAnimationEnd;
  94170. /**
  94171. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  94172. */
  94173. isVisible: boolean;
  94174. /**
  94175. * Gets or sets the sprite size
  94176. */
  94177. get size(): number;
  94178. set size(value: number);
  94179. /**
  94180. * Creates a new Sprite
  94181. * @param name defines the name
  94182. * @param manager defines the manager
  94183. */
  94184. constructor(
  94185. /** defines the name */
  94186. name: string, manager: ISpriteManager);
  94187. /**
  94188. * Starts an animation
  94189. * @param from defines the initial key
  94190. * @param to defines the end key
  94191. * @param loop defines if the animation must loop
  94192. * @param delay defines the start delay (in ms)
  94193. * @param onAnimationEnd defines a callback to call when animation ends
  94194. */
  94195. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  94196. /** Stops current animation (if any) */
  94197. stopAnimation(): void;
  94198. /** @hidden */
  94199. _animate(deltaTime: number): void;
  94200. /** Release associated resources */
  94201. dispose(): void;
  94202. }
  94203. }
  94204. declare module BABYLON {
  94205. /**
  94206. * Information about the result of picking within a scene
  94207. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  94208. */
  94209. export class PickingInfo {
  94210. /** @hidden */
  94211. _pickingUnavailable: boolean;
  94212. /**
  94213. * If the pick collided with an object
  94214. */
  94215. hit: boolean;
  94216. /**
  94217. * Distance away where the pick collided
  94218. */
  94219. distance: number;
  94220. /**
  94221. * The location of pick collision
  94222. */
  94223. pickedPoint: Nullable<Vector3>;
  94224. /**
  94225. * The mesh corresponding the the pick collision
  94226. */
  94227. pickedMesh: Nullable<AbstractMesh>;
  94228. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  94229. bu: number;
  94230. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  94231. bv: number;
  94232. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  94233. faceId: number;
  94234. /** Id of the the submesh that was picked */
  94235. subMeshId: number;
  94236. /** If a sprite was picked, this will be the sprite the pick collided with */
  94237. pickedSprite: Nullable<Sprite>;
  94238. /**
  94239. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  94240. */
  94241. originMesh: Nullable<AbstractMesh>;
  94242. /**
  94243. * The ray that was used to perform the picking.
  94244. */
  94245. ray: Nullable<Ray>;
  94246. /**
  94247. * Gets the normal correspodning to the face the pick collided with
  94248. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  94249. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  94250. * @returns The normal correspodning to the face the pick collided with
  94251. */
  94252. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  94253. /**
  94254. * Gets the texture coordinates of where the pick occured
  94255. * @returns the vector containing the coordnates of the texture
  94256. */
  94257. getTextureCoordinates(): Nullable<Vector2>;
  94258. }
  94259. }
  94260. declare module BABYLON {
  94261. /**
  94262. * Gather the list of pointer event types as constants.
  94263. */
  94264. export class PointerEventTypes {
  94265. /**
  94266. * 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.
  94267. */
  94268. static readonly POINTERDOWN: number;
  94269. /**
  94270. * The pointerup event is fired when a pointer is no longer active.
  94271. */
  94272. static readonly POINTERUP: number;
  94273. /**
  94274. * The pointermove event is fired when a pointer changes coordinates.
  94275. */
  94276. static readonly POINTERMOVE: number;
  94277. /**
  94278. * The pointerwheel event is fired when a mouse wheel has been rotated.
  94279. */
  94280. static readonly POINTERWHEEL: number;
  94281. /**
  94282. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  94283. */
  94284. static readonly POINTERPICK: number;
  94285. /**
  94286. * The pointertap event is fired when a the object has been touched and released without drag.
  94287. */
  94288. static readonly POINTERTAP: number;
  94289. /**
  94290. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  94291. */
  94292. static readonly POINTERDOUBLETAP: number;
  94293. }
  94294. /**
  94295. * Base class of pointer info types.
  94296. */
  94297. export class PointerInfoBase {
  94298. /**
  94299. * Defines the type of event (PointerEventTypes)
  94300. */
  94301. type: number;
  94302. /**
  94303. * Defines the related dom event
  94304. */
  94305. event: PointerEvent | MouseWheelEvent;
  94306. /**
  94307. * Instantiates the base class of pointers info.
  94308. * @param type Defines the type of event (PointerEventTypes)
  94309. * @param event Defines the related dom event
  94310. */
  94311. constructor(
  94312. /**
  94313. * Defines the type of event (PointerEventTypes)
  94314. */
  94315. type: number,
  94316. /**
  94317. * Defines the related dom event
  94318. */
  94319. event: PointerEvent | MouseWheelEvent);
  94320. }
  94321. /**
  94322. * This class is used to store pointer related info for the onPrePointerObservable event.
  94323. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  94324. */
  94325. export class PointerInfoPre extends PointerInfoBase {
  94326. /**
  94327. * Ray from a pointer if availible (eg. 6dof controller)
  94328. */
  94329. ray: Nullable<Ray>;
  94330. /**
  94331. * Defines the local position of the pointer on the canvas.
  94332. */
  94333. localPosition: Vector2;
  94334. /**
  94335. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  94336. */
  94337. skipOnPointerObservable: boolean;
  94338. /**
  94339. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  94340. * @param type Defines the type of event (PointerEventTypes)
  94341. * @param event Defines the related dom event
  94342. * @param localX Defines the local x coordinates of the pointer when the event occured
  94343. * @param localY Defines the local y coordinates of the pointer when the event occured
  94344. */
  94345. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  94346. }
  94347. /**
  94348. * This type contains all the data related to a pointer event in Babylon.js.
  94349. * 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.
  94350. */
  94351. export class PointerInfo extends PointerInfoBase {
  94352. /**
  94353. * Defines the picking info associated to the info (if any)\
  94354. */
  94355. pickInfo: Nullable<PickingInfo>;
  94356. /**
  94357. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  94358. * @param type Defines the type of event (PointerEventTypes)
  94359. * @param event Defines the related dom event
  94360. * @param pickInfo Defines the picking info associated to the info (if any)\
  94361. */
  94362. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  94363. /**
  94364. * Defines the picking info associated to the info (if any)\
  94365. */
  94366. pickInfo: Nullable<PickingInfo>);
  94367. }
  94368. /**
  94369. * Data relating to a touch event on the screen.
  94370. */
  94371. export interface PointerTouch {
  94372. /**
  94373. * X coordinate of touch.
  94374. */
  94375. x: number;
  94376. /**
  94377. * Y coordinate of touch.
  94378. */
  94379. y: number;
  94380. /**
  94381. * Id of touch. Unique for each finger.
  94382. */
  94383. pointerId: number;
  94384. /**
  94385. * Event type passed from DOM.
  94386. */
  94387. type: any;
  94388. }
  94389. }
  94390. declare module BABYLON {
  94391. /**
  94392. * Manage the mouse inputs to control the movement of a free camera.
  94393. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  94394. */
  94395. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  94396. /**
  94397. * Define if touch is enabled in the mouse input
  94398. */
  94399. touchEnabled: boolean;
  94400. /**
  94401. * Defines the camera the input is attached to.
  94402. */
  94403. camera: FreeCamera;
  94404. /**
  94405. * Defines the buttons associated with the input to handle camera move.
  94406. */
  94407. buttons: number[];
  94408. /**
  94409. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  94410. */
  94411. angularSensibility: number;
  94412. private _pointerInput;
  94413. private _onMouseMove;
  94414. private _observer;
  94415. private previousPosition;
  94416. /**
  94417. * Observable for when a pointer move event occurs containing the move offset
  94418. */
  94419. onPointerMovedObservable: Observable<{
  94420. offsetX: number;
  94421. offsetY: number;
  94422. }>;
  94423. /**
  94424. * @hidden
  94425. * If the camera should be rotated automatically based on pointer movement
  94426. */
  94427. _allowCameraRotation: boolean;
  94428. /**
  94429. * Manage the mouse inputs to control the movement of a free camera.
  94430. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  94431. * @param touchEnabled Defines if touch is enabled or not
  94432. */
  94433. constructor(
  94434. /**
  94435. * Define if touch is enabled in the mouse input
  94436. */
  94437. touchEnabled?: boolean);
  94438. /**
  94439. * Attach the input controls to a specific dom element to get the input from.
  94440. * @param element Defines the element the controls should be listened from
  94441. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  94442. */
  94443. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  94444. /**
  94445. * Called on JS contextmenu event.
  94446. * Override this method to provide functionality.
  94447. */
  94448. protected onContextMenu(evt: PointerEvent): void;
  94449. /**
  94450. * Detach the current controls from the specified dom element.
  94451. * @param element Defines the element to stop listening the inputs from
  94452. */
  94453. detachControl(element: Nullable<HTMLElement>): void;
  94454. /**
  94455. * Gets the class name of the current intput.
  94456. * @returns the class name
  94457. */
  94458. getClassName(): string;
  94459. /**
  94460. * Get the friendly name associated with the input class.
  94461. * @returns the input friendly name
  94462. */
  94463. getSimpleName(): string;
  94464. }
  94465. }
  94466. declare module BABYLON {
  94467. /**
  94468. * Manage the touch inputs to control the movement of a free camera.
  94469. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  94470. */
  94471. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  94472. /**
  94473. * Defines the camera the input is attached to.
  94474. */
  94475. camera: FreeCamera;
  94476. /**
  94477. * Defines the touch sensibility for rotation.
  94478. * The higher the faster.
  94479. */
  94480. touchAngularSensibility: number;
  94481. /**
  94482. * Defines the touch sensibility for move.
  94483. * The higher the faster.
  94484. */
  94485. touchMoveSensibility: number;
  94486. private _offsetX;
  94487. private _offsetY;
  94488. private _pointerPressed;
  94489. private _pointerInput;
  94490. private _observer;
  94491. private _onLostFocus;
  94492. /**
  94493. * Attach the input controls to a specific dom element to get the input from.
  94494. * @param element Defines the element the controls should be listened from
  94495. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  94496. */
  94497. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  94498. /**
  94499. * Detach the current controls from the specified dom element.
  94500. * @param element Defines the element to stop listening the inputs from
  94501. */
  94502. detachControl(element: Nullable<HTMLElement>): void;
  94503. /**
  94504. * Update the current camera state depending on the inputs that have been used this frame.
  94505. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  94506. */
  94507. checkInputs(): void;
  94508. /**
  94509. * Gets the class name of the current intput.
  94510. * @returns the class name
  94511. */
  94512. getClassName(): string;
  94513. /**
  94514. * Get the friendly name associated with the input class.
  94515. * @returns the input friendly name
  94516. */
  94517. getSimpleName(): string;
  94518. }
  94519. }
  94520. declare module BABYLON {
  94521. /**
  94522. * Default Inputs manager for the FreeCamera.
  94523. * It groups all the default supported inputs for ease of use.
  94524. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  94525. */
  94526. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  94527. /**
  94528. * @hidden
  94529. */
  94530. _mouseInput: Nullable<FreeCameraMouseInput>;
  94531. /**
  94532. * Instantiates a new FreeCameraInputsManager.
  94533. * @param camera Defines the camera the inputs belong to
  94534. */
  94535. constructor(camera: FreeCamera);
  94536. /**
  94537. * Add keyboard input support to the input manager.
  94538. * @returns the current input manager
  94539. */
  94540. addKeyboard(): FreeCameraInputsManager;
  94541. /**
  94542. * Add mouse input support to the input manager.
  94543. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  94544. * @returns the current input manager
  94545. */
  94546. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  94547. /**
  94548. * Removes the mouse input support from the manager
  94549. * @returns the current input manager
  94550. */
  94551. removeMouse(): FreeCameraInputsManager;
  94552. /**
  94553. * Add touch input support to the input manager.
  94554. * @returns the current input manager
  94555. */
  94556. addTouch(): FreeCameraInputsManager;
  94557. /**
  94558. * Remove all attached input methods from a camera
  94559. */
  94560. clear(): void;
  94561. }
  94562. }
  94563. declare module BABYLON {
  94564. /**
  94565. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  94566. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  94567. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  94568. */
  94569. export class FreeCamera extends TargetCamera {
  94570. /**
  94571. * Define the collision ellipsoid of the camera.
  94572. * This is helpful to simulate a camera body like the player body around the camera
  94573. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  94574. */
  94575. ellipsoid: Vector3;
  94576. /**
  94577. * Define an offset for the position of the ellipsoid around the camera.
  94578. * This can be helpful to determine the center of the body near the gravity center of the body
  94579. * instead of its head.
  94580. */
  94581. ellipsoidOffset: Vector3;
  94582. /**
  94583. * Enable or disable collisions of the camera with the rest of the scene objects.
  94584. */
  94585. checkCollisions: boolean;
  94586. /**
  94587. * Enable or disable gravity on the camera.
  94588. */
  94589. applyGravity: boolean;
  94590. /**
  94591. * Define the input manager associated to the camera.
  94592. */
  94593. inputs: FreeCameraInputsManager;
  94594. /**
  94595. * Gets the input sensibility for a mouse input. (default is 2000.0)
  94596. * Higher values reduce sensitivity.
  94597. */
  94598. get angularSensibility(): number;
  94599. /**
  94600. * Sets the input sensibility for a mouse input. (default is 2000.0)
  94601. * Higher values reduce sensitivity.
  94602. */
  94603. set angularSensibility(value: number);
  94604. /**
  94605. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  94606. */
  94607. get keysUp(): number[];
  94608. set keysUp(value: number[]);
  94609. /**
  94610. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  94611. */
  94612. get keysUpward(): number[];
  94613. set keysUpward(value: number[]);
  94614. /**
  94615. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  94616. */
  94617. get keysDown(): number[];
  94618. set keysDown(value: number[]);
  94619. /**
  94620. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  94621. */
  94622. get keysDownward(): number[];
  94623. set keysDownward(value: number[]);
  94624. /**
  94625. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  94626. */
  94627. get keysLeft(): number[];
  94628. set keysLeft(value: number[]);
  94629. /**
  94630. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  94631. */
  94632. get keysRight(): number[];
  94633. set keysRight(value: number[]);
  94634. /**
  94635. * Event raised when the camera collide with a mesh in the scene.
  94636. */
  94637. onCollide: (collidedMesh: AbstractMesh) => void;
  94638. private _collider;
  94639. private _needMoveForGravity;
  94640. private _oldPosition;
  94641. private _diffPosition;
  94642. private _newPosition;
  94643. /** @hidden */
  94644. _localDirection: Vector3;
  94645. /** @hidden */
  94646. _transformedDirection: Vector3;
  94647. /**
  94648. * Instantiates a Free Camera.
  94649. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  94650. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  94651. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  94652. * @param name Define the name of the camera in the scene
  94653. * @param position Define the start position of the camera in the scene
  94654. * @param scene Define the scene the camera belongs to
  94655. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  94656. */
  94657. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  94658. /**
  94659. * Attached controls to the current camera.
  94660. * @param element Defines the element the controls should be listened from
  94661. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  94662. */
  94663. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  94664. /**
  94665. * Detach the current controls from the camera.
  94666. * The camera will stop reacting to inputs.
  94667. * @param element Defines the element to stop listening the inputs from
  94668. */
  94669. detachControl(element: HTMLElement): void;
  94670. private _collisionMask;
  94671. /**
  94672. * Define a collision mask to limit the list of object the camera can collide with
  94673. */
  94674. get collisionMask(): number;
  94675. set collisionMask(mask: number);
  94676. /** @hidden */
  94677. _collideWithWorld(displacement: Vector3): void;
  94678. private _onCollisionPositionChange;
  94679. /** @hidden */
  94680. _checkInputs(): void;
  94681. /** @hidden */
  94682. _decideIfNeedsToMove(): boolean;
  94683. /** @hidden */
  94684. _updatePosition(): void;
  94685. /**
  94686. * Destroy the camera and release the current resources hold by it.
  94687. */
  94688. dispose(): void;
  94689. /**
  94690. * Gets the current object class name.
  94691. * @return the class name
  94692. */
  94693. getClassName(): string;
  94694. }
  94695. }
  94696. declare module BABYLON {
  94697. /**
  94698. * Represents a gamepad control stick position
  94699. */
  94700. export class StickValues {
  94701. /**
  94702. * The x component of the control stick
  94703. */
  94704. x: number;
  94705. /**
  94706. * The y component of the control stick
  94707. */
  94708. y: number;
  94709. /**
  94710. * Initializes the gamepad x and y control stick values
  94711. * @param x The x component of the gamepad control stick value
  94712. * @param y The y component of the gamepad control stick value
  94713. */
  94714. constructor(
  94715. /**
  94716. * The x component of the control stick
  94717. */
  94718. x: number,
  94719. /**
  94720. * The y component of the control stick
  94721. */
  94722. y: number);
  94723. }
  94724. /**
  94725. * An interface which manages callbacks for gamepad button changes
  94726. */
  94727. export interface GamepadButtonChanges {
  94728. /**
  94729. * Called when a gamepad has been changed
  94730. */
  94731. changed: boolean;
  94732. /**
  94733. * Called when a gamepad press event has been triggered
  94734. */
  94735. pressChanged: boolean;
  94736. /**
  94737. * Called when a touch event has been triggered
  94738. */
  94739. touchChanged: boolean;
  94740. /**
  94741. * Called when a value has changed
  94742. */
  94743. valueChanged: boolean;
  94744. }
  94745. /**
  94746. * Represents a gamepad
  94747. */
  94748. export class Gamepad {
  94749. /**
  94750. * The id of the gamepad
  94751. */
  94752. id: string;
  94753. /**
  94754. * The index of the gamepad
  94755. */
  94756. index: number;
  94757. /**
  94758. * The browser gamepad
  94759. */
  94760. browserGamepad: any;
  94761. /**
  94762. * Specifies what type of gamepad this represents
  94763. */
  94764. type: number;
  94765. private _leftStick;
  94766. private _rightStick;
  94767. /** @hidden */
  94768. _isConnected: boolean;
  94769. private _leftStickAxisX;
  94770. private _leftStickAxisY;
  94771. private _rightStickAxisX;
  94772. private _rightStickAxisY;
  94773. /**
  94774. * Triggered when the left control stick has been changed
  94775. */
  94776. private _onleftstickchanged;
  94777. /**
  94778. * Triggered when the right control stick has been changed
  94779. */
  94780. private _onrightstickchanged;
  94781. /**
  94782. * Represents a gamepad controller
  94783. */
  94784. static GAMEPAD: number;
  94785. /**
  94786. * Represents a generic controller
  94787. */
  94788. static GENERIC: number;
  94789. /**
  94790. * Represents an XBox controller
  94791. */
  94792. static XBOX: number;
  94793. /**
  94794. * Represents a pose-enabled controller
  94795. */
  94796. static POSE_ENABLED: number;
  94797. /**
  94798. * Represents an Dual Shock controller
  94799. */
  94800. static DUALSHOCK: number;
  94801. /**
  94802. * Specifies whether the left control stick should be Y-inverted
  94803. */
  94804. protected _invertLeftStickY: boolean;
  94805. /**
  94806. * Specifies if the gamepad has been connected
  94807. */
  94808. get isConnected(): boolean;
  94809. /**
  94810. * Initializes the gamepad
  94811. * @param id The id of the gamepad
  94812. * @param index The index of the gamepad
  94813. * @param browserGamepad The browser gamepad
  94814. * @param leftStickX The x component of the left joystick
  94815. * @param leftStickY The y component of the left joystick
  94816. * @param rightStickX The x component of the right joystick
  94817. * @param rightStickY The y component of the right joystick
  94818. */
  94819. constructor(
  94820. /**
  94821. * The id of the gamepad
  94822. */
  94823. id: string,
  94824. /**
  94825. * The index of the gamepad
  94826. */
  94827. index: number,
  94828. /**
  94829. * The browser gamepad
  94830. */
  94831. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  94832. /**
  94833. * Callback triggered when the left joystick has changed
  94834. * @param callback
  94835. */
  94836. onleftstickchanged(callback: (values: StickValues) => void): void;
  94837. /**
  94838. * Callback triggered when the right joystick has changed
  94839. * @param callback
  94840. */
  94841. onrightstickchanged(callback: (values: StickValues) => void): void;
  94842. /**
  94843. * Gets the left joystick
  94844. */
  94845. get leftStick(): StickValues;
  94846. /**
  94847. * Sets the left joystick values
  94848. */
  94849. set leftStick(newValues: StickValues);
  94850. /**
  94851. * Gets the right joystick
  94852. */
  94853. get rightStick(): StickValues;
  94854. /**
  94855. * Sets the right joystick value
  94856. */
  94857. set rightStick(newValues: StickValues);
  94858. /**
  94859. * Updates the gamepad joystick positions
  94860. */
  94861. update(): void;
  94862. /**
  94863. * Disposes the gamepad
  94864. */
  94865. dispose(): void;
  94866. }
  94867. /**
  94868. * Represents a generic gamepad
  94869. */
  94870. export class GenericPad extends Gamepad {
  94871. private _buttons;
  94872. private _onbuttondown;
  94873. private _onbuttonup;
  94874. /**
  94875. * Observable triggered when a button has been pressed
  94876. */
  94877. onButtonDownObservable: Observable<number>;
  94878. /**
  94879. * Observable triggered when a button has been released
  94880. */
  94881. onButtonUpObservable: Observable<number>;
  94882. /**
  94883. * Callback triggered when a button has been pressed
  94884. * @param callback Called when a button has been pressed
  94885. */
  94886. onbuttondown(callback: (buttonPressed: number) => void): void;
  94887. /**
  94888. * Callback triggered when a button has been released
  94889. * @param callback Called when a button has been released
  94890. */
  94891. onbuttonup(callback: (buttonReleased: number) => void): void;
  94892. /**
  94893. * Initializes the generic gamepad
  94894. * @param id The id of the generic gamepad
  94895. * @param index The index of the generic gamepad
  94896. * @param browserGamepad The browser gamepad
  94897. */
  94898. constructor(id: string, index: number, browserGamepad: any);
  94899. private _setButtonValue;
  94900. /**
  94901. * Updates the generic gamepad
  94902. */
  94903. update(): void;
  94904. /**
  94905. * Disposes the generic gamepad
  94906. */
  94907. dispose(): void;
  94908. }
  94909. }
  94910. declare module BABYLON {
  94911. /**
  94912. * Defines the types of pose enabled controllers that are supported
  94913. */
  94914. export enum PoseEnabledControllerType {
  94915. /**
  94916. * HTC Vive
  94917. */
  94918. VIVE = 0,
  94919. /**
  94920. * Oculus Rift
  94921. */
  94922. OCULUS = 1,
  94923. /**
  94924. * Windows mixed reality
  94925. */
  94926. WINDOWS = 2,
  94927. /**
  94928. * Samsung gear VR
  94929. */
  94930. GEAR_VR = 3,
  94931. /**
  94932. * Google Daydream
  94933. */
  94934. DAYDREAM = 4,
  94935. /**
  94936. * Generic
  94937. */
  94938. GENERIC = 5
  94939. }
  94940. /**
  94941. * Defines the MutableGamepadButton interface for the state of a gamepad button
  94942. */
  94943. export interface MutableGamepadButton {
  94944. /**
  94945. * Value of the button/trigger
  94946. */
  94947. value: number;
  94948. /**
  94949. * If the button/trigger is currently touched
  94950. */
  94951. touched: boolean;
  94952. /**
  94953. * If the button/trigger is currently pressed
  94954. */
  94955. pressed: boolean;
  94956. }
  94957. /**
  94958. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  94959. * @hidden
  94960. */
  94961. export interface ExtendedGamepadButton extends GamepadButton {
  94962. /**
  94963. * If the button/trigger is currently pressed
  94964. */
  94965. readonly pressed: boolean;
  94966. /**
  94967. * If the button/trigger is currently touched
  94968. */
  94969. readonly touched: boolean;
  94970. /**
  94971. * Value of the button/trigger
  94972. */
  94973. readonly value: number;
  94974. }
  94975. /** @hidden */
  94976. export interface _GamePadFactory {
  94977. /**
  94978. * Returns whether or not the current gamepad can be created for this type of controller.
  94979. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  94980. * @returns true if it can be created, otherwise false
  94981. */
  94982. canCreate(gamepadInfo: any): boolean;
  94983. /**
  94984. * Creates a new instance of the Gamepad.
  94985. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  94986. * @returns the new gamepad instance
  94987. */
  94988. create(gamepadInfo: any): Gamepad;
  94989. }
  94990. /**
  94991. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  94992. */
  94993. export class PoseEnabledControllerHelper {
  94994. /** @hidden */
  94995. static _ControllerFactories: _GamePadFactory[];
  94996. /** @hidden */
  94997. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  94998. /**
  94999. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  95000. * @param vrGamepad the gamepad to initialized
  95001. * @returns a vr controller of the type the gamepad identified as
  95002. */
  95003. static InitiateController(vrGamepad: any): Gamepad;
  95004. }
  95005. /**
  95006. * Defines the PoseEnabledController object that contains state of a vr capable controller
  95007. */
  95008. export class PoseEnabledController extends Gamepad implements PoseControlled {
  95009. /**
  95010. * If the controller is used in a webXR session
  95011. */
  95012. isXR: boolean;
  95013. private _deviceRoomPosition;
  95014. private _deviceRoomRotationQuaternion;
  95015. /**
  95016. * The device position in babylon space
  95017. */
  95018. devicePosition: Vector3;
  95019. /**
  95020. * The device rotation in babylon space
  95021. */
  95022. deviceRotationQuaternion: Quaternion;
  95023. /**
  95024. * The scale factor of the device in babylon space
  95025. */
  95026. deviceScaleFactor: number;
  95027. /**
  95028. * (Likely devicePosition should be used instead) The device position in its room space
  95029. */
  95030. position: Vector3;
  95031. /**
  95032. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  95033. */
  95034. rotationQuaternion: Quaternion;
  95035. /**
  95036. * The type of controller (Eg. Windows mixed reality)
  95037. */
  95038. controllerType: PoseEnabledControllerType;
  95039. protected _calculatedPosition: Vector3;
  95040. private _calculatedRotation;
  95041. /**
  95042. * The raw pose from the device
  95043. */
  95044. rawPose: DevicePose;
  95045. private _trackPosition;
  95046. private _maxRotationDistFromHeadset;
  95047. private _draggedRoomRotation;
  95048. /**
  95049. * @hidden
  95050. */
  95051. _disableTrackPosition(fixedPosition: Vector3): void;
  95052. /**
  95053. * Internal, the mesh attached to the controller
  95054. * @hidden
  95055. */
  95056. _mesh: Nullable<AbstractMesh>;
  95057. private _poseControlledCamera;
  95058. private _leftHandSystemQuaternion;
  95059. /**
  95060. * Internal, matrix used to convert room space to babylon space
  95061. * @hidden
  95062. */
  95063. _deviceToWorld: Matrix;
  95064. /**
  95065. * Node to be used when casting a ray from the controller
  95066. * @hidden
  95067. */
  95068. _pointingPoseNode: Nullable<TransformNode>;
  95069. /**
  95070. * Name of the child mesh that can be used to cast a ray from the controller
  95071. */
  95072. static readonly POINTING_POSE: string;
  95073. /**
  95074. * Creates a new PoseEnabledController from a gamepad
  95075. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  95076. */
  95077. constructor(browserGamepad: any);
  95078. private _workingMatrix;
  95079. /**
  95080. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  95081. */
  95082. update(): void;
  95083. /**
  95084. * Updates only the pose device and mesh without doing any button event checking
  95085. */
  95086. protected _updatePoseAndMesh(): void;
  95087. /**
  95088. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  95089. * @param poseData raw pose fromthe device
  95090. */
  95091. updateFromDevice(poseData: DevicePose): void;
  95092. /**
  95093. * @hidden
  95094. */
  95095. _meshAttachedObservable: Observable<AbstractMesh>;
  95096. /**
  95097. * Attaches a mesh to the controller
  95098. * @param mesh the mesh to be attached
  95099. */
  95100. attachToMesh(mesh: AbstractMesh): void;
  95101. /**
  95102. * Attaches the controllers mesh to a camera
  95103. * @param camera the camera the mesh should be attached to
  95104. */
  95105. attachToPoseControlledCamera(camera: TargetCamera): void;
  95106. /**
  95107. * Disposes of the controller
  95108. */
  95109. dispose(): void;
  95110. /**
  95111. * The mesh that is attached to the controller
  95112. */
  95113. get mesh(): Nullable<AbstractMesh>;
  95114. /**
  95115. * Gets the ray of the controller in the direction the controller is pointing
  95116. * @param length the length the resulting ray should be
  95117. * @returns a ray in the direction the controller is pointing
  95118. */
  95119. getForwardRay(length?: number): Ray;
  95120. }
  95121. }
  95122. declare module BABYLON {
  95123. /**
  95124. * Defines the WebVRController object that represents controllers tracked in 3D space
  95125. */
  95126. export abstract class WebVRController extends PoseEnabledController {
  95127. /**
  95128. * Internal, the default controller model for the controller
  95129. */
  95130. protected _defaultModel: Nullable<AbstractMesh>;
  95131. /**
  95132. * Fired when the trigger state has changed
  95133. */
  95134. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  95135. /**
  95136. * Fired when the main button state has changed
  95137. */
  95138. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  95139. /**
  95140. * Fired when the secondary button state has changed
  95141. */
  95142. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  95143. /**
  95144. * Fired when the pad state has changed
  95145. */
  95146. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  95147. /**
  95148. * Fired when controllers stick values have changed
  95149. */
  95150. onPadValuesChangedObservable: Observable<StickValues>;
  95151. /**
  95152. * Array of button availible on the controller
  95153. */
  95154. protected _buttons: Array<MutableGamepadButton>;
  95155. private _onButtonStateChange;
  95156. /**
  95157. * Fired when a controller button's state has changed
  95158. * @param callback the callback containing the button that was modified
  95159. */
  95160. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  95161. /**
  95162. * X and Y axis corresponding to the controllers joystick
  95163. */
  95164. pad: StickValues;
  95165. /**
  95166. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  95167. */
  95168. hand: string;
  95169. /**
  95170. * The default controller model for the controller
  95171. */
  95172. get defaultModel(): Nullable<AbstractMesh>;
  95173. /**
  95174. * Creates a new WebVRController from a gamepad
  95175. * @param vrGamepad the gamepad that the WebVRController should be created from
  95176. */
  95177. constructor(vrGamepad: any);
  95178. /**
  95179. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  95180. */
  95181. update(): void;
  95182. /**
  95183. * Function to be called when a button is modified
  95184. */
  95185. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  95186. /**
  95187. * Loads a mesh and attaches it to the controller
  95188. * @param scene the scene the mesh should be added to
  95189. * @param meshLoaded callback for when the mesh has been loaded
  95190. */
  95191. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  95192. private _setButtonValue;
  95193. private _changes;
  95194. private _checkChanges;
  95195. /**
  95196. * Disposes of th webVRCOntroller
  95197. */
  95198. dispose(): void;
  95199. }
  95200. }
  95201. declare module BABYLON {
  95202. /**
  95203. * The HemisphericLight simulates the ambient environment light,
  95204. * so the passed direction is the light reflection direction, not the incoming direction.
  95205. */
  95206. export class HemisphericLight extends Light {
  95207. /**
  95208. * The groundColor is the light in the opposite direction to the one specified during creation.
  95209. * 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.
  95210. */
  95211. groundColor: Color3;
  95212. /**
  95213. * The light reflection direction, not the incoming direction.
  95214. */
  95215. direction: Vector3;
  95216. /**
  95217. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  95218. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  95219. * The HemisphericLight can't cast shadows.
  95220. * Documentation : https://doc.babylonjs.com/babylon101/lights
  95221. * @param name The friendly name of the light
  95222. * @param direction The direction of the light reflection
  95223. * @param scene The scene the light belongs to
  95224. */
  95225. constructor(name: string, direction: Vector3, scene: Scene);
  95226. protected _buildUniformLayout(): void;
  95227. /**
  95228. * Returns the string "HemisphericLight".
  95229. * @return The class name
  95230. */
  95231. getClassName(): string;
  95232. /**
  95233. * Sets the HemisphericLight direction towards the passed target (Vector3).
  95234. * Returns the updated direction.
  95235. * @param target The target the direction should point to
  95236. * @return The computed direction
  95237. */
  95238. setDirectionToTarget(target: Vector3): Vector3;
  95239. /**
  95240. * Returns the shadow generator associated to the light.
  95241. * @returns Always null for hemispheric lights because it does not support shadows.
  95242. */
  95243. getShadowGenerator(): Nullable<IShadowGenerator>;
  95244. /**
  95245. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  95246. * @param effect The effect to update
  95247. * @param lightIndex The index of the light in the effect to update
  95248. * @returns The hemispheric light
  95249. */
  95250. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  95251. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  95252. /**
  95253. * Computes the world matrix of the node
  95254. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  95255. * @param useWasUpdatedFlag defines a reserved property
  95256. * @returns the world matrix
  95257. */
  95258. computeWorldMatrix(): Matrix;
  95259. /**
  95260. * Returns the integer 3.
  95261. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  95262. */
  95263. getTypeID(): number;
  95264. /**
  95265. * Prepares the list of defines specific to the light type.
  95266. * @param defines the list of defines
  95267. * @param lightIndex defines the index of the light for the effect
  95268. */
  95269. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  95270. }
  95271. }
  95272. declare module BABYLON {
  95273. /** @hidden */
  95274. export var vrMultiviewToSingleviewPixelShader: {
  95275. name: string;
  95276. shader: string;
  95277. };
  95278. }
  95279. declare module BABYLON {
  95280. /**
  95281. * Renders to multiple views with a single draw call
  95282. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  95283. */
  95284. export class MultiviewRenderTarget extends RenderTargetTexture {
  95285. /**
  95286. * Creates a multiview render target
  95287. * @param scene scene used with the render target
  95288. * @param size the size of the render target (used for each view)
  95289. */
  95290. constructor(scene: Scene, size?: number | {
  95291. width: number;
  95292. height: number;
  95293. } | {
  95294. ratio: number;
  95295. });
  95296. /**
  95297. * @hidden
  95298. * @param faceIndex the face index, if its a cube texture
  95299. */
  95300. _bindFrameBuffer(faceIndex?: number): void;
  95301. /**
  95302. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  95303. * @returns the view count
  95304. */
  95305. getViewCount(): number;
  95306. }
  95307. }
  95308. declare module BABYLON {
  95309. /**
  95310. * Represents a camera frustum
  95311. */
  95312. export class Frustum {
  95313. /**
  95314. * Gets the planes representing the frustum
  95315. * @param transform matrix to be applied to the returned planes
  95316. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  95317. */
  95318. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  95319. /**
  95320. * Gets the near frustum plane transformed by the transform matrix
  95321. * @param transform transformation matrix to be applied to the resulting frustum plane
  95322. * @param frustumPlane the resuling frustum plane
  95323. */
  95324. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  95325. /**
  95326. * Gets the far frustum plane transformed by the transform matrix
  95327. * @param transform transformation matrix to be applied to the resulting frustum plane
  95328. * @param frustumPlane the resuling frustum plane
  95329. */
  95330. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  95331. /**
  95332. * Gets the left frustum plane transformed by the transform matrix
  95333. * @param transform transformation matrix to be applied to the resulting frustum plane
  95334. * @param frustumPlane the resuling frustum plane
  95335. */
  95336. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  95337. /**
  95338. * Gets the right frustum plane transformed by the transform matrix
  95339. * @param transform transformation matrix to be applied to the resulting frustum plane
  95340. * @param frustumPlane the resuling frustum plane
  95341. */
  95342. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  95343. /**
  95344. * Gets the top frustum plane transformed by the transform matrix
  95345. * @param transform transformation matrix to be applied to the resulting frustum plane
  95346. * @param frustumPlane the resuling frustum plane
  95347. */
  95348. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  95349. /**
  95350. * Gets the bottom frustum plane transformed by the transform matrix
  95351. * @param transform transformation matrix to be applied to the resulting frustum plane
  95352. * @param frustumPlane the resuling frustum plane
  95353. */
  95354. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  95355. /**
  95356. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  95357. * @param transform transformation matrix to be applied to the resulting frustum planes
  95358. * @param frustumPlanes the resuling frustum planes
  95359. */
  95360. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  95361. }
  95362. }
  95363. declare module BABYLON {
  95364. interface Engine {
  95365. /**
  95366. * Creates a new multiview render target
  95367. * @param width defines the width of the texture
  95368. * @param height defines the height of the texture
  95369. * @returns the created multiview texture
  95370. */
  95371. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  95372. /**
  95373. * Binds a multiview framebuffer to be drawn to
  95374. * @param multiviewTexture texture to bind
  95375. */
  95376. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  95377. }
  95378. interface Camera {
  95379. /**
  95380. * @hidden
  95381. * 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)
  95382. */
  95383. _useMultiviewToSingleView: boolean;
  95384. /**
  95385. * @hidden
  95386. * 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)
  95387. */
  95388. _multiviewTexture: Nullable<RenderTargetTexture>;
  95389. /**
  95390. * @hidden
  95391. * ensures the multiview texture of the camera exists and has the specified width/height
  95392. * @param width height to set on the multiview texture
  95393. * @param height width to set on the multiview texture
  95394. */
  95395. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  95396. }
  95397. interface Scene {
  95398. /** @hidden */
  95399. _transformMatrixR: Matrix;
  95400. /** @hidden */
  95401. _multiviewSceneUbo: Nullable<UniformBuffer>;
  95402. /** @hidden */
  95403. _createMultiviewUbo(): void;
  95404. /** @hidden */
  95405. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  95406. /** @hidden */
  95407. _renderMultiviewToSingleView(camera: Camera): void;
  95408. }
  95409. }
  95410. declare module BABYLON {
  95411. /**
  95412. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  95413. * This will not be used for webXR as it supports displaying texture arrays directly
  95414. */
  95415. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  95416. /**
  95417. * Initializes a VRMultiviewToSingleview
  95418. * @param name name of the post process
  95419. * @param camera camera to be applied to
  95420. * @param scaleFactor scaling factor to the size of the output texture
  95421. */
  95422. constructor(name: string, camera: Camera, scaleFactor: number);
  95423. }
  95424. }
  95425. declare module BABYLON {
  95426. /**
  95427. * Interface used to define additional presentation attributes
  95428. */
  95429. export interface IVRPresentationAttributes {
  95430. /**
  95431. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  95432. */
  95433. highRefreshRate: boolean;
  95434. /**
  95435. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  95436. */
  95437. foveationLevel: number;
  95438. }
  95439. interface Engine {
  95440. /** @hidden */
  95441. _vrDisplay: any;
  95442. /** @hidden */
  95443. _vrSupported: boolean;
  95444. /** @hidden */
  95445. _oldSize: Size;
  95446. /** @hidden */
  95447. _oldHardwareScaleFactor: number;
  95448. /** @hidden */
  95449. _vrExclusivePointerMode: boolean;
  95450. /** @hidden */
  95451. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  95452. /** @hidden */
  95453. _onVRDisplayPointerRestricted: () => void;
  95454. /** @hidden */
  95455. _onVRDisplayPointerUnrestricted: () => void;
  95456. /** @hidden */
  95457. _onVrDisplayConnect: Nullable<(display: any) => void>;
  95458. /** @hidden */
  95459. _onVrDisplayDisconnect: Nullable<() => void>;
  95460. /** @hidden */
  95461. _onVrDisplayPresentChange: Nullable<() => void>;
  95462. /**
  95463. * Observable signaled when VR display mode changes
  95464. */
  95465. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  95466. /**
  95467. * Observable signaled when VR request present is complete
  95468. */
  95469. onVRRequestPresentComplete: Observable<boolean>;
  95470. /**
  95471. * Observable signaled when VR request present starts
  95472. */
  95473. onVRRequestPresentStart: Observable<Engine>;
  95474. /**
  95475. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  95476. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  95477. */
  95478. isInVRExclusivePointerMode: boolean;
  95479. /**
  95480. * Gets a boolean indicating if a webVR device was detected
  95481. * @returns true if a webVR device was detected
  95482. */
  95483. isVRDevicePresent(): boolean;
  95484. /**
  95485. * Gets the current webVR device
  95486. * @returns the current webVR device (or null)
  95487. */
  95488. getVRDevice(): any;
  95489. /**
  95490. * Initializes a webVR display and starts listening to display change events
  95491. * The onVRDisplayChangedObservable will be notified upon these changes
  95492. * @returns A promise containing a VRDisplay and if vr is supported
  95493. */
  95494. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  95495. /** @hidden */
  95496. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  95497. /**
  95498. * Gets or sets the presentation attributes used to configure VR rendering
  95499. */
  95500. vrPresentationAttributes?: IVRPresentationAttributes;
  95501. /**
  95502. * Call this function to switch to webVR mode
  95503. * Will do nothing if webVR is not supported or if there is no webVR device
  95504. * @param options the webvr options provided to the camera. mainly used for multiview
  95505. * @see http://doc.babylonjs.com/how_to/webvr_camera
  95506. */
  95507. enableVR(options: WebVROptions): void;
  95508. /** @hidden */
  95509. _onVRFullScreenTriggered(): void;
  95510. }
  95511. }
  95512. declare module BABYLON {
  95513. /**
  95514. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  95515. * IMPORTANT!! The data is right-hand data.
  95516. * @export
  95517. * @interface DevicePose
  95518. */
  95519. export interface DevicePose {
  95520. /**
  95521. * The position of the device, values in array are [x,y,z].
  95522. */
  95523. readonly position: Nullable<Float32Array>;
  95524. /**
  95525. * The linearVelocity of the device, values in array are [x,y,z].
  95526. */
  95527. readonly linearVelocity: Nullable<Float32Array>;
  95528. /**
  95529. * The linearAcceleration of the device, values in array are [x,y,z].
  95530. */
  95531. readonly linearAcceleration: Nullable<Float32Array>;
  95532. /**
  95533. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  95534. */
  95535. readonly orientation: Nullable<Float32Array>;
  95536. /**
  95537. * The angularVelocity of the device, values in array are [x,y,z].
  95538. */
  95539. readonly angularVelocity: Nullable<Float32Array>;
  95540. /**
  95541. * The angularAcceleration of the device, values in array are [x,y,z].
  95542. */
  95543. readonly angularAcceleration: Nullable<Float32Array>;
  95544. }
  95545. /**
  95546. * Interface representing a pose controlled object in Babylon.
  95547. * A pose controlled object has both regular pose values as well as pose values
  95548. * from an external device such as a VR head mounted display
  95549. */
  95550. export interface PoseControlled {
  95551. /**
  95552. * The position of the object in babylon space.
  95553. */
  95554. position: Vector3;
  95555. /**
  95556. * The rotation quaternion of the object in babylon space.
  95557. */
  95558. rotationQuaternion: Quaternion;
  95559. /**
  95560. * The position of the device in babylon space.
  95561. */
  95562. devicePosition?: Vector3;
  95563. /**
  95564. * The rotation quaternion of the device in babylon space.
  95565. */
  95566. deviceRotationQuaternion: Quaternion;
  95567. /**
  95568. * The raw pose coming from the device.
  95569. */
  95570. rawPose: Nullable<DevicePose>;
  95571. /**
  95572. * The scale of the device to be used when translating from device space to babylon space.
  95573. */
  95574. deviceScaleFactor: number;
  95575. /**
  95576. * Updates the poseControlled values based on the input device pose.
  95577. * @param poseData the pose data to update the object with
  95578. */
  95579. updateFromDevice(poseData: DevicePose): void;
  95580. }
  95581. /**
  95582. * Set of options to customize the webVRCamera
  95583. */
  95584. export interface WebVROptions {
  95585. /**
  95586. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  95587. */
  95588. trackPosition?: boolean;
  95589. /**
  95590. * Sets the scale of the vrDevice in babylon space. (default: 1)
  95591. */
  95592. positionScale?: number;
  95593. /**
  95594. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  95595. */
  95596. displayName?: string;
  95597. /**
  95598. * Should the native controller meshes be initialized. (default: true)
  95599. */
  95600. controllerMeshes?: boolean;
  95601. /**
  95602. * Creating a default HemiLight only on controllers. (default: true)
  95603. */
  95604. defaultLightingOnControllers?: boolean;
  95605. /**
  95606. * If you don't want to use the default VR button of the helper. (default: false)
  95607. */
  95608. useCustomVRButton?: boolean;
  95609. /**
  95610. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  95611. */
  95612. customVRButton?: HTMLButtonElement;
  95613. /**
  95614. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  95615. */
  95616. rayLength?: number;
  95617. /**
  95618. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  95619. */
  95620. defaultHeight?: number;
  95621. /**
  95622. * If multiview should be used if availible (default: false)
  95623. */
  95624. useMultiview?: boolean;
  95625. }
  95626. /**
  95627. * This represents a WebVR camera.
  95628. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  95629. * @example http://doc.babylonjs.com/how_to/webvr_camera
  95630. */
  95631. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  95632. private webVROptions;
  95633. /**
  95634. * @hidden
  95635. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  95636. */
  95637. _vrDevice: any;
  95638. /**
  95639. * The rawPose of the vrDevice.
  95640. */
  95641. rawPose: Nullable<DevicePose>;
  95642. private _onVREnabled;
  95643. private _specsVersion;
  95644. private _attached;
  95645. private _frameData;
  95646. protected _descendants: Array<Node>;
  95647. private _deviceRoomPosition;
  95648. /** @hidden */
  95649. _deviceRoomRotationQuaternion: Quaternion;
  95650. private _standingMatrix;
  95651. /**
  95652. * Represents device position in babylon space.
  95653. */
  95654. devicePosition: Vector3;
  95655. /**
  95656. * Represents device rotation in babylon space.
  95657. */
  95658. deviceRotationQuaternion: Quaternion;
  95659. /**
  95660. * The scale of the device to be used when translating from device space to babylon space.
  95661. */
  95662. deviceScaleFactor: number;
  95663. private _deviceToWorld;
  95664. private _worldToDevice;
  95665. /**
  95666. * References to the webVR controllers for the vrDevice.
  95667. */
  95668. controllers: Array<WebVRController>;
  95669. /**
  95670. * Emits an event when a controller is attached.
  95671. */
  95672. onControllersAttachedObservable: Observable<WebVRController[]>;
  95673. /**
  95674. * Emits an event when a controller's mesh has been loaded;
  95675. */
  95676. onControllerMeshLoadedObservable: Observable<WebVRController>;
  95677. /**
  95678. * Emits an event when the HMD's pose has been updated.
  95679. */
  95680. onPoseUpdatedFromDeviceObservable: Observable<any>;
  95681. private _poseSet;
  95682. /**
  95683. * If the rig cameras be used as parent instead of this camera.
  95684. */
  95685. rigParenting: boolean;
  95686. private _lightOnControllers;
  95687. private _defaultHeight?;
  95688. /**
  95689. * Instantiates a WebVRFreeCamera.
  95690. * @param name The name of the WebVRFreeCamera
  95691. * @param position The starting anchor position for the camera
  95692. * @param scene The scene the camera belongs to
  95693. * @param webVROptions a set of customizable options for the webVRCamera
  95694. */
  95695. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  95696. /**
  95697. * Gets the device distance from the ground in meters.
  95698. * @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.
  95699. */
  95700. deviceDistanceToRoomGround(): number;
  95701. /**
  95702. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  95703. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  95704. */
  95705. useStandingMatrix(callback?: (bool: boolean) => void): void;
  95706. /**
  95707. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  95708. * @returns A promise with a boolean set to if the standing matrix is supported.
  95709. */
  95710. useStandingMatrixAsync(): Promise<boolean>;
  95711. /**
  95712. * Disposes the camera
  95713. */
  95714. dispose(): void;
  95715. /**
  95716. * Gets a vrController by name.
  95717. * @param name The name of the controller to retreive
  95718. * @returns the controller matching the name specified or null if not found
  95719. */
  95720. getControllerByName(name: string): Nullable<WebVRController>;
  95721. private _leftController;
  95722. /**
  95723. * The controller corresponding to the users left hand.
  95724. */
  95725. get leftController(): Nullable<WebVRController>;
  95726. private _rightController;
  95727. /**
  95728. * The controller corresponding to the users right hand.
  95729. */
  95730. get rightController(): Nullable<WebVRController>;
  95731. /**
  95732. * Casts a ray forward from the vrCamera's gaze.
  95733. * @param length Length of the ray (default: 100)
  95734. * @returns the ray corresponding to the gaze
  95735. */
  95736. getForwardRay(length?: number): Ray;
  95737. /**
  95738. * @hidden
  95739. * Updates the camera based on device's frame data
  95740. */
  95741. _checkInputs(): void;
  95742. /**
  95743. * Updates the poseControlled values based on the input device pose.
  95744. * @param poseData Pose coming from the device
  95745. */
  95746. updateFromDevice(poseData: DevicePose): void;
  95747. private _htmlElementAttached;
  95748. private _detachIfAttached;
  95749. /**
  95750. * WebVR's attach control will start broadcasting frames to the device.
  95751. * Note that in certain browsers (chrome for example) this function must be called
  95752. * within a user-interaction callback. Example:
  95753. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  95754. *
  95755. * @param element html element to attach the vrDevice to
  95756. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  95757. */
  95758. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  95759. /**
  95760. * Detaches the camera from the html element and disables VR
  95761. *
  95762. * @param element html element to detach from
  95763. */
  95764. detachControl(element: HTMLElement): void;
  95765. /**
  95766. * @returns the name of this class
  95767. */
  95768. getClassName(): string;
  95769. /**
  95770. * Calls resetPose on the vrDisplay
  95771. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  95772. */
  95773. resetToCurrentRotation(): void;
  95774. /**
  95775. * @hidden
  95776. * Updates the rig cameras (left and right eye)
  95777. */
  95778. _updateRigCameras(): void;
  95779. private _workingVector;
  95780. private _oneVector;
  95781. private _workingMatrix;
  95782. private updateCacheCalled;
  95783. private _correctPositionIfNotTrackPosition;
  95784. /**
  95785. * @hidden
  95786. * Updates the cached values of the camera
  95787. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  95788. */
  95789. _updateCache(ignoreParentClass?: boolean): void;
  95790. /**
  95791. * @hidden
  95792. * Get current device position in babylon world
  95793. */
  95794. _computeDevicePosition(): void;
  95795. /**
  95796. * Updates the current device position and rotation in the babylon world
  95797. */
  95798. update(): void;
  95799. /**
  95800. * @hidden
  95801. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  95802. * @returns an identity matrix
  95803. */
  95804. _getViewMatrix(): Matrix;
  95805. private _tmpMatrix;
  95806. /**
  95807. * This function is called by the two RIG cameras.
  95808. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  95809. * @hidden
  95810. */
  95811. _getWebVRViewMatrix(): Matrix;
  95812. /** @hidden */
  95813. _getWebVRProjectionMatrix(): Matrix;
  95814. private _onGamepadConnectedObserver;
  95815. private _onGamepadDisconnectedObserver;
  95816. private _updateCacheWhenTrackingDisabledObserver;
  95817. /**
  95818. * Initializes the controllers and their meshes
  95819. */
  95820. initControllers(): void;
  95821. }
  95822. }
  95823. declare module BABYLON {
  95824. /**
  95825. * Size options for a post process
  95826. */
  95827. export type PostProcessOptions = {
  95828. width: number;
  95829. height: number;
  95830. };
  95831. /**
  95832. * PostProcess can be used to apply a shader to a texture after it has been rendered
  95833. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  95834. */
  95835. export class PostProcess {
  95836. /** Name of the PostProcess. */
  95837. name: string;
  95838. /**
  95839. * Gets or sets the unique id of the post process
  95840. */
  95841. uniqueId: number;
  95842. /**
  95843. * Width of the texture to apply the post process on
  95844. */
  95845. width: number;
  95846. /**
  95847. * Height of the texture to apply the post process on
  95848. */
  95849. height: number;
  95850. /**
  95851. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  95852. * @hidden
  95853. */
  95854. _outputTexture: Nullable<InternalTexture>;
  95855. /**
  95856. * Sampling mode used by the shader
  95857. * See https://doc.babylonjs.com/classes/3.1/texture
  95858. */
  95859. renderTargetSamplingMode: number;
  95860. /**
  95861. * Clear color to use when screen clearing
  95862. */
  95863. clearColor: Color4;
  95864. /**
  95865. * If the buffer needs to be cleared before applying the post process. (default: true)
  95866. * Should be set to false if shader will overwrite all previous pixels.
  95867. */
  95868. autoClear: boolean;
  95869. /**
  95870. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  95871. */
  95872. alphaMode: number;
  95873. /**
  95874. * Sets the setAlphaBlendConstants of the babylon engine
  95875. */
  95876. alphaConstants: Color4;
  95877. /**
  95878. * Animations to be used for the post processing
  95879. */
  95880. animations: Animation[];
  95881. /**
  95882. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  95883. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  95884. */
  95885. enablePixelPerfectMode: boolean;
  95886. /**
  95887. * Force the postprocess to be applied without taking in account viewport
  95888. */
  95889. forceFullscreenViewport: boolean;
  95890. /**
  95891. * List of inspectable custom properties (used by the Inspector)
  95892. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  95893. */
  95894. inspectableCustomProperties: IInspectable[];
  95895. /**
  95896. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  95897. *
  95898. * | Value | Type | Description |
  95899. * | ----- | ----------------------------------- | ----------- |
  95900. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  95901. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  95902. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  95903. *
  95904. */
  95905. scaleMode: number;
  95906. /**
  95907. * Force textures to be a power of two (default: false)
  95908. */
  95909. alwaysForcePOT: boolean;
  95910. private _samples;
  95911. /**
  95912. * Number of sample textures (default: 1)
  95913. */
  95914. get samples(): number;
  95915. set samples(n: number);
  95916. /**
  95917. * Modify the scale of the post process to be the same as the viewport (default: false)
  95918. */
  95919. adaptScaleToCurrentViewport: boolean;
  95920. private _camera;
  95921. private _scene;
  95922. private _engine;
  95923. private _options;
  95924. private _reusable;
  95925. private _textureType;
  95926. private _textureFormat;
  95927. /**
  95928. * Smart array of input and output textures for the post process.
  95929. * @hidden
  95930. */
  95931. _textures: SmartArray<InternalTexture>;
  95932. /**
  95933. * The index in _textures that corresponds to the output texture.
  95934. * @hidden
  95935. */
  95936. _currentRenderTextureInd: number;
  95937. private _effect;
  95938. private _samplers;
  95939. private _fragmentUrl;
  95940. private _vertexUrl;
  95941. private _parameters;
  95942. private _scaleRatio;
  95943. protected _indexParameters: any;
  95944. private _shareOutputWithPostProcess;
  95945. private _texelSize;
  95946. private _forcedOutputTexture;
  95947. /**
  95948. * Returns the fragment url or shader name used in the post process.
  95949. * @returns the fragment url or name in the shader store.
  95950. */
  95951. getEffectName(): string;
  95952. /**
  95953. * An event triggered when the postprocess is activated.
  95954. */
  95955. onActivateObservable: Observable<Camera>;
  95956. private _onActivateObserver;
  95957. /**
  95958. * A function that is added to the onActivateObservable
  95959. */
  95960. set onActivate(callback: Nullable<(camera: Camera) => void>);
  95961. /**
  95962. * An event triggered when the postprocess changes its size.
  95963. */
  95964. onSizeChangedObservable: Observable<PostProcess>;
  95965. private _onSizeChangedObserver;
  95966. /**
  95967. * A function that is added to the onSizeChangedObservable
  95968. */
  95969. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  95970. /**
  95971. * An event triggered when the postprocess applies its effect.
  95972. */
  95973. onApplyObservable: Observable<Effect>;
  95974. private _onApplyObserver;
  95975. /**
  95976. * A function that is added to the onApplyObservable
  95977. */
  95978. set onApply(callback: (effect: Effect) => void);
  95979. /**
  95980. * An event triggered before rendering the postprocess
  95981. */
  95982. onBeforeRenderObservable: Observable<Effect>;
  95983. private _onBeforeRenderObserver;
  95984. /**
  95985. * A function that is added to the onBeforeRenderObservable
  95986. */
  95987. set onBeforeRender(callback: (effect: Effect) => void);
  95988. /**
  95989. * An event triggered after rendering the postprocess
  95990. */
  95991. onAfterRenderObservable: Observable<Effect>;
  95992. private _onAfterRenderObserver;
  95993. /**
  95994. * A function that is added to the onAfterRenderObservable
  95995. */
  95996. set onAfterRender(callback: (efect: Effect) => void);
  95997. /**
  95998. * 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
  95999. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  96000. */
  96001. get inputTexture(): InternalTexture;
  96002. set inputTexture(value: InternalTexture);
  96003. /**
  96004. * Gets the camera which post process is applied to.
  96005. * @returns The camera the post process is applied to.
  96006. */
  96007. getCamera(): Camera;
  96008. /**
  96009. * Gets the texel size of the postprocess.
  96010. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  96011. */
  96012. get texelSize(): Vector2;
  96013. /**
  96014. * Creates a new instance PostProcess
  96015. * @param name The name of the PostProcess.
  96016. * @param fragmentUrl The url of the fragment shader to be used.
  96017. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  96018. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  96019. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  96020. * @param camera The camera to apply the render pass to.
  96021. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  96022. * @param engine The engine which the post process will be applied. (default: current engine)
  96023. * @param reusable If the post process can be reused on the same frame. (default: false)
  96024. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  96025. * @param textureType Type of textures used when performing the post process. (default: 0)
  96026. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  96027. * @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
  96028. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  96029. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  96030. */
  96031. constructor(
  96032. /** Name of the PostProcess. */
  96033. 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);
  96034. /**
  96035. * Gets a string idenfifying the name of the class
  96036. * @returns "PostProcess" string
  96037. */
  96038. getClassName(): string;
  96039. /**
  96040. * Gets the engine which this post process belongs to.
  96041. * @returns The engine the post process was enabled with.
  96042. */
  96043. getEngine(): Engine;
  96044. /**
  96045. * The effect that is created when initializing the post process.
  96046. * @returns The created effect corresponding the the postprocess.
  96047. */
  96048. getEffect(): Effect;
  96049. /**
  96050. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  96051. * @param postProcess The post process to share the output with.
  96052. * @returns This post process.
  96053. */
  96054. shareOutputWith(postProcess: PostProcess): PostProcess;
  96055. /**
  96056. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  96057. * This should be called if the post process that shares output with this post process is disabled/disposed.
  96058. */
  96059. useOwnOutput(): void;
  96060. /**
  96061. * Updates the effect with the current post process compile time values and recompiles the shader.
  96062. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  96063. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  96064. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  96065. * @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
  96066. * @param onCompiled Called when the shader has been compiled.
  96067. * @param onError Called if there is an error when compiling a shader.
  96068. * @param vertexUrl The url of the vertex shader to be used (default: the one given at construction time)
  96069. * @param fragmentUrl The url of the fragment shader to be used (default: the one given at construction time)
  96070. */
  96071. 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;
  96072. /**
  96073. * The post process is reusable if it can be used multiple times within one frame.
  96074. * @returns If the post process is reusable
  96075. */
  96076. isReusable(): boolean;
  96077. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  96078. markTextureDirty(): void;
  96079. /**
  96080. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  96081. * 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.
  96082. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  96083. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  96084. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  96085. * @returns The target texture that was bound to be written to.
  96086. */
  96087. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  96088. /**
  96089. * If the post process is supported.
  96090. */
  96091. get isSupported(): boolean;
  96092. /**
  96093. * The aspect ratio of the output texture.
  96094. */
  96095. get aspectRatio(): number;
  96096. /**
  96097. * Get a value indicating if the post-process is ready to be used
  96098. * @returns true if the post-process is ready (shader is compiled)
  96099. */
  96100. isReady(): boolean;
  96101. /**
  96102. * Binds all textures and uniforms to the shader, this will be run on every pass.
  96103. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  96104. */
  96105. apply(): Nullable<Effect>;
  96106. private _disposeTextures;
  96107. /**
  96108. * Disposes the post process.
  96109. * @param camera The camera to dispose the post process on.
  96110. */
  96111. dispose(camera?: Camera): void;
  96112. }
  96113. }
  96114. declare module BABYLON {
  96115. /** @hidden */
  96116. export var kernelBlurVaryingDeclaration: {
  96117. name: string;
  96118. shader: string;
  96119. };
  96120. }
  96121. declare module BABYLON {
  96122. /** @hidden */
  96123. export var kernelBlurFragment: {
  96124. name: string;
  96125. shader: string;
  96126. };
  96127. }
  96128. declare module BABYLON {
  96129. /** @hidden */
  96130. export var kernelBlurFragment2: {
  96131. name: string;
  96132. shader: string;
  96133. };
  96134. }
  96135. declare module BABYLON {
  96136. /** @hidden */
  96137. export var kernelBlurPixelShader: {
  96138. name: string;
  96139. shader: string;
  96140. };
  96141. }
  96142. declare module BABYLON {
  96143. /** @hidden */
  96144. export var kernelBlurVertex: {
  96145. name: string;
  96146. shader: string;
  96147. };
  96148. }
  96149. declare module BABYLON {
  96150. /** @hidden */
  96151. export var kernelBlurVertexShader: {
  96152. name: string;
  96153. shader: string;
  96154. };
  96155. }
  96156. declare module BABYLON {
  96157. /**
  96158. * The Blur Post Process which blurs an image based on a kernel and direction.
  96159. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  96160. */
  96161. export class BlurPostProcess extends PostProcess {
  96162. /** The direction in which to blur the image. */
  96163. direction: Vector2;
  96164. private blockCompilation;
  96165. protected _kernel: number;
  96166. protected _idealKernel: number;
  96167. protected _packedFloat: boolean;
  96168. private _staticDefines;
  96169. /**
  96170. * Sets the length in pixels of the blur sample region
  96171. */
  96172. set kernel(v: number);
  96173. /**
  96174. * Gets the length in pixels of the blur sample region
  96175. */
  96176. get kernel(): number;
  96177. /**
  96178. * Sets wether or not the blur needs to unpack/repack floats
  96179. */
  96180. set packedFloat(v: boolean);
  96181. /**
  96182. * Gets wether or not the blur is unpacking/repacking floats
  96183. */
  96184. get packedFloat(): boolean;
  96185. /**
  96186. * Creates a new instance BlurPostProcess
  96187. * @param name The name of the effect.
  96188. * @param direction The direction in which to blur the image.
  96189. * @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.
  96190. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  96191. * @param camera The camera to apply the render pass to.
  96192. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  96193. * @param engine The engine which the post process will be applied. (default: current engine)
  96194. * @param reusable If the post process can be reused on the same frame. (default: false)
  96195. * @param textureType Type of textures used when performing the post process. (default: 0)
  96196. * @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)
  96197. */
  96198. constructor(name: string,
  96199. /** The direction in which to blur the image. */
  96200. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  96201. /**
  96202. * Updates the effect with the current post process compile time values and recompiles the shader.
  96203. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  96204. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  96205. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  96206. * @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
  96207. * @param onCompiled Called when the shader has been compiled.
  96208. * @param onError Called if there is an error when compiling a shader.
  96209. */
  96210. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  96211. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  96212. /**
  96213. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  96214. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  96215. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  96216. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  96217. * The gaps between physical kernels are compensated for in the weighting of the samples
  96218. * @param idealKernel Ideal blur kernel.
  96219. * @return Nearest best kernel.
  96220. */
  96221. protected _nearestBestKernel(idealKernel: number): number;
  96222. /**
  96223. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  96224. * @param x The point on the Gaussian distribution to sample.
  96225. * @return the value of the Gaussian function at x.
  96226. */
  96227. protected _gaussianWeight(x: number): number;
  96228. /**
  96229. * Generates a string that can be used as a floating point number in GLSL.
  96230. * @param x Value to print.
  96231. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  96232. * @return GLSL float string.
  96233. */
  96234. protected _glslFloat(x: number, decimalFigures?: number): string;
  96235. }
  96236. }
  96237. declare module BABYLON {
  96238. /**
  96239. * Mirror texture can be used to simulate the view from a mirror in a scene.
  96240. * It will dynamically be rendered every frame to adapt to the camera point of view.
  96241. * You can then easily use it as a reflectionTexture on a flat surface.
  96242. * In case the surface is not a plane, please consider relying on reflection probes.
  96243. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  96244. */
  96245. export class MirrorTexture extends RenderTargetTexture {
  96246. private scene;
  96247. /**
  96248. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  96249. * 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.
  96250. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  96251. */
  96252. mirrorPlane: Plane;
  96253. /**
  96254. * Define the blur ratio used to blur the reflection if needed.
  96255. */
  96256. set blurRatio(value: number);
  96257. get blurRatio(): number;
  96258. /**
  96259. * Define the adaptive blur kernel used to blur the reflection if needed.
  96260. * This will autocompute the closest best match for the `blurKernel`
  96261. */
  96262. set adaptiveBlurKernel(value: number);
  96263. /**
  96264. * Define the blur kernel used to blur the reflection if needed.
  96265. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  96266. */
  96267. set blurKernel(value: number);
  96268. /**
  96269. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  96270. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  96271. */
  96272. set blurKernelX(value: number);
  96273. get blurKernelX(): number;
  96274. /**
  96275. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  96276. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  96277. */
  96278. set blurKernelY(value: number);
  96279. get blurKernelY(): number;
  96280. private _autoComputeBlurKernel;
  96281. protected _onRatioRescale(): void;
  96282. private _updateGammaSpace;
  96283. private _imageProcessingConfigChangeObserver;
  96284. private _transformMatrix;
  96285. private _mirrorMatrix;
  96286. private _savedViewMatrix;
  96287. private _blurX;
  96288. private _blurY;
  96289. private _adaptiveBlurKernel;
  96290. private _blurKernelX;
  96291. private _blurKernelY;
  96292. private _blurRatio;
  96293. /**
  96294. * Instantiates a Mirror Texture.
  96295. * Mirror texture can be used to simulate the view from a mirror in a scene.
  96296. * It will dynamically be rendered every frame to adapt to the camera point of view.
  96297. * You can then easily use it as a reflectionTexture on a flat surface.
  96298. * In case the surface is not a plane, please consider relying on reflection probes.
  96299. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  96300. * @param name
  96301. * @param size
  96302. * @param scene
  96303. * @param generateMipMaps
  96304. * @param type
  96305. * @param samplingMode
  96306. * @param generateDepthBuffer
  96307. */
  96308. constructor(name: string, size: number | {
  96309. width: number;
  96310. height: number;
  96311. } | {
  96312. ratio: number;
  96313. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  96314. private _preparePostProcesses;
  96315. /**
  96316. * Clone the mirror texture.
  96317. * @returns the cloned texture
  96318. */
  96319. clone(): MirrorTexture;
  96320. /**
  96321. * Serialize the texture to a JSON representation you could use in Parse later on
  96322. * @returns the serialized JSON representation
  96323. */
  96324. serialize(): any;
  96325. /**
  96326. * Dispose the texture and release its associated resources.
  96327. */
  96328. dispose(): void;
  96329. }
  96330. }
  96331. declare module BABYLON {
  96332. /**
  96333. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  96334. * @see http://doc.babylonjs.com/babylon101/materials#texture
  96335. */
  96336. export class Texture extends BaseTexture {
  96337. /**
  96338. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  96339. */
  96340. static SerializeBuffers: boolean;
  96341. /** @hidden */
  96342. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  96343. /** @hidden */
  96344. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  96345. /** @hidden */
  96346. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  96347. /** nearest is mag = nearest and min = nearest and mip = linear */
  96348. static readonly NEAREST_SAMPLINGMODE: number;
  96349. /** nearest is mag = nearest and min = nearest and mip = linear */
  96350. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  96351. /** Bilinear is mag = linear and min = linear and mip = nearest */
  96352. static readonly BILINEAR_SAMPLINGMODE: number;
  96353. /** Bilinear is mag = linear and min = linear and mip = nearest */
  96354. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  96355. /** Trilinear is mag = linear and min = linear and mip = linear */
  96356. static readonly TRILINEAR_SAMPLINGMODE: number;
  96357. /** Trilinear is mag = linear and min = linear and mip = linear */
  96358. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  96359. /** mag = nearest and min = nearest and mip = nearest */
  96360. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  96361. /** mag = nearest and min = linear and mip = nearest */
  96362. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  96363. /** mag = nearest and min = linear and mip = linear */
  96364. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  96365. /** mag = nearest and min = linear and mip = none */
  96366. static readonly NEAREST_LINEAR: number;
  96367. /** mag = nearest and min = nearest and mip = none */
  96368. static readonly NEAREST_NEAREST: number;
  96369. /** mag = linear and min = nearest and mip = nearest */
  96370. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  96371. /** mag = linear and min = nearest and mip = linear */
  96372. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  96373. /** mag = linear and min = linear and mip = none */
  96374. static readonly LINEAR_LINEAR: number;
  96375. /** mag = linear and min = nearest and mip = none */
  96376. static readonly LINEAR_NEAREST: number;
  96377. /** Explicit coordinates mode */
  96378. static readonly EXPLICIT_MODE: number;
  96379. /** Spherical coordinates mode */
  96380. static readonly SPHERICAL_MODE: number;
  96381. /** Planar coordinates mode */
  96382. static readonly PLANAR_MODE: number;
  96383. /** Cubic coordinates mode */
  96384. static readonly CUBIC_MODE: number;
  96385. /** Projection coordinates mode */
  96386. static readonly PROJECTION_MODE: number;
  96387. /** Inverse Cubic coordinates mode */
  96388. static readonly SKYBOX_MODE: number;
  96389. /** Inverse Cubic coordinates mode */
  96390. static readonly INVCUBIC_MODE: number;
  96391. /** Equirectangular coordinates mode */
  96392. static readonly EQUIRECTANGULAR_MODE: number;
  96393. /** Equirectangular Fixed coordinates mode */
  96394. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  96395. /** Equirectangular Fixed Mirrored coordinates mode */
  96396. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  96397. /** Texture is not repeating outside of 0..1 UVs */
  96398. static readonly CLAMP_ADDRESSMODE: number;
  96399. /** Texture is repeating outside of 0..1 UVs */
  96400. static readonly WRAP_ADDRESSMODE: number;
  96401. /** Texture is repeating and mirrored */
  96402. static readonly MIRROR_ADDRESSMODE: number;
  96403. /**
  96404. * 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
  96405. */
  96406. static UseSerializedUrlIfAny: boolean;
  96407. /**
  96408. * Define the url of the texture.
  96409. */
  96410. url: Nullable<string>;
  96411. /**
  96412. * Define an offset on the texture to offset the u coordinates of the UVs
  96413. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  96414. */
  96415. uOffset: number;
  96416. /**
  96417. * Define an offset on the texture to offset the v coordinates of the UVs
  96418. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  96419. */
  96420. vOffset: number;
  96421. /**
  96422. * Define an offset on the texture to scale the u coordinates of the UVs
  96423. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  96424. */
  96425. uScale: number;
  96426. /**
  96427. * Define an offset on the texture to scale the v coordinates of the UVs
  96428. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  96429. */
  96430. vScale: number;
  96431. /**
  96432. * Define an offset on the texture to rotate around the u coordinates of the UVs
  96433. * @see http://doc.babylonjs.com/how_to/more_materials
  96434. */
  96435. uAng: number;
  96436. /**
  96437. * Define an offset on the texture to rotate around the v coordinates of the UVs
  96438. * @see http://doc.babylonjs.com/how_to/more_materials
  96439. */
  96440. vAng: number;
  96441. /**
  96442. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  96443. * @see http://doc.babylonjs.com/how_to/more_materials
  96444. */
  96445. wAng: number;
  96446. /**
  96447. * Defines the center of rotation (U)
  96448. */
  96449. uRotationCenter: number;
  96450. /**
  96451. * Defines the center of rotation (V)
  96452. */
  96453. vRotationCenter: number;
  96454. /**
  96455. * Defines the center of rotation (W)
  96456. */
  96457. wRotationCenter: number;
  96458. /**
  96459. * Are mip maps generated for this texture or not.
  96460. */
  96461. get noMipmap(): boolean;
  96462. /**
  96463. * List of inspectable custom properties (used by the Inspector)
  96464. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  96465. */
  96466. inspectableCustomProperties: Nullable<IInspectable[]>;
  96467. private _noMipmap;
  96468. /** @hidden */
  96469. _invertY: boolean;
  96470. private _rowGenerationMatrix;
  96471. private _cachedTextureMatrix;
  96472. private _projectionModeMatrix;
  96473. private _t0;
  96474. private _t1;
  96475. private _t2;
  96476. private _cachedUOffset;
  96477. private _cachedVOffset;
  96478. private _cachedUScale;
  96479. private _cachedVScale;
  96480. private _cachedUAng;
  96481. private _cachedVAng;
  96482. private _cachedWAng;
  96483. private _cachedProjectionMatrixId;
  96484. private _cachedCoordinatesMode;
  96485. /** @hidden */
  96486. protected _initialSamplingMode: number;
  96487. /** @hidden */
  96488. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  96489. private _deleteBuffer;
  96490. protected _format: Nullable<number>;
  96491. private _delayedOnLoad;
  96492. private _delayedOnError;
  96493. private _mimeType?;
  96494. /**
  96495. * Observable triggered once the texture has been loaded.
  96496. */
  96497. onLoadObservable: Observable<Texture>;
  96498. protected _isBlocking: boolean;
  96499. /**
  96500. * Is the texture preventing material to render while loading.
  96501. * If false, a default texture will be used instead of the loading one during the preparation step.
  96502. */
  96503. set isBlocking(value: boolean);
  96504. get isBlocking(): boolean;
  96505. /**
  96506. * Get the current sampling mode associated with the texture.
  96507. */
  96508. get samplingMode(): number;
  96509. /**
  96510. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  96511. */
  96512. get invertY(): boolean;
  96513. /**
  96514. * Instantiates a new texture.
  96515. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  96516. * @see http://doc.babylonjs.com/babylon101/materials#texture
  96517. * @param url defines the url of the picture to load as a texture
  96518. * @param sceneOrEngine defines the scene or engine the texture will belong to
  96519. * @param noMipmap defines if the texture will require mip maps or not
  96520. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  96521. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  96522. * @param onLoad defines a callback triggered when the texture has been loaded
  96523. * @param onError defines a callback triggered when an error occurred during the loading session
  96524. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  96525. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  96526. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  96527. * @param mimeType defines an optional mime type information
  96528. */
  96529. 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);
  96530. /**
  96531. * Update the url (and optional buffer) of this texture if url was null during construction.
  96532. * @param url the url of the texture
  96533. * @param buffer the buffer of the texture (defaults to null)
  96534. * @param onLoad callback called when the texture is loaded (defaults to null)
  96535. */
  96536. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  96537. /**
  96538. * Finish the loading sequence of a texture flagged as delayed load.
  96539. * @hidden
  96540. */
  96541. delayLoad(): void;
  96542. private _prepareRowForTextureGeneration;
  96543. /**
  96544. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  96545. * @returns the transform matrix of the texture.
  96546. */
  96547. getTextureMatrix(uBase?: number): Matrix;
  96548. /**
  96549. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  96550. * @returns The reflection texture transform
  96551. */
  96552. getReflectionTextureMatrix(): Matrix;
  96553. /**
  96554. * Clones the texture.
  96555. * @returns the cloned texture
  96556. */
  96557. clone(): Texture;
  96558. /**
  96559. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  96560. * @returns The JSON representation of the texture
  96561. */
  96562. serialize(): any;
  96563. /**
  96564. * Get the current class name of the texture useful for serialization or dynamic coding.
  96565. * @returns "Texture"
  96566. */
  96567. getClassName(): string;
  96568. /**
  96569. * Dispose the texture and release its associated resources.
  96570. */
  96571. dispose(): void;
  96572. /**
  96573. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  96574. * @param parsedTexture Define the JSON representation of the texture
  96575. * @param scene Define the scene the parsed texture should be instantiated in
  96576. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  96577. * @returns The parsed texture if successful
  96578. */
  96579. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  96580. /**
  96581. * Creates a texture from its base 64 representation.
  96582. * @param data Define the base64 payload without the data: prefix
  96583. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  96584. * @param scene Define the scene the texture should belong to
  96585. * @param noMipmap Forces the texture to not create mip map information if true
  96586. * @param invertY define if the texture needs to be inverted on the y axis during loading
  96587. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  96588. * @param onLoad define a callback triggered when the texture has been loaded
  96589. * @param onError define a callback triggered when an error occurred during the loading session
  96590. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  96591. * @returns the created texture
  96592. */
  96593. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  96594. /**
  96595. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  96596. * @param data Define the base64 payload without the data: prefix
  96597. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  96598. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  96599. * @param scene Define the scene the texture should belong to
  96600. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  96601. * @param noMipmap Forces the texture to not create mip map information if true
  96602. * @param invertY define if the texture needs to be inverted on the y axis during loading
  96603. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  96604. * @param onLoad define a callback triggered when the texture has been loaded
  96605. * @param onError define a callback triggered when an error occurred during the loading session
  96606. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  96607. * @returns the created texture
  96608. */
  96609. 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;
  96610. }
  96611. }
  96612. declare module BABYLON {
  96613. /**
  96614. * PostProcessManager is used to manage one or more post processes or post process pipelines
  96615. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  96616. */
  96617. export class PostProcessManager {
  96618. private _scene;
  96619. private _indexBuffer;
  96620. private _vertexBuffers;
  96621. /**
  96622. * Creates a new instance PostProcess
  96623. * @param scene The scene that the post process is associated with.
  96624. */
  96625. constructor(scene: Scene);
  96626. private _prepareBuffers;
  96627. private _buildIndexBuffer;
  96628. /**
  96629. * Rebuilds the vertex buffers of the manager.
  96630. * @hidden
  96631. */
  96632. _rebuild(): void;
  96633. /**
  96634. * Prepares a frame to be run through a post process.
  96635. * @param sourceTexture The input texture to the post procesess. (default: null)
  96636. * @param postProcesses An array of post processes to be run. (default: null)
  96637. * @returns True if the post processes were able to be run.
  96638. * @hidden
  96639. */
  96640. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  96641. /**
  96642. * Manually render a set of post processes to a texture.
  96643. * Please note, the frame buffer won't be unbound after the call in case you have more render to do.
  96644. * @param postProcesses An array of post processes to be run.
  96645. * @param targetTexture The target texture to render to.
  96646. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  96647. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  96648. * @param lodLevel defines which lod of the texture to render to
  96649. */
  96650. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  96651. /**
  96652. * Finalize the result of the output of the postprocesses.
  96653. * @param doNotPresent If true the result will not be displayed to the screen.
  96654. * @param targetTexture The target texture to render to.
  96655. * @param faceIndex The index of the face to bind the target texture to.
  96656. * @param postProcesses The array of post processes to render.
  96657. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  96658. * @hidden
  96659. */
  96660. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  96661. /**
  96662. * Disposes of the post process manager.
  96663. */
  96664. dispose(): void;
  96665. }
  96666. }
  96667. declare module BABYLON {
  96668. /**
  96669. * This Helps creating a texture that will be created from a camera in your scene.
  96670. * It is basically a dynamic texture that could be used to create special effects for instance.
  96671. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  96672. */
  96673. export class RenderTargetTexture extends Texture {
  96674. isCube: boolean;
  96675. /**
  96676. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  96677. */
  96678. static readonly REFRESHRATE_RENDER_ONCE: number;
  96679. /**
  96680. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  96681. */
  96682. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  96683. /**
  96684. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  96685. * the central point of your effect and can save a lot of performances.
  96686. */
  96687. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  96688. /**
  96689. * Use this predicate to dynamically define the list of mesh you want to render.
  96690. * If set, the renderList property will be overwritten.
  96691. */
  96692. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  96693. private _renderList;
  96694. /**
  96695. * Use this list to define the list of mesh you want to render.
  96696. */
  96697. get renderList(): Nullable<Array<AbstractMesh>>;
  96698. set renderList(value: Nullable<Array<AbstractMesh>>);
  96699. /**
  96700. * Use this function to overload the renderList array at rendering time.
  96701. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  96702. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  96703. * the cube (if the RTT is a cube, else layerOrFace=0).
  96704. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  96705. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  96706. * hold dummy elements!
  96707. */
  96708. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  96709. private _hookArray;
  96710. /**
  96711. * Define if particles should be rendered in your texture.
  96712. */
  96713. renderParticles: boolean;
  96714. /**
  96715. * Define if sprites should be rendered in your texture.
  96716. */
  96717. renderSprites: boolean;
  96718. /**
  96719. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  96720. */
  96721. coordinatesMode: number;
  96722. /**
  96723. * Define the camera used to render the texture.
  96724. */
  96725. activeCamera: Nullable<Camera>;
  96726. /**
  96727. * Override the mesh isReady function with your own one.
  96728. */
  96729. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  96730. /**
  96731. * Override the render function of the texture with your own one.
  96732. */
  96733. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  96734. /**
  96735. * Define if camera post processes should be use while rendering the texture.
  96736. */
  96737. useCameraPostProcesses: boolean;
  96738. /**
  96739. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  96740. */
  96741. ignoreCameraViewport: boolean;
  96742. private _postProcessManager;
  96743. private _postProcesses;
  96744. private _resizeObserver;
  96745. /**
  96746. * An event triggered when the texture is unbind.
  96747. */
  96748. onBeforeBindObservable: Observable<RenderTargetTexture>;
  96749. /**
  96750. * An event triggered when the texture is unbind.
  96751. */
  96752. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  96753. private _onAfterUnbindObserver;
  96754. /**
  96755. * Set a after unbind callback in the texture.
  96756. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  96757. */
  96758. set onAfterUnbind(callback: () => void);
  96759. /**
  96760. * An event triggered before rendering the texture
  96761. */
  96762. onBeforeRenderObservable: Observable<number>;
  96763. private _onBeforeRenderObserver;
  96764. /**
  96765. * Set a before render callback in the texture.
  96766. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  96767. */
  96768. set onBeforeRender(callback: (faceIndex: number) => void);
  96769. /**
  96770. * An event triggered after rendering the texture
  96771. */
  96772. onAfterRenderObservable: Observable<number>;
  96773. private _onAfterRenderObserver;
  96774. /**
  96775. * Set a after render callback in the texture.
  96776. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  96777. */
  96778. set onAfterRender(callback: (faceIndex: number) => void);
  96779. /**
  96780. * An event triggered after the texture clear
  96781. */
  96782. onClearObservable: Observable<Engine>;
  96783. private _onClearObserver;
  96784. /**
  96785. * Set a clear callback in the texture.
  96786. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  96787. */
  96788. set onClear(callback: (Engine: Engine) => void);
  96789. /**
  96790. * An event triggered when the texture is resized.
  96791. */
  96792. onResizeObservable: Observable<RenderTargetTexture>;
  96793. /**
  96794. * Define the clear color of the Render Target if it should be different from the scene.
  96795. */
  96796. clearColor: Color4;
  96797. protected _size: number | {
  96798. width: number;
  96799. height: number;
  96800. layers?: number;
  96801. };
  96802. protected _initialSizeParameter: number | {
  96803. width: number;
  96804. height: number;
  96805. } | {
  96806. ratio: number;
  96807. };
  96808. protected _sizeRatio: Nullable<number>;
  96809. /** @hidden */
  96810. _generateMipMaps: boolean;
  96811. protected _renderingManager: RenderingManager;
  96812. /** @hidden */
  96813. _waitingRenderList: string[];
  96814. protected _doNotChangeAspectRatio: boolean;
  96815. protected _currentRefreshId: number;
  96816. protected _refreshRate: number;
  96817. protected _textureMatrix: Matrix;
  96818. protected _samples: number;
  96819. protected _renderTargetOptions: RenderTargetCreationOptions;
  96820. /**
  96821. * Gets render target creation options that were used.
  96822. */
  96823. get renderTargetOptions(): RenderTargetCreationOptions;
  96824. protected _onRatioRescale(): void;
  96825. /**
  96826. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  96827. * It must define where the camera used to render the texture is set
  96828. */
  96829. boundingBoxPosition: Vector3;
  96830. private _boundingBoxSize;
  96831. /**
  96832. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  96833. * When defined, the cubemap will switch to local mode
  96834. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  96835. * @example https://www.babylonjs-playground.com/#RNASML
  96836. */
  96837. set boundingBoxSize(value: Vector3);
  96838. get boundingBoxSize(): Vector3;
  96839. /**
  96840. * In case the RTT has been created with a depth texture, get the associated
  96841. * depth texture.
  96842. * Otherwise, return null.
  96843. */
  96844. get depthStencilTexture(): Nullable<InternalTexture>;
  96845. /**
  96846. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  96847. * or used a shadow, depth texture...
  96848. * @param name The friendly name of the texture
  96849. * @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)
  96850. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  96851. * @param generateMipMaps True if mip maps need to be generated after render.
  96852. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  96853. * @param type The type of the buffer in the RTT (int, half float, float...)
  96854. * @param isCube True if a cube texture needs to be created
  96855. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  96856. * @param generateDepthBuffer True to generate a depth buffer
  96857. * @param generateStencilBuffer True to generate a stencil buffer
  96858. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  96859. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  96860. * @param delayAllocation if the texture allocation should be delayed (default: false)
  96861. */
  96862. constructor(name: string, size: number | {
  96863. width: number;
  96864. height: number;
  96865. layers?: number;
  96866. } | {
  96867. ratio: number;
  96868. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  96869. /**
  96870. * Creates a depth stencil texture.
  96871. * This is only available in WebGL 2 or with the depth texture extension available.
  96872. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  96873. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  96874. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  96875. */
  96876. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  96877. private _processSizeParameter;
  96878. /**
  96879. * Define the number of samples to use in case of MSAA.
  96880. * It defaults to one meaning no MSAA has been enabled.
  96881. */
  96882. get samples(): number;
  96883. set samples(value: number);
  96884. /**
  96885. * Resets the refresh counter of the texture and start bak from scratch.
  96886. * Could be useful to regenerate the texture if it is setup to render only once.
  96887. */
  96888. resetRefreshCounter(): void;
  96889. /**
  96890. * Define the refresh rate of the texture or the rendering frequency.
  96891. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  96892. */
  96893. get refreshRate(): number;
  96894. set refreshRate(value: number);
  96895. /**
  96896. * Adds a post process to the render target rendering passes.
  96897. * @param postProcess define the post process to add
  96898. */
  96899. addPostProcess(postProcess: PostProcess): void;
  96900. /**
  96901. * Clear all the post processes attached to the render target
  96902. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  96903. */
  96904. clearPostProcesses(dispose?: boolean): void;
  96905. /**
  96906. * Remove one of the post process from the list of attached post processes to the texture
  96907. * @param postProcess define the post process to remove from the list
  96908. */
  96909. removePostProcess(postProcess: PostProcess): void;
  96910. /** @hidden */
  96911. _shouldRender(): boolean;
  96912. /**
  96913. * Gets the actual render size of the texture.
  96914. * @returns the width of the render size
  96915. */
  96916. getRenderSize(): number;
  96917. /**
  96918. * Gets the actual render width of the texture.
  96919. * @returns the width of the render size
  96920. */
  96921. getRenderWidth(): number;
  96922. /**
  96923. * Gets the actual render height of the texture.
  96924. * @returns the height of the render size
  96925. */
  96926. getRenderHeight(): number;
  96927. /**
  96928. * Gets the actual number of layers of the texture.
  96929. * @returns the number of layers
  96930. */
  96931. getRenderLayers(): number;
  96932. /**
  96933. * Get if the texture can be rescaled or not.
  96934. */
  96935. get canRescale(): boolean;
  96936. /**
  96937. * Resize the texture using a ratio.
  96938. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  96939. */
  96940. scale(ratio: number): void;
  96941. /**
  96942. * Get the texture reflection matrix used to rotate/transform the reflection.
  96943. * @returns the reflection matrix
  96944. */
  96945. getReflectionTextureMatrix(): Matrix;
  96946. /**
  96947. * Resize the texture to a new desired size.
  96948. * Be carrefull as it will recreate all the data in the new texture.
  96949. * @param size Define the new size. It can be:
  96950. * - a number for squared texture,
  96951. * - an object containing { width: number, height: number }
  96952. * - or an object containing a ratio { ratio: number }
  96953. */
  96954. resize(size: number | {
  96955. width: number;
  96956. height: number;
  96957. } | {
  96958. ratio: number;
  96959. }): void;
  96960. private _defaultRenderListPrepared;
  96961. /**
  96962. * Renders all the objects from the render list into the texture.
  96963. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  96964. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  96965. */
  96966. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  96967. private _bestReflectionRenderTargetDimension;
  96968. private _prepareRenderingManager;
  96969. /**
  96970. * @hidden
  96971. * @param faceIndex face index to bind to if this is a cubetexture
  96972. * @param layer defines the index of the texture to bind in the array
  96973. */
  96974. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  96975. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  96976. private renderToTarget;
  96977. /**
  96978. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  96979. * This allowed control for front to back rendering or reversly depending of the special needs.
  96980. *
  96981. * @param renderingGroupId The rendering group id corresponding to its index
  96982. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  96983. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  96984. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  96985. */
  96986. 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;
  96987. /**
  96988. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  96989. *
  96990. * @param renderingGroupId The rendering group id corresponding to its index
  96991. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  96992. */
  96993. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  96994. /**
  96995. * Clones the texture.
  96996. * @returns the cloned texture
  96997. */
  96998. clone(): RenderTargetTexture;
  96999. /**
  97000. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  97001. * @returns The JSON representation of the texture
  97002. */
  97003. serialize(): any;
  97004. /**
  97005. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  97006. */
  97007. disposeFramebufferObjects(): void;
  97008. /**
  97009. * Dispose the texture and release its associated resources.
  97010. */
  97011. dispose(): void;
  97012. /** @hidden */
  97013. _rebuild(): void;
  97014. /**
  97015. * Clear the info related to rendering groups preventing retention point in material dispose.
  97016. */
  97017. freeRenderingGroups(): void;
  97018. /**
  97019. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  97020. * @returns the view count
  97021. */
  97022. getViewCount(): number;
  97023. }
  97024. }
  97025. declare module BABYLON {
  97026. /**
  97027. * Class used to manipulate GUIDs
  97028. */
  97029. export class GUID {
  97030. /**
  97031. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  97032. * Be aware Math.random() could cause collisions, but:
  97033. * "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"
  97034. * @returns a pseudo random id
  97035. */
  97036. static RandomId(): string;
  97037. }
  97038. }
  97039. declare module BABYLON {
  97040. /**
  97041. * Options to be used when creating a shadow depth material
  97042. */
  97043. export interface IIOptionShadowDepthMaterial {
  97044. /** Variables in the vertex shader code that need to have their names remapped.
  97045. * The format is: ["var_name", "var_remapped_name", "var_name", "var_remapped_name", ...]
  97046. * "var_name" should be either: worldPos or vNormalW
  97047. * So, if the variable holding the world position in your vertex shader is not named worldPos, you must tell the system
  97048. * the name to use instead by using: ["worldPos", "myWorldPosVar"] assuming the variable is named myWorldPosVar in your code.
  97049. * If the normal must also be remapped: ["worldPos", "myWorldPosVar", "vNormalW", "myWorldNormal"]
  97050. */
  97051. remappedVariables?: string[];
  97052. /** Set standalone to true if the base material wrapped by ShadowDepthMaterial is not used for a regular object but for depth shadow generation only */
  97053. standalone?: boolean;
  97054. }
  97055. /**
  97056. * Class that can be used to wrap a base material to generate accurate shadows when using custom vertex/fragment code in the base material
  97057. */
  97058. export class ShadowDepthWrapper {
  97059. private _scene;
  97060. private _options?;
  97061. private _baseMaterial;
  97062. private _onEffectCreatedObserver;
  97063. private _subMeshToEffect;
  97064. private _subMeshToDepthEffect;
  97065. private _meshes;
  97066. /** @hidden */
  97067. _matriceNames: any;
  97068. /** Gets the standalone status of the wrapper */
  97069. get standalone(): boolean;
  97070. /** Gets the base material the wrapper is built upon */
  97071. get baseMaterial(): Material;
  97072. /**
  97073. * Instantiate a new shadow depth wrapper.
  97074. * It works by injecting some specific code in the vertex/fragment shaders of the base material and is used by a shadow generator to
  97075. * generate the shadow depth map. For more information, please refer to the documentation:
  97076. * https://doc.babylonjs.com/babylon101/shadows
  97077. * @param baseMaterial Material to wrap
  97078. * @param scene Define the scene the material belongs to
  97079. * @param options Options used to create the wrapper
  97080. */
  97081. constructor(baseMaterial: Material, scene: Scene, options?: IIOptionShadowDepthMaterial);
  97082. /**
  97083. * Gets the effect to use to generate the depth map
  97084. * @param subMesh subMesh to get the effect for
  97085. * @param shadowGenerator shadow generator to get the effect for
  97086. * @returns the effect to use to generate the depth map for the subMesh + shadow generator specified
  97087. */
  97088. getEffect(subMesh: Nullable<SubMesh>, shadowGenerator: ShadowGenerator): Nullable<Effect>;
  97089. /**
  97090. * Specifies that the submesh is ready to be used for depth rendering
  97091. * @param subMesh submesh to check
  97092. * @param defines the list of defines to take into account when checking the effect
  97093. * @param shadowGenerator combined with subMesh, it defines the effect to check
  97094. * @param useInstances specifies that instances should be used
  97095. * @returns a boolean indicating that the submesh is ready or not
  97096. */
  97097. isReadyForSubMesh(subMesh: SubMesh, defines: string[], shadowGenerator: ShadowGenerator, useInstances: boolean): boolean;
  97098. /**
  97099. * Disposes the resources
  97100. */
  97101. dispose(): void;
  97102. private _makeEffect;
  97103. }
  97104. }
  97105. declare module BABYLON {
  97106. /**
  97107. * Options for compiling materials.
  97108. */
  97109. export interface IMaterialCompilationOptions {
  97110. /**
  97111. * Defines whether clip planes are enabled.
  97112. */
  97113. clipPlane: boolean;
  97114. /**
  97115. * Defines whether instances are enabled.
  97116. */
  97117. useInstances: boolean;
  97118. }
  97119. /**
  97120. * Base class for the main features of a material in Babylon.js
  97121. */
  97122. export class Material implements IAnimatable {
  97123. /**
  97124. * Returns the triangle fill mode
  97125. */
  97126. static readonly TriangleFillMode: number;
  97127. /**
  97128. * Returns the wireframe mode
  97129. */
  97130. static readonly WireFrameFillMode: number;
  97131. /**
  97132. * Returns the point fill mode
  97133. */
  97134. static readonly PointFillMode: number;
  97135. /**
  97136. * Returns the point list draw mode
  97137. */
  97138. static readonly PointListDrawMode: number;
  97139. /**
  97140. * Returns the line list draw mode
  97141. */
  97142. static readonly LineListDrawMode: number;
  97143. /**
  97144. * Returns the line loop draw mode
  97145. */
  97146. static readonly LineLoopDrawMode: number;
  97147. /**
  97148. * Returns the line strip draw mode
  97149. */
  97150. static readonly LineStripDrawMode: number;
  97151. /**
  97152. * Returns the triangle strip draw mode
  97153. */
  97154. static readonly TriangleStripDrawMode: number;
  97155. /**
  97156. * Returns the triangle fan draw mode
  97157. */
  97158. static readonly TriangleFanDrawMode: number;
  97159. /**
  97160. * Stores the clock-wise side orientation
  97161. */
  97162. static readonly ClockWiseSideOrientation: number;
  97163. /**
  97164. * Stores the counter clock-wise side orientation
  97165. */
  97166. static readonly CounterClockWiseSideOrientation: number;
  97167. /**
  97168. * The dirty texture flag value
  97169. */
  97170. static readonly TextureDirtyFlag: number;
  97171. /**
  97172. * The dirty light flag value
  97173. */
  97174. static readonly LightDirtyFlag: number;
  97175. /**
  97176. * The dirty fresnel flag value
  97177. */
  97178. static readonly FresnelDirtyFlag: number;
  97179. /**
  97180. * The dirty attribute flag value
  97181. */
  97182. static readonly AttributesDirtyFlag: number;
  97183. /**
  97184. * The dirty misc flag value
  97185. */
  97186. static readonly MiscDirtyFlag: number;
  97187. /**
  97188. * The all dirty flag value
  97189. */
  97190. static readonly AllDirtyFlag: number;
  97191. /**
  97192. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  97193. */
  97194. static readonly MATERIAL_OPAQUE: number;
  97195. /**
  97196. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  97197. */
  97198. static readonly MATERIAL_ALPHATEST: number;
  97199. /**
  97200. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  97201. */
  97202. static readonly MATERIAL_ALPHABLEND: number;
  97203. /**
  97204. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  97205. * They are also discarded below the alpha cutoff threshold to improve performances.
  97206. */
  97207. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  97208. /**
  97209. * Custom callback helping to override the default shader used in the material.
  97210. */
  97211. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: MaterialDefines | string[], attributes?: string[]) => string;
  97212. /**
  97213. * Custom shadow depth material to use for shadow rendering instead of the in-built one
  97214. */
  97215. shadowDepthWrapper: Nullable<ShadowDepthWrapper>;
  97216. /**
  97217. * The ID of the material
  97218. */
  97219. id: string;
  97220. /**
  97221. * Gets or sets the unique id of the material
  97222. */
  97223. uniqueId: number;
  97224. /**
  97225. * The name of the material
  97226. */
  97227. name: string;
  97228. /**
  97229. * Gets or sets user defined metadata
  97230. */
  97231. metadata: any;
  97232. /**
  97233. * For internal use only. Please do not use.
  97234. */
  97235. reservedDataStore: any;
  97236. /**
  97237. * Specifies if the ready state should be checked on each call
  97238. */
  97239. checkReadyOnEveryCall: boolean;
  97240. /**
  97241. * Specifies if the ready state should be checked once
  97242. */
  97243. checkReadyOnlyOnce: boolean;
  97244. /**
  97245. * The state of the material
  97246. */
  97247. state: string;
  97248. /**
  97249. * The alpha value of the material
  97250. */
  97251. protected _alpha: number;
  97252. /**
  97253. * List of inspectable custom properties (used by the Inspector)
  97254. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  97255. */
  97256. inspectableCustomProperties: IInspectable[];
  97257. /**
  97258. * Sets the alpha value of the material
  97259. */
  97260. set alpha(value: number);
  97261. /**
  97262. * Gets the alpha value of the material
  97263. */
  97264. get alpha(): number;
  97265. /**
  97266. * Specifies if back face culling is enabled
  97267. */
  97268. protected _backFaceCulling: boolean;
  97269. /**
  97270. * Sets the back-face culling state
  97271. */
  97272. set backFaceCulling(value: boolean);
  97273. /**
  97274. * Gets the back-face culling state
  97275. */
  97276. get backFaceCulling(): boolean;
  97277. /**
  97278. * Stores the value for side orientation
  97279. */
  97280. sideOrientation: number;
  97281. /**
  97282. * Callback triggered when the material is compiled
  97283. */
  97284. onCompiled: Nullable<(effect: Effect) => void>;
  97285. /**
  97286. * Callback triggered when an error occurs
  97287. */
  97288. onError: Nullable<(effect: Effect, errors: string) => void>;
  97289. /**
  97290. * Callback triggered to get the render target textures
  97291. */
  97292. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  97293. /**
  97294. * Gets a boolean indicating that current material needs to register RTT
  97295. */
  97296. get hasRenderTargetTextures(): boolean;
  97297. /**
  97298. * Specifies if the material should be serialized
  97299. */
  97300. doNotSerialize: boolean;
  97301. /**
  97302. * @hidden
  97303. */
  97304. _storeEffectOnSubMeshes: boolean;
  97305. /**
  97306. * Stores the animations for the material
  97307. */
  97308. animations: Nullable<Array<Animation>>;
  97309. /**
  97310. * An event triggered when the material is disposed
  97311. */
  97312. onDisposeObservable: Observable<Material>;
  97313. /**
  97314. * An observer which watches for dispose events
  97315. */
  97316. private _onDisposeObserver;
  97317. private _onUnBindObservable;
  97318. /**
  97319. * Called during a dispose event
  97320. */
  97321. set onDispose(callback: () => void);
  97322. private _onBindObservable;
  97323. /**
  97324. * An event triggered when the material is bound
  97325. */
  97326. get onBindObservable(): Observable<AbstractMesh>;
  97327. /**
  97328. * An observer which watches for bind events
  97329. */
  97330. private _onBindObserver;
  97331. /**
  97332. * Called during a bind event
  97333. */
  97334. set onBind(callback: (Mesh: AbstractMesh) => void);
  97335. /**
  97336. * An event triggered when the material is unbound
  97337. */
  97338. get onUnBindObservable(): Observable<Material>;
  97339. protected _onEffectCreatedObservable: Nullable<Observable<{
  97340. effect: Effect;
  97341. subMesh: Nullable<SubMesh>;
  97342. }>>;
  97343. /**
  97344. * An event triggered when the effect is (re)created
  97345. */
  97346. get onEffectCreatedObservable(): Observable<{
  97347. effect: Effect;
  97348. subMesh: Nullable<SubMesh>;
  97349. }>;
  97350. /**
  97351. * Stores the value of the alpha mode
  97352. */
  97353. private _alphaMode;
  97354. /**
  97355. * Sets the value of the alpha mode.
  97356. *
  97357. * | Value | Type | Description |
  97358. * | --- | --- | --- |
  97359. * | 0 | ALPHA_DISABLE | |
  97360. * | 1 | ALPHA_ADD | |
  97361. * | 2 | ALPHA_COMBINE | |
  97362. * | 3 | ALPHA_SUBTRACT | |
  97363. * | 4 | ALPHA_MULTIPLY | |
  97364. * | 5 | ALPHA_MAXIMIZED | |
  97365. * | 6 | ALPHA_ONEONE | |
  97366. * | 7 | ALPHA_PREMULTIPLIED | |
  97367. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  97368. * | 9 | ALPHA_INTERPOLATE | |
  97369. * | 10 | ALPHA_SCREENMODE | |
  97370. *
  97371. */
  97372. set alphaMode(value: number);
  97373. /**
  97374. * Gets the value of the alpha mode
  97375. */
  97376. get alphaMode(): number;
  97377. /**
  97378. * Stores the state of the need depth pre-pass value
  97379. */
  97380. private _needDepthPrePass;
  97381. /**
  97382. * Sets the need depth pre-pass value
  97383. */
  97384. set needDepthPrePass(value: boolean);
  97385. /**
  97386. * Gets the depth pre-pass value
  97387. */
  97388. get needDepthPrePass(): boolean;
  97389. /**
  97390. * Specifies if depth writing should be disabled
  97391. */
  97392. disableDepthWrite: boolean;
  97393. /**
  97394. * Specifies if color writing should be disabled
  97395. */
  97396. disableColorWrite: boolean;
  97397. /**
  97398. * Specifies if depth writing should be forced
  97399. */
  97400. forceDepthWrite: boolean;
  97401. /**
  97402. * Specifies the depth function that should be used. 0 means the default engine function
  97403. */
  97404. depthFunction: number;
  97405. /**
  97406. * Specifies if there should be a separate pass for culling
  97407. */
  97408. separateCullingPass: boolean;
  97409. /**
  97410. * Stores the state specifing if fog should be enabled
  97411. */
  97412. private _fogEnabled;
  97413. /**
  97414. * Sets the state for enabling fog
  97415. */
  97416. set fogEnabled(value: boolean);
  97417. /**
  97418. * Gets the value of the fog enabled state
  97419. */
  97420. get fogEnabled(): boolean;
  97421. /**
  97422. * Stores the size of points
  97423. */
  97424. pointSize: number;
  97425. /**
  97426. * Stores the z offset value
  97427. */
  97428. zOffset: number;
  97429. get wireframe(): boolean;
  97430. /**
  97431. * Sets the state of wireframe mode
  97432. */
  97433. set wireframe(value: boolean);
  97434. /**
  97435. * Gets the value specifying if point clouds are enabled
  97436. */
  97437. get pointsCloud(): boolean;
  97438. /**
  97439. * Sets the state of point cloud mode
  97440. */
  97441. set pointsCloud(value: boolean);
  97442. /**
  97443. * Gets the material fill mode
  97444. */
  97445. get fillMode(): number;
  97446. /**
  97447. * Sets the material fill mode
  97448. */
  97449. set fillMode(value: number);
  97450. /**
  97451. * @hidden
  97452. * Stores the effects for the material
  97453. */
  97454. _effect: Nullable<Effect>;
  97455. /**
  97456. * Specifies if uniform buffers should be used
  97457. */
  97458. private _useUBO;
  97459. /**
  97460. * Stores a reference to the scene
  97461. */
  97462. private _scene;
  97463. /**
  97464. * Stores the fill mode state
  97465. */
  97466. private _fillMode;
  97467. /**
  97468. * Specifies if the depth write state should be cached
  97469. */
  97470. private _cachedDepthWriteState;
  97471. /**
  97472. * Specifies if the color write state should be cached
  97473. */
  97474. private _cachedColorWriteState;
  97475. /**
  97476. * Specifies if the depth function state should be cached
  97477. */
  97478. private _cachedDepthFunctionState;
  97479. /**
  97480. * Stores the uniform buffer
  97481. */
  97482. protected _uniformBuffer: UniformBuffer;
  97483. /** @hidden */
  97484. _indexInSceneMaterialArray: number;
  97485. /** @hidden */
  97486. meshMap: Nullable<{
  97487. [id: string]: AbstractMesh | undefined;
  97488. }>;
  97489. /**
  97490. * Creates a material instance
  97491. * @param name defines the name of the material
  97492. * @param scene defines the scene to reference
  97493. * @param doNotAdd specifies if the material should be added to the scene
  97494. */
  97495. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  97496. /**
  97497. * Returns a string representation of the current material
  97498. * @param fullDetails defines a boolean indicating which levels of logging is desired
  97499. * @returns a string with material information
  97500. */
  97501. toString(fullDetails?: boolean): string;
  97502. /**
  97503. * Gets the class name of the material
  97504. * @returns a string with the class name of the material
  97505. */
  97506. getClassName(): string;
  97507. /**
  97508. * Specifies if updates for the material been locked
  97509. */
  97510. get isFrozen(): boolean;
  97511. /**
  97512. * Locks updates for the material
  97513. */
  97514. freeze(): void;
  97515. /**
  97516. * Unlocks updates for the material
  97517. */
  97518. unfreeze(): void;
  97519. /**
  97520. * Specifies if the material is ready to be used
  97521. * @param mesh defines the mesh to check
  97522. * @param useInstances specifies if instances should be used
  97523. * @returns a boolean indicating if the material is ready to be used
  97524. */
  97525. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  97526. /**
  97527. * Specifies that the submesh is ready to be used
  97528. * @param mesh defines the mesh to check
  97529. * @param subMesh defines which submesh to check
  97530. * @param useInstances specifies that instances should be used
  97531. * @returns a boolean indicating that the submesh is ready or not
  97532. */
  97533. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  97534. /**
  97535. * Returns the material effect
  97536. * @returns the effect associated with the material
  97537. */
  97538. getEffect(): Nullable<Effect>;
  97539. /**
  97540. * Returns the current scene
  97541. * @returns a Scene
  97542. */
  97543. getScene(): Scene;
  97544. /**
  97545. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  97546. */
  97547. protected _forceAlphaTest: boolean;
  97548. /**
  97549. * The transparency mode of the material.
  97550. */
  97551. protected _transparencyMode: Nullable<number>;
  97552. /**
  97553. * Gets the current transparency mode.
  97554. */
  97555. get transparencyMode(): Nullable<number>;
  97556. /**
  97557. * Sets the transparency mode of the material.
  97558. *
  97559. * | Value | Type | Description |
  97560. * | ----- | ----------------------------------- | ----------- |
  97561. * | 0 | OPAQUE | |
  97562. * | 1 | ALPHATEST | |
  97563. * | 2 | ALPHABLEND | |
  97564. * | 3 | ALPHATESTANDBLEND | |
  97565. *
  97566. */
  97567. set transparencyMode(value: Nullable<number>);
  97568. /**
  97569. * Returns true if alpha blending should be disabled.
  97570. */
  97571. protected get _disableAlphaBlending(): boolean;
  97572. /**
  97573. * Specifies whether or not this material should be rendered in alpha blend mode.
  97574. * @returns a boolean specifying if alpha blending is needed
  97575. */
  97576. needAlphaBlending(): boolean;
  97577. /**
  97578. * Specifies if the mesh will require alpha blending
  97579. * @param mesh defines the mesh to check
  97580. * @returns a boolean specifying if alpha blending is needed for the mesh
  97581. */
  97582. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  97583. /**
  97584. * Specifies whether or not this material should be rendered in alpha test mode.
  97585. * @returns a boolean specifying if an alpha test is needed.
  97586. */
  97587. needAlphaTesting(): boolean;
  97588. /**
  97589. * Specifies if material alpha testing should be turned on for the mesh
  97590. * @param mesh defines the mesh to check
  97591. */
  97592. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  97593. /**
  97594. * Gets the texture used for the alpha test
  97595. * @returns the texture to use for alpha testing
  97596. */
  97597. getAlphaTestTexture(): Nullable<BaseTexture>;
  97598. /**
  97599. * Marks the material to indicate that it needs to be re-calculated
  97600. */
  97601. markDirty(): void;
  97602. /** @hidden */
  97603. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  97604. /**
  97605. * Binds the material to the mesh
  97606. * @param world defines the world transformation matrix
  97607. * @param mesh defines the mesh to bind the material to
  97608. */
  97609. bind(world: Matrix, mesh?: Mesh): void;
  97610. /**
  97611. * Binds the submesh to the material
  97612. * @param world defines the world transformation matrix
  97613. * @param mesh defines the mesh containing the submesh
  97614. * @param subMesh defines the submesh to bind the material to
  97615. */
  97616. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  97617. /**
  97618. * Binds the world matrix to the material
  97619. * @param world defines the world transformation matrix
  97620. */
  97621. bindOnlyWorldMatrix(world: Matrix): void;
  97622. /**
  97623. * Binds the scene's uniform buffer to the effect.
  97624. * @param effect defines the effect to bind to the scene uniform buffer
  97625. * @param sceneUbo defines the uniform buffer storing scene data
  97626. */
  97627. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  97628. /**
  97629. * Binds the view matrix to the effect
  97630. * @param effect defines the effect to bind the view matrix to
  97631. */
  97632. bindView(effect: Effect): void;
  97633. /**
  97634. * Binds the view projection matrix to the effect
  97635. * @param effect defines the effect to bind the view projection matrix to
  97636. */
  97637. bindViewProjection(effect: Effect): void;
  97638. /**
  97639. * Processes to execute after binding the material to a mesh
  97640. * @param mesh defines the rendered mesh
  97641. */
  97642. protected _afterBind(mesh?: Mesh): void;
  97643. /**
  97644. * Unbinds the material from the mesh
  97645. */
  97646. unbind(): void;
  97647. /**
  97648. * Gets the active textures from the material
  97649. * @returns an array of textures
  97650. */
  97651. getActiveTextures(): BaseTexture[];
  97652. /**
  97653. * Specifies if the material uses a texture
  97654. * @param texture defines the texture to check against the material
  97655. * @returns a boolean specifying if the material uses the texture
  97656. */
  97657. hasTexture(texture: BaseTexture): boolean;
  97658. /**
  97659. * Makes a duplicate of the material, and gives it a new name
  97660. * @param name defines the new name for the duplicated material
  97661. * @returns the cloned material
  97662. */
  97663. clone(name: string): Nullable<Material>;
  97664. /**
  97665. * Gets the meshes bound to the material
  97666. * @returns an array of meshes bound to the material
  97667. */
  97668. getBindedMeshes(): AbstractMesh[];
  97669. /**
  97670. * Force shader compilation
  97671. * @param mesh defines the mesh associated with this material
  97672. * @param onCompiled defines a function to execute once the material is compiled
  97673. * @param options defines the options to configure the compilation
  97674. * @param onError defines a function to execute if the material fails compiling
  97675. */
  97676. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  97677. /**
  97678. * Force shader compilation
  97679. * @param mesh defines the mesh that will use this material
  97680. * @param options defines additional options for compiling the shaders
  97681. * @returns a promise that resolves when the compilation completes
  97682. */
  97683. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  97684. private static readonly _AllDirtyCallBack;
  97685. private static readonly _ImageProcessingDirtyCallBack;
  97686. private static readonly _TextureDirtyCallBack;
  97687. private static readonly _FresnelDirtyCallBack;
  97688. private static readonly _MiscDirtyCallBack;
  97689. private static readonly _LightsDirtyCallBack;
  97690. private static readonly _AttributeDirtyCallBack;
  97691. private static _FresnelAndMiscDirtyCallBack;
  97692. private static _TextureAndMiscDirtyCallBack;
  97693. private static readonly _DirtyCallbackArray;
  97694. private static readonly _RunDirtyCallBacks;
  97695. /**
  97696. * Marks a define in the material to indicate that it needs to be re-computed
  97697. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  97698. */
  97699. markAsDirty(flag: number): void;
  97700. /**
  97701. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  97702. * @param func defines a function which checks material defines against the submeshes
  97703. */
  97704. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  97705. /**
  97706. * Indicates that we need to re-calculated for all submeshes
  97707. */
  97708. protected _markAllSubMeshesAsAllDirty(): void;
  97709. /**
  97710. * Indicates that image processing needs to be re-calculated for all submeshes
  97711. */
  97712. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  97713. /**
  97714. * Indicates that textures need to be re-calculated for all submeshes
  97715. */
  97716. protected _markAllSubMeshesAsTexturesDirty(): void;
  97717. /**
  97718. * Indicates that fresnel needs to be re-calculated for all submeshes
  97719. */
  97720. protected _markAllSubMeshesAsFresnelDirty(): void;
  97721. /**
  97722. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  97723. */
  97724. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  97725. /**
  97726. * Indicates that lights need to be re-calculated for all submeshes
  97727. */
  97728. protected _markAllSubMeshesAsLightsDirty(): void;
  97729. /**
  97730. * Indicates that attributes need to be re-calculated for all submeshes
  97731. */
  97732. protected _markAllSubMeshesAsAttributesDirty(): void;
  97733. /**
  97734. * Indicates that misc needs to be re-calculated for all submeshes
  97735. */
  97736. protected _markAllSubMeshesAsMiscDirty(): void;
  97737. /**
  97738. * Indicates that textures and misc need to be re-calculated for all submeshes
  97739. */
  97740. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  97741. /**
  97742. * Disposes the material
  97743. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  97744. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  97745. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  97746. */
  97747. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  97748. /** @hidden */
  97749. private releaseVertexArrayObject;
  97750. /**
  97751. * Serializes this material
  97752. * @returns the serialized material object
  97753. */
  97754. serialize(): any;
  97755. /**
  97756. * Creates a material from parsed material data
  97757. * @param parsedMaterial defines parsed material data
  97758. * @param scene defines the hosting scene
  97759. * @param rootUrl defines the root URL to use to load textures
  97760. * @returns a new material
  97761. */
  97762. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  97763. }
  97764. }
  97765. declare module BABYLON {
  97766. /**
  97767. * A multi-material is used to apply different materials to different parts of the same object without the need of
  97768. * separate meshes. This can be use to improve performances.
  97769. * @see http://doc.babylonjs.com/how_to/multi_materials
  97770. */
  97771. export class MultiMaterial extends Material {
  97772. private _subMaterials;
  97773. /**
  97774. * Gets or Sets the list of Materials used within the multi material.
  97775. * They need to be ordered according to the submeshes order in the associated mesh
  97776. */
  97777. get subMaterials(): Nullable<Material>[];
  97778. set subMaterials(value: Nullable<Material>[]);
  97779. /**
  97780. * Function used to align with Node.getChildren()
  97781. * @returns the list of Materials used within the multi material
  97782. */
  97783. getChildren(): Nullable<Material>[];
  97784. /**
  97785. * Instantiates a new Multi Material
  97786. * A multi-material is used to apply different materials to different parts of the same object without the need of
  97787. * separate meshes. This can be use to improve performances.
  97788. * @see http://doc.babylonjs.com/how_to/multi_materials
  97789. * @param name Define the name in the scene
  97790. * @param scene Define the scene the material belongs to
  97791. */
  97792. constructor(name: string, scene: Scene);
  97793. private _hookArray;
  97794. /**
  97795. * Get one of the submaterial by its index in the submaterials array
  97796. * @param index The index to look the sub material at
  97797. * @returns The Material if the index has been defined
  97798. */
  97799. getSubMaterial(index: number): Nullable<Material>;
  97800. /**
  97801. * Get the list of active textures for the whole sub materials list.
  97802. * @returns All the textures that will be used during the rendering
  97803. */
  97804. getActiveTextures(): BaseTexture[];
  97805. /**
  97806. * Gets the current class name of the material e.g. "MultiMaterial"
  97807. * Mainly use in serialization.
  97808. * @returns the class name
  97809. */
  97810. getClassName(): string;
  97811. /**
  97812. * Checks if the material is ready to render the requested sub mesh
  97813. * @param mesh Define the mesh the submesh belongs to
  97814. * @param subMesh Define the sub mesh to look readyness for
  97815. * @param useInstances Define whether or not the material is used with instances
  97816. * @returns true if ready, otherwise false
  97817. */
  97818. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  97819. /**
  97820. * Clones the current material and its related sub materials
  97821. * @param name Define the name of the newly cloned material
  97822. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  97823. * @returns the cloned material
  97824. */
  97825. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  97826. /**
  97827. * Serializes the materials into a JSON representation.
  97828. * @returns the JSON representation
  97829. */
  97830. serialize(): any;
  97831. /**
  97832. * Dispose the material and release its associated resources
  97833. * @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)
  97834. * @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)
  97835. * @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)
  97836. */
  97837. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  97838. /**
  97839. * Creates a MultiMaterial from parsed MultiMaterial data.
  97840. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  97841. * @param scene defines the hosting scene
  97842. * @returns a new MultiMaterial
  97843. */
  97844. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  97845. }
  97846. }
  97847. declare module BABYLON {
  97848. /**
  97849. * Base class for submeshes
  97850. */
  97851. export class BaseSubMesh {
  97852. /** @hidden */
  97853. _materialDefines: Nullable<MaterialDefines>;
  97854. /** @hidden */
  97855. _materialEffect: Nullable<Effect>;
  97856. /** @hidden */
  97857. _effectOverride: Nullable<Effect>;
  97858. /**
  97859. * Gets material defines used by the effect associated to the sub mesh
  97860. */
  97861. get materialDefines(): Nullable<MaterialDefines>;
  97862. /**
  97863. * Sets material defines used by the effect associated to the sub mesh
  97864. */
  97865. set materialDefines(defines: Nullable<MaterialDefines>);
  97866. /**
  97867. * Gets associated effect
  97868. */
  97869. get effect(): Nullable<Effect>;
  97870. /**
  97871. * Sets associated effect (effect used to render this submesh)
  97872. * @param effect defines the effect to associate with
  97873. * @param defines defines the set of defines used to compile this effect
  97874. */
  97875. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  97876. }
  97877. /**
  97878. * Defines a subdivision inside a mesh
  97879. */
  97880. export class SubMesh extends BaseSubMesh implements ICullable {
  97881. /** the material index to use */
  97882. materialIndex: number;
  97883. /** vertex index start */
  97884. verticesStart: number;
  97885. /** vertices count */
  97886. verticesCount: number;
  97887. /** index start */
  97888. indexStart: number;
  97889. /** indices count */
  97890. indexCount: number;
  97891. /** @hidden */
  97892. _linesIndexCount: number;
  97893. private _mesh;
  97894. private _renderingMesh;
  97895. private _boundingInfo;
  97896. private _linesIndexBuffer;
  97897. /** @hidden */
  97898. _lastColliderWorldVertices: Nullable<Vector3[]>;
  97899. /** @hidden */
  97900. _trianglePlanes: Plane[];
  97901. /** @hidden */
  97902. _lastColliderTransformMatrix: Nullable<Matrix>;
  97903. /** @hidden */
  97904. _renderId: number;
  97905. /** @hidden */
  97906. _alphaIndex: number;
  97907. /** @hidden */
  97908. _distanceToCamera: number;
  97909. /** @hidden */
  97910. _id: number;
  97911. private _currentMaterial;
  97912. /**
  97913. * Add a new submesh to a mesh
  97914. * @param materialIndex defines the material index to use
  97915. * @param verticesStart defines vertex index start
  97916. * @param verticesCount defines vertices count
  97917. * @param indexStart defines index start
  97918. * @param indexCount defines indices count
  97919. * @param mesh defines the parent mesh
  97920. * @param renderingMesh defines an optional rendering mesh
  97921. * @param createBoundingBox defines if bounding box should be created for this submesh
  97922. * @returns the new submesh
  97923. */
  97924. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  97925. /**
  97926. * Creates a new submesh
  97927. * @param materialIndex defines the material index to use
  97928. * @param verticesStart defines vertex index start
  97929. * @param verticesCount defines vertices count
  97930. * @param indexStart defines index start
  97931. * @param indexCount defines indices count
  97932. * @param mesh defines the parent mesh
  97933. * @param renderingMesh defines an optional rendering mesh
  97934. * @param createBoundingBox defines if bounding box should be created for this submesh
  97935. */
  97936. constructor(
  97937. /** the material index to use */
  97938. materialIndex: number,
  97939. /** vertex index start */
  97940. verticesStart: number,
  97941. /** vertices count */
  97942. verticesCount: number,
  97943. /** index start */
  97944. indexStart: number,
  97945. /** indices count */
  97946. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  97947. /**
  97948. * Returns true if this submesh covers the entire parent mesh
  97949. * @ignorenaming
  97950. */
  97951. get IsGlobal(): boolean;
  97952. /**
  97953. * Returns the submesh BoudingInfo object
  97954. * @returns current bounding info (or mesh's one if the submesh is global)
  97955. */
  97956. getBoundingInfo(): BoundingInfo;
  97957. /**
  97958. * Sets the submesh BoundingInfo
  97959. * @param boundingInfo defines the new bounding info to use
  97960. * @returns the SubMesh
  97961. */
  97962. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  97963. /**
  97964. * Returns the mesh of the current submesh
  97965. * @return the parent mesh
  97966. */
  97967. getMesh(): AbstractMesh;
  97968. /**
  97969. * Returns the rendering mesh of the submesh
  97970. * @returns the rendering mesh (could be different from parent mesh)
  97971. */
  97972. getRenderingMesh(): Mesh;
  97973. /**
  97974. * Returns the submesh material
  97975. * @returns null or the current material
  97976. */
  97977. getMaterial(): Nullable<Material>;
  97978. /**
  97979. * Sets a new updated BoundingInfo object to the submesh
  97980. * @param data defines an optional position array to use to determine the bounding info
  97981. * @returns the SubMesh
  97982. */
  97983. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  97984. /** @hidden */
  97985. _checkCollision(collider: Collider): boolean;
  97986. /**
  97987. * Updates the submesh BoundingInfo
  97988. * @param world defines the world matrix to use to update the bounding info
  97989. * @returns the submesh
  97990. */
  97991. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  97992. /**
  97993. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  97994. * @param frustumPlanes defines the frustum planes
  97995. * @returns true if the submesh is intersecting with the frustum
  97996. */
  97997. isInFrustum(frustumPlanes: Plane[]): boolean;
  97998. /**
  97999. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  98000. * @param frustumPlanes defines the frustum planes
  98001. * @returns true if the submesh is inside the frustum
  98002. */
  98003. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  98004. /**
  98005. * Renders the submesh
  98006. * @param enableAlphaMode defines if alpha needs to be used
  98007. * @returns the submesh
  98008. */
  98009. render(enableAlphaMode: boolean): SubMesh;
  98010. /**
  98011. * @hidden
  98012. */
  98013. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  98014. /**
  98015. * Checks if the submesh intersects with a ray
  98016. * @param ray defines the ray to test
  98017. * @returns true is the passed ray intersects the submesh bounding box
  98018. */
  98019. canIntersects(ray: Ray): boolean;
  98020. /**
  98021. * Intersects current submesh with a ray
  98022. * @param ray defines the ray to test
  98023. * @param positions defines mesh's positions array
  98024. * @param indices defines mesh's indices array
  98025. * @param fastCheck defines if the first intersection will be used (and not the closest)
  98026. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  98027. * @returns intersection info or null if no intersection
  98028. */
  98029. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  98030. /** @hidden */
  98031. private _intersectLines;
  98032. /** @hidden */
  98033. private _intersectUnIndexedLines;
  98034. /** @hidden */
  98035. private _intersectTriangles;
  98036. /** @hidden */
  98037. private _intersectUnIndexedTriangles;
  98038. /** @hidden */
  98039. _rebuild(): void;
  98040. /**
  98041. * Creates a new submesh from the passed mesh
  98042. * @param newMesh defines the new hosting mesh
  98043. * @param newRenderingMesh defines an optional rendering mesh
  98044. * @returns the new submesh
  98045. */
  98046. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  98047. /**
  98048. * Release associated resources
  98049. */
  98050. dispose(): void;
  98051. /**
  98052. * Gets the class name
  98053. * @returns the string "SubMesh".
  98054. */
  98055. getClassName(): string;
  98056. /**
  98057. * Creates a new submesh from indices data
  98058. * @param materialIndex the index of the main mesh material
  98059. * @param startIndex the index where to start the copy in the mesh indices array
  98060. * @param indexCount the number of indices to copy then from the startIndex
  98061. * @param mesh the main mesh to create the submesh from
  98062. * @param renderingMesh the optional rendering mesh
  98063. * @returns a new submesh
  98064. */
  98065. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  98066. }
  98067. }
  98068. declare module BABYLON {
  98069. /**
  98070. * Class used to represent data loading progression
  98071. */
  98072. export class SceneLoaderFlags {
  98073. private static _ForceFullSceneLoadingForIncremental;
  98074. private static _ShowLoadingScreen;
  98075. private static _CleanBoneMatrixWeights;
  98076. private static _loggingLevel;
  98077. /**
  98078. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  98079. */
  98080. static get ForceFullSceneLoadingForIncremental(): boolean;
  98081. static set ForceFullSceneLoadingForIncremental(value: boolean);
  98082. /**
  98083. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  98084. */
  98085. static get ShowLoadingScreen(): boolean;
  98086. static set ShowLoadingScreen(value: boolean);
  98087. /**
  98088. * Defines the current logging level (while loading the scene)
  98089. * @ignorenaming
  98090. */
  98091. static get loggingLevel(): number;
  98092. static set loggingLevel(value: number);
  98093. /**
  98094. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  98095. */
  98096. static get CleanBoneMatrixWeights(): boolean;
  98097. static set CleanBoneMatrixWeights(value: boolean);
  98098. }
  98099. }
  98100. declare module BABYLON {
  98101. /**
  98102. * Class used to store geometry data (vertex buffers + index buffer)
  98103. */
  98104. export class Geometry implements IGetSetVerticesData {
  98105. /**
  98106. * Gets or sets the ID of the geometry
  98107. */
  98108. id: string;
  98109. /**
  98110. * Gets or sets the unique ID of the geometry
  98111. */
  98112. uniqueId: number;
  98113. /**
  98114. * Gets the delay loading state of the geometry (none by default which means not delayed)
  98115. */
  98116. delayLoadState: number;
  98117. /**
  98118. * Gets the file containing the data to load when running in delay load state
  98119. */
  98120. delayLoadingFile: Nullable<string>;
  98121. /**
  98122. * Callback called when the geometry is updated
  98123. */
  98124. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  98125. private _scene;
  98126. private _engine;
  98127. private _meshes;
  98128. private _totalVertices;
  98129. /** @hidden */
  98130. _indices: IndicesArray;
  98131. /** @hidden */
  98132. _vertexBuffers: {
  98133. [key: string]: VertexBuffer;
  98134. };
  98135. private _isDisposed;
  98136. private _extend;
  98137. private _boundingBias;
  98138. /** @hidden */
  98139. _delayInfo: Array<string>;
  98140. private _indexBuffer;
  98141. private _indexBufferIsUpdatable;
  98142. /** @hidden */
  98143. _boundingInfo: Nullable<BoundingInfo>;
  98144. /** @hidden */
  98145. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  98146. /** @hidden */
  98147. _softwareSkinningFrameId: number;
  98148. private _vertexArrayObjects;
  98149. private _updatable;
  98150. /** @hidden */
  98151. _positions: Nullable<Vector3[]>;
  98152. /**
  98153. * 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
  98154. */
  98155. get boundingBias(): Vector2;
  98156. /**
  98157. * 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
  98158. */
  98159. set boundingBias(value: Vector2);
  98160. /**
  98161. * Static function used to attach a new empty geometry to a mesh
  98162. * @param mesh defines the mesh to attach the geometry to
  98163. * @returns the new Geometry
  98164. */
  98165. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  98166. /** Get the list of meshes using this geometry */
  98167. get meshes(): Mesh[];
  98168. /**
  98169. * Creates a new geometry
  98170. * @param id defines the unique ID
  98171. * @param scene defines the hosting scene
  98172. * @param vertexData defines the VertexData used to get geometry data
  98173. * @param updatable defines if geometry must be updatable (false by default)
  98174. * @param mesh defines the mesh that will be associated with the geometry
  98175. */
  98176. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  98177. /**
  98178. * Gets the current extend of the geometry
  98179. */
  98180. get extend(): {
  98181. minimum: Vector3;
  98182. maximum: Vector3;
  98183. };
  98184. /**
  98185. * Gets the hosting scene
  98186. * @returns the hosting Scene
  98187. */
  98188. getScene(): Scene;
  98189. /**
  98190. * Gets the hosting engine
  98191. * @returns the hosting Engine
  98192. */
  98193. getEngine(): Engine;
  98194. /**
  98195. * Defines if the geometry is ready to use
  98196. * @returns true if the geometry is ready to be used
  98197. */
  98198. isReady(): boolean;
  98199. /**
  98200. * Gets a value indicating that the geometry should not be serialized
  98201. */
  98202. get doNotSerialize(): boolean;
  98203. /** @hidden */
  98204. _rebuild(): void;
  98205. /**
  98206. * Affects all geometry data in one call
  98207. * @param vertexData defines the geometry data
  98208. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  98209. */
  98210. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  98211. /**
  98212. * Set specific vertex data
  98213. * @param kind defines the data kind (Position, normal, etc...)
  98214. * @param data defines the vertex data to use
  98215. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  98216. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  98217. */
  98218. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  98219. /**
  98220. * Removes a specific vertex data
  98221. * @param kind defines the data kind (Position, normal, etc...)
  98222. */
  98223. removeVerticesData(kind: string): void;
  98224. /**
  98225. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  98226. * @param buffer defines the vertex buffer to use
  98227. * @param totalVertices defines the total number of vertices for position kind (could be null)
  98228. */
  98229. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  98230. /**
  98231. * Update a specific vertex buffer
  98232. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  98233. * It will do nothing if the buffer is not updatable
  98234. * @param kind defines the data kind (Position, normal, etc...)
  98235. * @param data defines the data to use
  98236. * @param offset defines the offset in the target buffer where to store the data
  98237. * @param useBytes set to true if the offset is in bytes
  98238. */
  98239. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  98240. /**
  98241. * Update a specific vertex buffer
  98242. * This function will create a new buffer if the current one is not updatable
  98243. * @param kind defines the data kind (Position, normal, etc...)
  98244. * @param data defines the data to use
  98245. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  98246. */
  98247. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  98248. private _updateBoundingInfo;
  98249. /** @hidden */
  98250. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  98251. /**
  98252. * Gets total number of vertices
  98253. * @returns the total number of vertices
  98254. */
  98255. getTotalVertices(): number;
  98256. /**
  98257. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  98258. * @param kind defines the data kind (Position, normal, etc...)
  98259. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  98260. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  98261. * @returns a float array containing vertex data
  98262. */
  98263. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  98264. /**
  98265. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  98266. * @param kind defines the data kind (Position, normal, etc...)
  98267. * @returns true if the vertex buffer with the specified kind is updatable
  98268. */
  98269. isVertexBufferUpdatable(kind: string): boolean;
  98270. /**
  98271. * Gets a specific vertex buffer
  98272. * @param kind defines the data kind (Position, normal, etc...)
  98273. * @returns a VertexBuffer
  98274. */
  98275. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  98276. /**
  98277. * Returns all vertex buffers
  98278. * @return an object holding all vertex buffers indexed by kind
  98279. */
  98280. getVertexBuffers(): Nullable<{
  98281. [key: string]: VertexBuffer;
  98282. }>;
  98283. /**
  98284. * Gets a boolean indicating if specific vertex buffer is present
  98285. * @param kind defines the data kind (Position, normal, etc...)
  98286. * @returns true if data is present
  98287. */
  98288. isVerticesDataPresent(kind: string): boolean;
  98289. /**
  98290. * Gets a list of all attached data kinds (Position, normal, etc...)
  98291. * @returns a list of string containing all kinds
  98292. */
  98293. getVerticesDataKinds(): string[];
  98294. /**
  98295. * Update index buffer
  98296. * @param indices defines the indices to store in the index buffer
  98297. * @param offset defines the offset in the target buffer where to store the data
  98298. * @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)
  98299. */
  98300. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  98301. /**
  98302. * Creates a new index buffer
  98303. * @param indices defines the indices to store in the index buffer
  98304. * @param totalVertices defines the total number of vertices (could be null)
  98305. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  98306. */
  98307. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  98308. /**
  98309. * Return the total number of indices
  98310. * @returns the total number of indices
  98311. */
  98312. getTotalIndices(): number;
  98313. /**
  98314. * Gets the index buffer array
  98315. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  98316. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  98317. * @returns the index buffer array
  98318. */
  98319. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  98320. /**
  98321. * Gets the index buffer
  98322. * @return the index buffer
  98323. */
  98324. getIndexBuffer(): Nullable<DataBuffer>;
  98325. /** @hidden */
  98326. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  98327. /**
  98328. * Release the associated resources for a specific mesh
  98329. * @param mesh defines the source mesh
  98330. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  98331. */
  98332. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  98333. /**
  98334. * Apply current geometry to a given mesh
  98335. * @param mesh defines the mesh to apply geometry to
  98336. */
  98337. applyToMesh(mesh: Mesh): void;
  98338. private _updateExtend;
  98339. private _applyToMesh;
  98340. private notifyUpdate;
  98341. /**
  98342. * Load the geometry if it was flagged as delay loaded
  98343. * @param scene defines the hosting scene
  98344. * @param onLoaded defines a callback called when the geometry is loaded
  98345. */
  98346. load(scene: Scene, onLoaded?: () => void): void;
  98347. private _queueLoad;
  98348. /**
  98349. * Invert the geometry to move from a right handed system to a left handed one.
  98350. */
  98351. toLeftHanded(): void;
  98352. /** @hidden */
  98353. _resetPointsArrayCache(): void;
  98354. /** @hidden */
  98355. _generatePointsArray(): boolean;
  98356. /**
  98357. * Gets a value indicating if the geometry is disposed
  98358. * @returns true if the geometry was disposed
  98359. */
  98360. isDisposed(): boolean;
  98361. private _disposeVertexArrayObjects;
  98362. /**
  98363. * Free all associated resources
  98364. */
  98365. dispose(): void;
  98366. /**
  98367. * Clone the current geometry into a new geometry
  98368. * @param id defines the unique ID of the new geometry
  98369. * @returns a new geometry object
  98370. */
  98371. copy(id: string): Geometry;
  98372. /**
  98373. * Serialize the current geometry info (and not the vertices data) into a JSON object
  98374. * @return a JSON representation of the current geometry data (without the vertices data)
  98375. */
  98376. serialize(): any;
  98377. private toNumberArray;
  98378. /**
  98379. * Serialize all vertices data into a JSON oject
  98380. * @returns a JSON representation of the current geometry data
  98381. */
  98382. serializeVerticeData(): any;
  98383. /**
  98384. * Extracts a clone of a mesh geometry
  98385. * @param mesh defines the source mesh
  98386. * @param id defines the unique ID of the new geometry object
  98387. * @returns the new geometry object
  98388. */
  98389. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  98390. /**
  98391. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  98392. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  98393. * Be aware Math.random() could cause collisions, but:
  98394. * "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"
  98395. * @returns a string containing a new GUID
  98396. */
  98397. static RandomId(): string;
  98398. /** @hidden */
  98399. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  98400. private static _CleanMatricesWeights;
  98401. /**
  98402. * Create a new geometry from persisted data (Using .babylon file format)
  98403. * @param parsedVertexData defines the persisted data
  98404. * @param scene defines the hosting scene
  98405. * @param rootUrl defines the root url to use to load assets (like delayed data)
  98406. * @returns the new geometry object
  98407. */
  98408. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  98409. }
  98410. }
  98411. declare module BABYLON {
  98412. /**
  98413. * Define an interface for all classes that will get and set the data on vertices
  98414. */
  98415. export interface IGetSetVerticesData {
  98416. /**
  98417. * Gets a boolean indicating if specific vertex data is present
  98418. * @param kind defines the vertex data kind to use
  98419. * @returns true is data kind is present
  98420. */
  98421. isVerticesDataPresent(kind: string): boolean;
  98422. /**
  98423. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  98424. * @param kind defines the data kind (Position, normal, etc...)
  98425. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  98426. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  98427. * @returns a float array containing vertex data
  98428. */
  98429. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  98430. /**
  98431. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  98432. * @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.
  98433. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  98434. * @returns the indices array or an empty array if the mesh has no geometry
  98435. */
  98436. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  98437. /**
  98438. * Set specific vertex data
  98439. * @param kind defines the data kind (Position, normal, etc...)
  98440. * @param data defines the vertex data to use
  98441. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  98442. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  98443. */
  98444. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  98445. /**
  98446. * Update a specific associated vertex buffer
  98447. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  98448. * - VertexBuffer.PositionKind
  98449. * - VertexBuffer.UVKind
  98450. * - VertexBuffer.UV2Kind
  98451. * - VertexBuffer.UV3Kind
  98452. * - VertexBuffer.UV4Kind
  98453. * - VertexBuffer.UV5Kind
  98454. * - VertexBuffer.UV6Kind
  98455. * - VertexBuffer.ColorKind
  98456. * - VertexBuffer.MatricesIndicesKind
  98457. * - VertexBuffer.MatricesIndicesExtraKind
  98458. * - VertexBuffer.MatricesWeightsKind
  98459. * - VertexBuffer.MatricesWeightsExtraKind
  98460. * @param data defines the data source
  98461. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  98462. * @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)
  98463. */
  98464. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  98465. /**
  98466. * Creates a new index buffer
  98467. * @param indices defines the indices to store in the index buffer
  98468. * @param totalVertices defines the total number of vertices (could be null)
  98469. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  98470. */
  98471. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  98472. }
  98473. /**
  98474. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  98475. */
  98476. export class VertexData {
  98477. /**
  98478. * Mesh side orientation : usually the external or front surface
  98479. */
  98480. static readonly FRONTSIDE: number;
  98481. /**
  98482. * Mesh side orientation : usually the internal or back surface
  98483. */
  98484. static readonly BACKSIDE: number;
  98485. /**
  98486. * Mesh side orientation : both internal and external or front and back surfaces
  98487. */
  98488. static readonly DOUBLESIDE: number;
  98489. /**
  98490. * Mesh side orientation : by default, `FRONTSIDE`
  98491. */
  98492. static readonly DEFAULTSIDE: number;
  98493. /**
  98494. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  98495. */
  98496. positions: Nullable<FloatArray>;
  98497. /**
  98498. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  98499. */
  98500. normals: Nullable<FloatArray>;
  98501. /**
  98502. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  98503. */
  98504. tangents: Nullable<FloatArray>;
  98505. /**
  98506. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  98507. */
  98508. uvs: Nullable<FloatArray>;
  98509. /**
  98510. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  98511. */
  98512. uvs2: Nullable<FloatArray>;
  98513. /**
  98514. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  98515. */
  98516. uvs3: Nullable<FloatArray>;
  98517. /**
  98518. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  98519. */
  98520. uvs4: Nullable<FloatArray>;
  98521. /**
  98522. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  98523. */
  98524. uvs5: Nullable<FloatArray>;
  98525. /**
  98526. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  98527. */
  98528. uvs6: Nullable<FloatArray>;
  98529. /**
  98530. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  98531. */
  98532. colors: Nullable<FloatArray>;
  98533. /**
  98534. * 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).
  98535. */
  98536. matricesIndices: Nullable<FloatArray>;
  98537. /**
  98538. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  98539. */
  98540. matricesWeights: Nullable<FloatArray>;
  98541. /**
  98542. * An array extending the number of possible indices
  98543. */
  98544. matricesIndicesExtra: Nullable<FloatArray>;
  98545. /**
  98546. * An array extending the number of possible weights when the number of indices is extended
  98547. */
  98548. matricesWeightsExtra: Nullable<FloatArray>;
  98549. /**
  98550. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  98551. */
  98552. indices: Nullable<IndicesArray>;
  98553. /**
  98554. * Uses the passed data array to set the set the values for the specified kind of data
  98555. * @param data a linear array of floating numbers
  98556. * @param kind the type of data that is being set, eg positions, colors etc
  98557. */
  98558. set(data: FloatArray, kind: string): void;
  98559. /**
  98560. * Associates the vertexData to the passed Mesh.
  98561. * Sets it as updatable or not (default `false`)
  98562. * @param mesh the mesh the vertexData is applied to
  98563. * @param updatable when used and having the value true allows new data to update the vertexData
  98564. * @returns the VertexData
  98565. */
  98566. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  98567. /**
  98568. * Associates the vertexData to the passed Geometry.
  98569. * Sets it as updatable or not (default `false`)
  98570. * @param geometry the geometry the vertexData is applied to
  98571. * @param updatable when used and having the value true allows new data to update the vertexData
  98572. * @returns VertexData
  98573. */
  98574. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  98575. /**
  98576. * Updates the associated mesh
  98577. * @param mesh the mesh to be updated
  98578. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  98579. * @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
  98580. * @returns VertexData
  98581. */
  98582. updateMesh(mesh: Mesh): VertexData;
  98583. /**
  98584. * Updates the associated geometry
  98585. * @param geometry the geometry to be updated
  98586. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  98587. * @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
  98588. * @returns VertexData.
  98589. */
  98590. updateGeometry(geometry: Geometry): VertexData;
  98591. private _applyTo;
  98592. private _update;
  98593. /**
  98594. * Transforms each position and each normal of the vertexData according to the passed Matrix
  98595. * @param matrix the transforming matrix
  98596. * @returns the VertexData
  98597. */
  98598. transform(matrix: Matrix): VertexData;
  98599. /**
  98600. * Merges the passed VertexData into the current one
  98601. * @param other the VertexData to be merged into the current one
  98602. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  98603. * @returns the modified VertexData
  98604. */
  98605. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  98606. private _mergeElement;
  98607. private _validate;
  98608. /**
  98609. * Serializes the VertexData
  98610. * @returns a serialized object
  98611. */
  98612. serialize(): any;
  98613. /**
  98614. * Extracts the vertexData from a mesh
  98615. * @param mesh the mesh from which to extract the VertexData
  98616. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  98617. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  98618. * @returns the object VertexData associated to the passed mesh
  98619. */
  98620. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  98621. /**
  98622. * Extracts the vertexData from the geometry
  98623. * @param geometry the geometry from which to extract the VertexData
  98624. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  98625. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  98626. * @returns the object VertexData associated to the passed mesh
  98627. */
  98628. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  98629. private static _ExtractFrom;
  98630. /**
  98631. * Creates the VertexData for a Ribbon
  98632. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  98633. * * pathArray array of paths, each of which an array of successive Vector3
  98634. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  98635. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  98636. * * 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
  98637. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  98638. * * 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)
  98639. * * 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)
  98640. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  98641. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  98642. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  98643. * @returns the VertexData of the ribbon
  98644. */
  98645. static CreateRibbon(options: {
  98646. pathArray: Vector3[][];
  98647. closeArray?: boolean;
  98648. closePath?: boolean;
  98649. offset?: number;
  98650. sideOrientation?: number;
  98651. frontUVs?: Vector4;
  98652. backUVs?: Vector4;
  98653. invertUV?: boolean;
  98654. uvs?: Vector2[];
  98655. colors?: Color4[];
  98656. }): VertexData;
  98657. /**
  98658. * Creates the VertexData for a box
  98659. * @param options an object used to set the following optional parameters for the box, required but can be empty
  98660. * * size sets the width, height and depth of the box to the value of size, optional default 1
  98661. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  98662. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  98663. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  98664. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  98665. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  98666. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  98667. * * 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)
  98668. * * 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)
  98669. * @returns the VertexData of the box
  98670. */
  98671. static CreateBox(options: {
  98672. size?: number;
  98673. width?: number;
  98674. height?: number;
  98675. depth?: number;
  98676. faceUV?: Vector4[];
  98677. faceColors?: Color4[];
  98678. sideOrientation?: number;
  98679. frontUVs?: Vector4;
  98680. backUVs?: Vector4;
  98681. }): VertexData;
  98682. /**
  98683. * Creates the VertexData for a tiled box
  98684. * @param options an object used to set the following optional parameters for the box, required but can be empty
  98685. * * faceTiles sets the pattern, tile size and number of tiles for a face
  98686. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  98687. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  98688. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  98689. * @returns the VertexData of the box
  98690. */
  98691. static CreateTiledBox(options: {
  98692. pattern?: number;
  98693. width?: number;
  98694. height?: number;
  98695. depth?: number;
  98696. tileSize?: number;
  98697. tileWidth?: number;
  98698. tileHeight?: number;
  98699. alignHorizontal?: number;
  98700. alignVertical?: number;
  98701. faceUV?: Vector4[];
  98702. faceColors?: Color4[];
  98703. sideOrientation?: number;
  98704. }): VertexData;
  98705. /**
  98706. * Creates the VertexData for a tiled plane
  98707. * @param options an object used to set the following optional parameters for the box, required but can be empty
  98708. * * pattern a limited pattern arrangement depending on the number
  98709. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  98710. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  98711. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  98712. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  98713. * * 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)
  98714. * * 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)
  98715. * @returns the VertexData of the tiled plane
  98716. */
  98717. static CreateTiledPlane(options: {
  98718. pattern?: number;
  98719. tileSize?: number;
  98720. tileWidth?: number;
  98721. tileHeight?: number;
  98722. size?: number;
  98723. width?: number;
  98724. height?: number;
  98725. alignHorizontal?: number;
  98726. alignVertical?: number;
  98727. sideOrientation?: number;
  98728. frontUVs?: Vector4;
  98729. backUVs?: Vector4;
  98730. }): VertexData;
  98731. /**
  98732. * Creates the VertexData for an ellipsoid, defaults to a sphere
  98733. * @param options an object used to set the following optional parameters for the box, required but can be empty
  98734. * * segments sets the number of horizontal strips optional, default 32
  98735. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  98736. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  98737. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  98738. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  98739. * * 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
  98740. * * 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
  98741. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  98742. * * 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)
  98743. * * 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)
  98744. * @returns the VertexData of the ellipsoid
  98745. */
  98746. static CreateSphere(options: {
  98747. segments?: number;
  98748. diameter?: number;
  98749. diameterX?: number;
  98750. diameterY?: number;
  98751. diameterZ?: number;
  98752. arc?: number;
  98753. slice?: number;
  98754. sideOrientation?: number;
  98755. frontUVs?: Vector4;
  98756. backUVs?: Vector4;
  98757. }): VertexData;
  98758. /**
  98759. * Creates the VertexData for a cylinder, cone or prism
  98760. * @param options an object used to set the following optional parameters for the box, required but can be empty
  98761. * * height sets the height (y direction) of the cylinder, optional, default 2
  98762. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  98763. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  98764. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  98765. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  98766. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  98767. * * 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
  98768. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  98769. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  98770. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  98771. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  98772. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  98773. * * 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)
  98774. * * 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)
  98775. * @returns the VertexData of the cylinder, cone or prism
  98776. */
  98777. static CreateCylinder(options: {
  98778. height?: number;
  98779. diameterTop?: number;
  98780. diameterBottom?: number;
  98781. diameter?: number;
  98782. tessellation?: number;
  98783. subdivisions?: number;
  98784. arc?: number;
  98785. faceColors?: Color4[];
  98786. faceUV?: Vector4[];
  98787. hasRings?: boolean;
  98788. enclose?: boolean;
  98789. sideOrientation?: number;
  98790. frontUVs?: Vector4;
  98791. backUVs?: Vector4;
  98792. }): VertexData;
  98793. /**
  98794. * Creates the VertexData for a torus
  98795. * @param options an object used to set the following optional parameters for the box, required but can be empty
  98796. * * diameter the diameter of the torus, optional default 1
  98797. * * thickness the diameter of the tube forming the torus, optional default 0.5
  98798. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  98799. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  98800. * * 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)
  98801. * * 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)
  98802. * @returns the VertexData of the torus
  98803. */
  98804. static CreateTorus(options: {
  98805. diameter?: number;
  98806. thickness?: number;
  98807. tessellation?: number;
  98808. sideOrientation?: number;
  98809. frontUVs?: Vector4;
  98810. backUVs?: Vector4;
  98811. }): VertexData;
  98812. /**
  98813. * Creates the VertexData of the LineSystem
  98814. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  98815. * - lines an array of lines, each line being an array of successive Vector3
  98816. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  98817. * @returns the VertexData of the LineSystem
  98818. */
  98819. static CreateLineSystem(options: {
  98820. lines: Vector3[][];
  98821. colors?: Nullable<Color4[][]>;
  98822. }): VertexData;
  98823. /**
  98824. * Create the VertexData for a DashedLines
  98825. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  98826. * - points an array successive Vector3
  98827. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  98828. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  98829. * - dashNb the intended total number of dashes, optional, default 200
  98830. * @returns the VertexData for the DashedLines
  98831. */
  98832. static CreateDashedLines(options: {
  98833. points: Vector3[];
  98834. dashSize?: number;
  98835. gapSize?: number;
  98836. dashNb?: number;
  98837. }): VertexData;
  98838. /**
  98839. * Creates the VertexData for a Ground
  98840. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  98841. * - width the width (x direction) of the ground, optional, default 1
  98842. * - height the height (z direction) of the ground, optional, default 1
  98843. * - subdivisions the number of subdivisions per side, optional, default 1
  98844. * @returns the VertexData of the Ground
  98845. */
  98846. static CreateGround(options: {
  98847. width?: number;
  98848. height?: number;
  98849. subdivisions?: number;
  98850. subdivisionsX?: number;
  98851. subdivisionsY?: number;
  98852. }): VertexData;
  98853. /**
  98854. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  98855. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  98856. * * xmin the ground minimum X coordinate, optional, default -1
  98857. * * zmin the ground minimum Z coordinate, optional, default -1
  98858. * * xmax the ground maximum X coordinate, optional, default 1
  98859. * * zmax the ground maximum Z coordinate, optional, default 1
  98860. * * 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}
  98861. * * 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}
  98862. * @returns the VertexData of the TiledGround
  98863. */
  98864. static CreateTiledGround(options: {
  98865. xmin: number;
  98866. zmin: number;
  98867. xmax: number;
  98868. zmax: number;
  98869. subdivisions?: {
  98870. w: number;
  98871. h: number;
  98872. };
  98873. precision?: {
  98874. w: number;
  98875. h: number;
  98876. };
  98877. }): VertexData;
  98878. /**
  98879. * Creates the VertexData of the Ground designed from a heightmap
  98880. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  98881. * * width the width (x direction) of the ground
  98882. * * height the height (z direction) of the ground
  98883. * * subdivisions the number of subdivisions per side
  98884. * * minHeight the minimum altitude on the ground, optional, default 0
  98885. * * maxHeight the maximum altitude on the ground, optional default 1
  98886. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  98887. * * buffer the array holding the image color data
  98888. * * bufferWidth the width of image
  98889. * * bufferHeight the height of image
  98890. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  98891. * @returns the VertexData of the Ground designed from a heightmap
  98892. */
  98893. static CreateGroundFromHeightMap(options: {
  98894. width: number;
  98895. height: number;
  98896. subdivisions: number;
  98897. minHeight: number;
  98898. maxHeight: number;
  98899. colorFilter: Color3;
  98900. buffer: Uint8Array;
  98901. bufferWidth: number;
  98902. bufferHeight: number;
  98903. alphaFilter: number;
  98904. }): VertexData;
  98905. /**
  98906. * Creates the VertexData for a Plane
  98907. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  98908. * * size sets the width and height of the plane to the value of size, optional default 1
  98909. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  98910. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  98911. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  98912. * * 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)
  98913. * * 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)
  98914. * @returns the VertexData of the box
  98915. */
  98916. static CreatePlane(options: {
  98917. size?: number;
  98918. width?: number;
  98919. height?: number;
  98920. sideOrientation?: number;
  98921. frontUVs?: Vector4;
  98922. backUVs?: Vector4;
  98923. }): VertexData;
  98924. /**
  98925. * Creates the VertexData of the Disc or regular Polygon
  98926. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  98927. * * radius the radius of the disc, optional default 0.5
  98928. * * tessellation the number of polygon sides, optional, default 64
  98929. * * 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
  98930. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  98931. * * 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)
  98932. * * 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)
  98933. * @returns the VertexData of the box
  98934. */
  98935. static CreateDisc(options: {
  98936. radius?: number;
  98937. tessellation?: number;
  98938. arc?: number;
  98939. sideOrientation?: number;
  98940. frontUVs?: Vector4;
  98941. backUVs?: Vector4;
  98942. }): VertexData;
  98943. /**
  98944. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  98945. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  98946. * @param polygon a mesh built from polygonTriangulation.build()
  98947. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  98948. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  98949. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  98950. * @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)
  98951. * @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)
  98952. * @param wrap a boolean, default false, when true and fUVs used texture is wrapped around all sides, when false texture is applied side
  98953. * @returns the VertexData of the Polygon
  98954. */
  98955. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4, wrap?: boolean): VertexData;
  98956. /**
  98957. * Creates the VertexData of the IcoSphere
  98958. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  98959. * * radius the radius of the IcoSphere, optional default 1
  98960. * * radiusX allows stretching in the x direction, optional, default radius
  98961. * * radiusY allows stretching in the y direction, optional, default radius
  98962. * * radiusZ allows stretching in the z direction, optional, default radius
  98963. * * flat when true creates a flat shaded mesh, optional, default true
  98964. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  98965. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  98966. * * 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)
  98967. * * 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)
  98968. * @returns the VertexData of the IcoSphere
  98969. */
  98970. static CreateIcoSphere(options: {
  98971. radius?: number;
  98972. radiusX?: number;
  98973. radiusY?: number;
  98974. radiusZ?: number;
  98975. flat?: boolean;
  98976. subdivisions?: number;
  98977. sideOrientation?: number;
  98978. frontUVs?: Vector4;
  98979. backUVs?: Vector4;
  98980. }): VertexData;
  98981. /**
  98982. * Creates the VertexData for a Polyhedron
  98983. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  98984. * * type provided types are:
  98985. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  98986. * * 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)
  98987. * * size the size of the IcoSphere, optional default 1
  98988. * * sizeX allows stretching in the x direction, optional, default size
  98989. * * sizeY allows stretching in the y direction, optional, default size
  98990. * * sizeZ allows stretching in the z direction, optional, default size
  98991. * * 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
  98992. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  98993. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  98994. * * flat when true creates a flat shaded mesh, optional, default true
  98995. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  98996. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  98997. * * 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)
  98998. * * 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)
  98999. * @returns the VertexData of the Polyhedron
  99000. */
  99001. static CreatePolyhedron(options: {
  99002. type?: number;
  99003. size?: number;
  99004. sizeX?: number;
  99005. sizeY?: number;
  99006. sizeZ?: number;
  99007. custom?: any;
  99008. faceUV?: Vector4[];
  99009. faceColors?: Color4[];
  99010. flat?: boolean;
  99011. sideOrientation?: number;
  99012. frontUVs?: Vector4;
  99013. backUVs?: Vector4;
  99014. }): VertexData;
  99015. /**
  99016. * Creates the VertexData for a TorusKnot
  99017. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  99018. * * radius the radius of the torus knot, optional, default 2
  99019. * * tube the thickness of the tube, optional, default 0.5
  99020. * * radialSegments the number of sides on each tube segments, optional, default 32
  99021. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  99022. * * p the number of windings around the z axis, optional, default 2
  99023. * * q the number of windings around the x axis, optional, default 3
  99024. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  99025. * * 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)
  99026. * * 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)
  99027. * @returns the VertexData of the Torus Knot
  99028. */
  99029. static CreateTorusKnot(options: {
  99030. radius?: number;
  99031. tube?: number;
  99032. radialSegments?: number;
  99033. tubularSegments?: number;
  99034. p?: number;
  99035. q?: number;
  99036. sideOrientation?: number;
  99037. frontUVs?: Vector4;
  99038. backUVs?: Vector4;
  99039. }): VertexData;
  99040. /**
  99041. * Compute normals for given positions and indices
  99042. * @param positions an array of vertex positions, [...., x, y, z, ......]
  99043. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  99044. * @param normals an array of vertex normals, [...., x, y, z, ......]
  99045. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  99046. * * facetNormals : optional array of facet normals (vector3)
  99047. * * facetPositions : optional array of facet positions (vector3)
  99048. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  99049. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  99050. * * bInfo : optional bounding info, required for facetPartitioning computation
  99051. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  99052. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  99053. * * useRightHandedSystem: optional boolean to for right handed system computation
  99054. * * depthSort : optional boolean to enable the facet depth sort computation
  99055. * * distanceTo : optional Vector3 to compute the facet depth from this location
  99056. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  99057. */
  99058. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  99059. facetNormals?: any;
  99060. facetPositions?: any;
  99061. facetPartitioning?: any;
  99062. ratio?: number;
  99063. bInfo?: any;
  99064. bbSize?: Vector3;
  99065. subDiv?: any;
  99066. useRightHandedSystem?: boolean;
  99067. depthSort?: boolean;
  99068. distanceTo?: Vector3;
  99069. depthSortedFacets?: any;
  99070. }): void;
  99071. /** @hidden */
  99072. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  99073. /**
  99074. * Applies VertexData created from the imported parameters to the geometry
  99075. * @param parsedVertexData the parsed data from an imported file
  99076. * @param geometry the geometry to apply the VertexData to
  99077. */
  99078. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  99079. }
  99080. }
  99081. declare module BABYLON {
  99082. /**
  99083. * Defines a target to use with MorphTargetManager
  99084. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  99085. */
  99086. export class MorphTarget implements IAnimatable {
  99087. /** defines the name of the target */
  99088. name: string;
  99089. /**
  99090. * Gets or sets the list of animations
  99091. */
  99092. animations: Animation[];
  99093. private _scene;
  99094. private _positions;
  99095. private _normals;
  99096. private _tangents;
  99097. private _uvs;
  99098. private _influence;
  99099. private _uniqueId;
  99100. /**
  99101. * Observable raised when the influence changes
  99102. */
  99103. onInfluenceChanged: Observable<boolean>;
  99104. /** @hidden */
  99105. _onDataLayoutChanged: Observable<void>;
  99106. /**
  99107. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  99108. */
  99109. get influence(): number;
  99110. set influence(influence: number);
  99111. /**
  99112. * Gets or sets the id of the morph Target
  99113. */
  99114. id: string;
  99115. private _animationPropertiesOverride;
  99116. /**
  99117. * Gets or sets the animation properties override
  99118. */
  99119. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  99120. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  99121. /**
  99122. * Creates a new MorphTarget
  99123. * @param name defines the name of the target
  99124. * @param influence defines the influence to use
  99125. * @param scene defines the scene the morphtarget belongs to
  99126. */
  99127. constructor(
  99128. /** defines the name of the target */
  99129. name: string, influence?: number, scene?: Nullable<Scene>);
  99130. /**
  99131. * Gets the unique ID of this manager
  99132. */
  99133. get uniqueId(): number;
  99134. /**
  99135. * Gets a boolean defining if the target contains position data
  99136. */
  99137. get hasPositions(): boolean;
  99138. /**
  99139. * Gets a boolean defining if the target contains normal data
  99140. */
  99141. get hasNormals(): boolean;
  99142. /**
  99143. * Gets a boolean defining if the target contains tangent data
  99144. */
  99145. get hasTangents(): boolean;
  99146. /**
  99147. * Gets a boolean defining if the target contains texture coordinates data
  99148. */
  99149. get hasUVs(): boolean;
  99150. /**
  99151. * Affects position data to this target
  99152. * @param data defines the position data to use
  99153. */
  99154. setPositions(data: Nullable<FloatArray>): void;
  99155. /**
  99156. * Gets the position data stored in this target
  99157. * @returns a FloatArray containing the position data (or null if not present)
  99158. */
  99159. getPositions(): Nullable<FloatArray>;
  99160. /**
  99161. * Affects normal data to this target
  99162. * @param data defines the normal data to use
  99163. */
  99164. setNormals(data: Nullable<FloatArray>): void;
  99165. /**
  99166. * Gets the normal data stored in this target
  99167. * @returns a FloatArray containing the normal data (or null if not present)
  99168. */
  99169. getNormals(): Nullable<FloatArray>;
  99170. /**
  99171. * Affects tangent data to this target
  99172. * @param data defines the tangent data to use
  99173. */
  99174. setTangents(data: Nullable<FloatArray>): void;
  99175. /**
  99176. * Gets the tangent data stored in this target
  99177. * @returns a FloatArray containing the tangent data (or null if not present)
  99178. */
  99179. getTangents(): Nullable<FloatArray>;
  99180. /**
  99181. * Affects texture coordinates data to this target
  99182. * @param data defines the texture coordinates data to use
  99183. */
  99184. setUVs(data: Nullable<FloatArray>): void;
  99185. /**
  99186. * Gets the texture coordinates data stored in this target
  99187. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  99188. */
  99189. getUVs(): Nullable<FloatArray>;
  99190. /**
  99191. * Clone the current target
  99192. * @returns a new MorphTarget
  99193. */
  99194. clone(): MorphTarget;
  99195. /**
  99196. * Serializes the current target into a Serialization object
  99197. * @returns the serialized object
  99198. */
  99199. serialize(): any;
  99200. /**
  99201. * Returns the string "MorphTarget"
  99202. * @returns "MorphTarget"
  99203. */
  99204. getClassName(): string;
  99205. /**
  99206. * Creates a new target from serialized data
  99207. * @param serializationObject defines the serialized data to use
  99208. * @returns a new MorphTarget
  99209. */
  99210. static Parse(serializationObject: any): MorphTarget;
  99211. /**
  99212. * Creates a MorphTarget from mesh data
  99213. * @param mesh defines the source mesh
  99214. * @param name defines the name to use for the new target
  99215. * @param influence defines the influence to attach to the target
  99216. * @returns a new MorphTarget
  99217. */
  99218. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  99219. }
  99220. }
  99221. declare module BABYLON {
  99222. /**
  99223. * This class is used to deform meshes using morphing between different targets
  99224. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  99225. */
  99226. export class MorphTargetManager {
  99227. private _targets;
  99228. private _targetInfluenceChangedObservers;
  99229. private _targetDataLayoutChangedObservers;
  99230. private _activeTargets;
  99231. private _scene;
  99232. private _influences;
  99233. private _supportsNormals;
  99234. private _supportsTangents;
  99235. private _supportsUVs;
  99236. private _vertexCount;
  99237. private _uniqueId;
  99238. private _tempInfluences;
  99239. /**
  99240. * Gets or sets a boolean indicating if normals must be morphed
  99241. */
  99242. enableNormalMorphing: boolean;
  99243. /**
  99244. * Gets or sets a boolean indicating if tangents must be morphed
  99245. */
  99246. enableTangentMorphing: boolean;
  99247. /**
  99248. * Gets or sets a boolean indicating if UV must be morphed
  99249. */
  99250. enableUVMorphing: boolean;
  99251. /**
  99252. * Creates a new MorphTargetManager
  99253. * @param scene defines the current scene
  99254. */
  99255. constructor(scene?: Nullable<Scene>);
  99256. /**
  99257. * Gets the unique ID of this manager
  99258. */
  99259. get uniqueId(): number;
  99260. /**
  99261. * Gets the number of vertices handled by this manager
  99262. */
  99263. get vertexCount(): number;
  99264. /**
  99265. * Gets a boolean indicating if this manager supports morphing of normals
  99266. */
  99267. get supportsNormals(): boolean;
  99268. /**
  99269. * Gets a boolean indicating if this manager supports morphing of tangents
  99270. */
  99271. get supportsTangents(): boolean;
  99272. /**
  99273. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  99274. */
  99275. get supportsUVs(): boolean;
  99276. /**
  99277. * Gets the number of targets stored in this manager
  99278. */
  99279. get numTargets(): number;
  99280. /**
  99281. * Gets the number of influencers (ie. the number of targets with influences > 0)
  99282. */
  99283. get numInfluencers(): number;
  99284. /**
  99285. * Gets the list of influences (one per target)
  99286. */
  99287. get influences(): Float32Array;
  99288. /**
  99289. * Gets the active target at specified index. An active target is a target with an influence > 0
  99290. * @param index defines the index to check
  99291. * @returns the requested target
  99292. */
  99293. getActiveTarget(index: number): MorphTarget;
  99294. /**
  99295. * Gets the target at specified index
  99296. * @param index defines the index to check
  99297. * @returns the requested target
  99298. */
  99299. getTarget(index: number): MorphTarget;
  99300. /**
  99301. * Add a new target to this manager
  99302. * @param target defines the target to add
  99303. */
  99304. addTarget(target: MorphTarget): void;
  99305. /**
  99306. * Removes a target from the manager
  99307. * @param target defines the target to remove
  99308. */
  99309. removeTarget(target: MorphTarget): void;
  99310. /**
  99311. * Clone the current manager
  99312. * @returns a new MorphTargetManager
  99313. */
  99314. clone(): MorphTargetManager;
  99315. /**
  99316. * Serializes the current manager into a Serialization object
  99317. * @returns the serialized object
  99318. */
  99319. serialize(): any;
  99320. private _syncActiveTargets;
  99321. /**
  99322. * Syncrhonize the targets with all the meshes using this morph target manager
  99323. */
  99324. synchronize(): void;
  99325. /**
  99326. * Creates a new MorphTargetManager from serialized data
  99327. * @param serializationObject defines the serialized data
  99328. * @param scene defines the hosting scene
  99329. * @returns the new MorphTargetManager
  99330. */
  99331. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  99332. }
  99333. }
  99334. declare module BABYLON {
  99335. /**
  99336. * Class used to represent a specific level of detail of a mesh
  99337. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  99338. */
  99339. export class MeshLODLevel {
  99340. /** Defines the distance where this level should start being displayed */
  99341. distance: number;
  99342. /** Defines the mesh to use to render this level */
  99343. mesh: Nullable<Mesh>;
  99344. /**
  99345. * Creates a new LOD level
  99346. * @param distance defines the distance where this level should star being displayed
  99347. * @param mesh defines the mesh to use to render this level
  99348. */
  99349. constructor(
  99350. /** Defines the distance where this level should start being displayed */
  99351. distance: number,
  99352. /** Defines the mesh to use to render this level */
  99353. mesh: Nullable<Mesh>);
  99354. }
  99355. }
  99356. declare module BABYLON {
  99357. /**
  99358. * Mesh representing the gorund
  99359. */
  99360. export class GroundMesh extends Mesh {
  99361. /** If octree should be generated */
  99362. generateOctree: boolean;
  99363. private _heightQuads;
  99364. /** @hidden */
  99365. _subdivisionsX: number;
  99366. /** @hidden */
  99367. _subdivisionsY: number;
  99368. /** @hidden */
  99369. _width: number;
  99370. /** @hidden */
  99371. _height: number;
  99372. /** @hidden */
  99373. _minX: number;
  99374. /** @hidden */
  99375. _maxX: number;
  99376. /** @hidden */
  99377. _minZ: number;
  99378. /** @hidden */
  99379. _maxZ: number;
  99380. constructor(name: string, scene: Scene);
  99381. /**
  99382. * "GroundMesh"
  99383. * @returns "GroundMesh"
  99384. */
  99385. getClassName(): string;
  99386. /**
  99387. * The minimum of x and y subdivisions
  99388. */
  99389. get subdivisions(): number;
  99390. /**
  99391. * X subdivisions
  99392. */
  99393. get subdivisionsX(): number;
  99394. /**
  99395. * Y subdivisions
  99396. */
  99397. get subdivisionsY(): number;
  99398. /**
  99399. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  99400. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  99401. * @param chunksCount the number of subdivisions for x and y
  99402. * @param octreeBlocksSize (Default: 32)
  99403. */
  99404. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  99405. /**
  99406. * Returns a height (y) value in the Worl system :
  99407. * the ground altitude at the coordinates (x, z) expressed in the World system.
  99408. * @param x x coordinate
  99409. * @param z z coordinate
  99410. * @returns the ground y position if (x, z) are outside the ground surface.
  99411. */
  99412. getHeightAtCoordinates(x: number, z: number): number;
  99413. /**
  99414. * Returns a normalized vector (Vector3) orthogonal to the ground
  99415. * at the ground coordinates (x, z) expressed in the World system.
  99416. * @param x x coordinate
  99417. * @param z z coordinate
  99418. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  99419. */
  99420. getNormalAtCoordinates(x: number, z: number): Vector3;
  99421. /**
  99422. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  99423. * at the ground coordinates (x, z) expressed in the World system.
  99424. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  99425. * @param x x coordinate
  99426. * @param z z coordinate
  99427. * @param ref vector to store the result
  99428. * @returns the GroundMesh.
  99429. */
  99430. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  99431. /**
  99432. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  99433. * if the ground has been updated.
  99434. * This can be used in the render loop.
  99435. * @returns the GroundMesh.
  99436. */
  99437. updateCoordinateHeights(): GroundMesh;
  99438. private _getFacetAt;
  99439. private _initHeightQuads;
  99440. private _computeHeightQuads;
  99441. /**
  99442. * Serializes this ground mesh
  99443. * @param serializationObject object to write serialization to
  99444. */
  99445. serialize(serializationObject: any): void;
  99446. /**
  99447. * Parses a serialized ground mesh
  99448. * @param parsedMesh the serialized mesh
  99449. * @param scene the scene to create the ground mesh in
  99450. * @returns the created ground mesh
  99451. */
  99452. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  99453. }
  99454. }
  99455. declare module BABYLON {
  99456. /**
  99457. * Interface for Physics-Joint data
  99458. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  99459. */
  99460. export interface PhysicsJointData {
  99461. /**
  99462. * The main pivot of the joint
  99463. */
  99464. mainPivot?: Vector3;
  99465. /**
  99466. * The connected pivot of the joint
  99467. */
  99468. connectedPivot?: Vector3;
  99469. /**
  99470. * The main axis of the joint
  99471. */
  99472. mainAxis?: Vector3;
  99473. /**
  99474. * The connected axis of the joint
  99475. */
  99476. connectedAxis?: Vector3;
  99477. /**
  99478. * The collision of the joint
  99479. */
  99480. collision?: boolean;
  99481. /**
  99482. * Native Oimo/Cannon/Energy data
  99483. */
  99484. nativeParams?: any;
  99485. }
  99486. /**
  99487. * This is a holder class for the physics joint created by the physics plugin
  99488. * It holds a set of functions to control the underlying joint
  99489. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  99490. */
  99491. export class PhysicsJoint {
  99492. /**
  99493. * The type of the physics joint
  99494. */
  99495. type: number;
  99496. /**
  99497. * The data for the physics joint
  99498. */
  99499. jointData: PhysicsJointData;
  99500. private _physicsJoint;
  99501. protected _physicsPlugin: IPhysicsEnginePlugin;
  99502. /**
  99503. * Initializes the physics joint
  99504. * @param type The type of the physics joint
  99505. * @param jointData The data for the physics joint
  99506. */
  99507. constructor(
  99508. /**
  99509. * The type of the physics joint
  99510. */
  99511. type: number,
  99512. /**
  99513. * The data for the physics joint
  99514. */
  99515. jointData: PhysicsJointData);
  99516. /**
  99517. * Gets the physics joint
  99518. */
  99519. get physicsJoint(): any;
  99520. /**
  99521. * Sets the physics joint
  99522. */
  99523. set physicsJoint(newJoint: any);
  99524. /**
  99525. * Sets the physics plugin
  99526. */
  99527. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  99528. /**
  99529. * Execute a function that is physics-plugin specific.
  99530. * @param {Function} func the function that will be executed.
  99531. * It accepts two parameters: the physics world and the physics joint
  99532. */
  99533. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  99534. /**
  99535. * Distance-Joint type
  99536. */
  99537. static DistanceJoint: number;
  99538. /**
  99539. * Hinge-Joint type
  99540. */
  99541. static HingeJoint: number;
  99542. /**
  99543. * Ball-and-Socket joint type
  99544. */
  99545. static BallAndSocketJoint: number;
  99546. /**
  99547. * Wheel-Joint type
  99548. */
  99549. static WheelJoint: number;
  99550. /**
  99551. * Slider-Joint type
  99552. */
  99553. static SliderJoint: number;
  99554. /**
  99555. * Prismatic-Joint type
  99556. */
  99557. static PrismaticJoint: number;
  99558. /**
  99559. * Universal-Joint type
  99560. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  99561. */
  99562. static UniversalJoint: number;
  99563. /**
  99564. * Hinge-Joint 2 type
  99565. */
  99566. static Hinge2Joint: number;
  99567. /**
  99568. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  99569. */
  99570. static PointToPointJoint: number;
  99571. /**
  99572. * Spring-Joint type
  99573. */
  99574. static SpringJoint: number;
  99575. /**
  99576. * Lock-Joint type
  99577. */
  99578. static LockJoint: number;
  99579. }
  99580. /**
  99581. * A class representing a physics distance joint
  99582. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  99583. */
  99584. export class DistanceJoint extends PhysicsJoint {
  99585. /**
  99586. *
  99587. * @param jointData The data for the Distance-Joint
  99588. */
  99589. constructor(jointData: DistanceJointData);
  99590. /**
  99591. * Update the predefined distance.
  99592. * @param maxDistance The maximum preferred distance
  99593. * @param minDistance The minimum preferred distance
  99594. */
  99595. updateDistance(maxDistance: number, minDistance?: number): void;
  99596. }
  99597. /**
  99598. * Represents a Motor-Enabled Joint
  99599. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  99600. */
  99601. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  99602. /**
  99603. * Initializes the Motor-Enabled Joint
  99604. * @param type The type of the joint
  99605. * @param jointData The physica joint data for the joint
  99606. */
  99607. constructor(type: number, jointData: PhysicsJointData);
  99608. /**
  99609. * Set the motor values.
  99610. * Attention, this function is plugin specific. Engines won't react 100% the same.
  99611. * @param force the force to apply
  99612. * @param maxForce max force for this motor.
  99613. */
  99614. setMotor(force?: number, maxForce?: number): void;
  99615. /**
  99616. * Set the motor's limits.
  99617. * Attention, this function is plugin specific. Engines won't react 100% the same.
  99618. * @param upperLimit The upper limit of the motor
  99619. * @param lowerLimit The lower limit of the motor
  99620. */
  99621. setLimit(upperLimit: number, lowerLimit?: number): void;
  99622. }
  99623. /**
  99624. * This class represents a single physics Hinge-Joint
  99625. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  99626. */
  99627. export class HingeJoint extends MotorEnabledJoint {
  99628. /**
  99629. * Initializes the Hinge-Joint
  99630. * @param jointData The joint data for the Hinge-Joint
  99631. */
  99632. constructor(jointData: PhysicsJointData);
  99633. /**
  99634. * Set the motor values.
  99635. * Attention, this function is plugin specific. Engines won't react 100% the same.
  99636. * @param {number} force the force to apply
  99637. * @param {number} maxForce max force for this motor.
  99638. */
  99639. setMotor(force?: number, maxForce?: number): void;
  99640. /**
  99641. * Set the motor's limits.
  99642. * Attention, this function is plugin specific. Engines won't react 100% the same.
  99643. * @param upperLimit The upper limit of the motor
  99644. * @param lowerLimit The lower limit of the motor
  99645. */
  99646. setLimit(upperLimit: number, lowerLimit?: number): void;
  99647. }
  99648. /**
  99649. * This class represents a dual hinge physics joint (same as wheel joint)
  99650. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  99651. */
  99652. export class Hinge2Joint extends MotorEnabledJoint {
  99653. /**
  99654. * Initializes the Hinge2-Joint
  99655. * @param jointData The joint data for the Hinge2-Joint
  99656. */
  99657. constructor(jointData: PhysicsJointData);
  99658. /**
  99659. * Set the motor values.
  99660. * Attention, this function is plugin specific. Engines won't react 100% the same.
  99661. * @param {number} targetSpeed the speed the motor is to reach
  99662. * @param {number} maxForce max force for this motor.
  99663. * @param {motorIndex} the motor's index, 0 or 1.
  99664. */
  99665. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  99666. /**
  99667. * Set the motor limits.
  99668. * Attention, this function is plugin specific. Engines won't react 100% the same.
  99669. * @param {number} upperLimit the upper limit
  99670. * @param {number} lowerLimit lower limit
  99671. * @param {motorIndex} the motor's index, 0 or 1.
  99672. */
  99673. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  99674. }
  99675. /**
  99676. * Interface for a motor enabled joint
  99677. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  99678. */
  99679. export interface IMotorEnabledJoint {
  99680. /**
  99681. * Physics joint
  99682. */
  99683. physicsJoint: any;
  99684. /**
  99685. * Sets the motor of the motor-enabled joint
  99686. * @param force The force of the motor
  99687. * @param maxForce The maximum force of the motor
  99688. * @param motorIndex The index of the motor
  99689. */
  99690. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  99691. /**
  99692. * Sets the limit of the motor
  99693. * @param upperLimit The upper limit of the motor
  99694. * @param lowerLimit The lower limit of the motor
  99695. * @param motorIndex The index of the motor
  99696. */
  99697. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  99698. }
  99699. /**
  99700. * Joint data for a Distance-Joint
  99701. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  99702. */
  99703. export interface DistanceJointData extends PhysicsJointData {
  99704. /**
  99705. * Max distance the 2 joint objects can be apart
  99706. */
  99707. maxDistance: number;
  99708. }
  99709. /**
  99710. * Joint data from a spring joint
  99711. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  99712. */
  99713. export interface SpringJointData extends PhysicsJointData {
  99714. /**
  99715. * Length of the spring
  99716. */
  99717. length: number;
  99718. /**
  99719. * Stiffness of the spring
  99720. */
  99721. stiffness: number;
  99722. /**
  99723. * Damping of the spring
  99724. */
  99725. damping: number;
  99726. /** this callback will be called when applying the force to the impostors. */
  99727. forceApplicationCallback: () => void;
  99728. }
  99729. }
  99730. declare module BABYLON {
  99731. /**
  99732. * Holds the data for the raycast result
  99733. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  99734. */
  99735. export class PhysicsRaycastResult {
  99736. private _hasHit;
  99737. private _hitDistance;
  99738. private _hitNormalWorld;
  99739. private _hitPointWorld;
  99740. private _rayFromWorld;
  99741. private _rayToWorld;
  99742. /**
  99743. * Gets if there was a hit
  99744. */
  99745. get hasHit(): boolean;
  99746. /**
  99747. * Gets the distance from the hit
  99748. */
  99749. get hitDistance(): number;
  99750. /**
  99751. * Gets the hit normal/direction in the world
  99752. */
  99753. get hitNormalWorld(): Vector3;
  99754. /**
  99755. * Gets the hit point in the world
  99756. */
  99757. get hitPointWorld(): Vector3;
  99758. /**
  99759. * Gets the ray "start point" of the ray in the world
  99760. */
  99761. get rayFromWorld(): Vector3;
  99762. /**
  99763. * Gets the ray "end point" of the ray in the world
  99764. */
  99765. get rayToWorld(): Vector3;
  99766. /**
  99767. * Sets the hit data (normal & point in world space)
  99768. * @param hitNormalWorld defines the normal in world space
  99769. * @param hitPointWorld defines the point in world space
  99770. */
  99771. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  99772. /**
  99773. * Sets the distance from the start point to the hit point
  99774. * @param distance
  99775. */
  99776. setHitDistance(distance: number): void;
  99777. /**
  99778. * Calculates the distance manually
  99779. */
  99780. calculateHitDistance(): void;
  99781. /**
  99782. * Resets all the values to default
  99783. * @param from The from point on world space
  99784. * @param to The to point on world space
  99785. */
  99786. reset(from?: Vector3, to?: Vector3): void;
  99787. }
  99788. /**
  99789. * Interface for the size containing width and height
  99790. */
  99791. interface IXYZ {
  99792. /**
  99793. * X
  99794. */
  99795. x: number;
  99796. /**
  99797. * Y
  99798. */
  99799. y: number;
  99800. /**
  99801. * Z
  99802. */
  99803. z: number;
  99804. }
  99805. }
  99806. declare module BABYLON {
  99807. /**
  99808. * Interface used to describe a physics joint
  99809. */
  99810. export interface PhysicsImpostorJoint {
  99811. /** Defines the main impostor to which the joint is linked */
  99812. mainImpostor: PhysicsImpostor;
  99813. /** Defines the impostor that is connected to the main impostor using this joint */
  99814. connectedImpostor: PhysicsImpostor;
  99815. /** Defines the joint itself */
  99816. joint: PhysicsJoint;
  99817. }
  99818. /** @hidden */
  99819. export interface IPhysicsEnginePlugin {
  99820. world: any;
  99821. name: string;
  99822. setGravity(gravity: Vector3): void;
  99823. setTimeStep(timeStep: number): void;
  99824. getTimeStep(): number;
  99825. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  99826. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  99827. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  99828. generatePhysicsBody(impostor: PhysicsImpostor): void;
  99829. removePhysicsBody(impostor: PhysicsImpostor): void;
  99830. generateJoint(joint: PhysicsImpostorJoint): void;
  99831. removeJoint(joint: PhysicsImpostorJoint): void;
  99832. isSupported(): boolean;
  99833. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  99834. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  99835. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  99836. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  99837. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  99838. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  99839. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  99840. getBodyMass(impostor: PhysicsImpostor): number;
  99841. getBodyFriction(impostor: PhysicsImpostor): number;
  99842. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  99843. getBodyRestitution(impostor: PhysicsImpostor): number;
  99844. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  99845. getBodyPressure?(impostor: PhysicsImpostor): number;
  99846. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  99847. getBodyStiffness?(impostor: PhysicsImpostor): number;
  99848. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  99849. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  99850. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  99851. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  99852. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  99853. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  99854. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  99855. sleepBody(impostor: PhysicsImpostor): void;
  99856. wakeUpBody(impostor: PhysicsImpostor): void;
  99857. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  99858. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  99859. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  99860. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  99861. getRadius(impostor: PhysicsImpostor): number;
  99862. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  99863. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  99864. dispose(): void;
  99865. }
  99866. /**
  99867. * Interface used to define a physics engine
  99868. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  99869. */
  99870. export interface IPhysicsEngine {
  99871. /**
  99872. * Gets the gravity vector used by the simulation
  99873. */
  99874. gravity: Vector3;
  99875. /**
  99876. * Sets the gravity vector used by the simulation
  99877. * @param gravity defines the gravity vector to use
  99878. */
  99879. setGravity(gravity: Vector3): void;
  99880. /**
  99881. * Set the time step of the physics engine.
  99882. * Default is 1/60.
  99883. * To slow it down, enter 1/600 for example.
  99884. * To speed it up, 1/30
  99885. * @param newTimeStep the new timestep to apply to this world.
  99886. */
  99887. setTimeStep(newTimeStep: number): void;
  99888. /**
  99889. * Get the time step of the physics engine.
  99890. * @returns the current time step
  99891. */
  99892. getTimeStep(): number;
  99893. /**
  99894. * Set the sub time step of the physics engine.
  99895. * Default is 0 meaning there is no sub steps
  99896. * To increase physics resolution precision, set a small value (like 1 ms)
  99897. * @param subTimeStep defines the new sub timestep used for physics resolution.
  99898. */
  99899. setSubTimeStep(subTimeStep: number): void;
  99900. /**
  99901. * Get the sub time step of the physics engine.
  99902. * @returns the current sub time step
  99903. */
  99904. getSubTimeStep(): number;
  99905. /**
  99906. * Release all resources
  99907. */
  99908. dispose(): void;
  99909. /**
  99910. * Gets the name of the current physics plugin
  99911. * @returns the name of the plugin
  99912. */
  99913. getPhysicsPluginName(): string;
  99914. /**
  99915. * Adding a new impostor for the impostor tracking.
  99916. * This will be done by the impostor itself.
  99917. * @param impostor the impostor to add
  99918. */
  99919. addImpostor(impostor: PhysicsImpostor): void;
  99920. /**
  99921. * Remove an impostor from the engine.
  99922. * This impostor and its mesh will not longer be updated by the physics engine.
  99923. * @param impostor the impostor to remove
  99924. */
  99925. removeImpostor(impostor: PhysicsImpostor): void;
  99926. /**
  99927. * Add a joint to the physics engine
  99928. * @param mainImpostor defines the main impostor to which the joint is added.
  99929. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  99930. * @param joint defines the joint that will connect both impostors.
  99931. */
  99932. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  99933. /**
  99934. * Removes a joint from the simulation
  99935. * @param mainImpostor defines the impostor used with the joint
  99936. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  99937. * @param joint defines the joint to remove
  99938. */
  99939. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  99940. /**
  99941. * Gets the current plugin used to run the simulation
  99942. * @returns current plugin
  99943. */
  99944. getPhysicsPlugin(): IPhysicsEnginePlugin;
  99945. /**
  99946. * Gets the list of physic impostors
  99947. * @returns an array of PhysicsImpostor
  99948. */
  99949. getImpostors(): Array<PhysicsImpostor>;
  99950. /**
  99951. * Gets the impostor for a physics enabled object
  99952. * @param object defines the object impersonated by the impostor
  99953. * @returns the PhysicsImpostor or null if not found
  99954. */
  99955. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  99956. /**
  99957. * Gets the impostor for a physics body object
  99958. * @param body defines physics body used by the impostor
  99959. * @returns the PhysicsImpostor or null if not found
  99960. */
  99961. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  99962. /**
  99963. * Does a raycast in the physics world
  99964. * @param from when should the ray start?
  99965. * @param to when should the ray end?
  99966. * @returns PhysicsRaycastResult
  99967. */
  99968. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  99969. /**
  99970. * Called by the scene. No need to call it.
  99971. * @param delta defines the timespam between frames
  99972. */
  99973. _step(delta: number): void;
  99974. }
  99975. }
  99976. declare module BABYLON {
  99977. /**
  99978. * The interface for the physics imposter parameters
  99979. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  99980. */
  99981. export interface PhysicsImpostorParameters {
  99982. /**
  99983. * The mass of the physics imposter
  99984. */
  99985. mass: number;
  99986. /**
  99987. * The friction of the physics imposter
  99988. */
  99989. friction?: number;
  99990. /**
  99991. * The coefficient of restitution of the physics imposter
  99992. */
  99993. restitution?: number;
  99994. /**
  99995. * The native options of the physics imposter
  99996. */
  99997. nativeOptions?: any;
  99998. /**
  99999. * Specifies if the parent should be ignored
  100000. */
  100001. ignoreParent?: boolean;
  100002. /**
  100003. * Specifies if bi-directional transformations should be disabled
  100004. */
  100005. disableBidirectionalTransformation?: boolean;
  100006. /**
  100007. * The pressure inside the physics imposter, soft object only
  100008. */
  100009. pressure?: number;
  100010. /**
  100011. * The stiffness the physics imposter, soft object only
  100012. */
  100013. stiffness?: number;
  100014. /**
  100015. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  100016. */
  100017. velocityIterations?: number;
  100018. /**
  100019. * The number of iterations used in maintaining consistent vertex positions, soft object only
  100020. */
  100021. positionIterations?: number;
  100022. /**
  100023. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  100024. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  100025. * Add to fix multiple points
  100026. */
  100027. fixedPoints?: number;
  100028. /**
  100029. * The collision margin around a soft object
  100030. */
  100031. margin?: number;
  100032. /**
  100033. * The collision margin around a soft object
  100034. */
  100035. damping?: number;
  100036. /**
  100037. * The path for a rope based on an extrusion
  100038. */
  100039. path?: any;
  100040. /**
  100041. * The shape of an extrusion used for a rope based on an extrusion
  100042. */
  100043. shape?: any;
  100044. }
  100045. /**
  100046. * Interface for a physics-enabled object
  100047. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  100048. */
  100049. export interface IPhysicsEnabledObject {
  100050. /**
  100051. * The position of the physics-enabled object
  100052. */
  100053. position: Vector3;
  100054. /**
  100055. * The rotation of the physics-enabled object
  100056. */
  100057. rotationQuaternion: Nullable<Quaternion>;
  100058. /**
  100059. * The scale of the physics-enabled object
  100060. */
  100061. scaling: Vector3;
  100062. /**
  100063. * The rotation of the physics-enabled object
  100064. */
  100065. rotation?: Vector3;
  100066. /**
  100067. * The parent of the physics-enabled object
  100068. */
  100069. parent?: any;
  100070. /**
  100071. * The bounding info of the physics-enabled object
  100072. * @returns The bounding info of the physics-enabled object
  100073. */
  100074. getBoundingInfo(): BoundingInfo;
  100075. /**
  100076. * Computes the world matrix
  100077. * @param force Specifies if the world matrix should be computed by force
  100078. * @returns A world matrix
  100079. */
  100080. computeWorldMatrix(force: boolean): Matrix;
  100081. /**
  100082. * Gets the world matrix
  100083. * @returns A world matrix
  100084. */
  100085. getWorldMatrix?(): Matrix;
  100086. /**
  100087. * Gets the child meshes
  100088. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  100089. * @returns An array of abstract meshes
  100090. */
  100091. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  100092. /**
  100093. * Gets the vertex data
  100094. * @param kind The type of vertex data
  100095. * @returns A nullable array of numbers, or a float32 array
  100096. */
  100097. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  100098. /**
  100099. * Gets the indices from the mesh
  100100. * @returns A nullable array of index arrays
  100101. */
  100102. getIndices?(): Nullable<IndicesArray>;
  100103. /**
  100104. * Gets the scene from the mesh
  100105. * @returns the indices array or null
  100106. */
  100107. getScene?(): Scene;
  100108. /**
  100109. * Gets the absolute position from the mesh
  100110. * @returns the absolute position
  100111. */
  100112. getAbsolutePosition(): Vector3;
  100113. /**
  100114. * Gets the absolute pivot point from the mesh
  100115. * @returns the absolute pivot point
  100116. */
  100117. getAbsolutePivotPoint(): Vector3;
  100118. /**
  100119. * Rotates the mesh
  100120. * @param axis The axis of rotation
  100121. * @param amount The amount of rotation
  100122. * @param space The space of the rotation
  100123. * @returns The rotation transform node
  100124. */
  100125. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  100126. /**
  100127. * Translates the mesh
  100128. * @param axis The axis of translation
  100129. * @param distance The distance of translation
  100130. * @param space The space of the translation
  100131. * @returns The transform node
  100132. */
  100133. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  100134. /**
  100135. * Sets the absolute position of the mesh
  100136. * @param absolutePosition The absolute position of the mesh
  100137. * @returns The transform node
  100138. */
  100139. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  100140. /**
  100141. * Gets the class name of the mesh
  100142. * @returns The class name
  100143. */
  100144. getClassName(): string;
  100145. }
  100146. /**
  100147. * Represents a physics imposter
  100148. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  100149. */
  100150. export class PhysicsImpostor {
  100151. /**
  100152. * The physics-enabled object used as the physics imposter
  100153. */
  100154. object: IPhysicsEnabledObject;
  100155. /**
  100156. * The type of the physics imposter
  100157. */
  100158. type: number;
  100159. private _options;
  100160. private _scene?;
  100161. /**
  100162. * The default object size of the imposter
  100163. */
  100164. static DEFAULT_OBJECT_SIZE: Vector3;
  100165. /**
  100166. * The identity quaternion of the imposter
  100167. */
  100168. static IDENTITY_QUATERNION: Quaternion;
  100169. /** @hidden */
  100170. _pluginData: any;
  100171. private _physicsEngine;
  100172. private _physicsBody;
  100173. private _bodyUpdateRequired;
  100174. private _onBeforePhysicsStepCallbacks;
  100175. private _onAfterPhysicsStepCallbacks;
  100176. /** @hidden */
  100177. _onPhysicsCollideCallbacks: Array<{
  100178. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  100179. otherImpostors: Array<PhysicsImpostor>;
  100180. }>;
  100181. private _deltaPosition;
  100182. private _deltaRotation;
  100183. private _deltaRotationConjugated;
  100184. /** @hidden */
  100185. _isFromLine: boolean;
  100186. private _parent;
  100187. private _isDisposed;
  100188. private static _tmpVecs;
  100189. private static _tmpQuat;
  100190. /**
  100191. * Specifies if the physics imposter is disposed
  100192. */
  100193. get isDisposed(): boolean;
  100194. /**
  100195. * Gets the mass of the physics imposter
  100196. */
  100197. get mass(): number;
  100198. set mass(value: number);
  100199. /**
  100200. * Gets the coefficient of friction
  100201. */
  100202. get friction(): number;
  100203. /**
  100204. * Sets the coefficient of friction
  100205. */
  100206. set friction(value: number);
  100207. /**
  100208. * Gets the coefficient of restitution
  100209. */
  100210. get restitution(): number;
  100211. /**
  100212. * Sets the coefficient of restitution
  100213. */
  100214. set restitution(value: number);
  100215. /**
  100216. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  100217. */
  100218. get pressure(): number;
  100219. /**
  100220. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  100221. */
  100222. set pressure(value: number);
  100223. /**
  100224. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  100225. */
  100226. get stiffness(): number;
  100227. /**
  100228. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  100229. */
  100230. set stiffness(value: number);
  100231. /**
  100232. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  100233. */
  100234. get velocityIterations(): number;
  100235. /**
  100236. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  100237. */
  100238. set velocityIterations(value: number);
  100239. /**
  100240. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  100241. */
  100242. get positionIterations(): number;
  100243. /**
  100244. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  100245. */
  100246. set positionIterations(value: number);
  100247. /**
  100248. * The unique id of the physics imposter
  100249. * set by the physics engine when adding this impostor to the array
  100250. */
  100251. uniqueId: number;
  100252. /**
  100253. * @hidden
  100254. */
  100255. soft: boolean;
  100256. /**
  100257. * @hidden
  100258. */
  100259. segments: number;
  100260. private _joints;
  100261. /**
  100262. * Initializes the physics imposter
  100263. * @param object The physics-enabled object used as the physics imposter
  100264. * @param type The type of the physics imposter
  100265. * @param _options The options for the physics imposter
  100266. * @param _scene The Babylon scene
  100267. */
  100268. constructor(
  100269. /**
  100270. * The physics-enabled object used as the physics imposter
  100271. */
  100272. object: IPhysicsEnabledObject,
  100273. /**
  100274. * The type of the physics imposter
  100275. */
  100276. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  100277. /**
  100278. * This function will completly initialize this impostor.
  100279. * It will create a new body - but only if this mesh has no parent.
  100280. * If it has, this impostor will not be used other than to define the impostor
  100281. * of the child mesh.
  100282. * @hidden
  100283. */
  100284. _init(): void;
  100285. private _getPhysicsParent;
  100286. /**
  100287. * Should a new body be generated.
  100288. * @returns boolean specifying if body initialization is required
  100289. */
  100290. isBodyInitRequired(): boolean;
  100291. /**
  100292. * Sets the updated scaling
  100293. * @param updated Specifies if the scaling is updated
  100294. */
  100295. setScalingUpdated(): void;
  100296. /**
  100297. * Force a regeneration of this or the parent's impostor's body.
  100298. * Use under cautious - This will remove all joints already implemented.
  100299. */
  100300. forceUpdate(): void;
  100301. /**
  100302. * Gets the body that holds this impostor. Either its own, or its parent.
  100303. */
  100304. get physicsBody(): any;
  100305. /**
  100306. * Get the parent of the physics imposter
  100307. * @returns Physics imposter or null
  100308. */
  100309. get parent(): Nullable<PhysicsImpostor>;
  100310. /**
  100311. * Sets the parent of the physics imposter
  100312. */
  100313. set parent(value: Nullable<PhysicsImpostor>);
  100314. /**
  100315. * Set the physics body. Used mainly by the physics engine/plugin
  100316. */
  100317. set physicsBody(physicsBody: any);
  100318. /**
  100319. * Resets the update flags
  100320. */
  100321. resetUpdateFlags(): void;
  100322. /**
  100323. * Gets the object extend size
  100324. * @returns the object extend size
  100325. */
  100326. getObjectExtendSize(): Vector3;
  100327. /**
  100328. * Gets the object center
  100329. * @returns The object center
  100330. */
  100331. getObjectCenter(): Vector3;
  100332. /**
  100333. * Get a specific parameter from the options parameters
  100334. * @param paramName The object parameter name
  100335. * @returns The object parameter
  100336. */
  100337. getParam(paramName: string): any;
  100338. /**
  100339. * Sets a specific parameter in the options given to the physics plugin
  100340. * @param paramName The parameter name
  100341. * @param value The value of the parameter
  100342. */
  100343. setParam(paramName: string, value: number): void;
  100344. /**
  100345. * Specifically change the body's mass option. Won't recreate the physics body object
  100346. * @param mass The mass of the physics imposter
  100347. */
  100348. setMass(mass: number): void;
  100349. /**
  100350. * Gets the linear velocity
  100351. * @returns linear velocity or null
  100352. */
  100353. getLinearVelocity(): Nullable<Vector3>;
  100354. /**
  100355. * Sets the linear velocity
  100356. * @param velocity linear velocity or null
  100357. */
  100358. setLinearVelocity(velocity: Nullable<Vector3>): void;
  100359. /**
  100360. * Gets the angular velocity
  100361. * @returns angular velocity or null
  100362. */
  100363. getAngularVelocity(): Nullable<Vector3>;
  100364. /**
  100365. * Sets the angular velocity
  100366. * @param velocity The velocity or null
  100367. */
  100368. setAngularVelocity(velocity: Nullable<Vector3>): void;
  100369. /**
  100370. * Execute a function with the physics plugin native code
  100371. * Provide a function the will have two variables - the world object and the physics body object
  100372. * @param func The function to execute with the physics plugin native code
  100373. */
  100374. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  100375. /**
  100376. * Register a function that will be executed before the physics world is stepping forward
  100377. * @param func The function to execute before the physics world is stepped forward
  100378. */
  100379. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  100380. /**
  100381. * Unregister a function that will be executed before the physics world is stepping forward
  100382. * @param func The function to execute before the physics world is stepped forward
  100383. */
  100384. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  100385. /**
  100386. * Register a function that will be executed after the physics step
  100387. * @param func The function to execute after physics step
  100388. */
  100389. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  100390. /**
  100391. * Unregisters a function that will be executed after the physics step
  100392. * @param func The function to execute after physics step
  100393. */
  100394. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  100395. /**
  100396. * register a function that will be executed when this impostor collides against a different body
  100397. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  100398. * @param func Callback that is executed on collision
  100399. */
  100400. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  100401. /**
  100402. * Unregisters the physics imposter on contact
  100403. * @param collideAgainst The physics object to collide against
  100404. * @param func Callback to execute on collision
  100405. */
  100406. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  100407. private _tmpQuat;
  100408. private _tmpQuat2;
  100409. /**
  100410. * Get the parent rotation
  100411. * @returns The parent rotation
  100412. */
  100413. getParentsRotation(): Quaternion;
  100414. /**
  100415. * this function is executed by the physics engine.
  100416. */
  100417. beforeStep: () => void;
  100418. /**
  100419. * this function is executed by the physics engine
  100420. */
  100421. afterStep: () => void;
  100422. /**
  100423. * Legacy collision detection event support
  100424. */
  100425. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  100426. /**
  100427. * event and body object due to cannon's event-based architecture.
  100428. */
  100429. onCollide: (e: {
  100430. body: any;
  100431. }) => void;
  100432. /**
  100433. * Apply a force
  100434. * @param force The force to apply
  100435. * @param contactPoint The contact point for the force
  100436. * @returns The physics imposter
  100437. */
  100438. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  100439. /**
  100440. * Apply an impulse
  100441. * @param force The impulse force
  100442. * @param contactPoint The contact point for the impulse force
  100443. * @returns The physics imposter
  100444. */
  100445. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  100446. /**
  100447. * A help function to create a joint
  100448. * @param otherImpostor A physics imposter used to create a joint
  100449. * @param jointType The type of joint
  100450. * @param jointData The data for the joint
  100451. * @returns The physics imposter
  100452. */
  100453. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  100454. /**
  100455. * Add a joint to this impostor with a different impostor
  100456. * @param otherImpostor A physics imposter used to add a joint
  100457. * @param joint The joint to add
  100458. * @returns The physics imposter
  100459. */
  100460. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  100461. /**
  100462. * Add an anchor to a cloth impostor
  100463. * @param otherImpostor rigid impostor to anchor to
  100464. * @param width ratio across width from 0 to 1
  100465. * @param height ratio up height from 0 to 1
  100466. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  100467. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  100468. * @returns impostor the soft imposter
  100469. */
  100470. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  100471. /**
  100472. * Add a hook to a rope impostor
  100473. * @param otherImpostor rigid impostor to anchor to
  100474. * @param length ratio across rope from 0 to 1
  100475. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  100476. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  100477. * @returns impostor the rope imposter
  100478. */
  100479. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  100480. /**
  100481. * Will keep this body still, in a sleep mode.
  100482. * @returns the physics imposter
  100483. */
  100484. sleep(): PhysicsImpostor;
  100485. /**
  100486. * Wake the body up.
  100487. * @returns The physics imposter
  100488. */
  100489. wakeUp(): PhysicsImpostor;
  100490. /**
  100491. * Clones the physics imposter
  100492. * @param newObject The physics imposter clones to this physics-enabled object
  100493. * @returns A nullable physics imposter
  100494. */
  100495. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  100496. /**
  100497. * Disposes the physics imposter
  100498. */
  100499. dispose(): void;
  100500. /**
  100501. * Sets the delta position
  100502. * @param position The delta position amount
  100503. */
  100504. setDeltaPosition(position: Vector3): void;
  100505. /**
  100506. * Sets the delta rotation
  100507. * @param rotation The delta rotation amount
  100508. */
  100509. setDeltaRotation(rotation: Quaternion): void;
  100510. /**
  100511. * Gets the box size of the physics imposter and stores the result in the input parameter
  100512. * @param result Stores the box size
  100513. * @returns The physics imposter
  100514. */
  100515. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  100516. /**
  100517. * Gets the radius of the physics imposter
  100518. * @returns Radius of the physics imposter
  100519. */
  100520. getRadius(): number;
  100521. /**
  100522. * Sync a bone with this impostor
  100523. * @param bone The bone to sync to the impostor.
  100524. * @param boneMesh The mesh that the bone is influencing.
  100525. * @param jointPivot The pivot of the joint / bone in local space.
  100526. * @param distToJoint Optional distance from the impostor to the joint.
  100527. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  100528. */
  100529. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  100530. /**
  100531. * Sync impostor to a bone
  100532. * @param bone The bone that the impostor will be synced to.
  100533. * @param boneMesh The mesh that the bone is influencing.
  100534. * @param jointPivot The pivot of the joint / bone in local space.
  100535. * @param distToJoint Optional distance from the impostor to the joint.
  100536. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  100537. * @param boneAxis Optional vector3 axis the bone is aligned with
  100538. */
  100539. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  100540. /**
  100541. * No-Imposter type
  100542. */
  100543. static NoImpostor: number;
  100544. /**
  100545. * Sphere-Imposter type
  100546. */
  100547. static SphereImpostor: number;
  100548. /**
  100549. * Box-Imposter type
  100550. */
  100551. static BoxImpostor: number;
  100552. /**
  100553. * Plane-Imposter type
  100554. */
  100555. static PlaneImpostor: number;
  100556. /**
  100557. * Mesh-imposter type
  100558. */
  100559. static MeshImpostor: number;
  100560. /**
  100561. * Capsule-Impostor type (Ammo.js plugin only)
  100562. */
  100563. static CapsuleImpostor: number;
  100564. /**
  100565. * Cylinder-Imposter type
  100566. */
  100567. static CylinderImpostor: number;
  100568. /**
  100569. * Particle-Imposter type
  100570. */
  100571. static ParticleImpostor: number;
  100572. /**
  100573. * Heightmap-Imposter type
  100574. */
  100575. static HeightmapImpostor: number;
  100576. /**
  100577. * ConvexHull-Impostor type (Ammo.js plugin only)
  100578. */
  100579. static ConvexHullImpostor: number;
  100580. /**
  100581. * Custom-Imposter type (Ammo.js plugin only)
  100582. */
  100583. static CustomImpostor: number;
  100584. /**
  100585. * Rope-Imposter type
  100586. */
  100587. static RopeImpostor: number;
  100588. /**
  100589. * Cloth-Imposter type
  100590. */
  100591. static ClothImpostor: number;
  100592. /**
  100593. * Softbody-Imposter type
  100594. */
  100595. static SoftbodyImpostor: number;
  100596. }
  100597. }
  100598. declare module BABYLON {
  100599. /**
  100600. * @hidden
  100601. **/
  100602. export class _CreationDataStorage {
  100603. closePath?: boolean;
  100604. closeArray?: boolean;
  100605. idx: number[];
  100606. dashSize: number;
  100607. gapSize: number;
  100608. path3D: Path3D;
  100609. pathArray: Vector3[][];
  100610. arc: number;
  100611. radius: number;
  100612. cap: number;
  100613. tessellation: number;
  100614. }
  100615. /**
  100616. * @hidden
  100617. **/
  100618. class _InstanceDataStorage {
  100619. visibleInstances: any;
  100620. batchCache: _InstancesBatch;
  100621. instancesBufferSize: number;
  100622. instancesBuffer: Nullable<Buffer>;
  100623. instancesData: Float32Array;
  100624. overridenInstanceCount: number;
  100625. isFrozen: boolean;
  100626. previousBatch: Nullable<_InstancesBatch>;
  100627. hardwareInstancedRendering: boolean;
  100628. sideOrientation: number;
  100629. manualUpdate: boolean;
  100630. }
  100631. /**
  100632. * @hidden
  100633. **/
  100634. export class _InstancesBatch {
  100635. mustReturn: boolean;
  100636. visibleInstances: Nullable<InstancedMesh[]>[];
  100637. renderSelf: boolean[];
  100638. hardwareInstancedRendering: boolean[];
  100639. }
  100640. /**
  100641. * Class used to represent renderable models
  100642. */
  100643. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  100644. /**
  100645. * Mesh side orientation : usually the external or front surface
  100646. */
  100647. static readonly FRONTSIDE: number;
  100648. /**
  100649. * Mesh side orientation : usually the internal or back surface
  100650. */
  100651. static readonly BACKSIDE: number;
  100652. /**
  100653. * Mesh side orientation : both internal and external or front and back surfaces
  100654. */
  100655. static readonly DOUBLESIDE: number;
  100656. /**
  100657. * Mesh side orientation : by default, `FRONTSIDE`
  100658. */
  100659. static readonly DEFAULTSIDE: number;
  100660. /**
  100661. * Mesh cap setting : no cap
  100662. */
  100663. static readonly NO_CAP: number;
  100664. /**
  100665. * Mesh cap setting : one cap at the beginning of the mesh
  100666. */
  100667. static readonly CAP_START: number;
  100668. /**
  100669. * Mesh cap setting : one cap at the end of the mesh
  100670. */
  100671. static readonly CAP_END: number;
  100672. /**
  100673. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  100674. */
  100675. static readonly CAP_ALL: number;
  100676. /**
  100677. * Mesh pattern setting : no flip or rotate
  100678. */
  100679. static readonly NO_FLIP: number;
  100680. /**
  100681. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  100682. */
  100683. static readonly FLIP_TILE: number;
  100684. /**
  100685. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  100686. */
  100687. static readonly ROTATE_TILE: number;
  100688. /**
  100689. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  100690. */
  100691. static readonly FLIP_ROW: number;
  100692. /**
  100693. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  100694. */
  100695. static readonly ROTATE_ROW: number;
  100696. /**
  100697. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  100698. */
  100699. static readonly FLIP_N_ROTATE_TILE: number;
  100700. /**
  100701. * Mesh pattern setting : rotate pattern and rotate
  100702. */
  100703. static readonly FLIP_N_ROTATE_ROW: number;
  100704. /**
  100705. * Mesh tile positioning : part tiles same on left/right or top/bottom
  100706. */
  100707. static readonly CENTER: number;
  100708. /**
  100709. * Mesh tile positioning : part tiles on left
  100710. */
  100711. static readonly LEFT: number;
  100712. /**
  100713. * Mesh tile positioning : part tiles on right
  100714. */
  100715. static readonly RIGHT: number;
  100716. /**
  100717. * Mesh tile positioning : part tiles on top
  100718. */
  100719. static readonly TOP: number;
  100720. /**
  100721. * Mesh tile positioning : part tiles on bottom
  100722. */
  100723. static readonly BOTTOM: number;
  100724. /**
  100725. * Gets the default side orientation.
  100726. * @param orientation the orientation to value to attempt to get
  100727. * @returns the default orientation
  100728. * @hidden
  100729. */
  100730. static _GetDefaultSideOrientation(orientation?: number): number;
  100731. private _internalMeshDataInfo;
  100732. /**
  100733. * An event triggered before rendering the mesh
  100734. */
  100735. get onBeforeRenderObservable(): Observable<Mesh>;
  100736. /**
  100737. * An event triggered before binding the mesh
  100738. */
  100739. get onBeforeBindObservable(): Observable<Mesh>;
  100740. /**
  100741. * An event triggered after rendering the mesh
  100742. */
  100743. get onAfterRenderObservable(): Observable<Mesh>;
  100744. /**
  100745. * An event triggered before drawing the mesh
  100746. */
  100747. get onBeforeDrawObservable(): Observable<Mesh>;
  100748. private _onBeforeDrawObserver;
  100749. /**
  100750. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  100751. */
  100752. set onBeforeDraw(callback: () => void);
  100753. get hasInstances(): boolean;
  100754. /**
  100755. * Gets the delay loading state of the mesh (when delay loading is turned on)
  100756. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  100757. */
  100758. delayLoadState: number;
  100759. /**
  100760. * Gets the list of instances created from this mesh
  100761. * it is not supposed to be modified manually.
  100762. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  100763. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  100764. */
  100765. instances: InstancedMesh[];
  100766. /**
  100767. * Gets the file containing delay loading data for this mesh
  100768. */
  100769. delayLoadingFile: string;
  100770. /** @hidden */
  100771. _binaryInfo: any;
  100772. /**
  100773. * User defined function used to change how LOD level selection is done
  100774. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  100775. */
  100776. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  100777. /**
  100778. * Gets or sets the morph target manager
  100779. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  100780. */
  100781. get morphTargetManager(): Nullable<MorphTargetManager>;
  100782. set morphTargetManager(value: Nullable<MorphTargetManager>);
  100783. /** @hidden */
  100784. _creationDataStorage: Nullable<_CreationDataStorage>;
  100785. /** @hidden */
  100786. _geometry: Nullable<Geometry>;
  100787. /** @hidden */
  100788. _delayInfo: Array<string>;
  100789. /** @hidden */
  100790. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  100791. /** @hidden */
  100792. _instanceDataStorage: _InstanceDataStorage;
  100793. private _effectiveMaterial;
  100794. /** @hidden */
  100795. _shouldGenerateFlatShading: boolean;
  100796. /** @hidden */
  100797. _originalBuilderSideOrientation: number;
  100798. /**
  100799. * Use this property to change the original side orientation defined at construction time
  100800. */
  100801. overrideMaterialSideOrientation: Nullable<number>;
  100802. /**
  100803. * Gets the source mesh (the one used to clone this one from)
  100804. */
  100805. get source(): Nullable<Mesh>;
  100806. /**
  100807. * Gets or sets a boolean indicating that this mesh does not use index buffer
  100808. */
  100809. get isUnIndexed(): boolean;
  100810. set isUnIndexed(value: boolean);
  100811. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  100812. get worldMatrixInstancedBuffer(): Float32Array;
  100813. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  100814. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  100815. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  100816. /**
  100817. * @constructor
  100818. * @param name The value used by scene.getMeshByName() to do a lookup.
  100819. * @param scene The scene to add this mesh to.
  100820. * @param parent The parent of this mesh, if it has one
  100821. * @param source An optional Mesh from which geometry is shared, cloned.
  100822. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  100823. * When false, achieved by calling a clone(), also passing False.
  100824. * This will make creation of children, recursive.
  100825. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  100826. */
  100827. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  100828. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  100829. doNotInstantiate: boolean;
  100830. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  100831. /**
  100832. * Gets the class name
  100833. * @returns the string "Mesh".
  100834. */
  100835. getClassName(): string;
  100836. /** @hidden */
  100837. get _isMesh(): boolean;
  100838. /**
  100839. * Returns a description of this mesh
  100840. * @param fullDetails define if full details about this mesh must be used
  100841. * @returns a descriptive string representing this mesh
  100842. */
  100843. toString(fullDetails?: boolean): string;
  100844. /** @hidden */
  100845. _unBindEffect(): void;
  100846. /**
  100847. * Gets a boolean indicating if this mesh has LOD
  100848. */
  100849. get hasLODLevels(): boolean;
  100850. /**
  100851. * Gets the list of MeshLODLevel associated with the current mesh
  100852. * @returns an array of MeshLODLevel
  100853. */
  100854. getLODLevels(): MeshLODLevel[];
  100855. private _sortLODLevels;
  100856. /**
  100857. * Add a mesh as LOD level triggered at the given distance.
  100858. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  100859. * @param distance The distance from the center of the object to show this level
  100860. * @param mesh The mesh to be added as LOD level (can be null)
  100861. * @return This mesh (for chaining)
  100862. */
  100863. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  100864. /**
  100865. * Returns the LOD level mesh at the passed distance or null if not found.
  100866. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  100867. * @param distance The distance from the center of the object to show this level
  100868. * @returns a Mesh or `null`
  100869. */
  100870. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  100871. /**
  100872. * Remove a mesh from the LOD array
  100873. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  100874. * @param mesh defines the mesh to be removed
  100875. * @return This mesh (for chaining)
  100876. */
  100877. removeLODLevel(mesh: Mesh): Mesh;
  100878. /**
  100879. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  100880. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  100881. * @param camera defines the camera to use to compute distance
  100882. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  100883. * @return This mesh (for chaining)
  100884. */
  100885. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  100886. /**
  100887. * Gets the mesh internal Geometry object
  100888. */
  100889. get geometry(): Nullable<Geometry>;
  100890. /**
  100891. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  100892. * @returns the total number of vertices
  100893. */
  100894. getTotalVertices(): number;
  100895. /**
  100896. * Returns the content of an associated vertex buffer
  100897. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  100898. * - VertexBuffer.PositionKind
  100899. * - VertexBuffer.UVKind
  100900. * - VertexBuffer.UV2Kind
  100901. * - VertexBuffer.UV3Kind
  100902. * - VertexBuffer.UV4Kind
  100903. * - VertexBuffer.UV5Kind
  100904. * - VertexBuffer.UV6Kind
  100905. * - VertexBuffer.ColorKind
  100906. * - VertexBuffer.MatricesIndicesKind
  100907. * - VertexBuffer.MatricesIndicesExtraKind
  100908. * - VertexBuffer.MatricesWeightsKind
  100909. * - VertexBuffer.MatricesWeightsExtraKind
  100910. * @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
  100911. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  100912. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  100913. */
  100914. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  100915. /**
  100916. * Returns the mesh VertexBuffer object from the requested `kind`
  100917. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  100918. * - VertexBuffer.PositionKind
  100919. * - VertexBuffer.NormalKind
  100920. * - VertexBuffer.UVKind
  100921. * - VertexBuffer.UV2Kind
  100922. * - VertexBuffer.UV3Kind
  100923. * - VertexBuffer.UV4Kind
  100924. * - VertexBuffer.UV5Kind
  100925. * - VertexBuffer.UV6Kind
  100926. * - VertexBuffer.ColorKind
  100927. * - VertexBuffer.MatricesIndicesKind
  100928. * - VertexBuffer.MatricesIndicesExtraKind
  100929. * - VertexBuffer.MatricesWeightsKind
  100930. * - VertexBuffer.MatricesWeightsExtraKind
  100931. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  100932. */
  100933. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  100934. /**
  100935. * Tests if a specific vertex buffer is associated with this mesh
  100936. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  100937. * - VertexBuffer.PositionKind
  100938. * - VertexBuffer.NormalKind
  100939. * - VertexBuffer.UVKind
  100940. * - VertexBuffer.UV2Kind
  100941. * - VertexBuffer.UV3Kind
  100942. * - VertexBuffer.UV4Kind
  100943. * - VertexBuffer.UV5Kind
  100944. * - VertexBuffer.UV6Kind
  100945. * - VertexBuffer.ColorKind
  100946. * - VertexBuffer.MatricesIndicesKind
  100947. * - VertexBuffer.MatricesIndicesExtraKind
  100948. * - VertexBuffer.MatricesWeightsKind
  100949. * - VertexBuffer.MatricesWeightsExtraKind
  100950. * @returns a boolean
  100951. */
  100952. isVerticesDataPresent(kind: string): boolean;
  100953. /**
  100954. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  100955. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  100956. * - VertexBuffer.PositionKind
  100957. * - VertexBuffer.UVKind
  100958. * - VertexBuffer.UV2Kind
  100959. * - VertexBuffer.UV3Kind
  100960. * - VertexBuffer.UV4Kind
  100961. * - VertexBuffer.UV5Kind
  100962. * - VertexBuffer.UV6Kind
  100963. * - VertexBuffer.ColorKind
  100964. * - VertexBuffer.MatricesIndicesKind
  100965. * - VertexBuffer.MatricesIndicesExtraKind
  100966. * - VertexBuffer.MatricesWeightsKind
  100967. * - VertexBuffer.MatricesWeightsExtraKind
  100968. * @returns a boolean
  100969. */
  100970. isVertexBufferUpdatable(kind: string): boolean;
  100971. /**
  100972. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  100973. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  100974. * - VertexBuffer.PositionKind
  100975. * - VertexBuffer.NormalKind
  100976. * - VertexBuffer.UVKind
  100977. * - VertexBuffer.UV2Kind
  100978. * - VertexBuffer.UV3Kind
  100979. * - VertexBuffer.UV4Kind
  100980. * - VertexBuffer.UV5Kind
  100981. * - VertexBuffer.UV6Kind
  100982. * - VertexBuffer.ColorKind
  100983. * - VertexBuffer.MatricesIndicesKind
  100984. * - VertexBuffer.MatricesIndicesExtraKind
  100985. * - VertexBuffer.MatricesWeightsKind
  100986. * - VertexBuffer.MatricesWeightsExtraKind
  100987. * @returns an array of strings
  100988. */
  100989. getVerticesDataKinds(): string[];
  100990. /**
  100991. * Returns a positive integer : the total number of indices in this mesh geometry.
  100992. * @returns the numner of indices or zero if the mesh has no geometry.
  100993. */
  100994. getTotalIndices(): number;
  100995. /**
  100996. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  100997. * @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.
  100998. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  100999. * @returns the indices array or an empty array if the mesh has no geometry
  101000. */
  101001. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  101002. get isBlocked(): boolean;
  101003. /**
  101004. * Determine if the current mesh is ready to be rendered
  101005. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  101006. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  101007. * @returns true if all associated assets are ready (material, textures, shaders)
  101008. */
  101009. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  101010. /**
  101011. * 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.
  101012. */
  101013. get areNormalsFrozen(): boolean;
  101014. /**
  101015. * 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.
  101016. * @returns the current mesh
  101017. */
  101018. freezeNormals(): Mesh;
  101019. /**
  101020. * 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
  101021. * @returns the current mesh
  101022. */
  101023. unfreezeNormals(): Mesh;
  101024. /**
  101025. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  101026. */
  101027. set overridenInstanceCount(count: number);
  101028. /** @hidden */
  101029. _preActivate(): Mesh;
  101030. /** @hidden */
  101031. _preActivateForIntermediateRendering(renderId: number): Mesh;
  101032. /** @hidden */
  101033. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  101034. /**
  101035. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  101036. * This means the mesh underlying bounding box and sphere are recomputed.
  101037. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  101038. * @returns the current mesh
  101039. */
  101040. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  101041. /** @hidden */
  101042. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  101043. /**
  101044. * This function will subdivide the mesh into multiple submeshes
  101045. * @param count defines the expected number of submeshes
  101046. */
  101047. subdivide(count: number): void;
  101048. /**
  101049. * Copy a FloatArray into a specific associated vertex buffer
  101050. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  101051. * - VertexBuffer.PositionKind
  101052. * - VertexBuffer.UVKind
  101053. * - VertexBuffer.UV2Kind
  101054. * - VertexBuffer.UV3Kind
  101055. * - VertexBuffer.UV4Kind
  101056. * - VertexBuffer.UV5Kind
  101057. * - VertexBuffer.UV6Kind
  101058. * - VertexBuffer.ColorKind
  101059. * - VertexBuffer.MatricesIndicesKind
  101060. * - VertexBuffer.MatricesIndicesExtraKind
  101061. * - VertexBuffer.MatricesWeightsKind
  101062. * - VertexBuffer.MatricesWeightsExtraKind
  101063. * @param data defines the data source
  101064. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  101065. * @param stride defines the data stride size (can be null)
  101066. * @returns the current mesh
  101067. */
  101068. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  101069. /**
  101070. * Delete a vertex buffer associated with this mesh
  101071. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  101072. * - VertexBuffer.PositionKind
  101073. * - VertexBuffer.UVKind
  101074. * - VertexBuffer.UV2Kind
  101075. * - VertexBuffer.UV3Kind
  101076. * - VertexBuffer.UV4Kind
  101077. * - VertexBuffer.UV5Kind
  101078. * - VertexBuffer.UV6Kind
  101079. * - VertexBuffer.ColorKind
  101080. * - VertexBuffer.MatricesIndicesKind
  101081. * - VertexBuffer.MatricesIndicesExtraKind
  101082. * - VertexBuffer.MatricesWeightsKind
  101083. * - VertexBuffer.MatricesWeightsExtraKind
  101084. */
  101085. removeVerticesData(kind: string): void;
  101086. /**
  101087. * Flags an associated vertex buffer as updatable
  101088. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  101089. * - VertexBuffer.PositionKind
  101090. * - VertexBuffer.UVKind
  101091. * - VertexBuffer.UV2Kind
  101092. * - VertexBuffer.UV3Kind
  101093. * - VertexBuffer.UV4Kind
  101094. * - VertexBuffer.UV5Kind
  101095. * - VertexBuffer.UV6Kind
  101096. * - VertexBuffer.ColorKind
  101097. * - VertexBuffer.MatricesIndicesKind
  101098. * - VertexBuffer.MatricesIndicesExtraKind
  101099. * - VertexBuffer.MatricesWeightsKind
  101100. * - VertexBuffer.MatricesWeightsExtraKind
  101101. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  101102. */
  101103. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  101104. /**
  101105. * Sets the mesh global Vertex Buffer
  101106. * @param buffer defines the buffer to use
  101107. * @returns the current mesh
  101108. */
  101109. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  101110. /**
  101111. * Update a specific associated vertex buffer
  101112. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  101113. * - VertexBuffer.PositionKind
  101114. * - VertexBuffer.UVKind
  101115. * - VertexBuffer.UV2Kind
  101116. * - VertexBuffer.UV3Kind
  101117. * - VertexBuffer.UV4Kind
  101118. * - VertexBuffer.UV5Kind
  101119. * - VertexBuffer.UV6Kind
  101120. * - VertexBuffer.ColorKind
  101121. * - VertexBuffer.MatricesIndicesKind
  101122. * - VertexBuffer.MatricesIndicesExtraKind
  101123. * - VertexBuffer.MatricesWeightsKind
  101124. * - VertexBuffer.MatricesWeightsExtraKind
  101125. * @param data defines the data source
  101126. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  101127. * @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)
  101128. * @returns the current mesh
  101129. */
  101130. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  101131. /**
  101132. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  101133. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  101134. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  101135. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  101136. * @returns the current mesh
  101137. */
  101138. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  101139. /**
  101140. * Creates a un-shared specific occurence of the geometry for the mesh.
  101141. * @returns the current mesh
  101142. */
  101143. makeGeometryUnique(): Mesh;
  101144. /**
  101145. * Set the index buffer of this mesh
  101146. * @param indices defines the source data
  101147. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  101148. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  101149. * @returns the current mesh
  101150. */
  101151. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  101152. /**
  101153. * Update the current index buffer
  101154. * @param indices defines the source data
  101155. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  101156. * @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)
  101157. * @returns the current mesh
  101158. */
  101159. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  101160. /**
  101161. * Invert the geometry to move from a right handed system to a left handed one.
  101162. * @returns the current mesh
  101163. */
  101164. toLeftHanded(): Mesh;
  101165. /** @hidden */
  101166. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  101167. /** @hidden */
  101168. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  101169. /**
  101170. * Registers for this mesh a javascript function called just before the rendering process
  101171. * @param func defines the function to call before rendering this mesh
  101172. * @returns the current mesh
  101173. */
  101174. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  101175. /**
  101176. * Disposes a previously registered javascript function called before the rendering
  101177. * @param func defines the function to remove
  101178. * @returns the current mesh
  101179. */
  101180. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  101181. /**
  101182. * Registers for this mesh a javascript function called just after the rendering is complete
  101183. * @param func defines the function to call after rendering this mesh
  101184. * @returns the current mesh
  101185. */
  101186. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  101187. /**
  101188. * Disposes a previously registered javascript function called after the rendering.
  101189. * @param func defines the function to remove
  101190. * @returns the current mesh
  101191. */
  101192. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  101193. /** @hidden */
  101194. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  101195. /** @hidden */
  101196. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  101197. /** @hidden */
  101198. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  101199. /** @hidden */
  101200. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  101201. /** @hidden */
  101202. _rebuild(): void;
  101203. /** @hidden */
  101204. _freeze(): void;
  101205. /** @hidden */
  101206. _unFreeze(): void;
  101207. /**
  101208. * 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
  101209. * @param subMesh defines the subMesh to render
  101210. * @param enableAlphaMode defines if alpha mode can be changed
  101211. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  101212. * @returns the current mesh
  101213. */
  101214. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  101215. private _onBeforeDraw;
  101216. /**
  101217. * Renormalize the mesh and patch it up if there are no weights
  101218. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  101219. * However in the case of zero weights then we set just a single influence to 1.
  101220. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  101221. */
  101222. cleanMatrixWeights(): void;
  101223. private normalizeSkinFourWeights;
  101224. private normalizeSkinWeightsAndExtra;
  101225. /**
  101226. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  101227. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  101228. * the user know there was an issue with importing the mesh
  101229. * @returns a validation object with skinned, valid and report string
  101230. */
  101231. validateSkinning(): {
  101232. skinned: boolean;
  101233. valid: boolean;
  101234. report: string;
  101235. };
  101236. /** @hidden */
  101237. _checkDelayState(): Mesh;
  101238. private _queueLoad;
  101239. /**
  101240. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  101241. * A mesh is in the frustum if its bounding box intersects the frustum
  101242. * @param frustumPlanes defines the frustum to test
  101243. * @returns true if the mesh is in the frustum planes
  101244. */
  101245. isInFrustum(frustumPlanes: Plane[]): boolean;
  101246. /**
  101247. * Sets the mesh material by the material or multiMaterial `id` property
  101248. * @param id is a string identifying the material or the multiMaterial
  101249. * @returns the current mesh
  101250. */
  101251. setMaterialByID(id: string): Mesh;
  101252. /**
  101253. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  101254. * @returns an array of IAnimatable
  101255. */
  101256. getAnimatables(): IAnimatable[];
  101257. /**
  101258. * Modifies the mesh geometry according to the passed transformation matrix.
  101259. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  101260. * The mesh normals are modified using the same transformation.
  101261. * Note that, under the hood, this method sets a new VertexBuffer each call.
  101262. * @param transform defines the transform matrix to use
  101263. * @see http://doc.babylonjs.com/resources/baking_transformations
  101264. * @returns the current mesh
  101265. */
  101266. bakeTransformIntoVertices(transform: Matrix): Mesh;
  101267. /**
  101268. * Modifies the mesh geometry according to its own current World Matrix.
  101269. * The mesh World Matrix is then reset.
  101270. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  101271. * Note that, under the hood, this method sets a new VertexBuffer each call.
  101272. * @see http://doc.babylonjs.com/resources/baking_transformations
  101273. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  101274. * @returns the current mesh
  101275. */
  101276. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  101277. /** @hidden */
  101278. get _positions(): Nullable<Vector3[]>;
  101279. /** @hidden */
  101280. _resetPointsArrayCache(): Mesh;
  101281. /** @hidden */
  101282. _generatePointsArray(): boolean;
  101283. /**
  101284. * Returns a new Mesh object generated from the current mesh properties.
  101285. * This method must not get confused with createInstance()
  101286. * @param name is a string, the name given to the new mesh
  101287. * @param newParent can be any Node object (default `null`)
  101288. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  101289. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  101290. * @returns a new mesh
  101291. */
  101292. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  101293. /**
  101294. * Releases resources associated with this mesh.
  101295. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  101296. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  101297. */
  101298. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  101299. /** @hidden */
  101300. _disposeInstanceSpecificData(): void;
  101301. /**
  101302. * Modifies the mesh geometry according to a displacement map.
  101303. * 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.
  101304. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  101305. * @param url is a string, the URL from the image file is to be downloaded.
  101306. * @param minHeight is the lower limit of the displacement.
  101307. * @param maxHeight is the upper limit of the displacement.
  101308. * @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.
  101309. * @param uvOffset is an optional vector2 used to offset UV.
  101310. * @param uvScale is an optional vector2 used to scale UV.
  101311. * @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.
  101312. * @returns the Mesh.
  101313. */
  101314. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  101315. /**
  101316. * Modifies the mesh geometry according to a displacementMap buffer.
  101317. * 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.
  101318. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  101319. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  101320. * @param heightMapWidth is the width of the buffer image.
  101321. * @param heightMapHeight is the height of the buffer image.
  101322. * @param minHeight is the lower limit of the displacement.
  101323. * @param maxHeight is the upper limit of the displacement.
  101324. * @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.
  101325. * @param uvOffset is an optional vector2 used to offset UV.
  101326. * @param uvScale is an optional vector2 used to scale UV.
  101327. * @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.
  101328. * @returns the Mesh.
  101329. */
  101330. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  101331. /**
  101332. * Modify the mesh to get a flat shading rendering.
  101333. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  101334. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  101335. * @returns current mesh
  101336. */
  101337. convertToFlatShadedMesh(): Mesh;
  101338. /**
  101339. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  101340. * In other words, more vertices, no more indices and a single bigger VBO.
  101341. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  101342. * @returns current mesh
  101343. */
  101344. convertToUnIndexedMesh(): Mesh;
  101345. /**
  101346. * Inverses facet orientations.
  101347. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  101348. * @param flipNormals will also inverts the normals
  101349. * @returns current mesh
  101350. */
  101351. flipFaces(flipNormals?: boolean): Mesh;
  101352. /**
  101353. * Increase the number of facets and hence vertices in a mesh
  101354. * Vertex normals are interpolated from existing vertex normals
  101355. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  101356. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  101357. */
  101358. increaseVertices(numberPerEdge: number): void;
  101359. /**
  101360. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  101361. * This will undo any application of covertToFlatShadedMesh
  101362. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  101363. */
  101364. forceSharedVertices(): void;
  101365. /** @hidden */
  101366. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  101367. /** @hidden */
  101368. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  101369. /**
  101370. * Creates a new InstancedMesh object from the mesh model.
  101371. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  101372. * @param name defines the name of the new instance
  101373. * @returns a new InstancedMesh
  101374. */
  101375. createInstance(name: string): InstancedMesh;
  101376. /**
  101377. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  101378. * After this call, all the mesh instances have the same submeshes than the current mesh.
  101379. * @returns the current mesh
  101380. */
  101381. synchronizeInstances(): Mesh;
  101382. /**
  101383. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  101384. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  101385. * This should be used together with the simplification to avoid disappearing triangles.
  101386. * @param successCallback an optional success callback to be called after the optimization finished.
  101387. * @returns the current mesh
  101388. */
  101389. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  101390. /**
  101391. * Serialize current mesh
  101392. * @param serializationObject defines the object which will receive the serialization data
  101393. */
  101394. serialize(serializationObject: any): void;
  101395. /** @hidden */
  101396. _syncGeometryWithMorphTargetManager(): void;
  101397. /** @hidden */
  101398. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  101399. /**
  101400. * Returns a new Mesh object parsed from the source provided.
  101401. * @param parsedMesh is the source
  101402. * @param scene defines the hosting scene
  101403. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  101404. * @returns a new Mesh
  101405. */
  101406. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  101407. /**
  101408. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  101409. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  101410. * @param name defines the name of the mesh to create
  101411. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  101412. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  101413. * @param closePath creates a seam between the first and the last points of each path of the path array
  101414. * @param offset is taken in account only if the `pathArray` is containing a single path
  101415. * @param scene defines the hosting scene
  101416. * @param updatable defines if the mesh must be flagged as updatable
  101417. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  101418. * @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)
  101419. * @returns a new Mesh
  101420. */
  101421. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  101422. /**
  101423. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  101424. * @param name defines the name of the mesh to create
  101425. * @param radius sets the radius size (float) of the polygon (default 0.5)
  101426. * @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
  101427. * @param scene defines the hosting scene
  101428. * @param updatable defines if the mesh must be flagged as updatable
  101429. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  101430. * @returns a new Mesh
  101431. */
  101432. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  101433. /**
  101434. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  101435. * @param name defines the name of the mesh to create
  101436. * @param size sets the size (float) of each box side (default 1)
  101437. * @param scene defines the hosting scene
  101438. * @param updatable defines if the mesh must be flagged as updatable
  101439. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  101440. * @returns a new Mesh
  101441. */
  101442. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  101443. /**
  101444. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  101445. * @param name defines the name of the mesh to create
  101446. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  101447. * @param diameter sets the diameter size (float) of the sphere (default 1)
  101448. * @param scene defines the hosting scene
  101449. * @param updatable defines if the mesh must be flagged as updatable
  101450. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  101451. * @returns a new Mesh
  101452. */
  101453. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  101454. /**
  101455. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  101456. * @param name defines the name of the mesh to create
  101457. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  101458. * @param diameter sets the diameter size (float) of the sphere (default 1)
  101459. * @param scene defines the hosting scene
  101460. * @returns a new Mesh
  101461. */
  101462. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  101463. /**
  101464. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  101465. * @param name defines the name of the mesh to create
  101466. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  101467. * @param diameterTop set the top cap diameter (floats, default 1)
  101468. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  101469. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  101470. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  101471. * @param scene defines the hosting scene
  101472. * @param updatable defines if the mesh must be flagged as updatable
  101473. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  101474. * @returns a new Mesh
  101475. */
  101476. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  101477. /**
  101478. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  101479. * @param name defines the name of the mesh to create
  101480. * @param diameter sets the diameter size (float) of the torus (default 1)
  101481. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  101482. * @param tessellation sets the number of torus sides (postive integer, default 16)
  101483. * @param scene defines the hosting scene
  101484. * @param updatable defines if the mesh must be flagged as updatable
  101485. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  101486. * @returns a new Mesh
  101487. */
  101488. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  101489. /**
  101490. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  101491. * @param name defines the name of the mesh to create
  101492. * @param radius sets the global radius size (float) of the torus knot (default 2)
  101493. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  101494. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  101495. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  101496. * @param p the number of windings on X axis (positive integers, default 2)
  101497. * @param q the number of windings on Y axis (positive integers, default 3)
  101498. * @param scene defines the hosting scene
  101499. * @param updatable defines if the mesh must be flagged as updatable
  101500. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  101501. * @returns a new Mesh
  101502. */
  101503. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  101504. /**
  101505. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  101506. * @param name defines the name of the mesh to create
  101507. * @param points is an array successive Vector3
  101508. * @param scene defines the hosting scene
  101509. * @param updatable defines if the mesh must be flagged as updatable
  101510. * @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).
  101511. * @returns a new Mesh
  101512. */
  101513. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  101514. /**
  101515. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  101516. * @param name defines the name of the mesh to create
  101517. * @param points is an array successive Vector3
  101518. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  101519. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  101520. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  101521. * @param scene defines the hosting scene
  101522. * @param updatable defines if the mesh must be flagged as updatable
  101523. * @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)
  101524. * @returns a new Mesh
  101525. */
  101526. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  101527. /**
  101528. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  101529. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  101530. * 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.
  101531. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  101532. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  101533. * Remember you can only change the shape positions, not their number when updating a polygon.
  101534. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  101535. * @param name defines the name of the mesh to create
  101536. * @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
  101537. * @param scene defines the hosting scene
  101538. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  101539. * @param updatable defines if the mesh must be flagged as updatable
  101540. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  101541. * @param earcutInjection can be used to inject your own earcut reference
  101542. * @returns a new Mesh
  101543. */
  101544. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  101545. /**
  101546. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  101547. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  101548. * @param name defines the name of the mesh to create
  101549. * @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
  101550. * @param depth defines the height of extrusion
  101551. * @param scene defines the hosting scene
  101552. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  101553. * @param updatable defines if the mesh must be flagged as updatable
  101554. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  101555. * @param earcutInjection can be used to inject your own earcut reference
  101556. * @returns a new Mesh
  101557. */
  101558. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  101559. /**
  101560. * Creates an extruded shape mesh.
  101561. * 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
  101562. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  101563. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  101564. * @param name defines the name of the mesh to create
  101565. * @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
  101566. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  101567. * @param scale is the value to scale the shape
  101568. * @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
  101569. * @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
  101570. * @param scene defines the hosting scene
  101571. * @param updatable defines if the mesh must be flagged as updatable
  101572. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  101573. * @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)
  101574. * @returns a new Mesh
  101575. */
  101576. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  101577. /**
  101578. * Creates an custom extruded shape mesh.
  101579. * The custom extrusion is a parametric shape.
  101580. * It has no predefined shape. Its final shape will depend on the input parameters.
  101581. * Please consider using the same method from the MeshBuilder class instead
  101582. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  101583. * @param name defines the name of the mesh to create
  101584. * @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
  101585. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  101586. * @param scaleFunction is a custom Javascript function called on each path point
  101587. * @param rotationFunction is a custom Javascript function called on each path point
  101588. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  101589. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  101590. * @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
  101591. * @param scene defines the hosting scene
  101592. * @param updatable defines if the mesh must be flagged as updatable
  101593. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  101594. * @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)
  101595. * @returns a new Mesh
  101596. */
  101597. 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;
  101598. /**
  101599. * Creates lathe mesh.
  101600. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  101601. * Please consider using the same method from the MeshBuilder class instead
  101602. * @param name defines the name of the mesh to create
  101603. * @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
  101604. * @param radius is the radius value of the lathe
  101605. * @param tessellation is the side number of the lathe.
  101606. * @param scene defines the hosting scene
  101607. * @param updatable defines if the mesh must be flagged as updatable
  101608. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  101609. * @returns a new Mesh
  101610. */
  101611. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  101612. /**
  101613. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  101614. * @param name defines the name of the mesh to create
  101615. * @param size sets the size (float) of both sides of the plane at once (default 1)
  101616. * @param scene defines the hosting scene
  101617. * @param updatable defines if the mesh must be flagged as updatable
  101618. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  101619. * @returns a new Mesh
  101620. */
  101621. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  101622. /**
  101623. * Creates a ground mesh.
  101624. * Please consider using the same method from the MeshBuilder class instead
  101625. * @param name defines the name of the mesh to create
  101626. * @param width set the width of the ground
  101627. * @param height set the height of the ground
  101628. * @param subdivisions sets the number of subdivisions per side
  101629. * @param scene defines the hosting scene
  101630. * @param updatable defines if the mesh must be flagged as updatable
  101631. * @returns a new Mesh
  101632. */
  101633. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  101634. /**
  101635. * Creates a tiled ground mesh.
  101636. * Please consider using the same method from the MeshBuilder class instead
  101637. * @param name defines the name of the mesh to create
  101638. * @param xmin set the ground minimum X coordinate
  101639. * @param zmin set the ground minimum Y coordinate
  101640. * @param xmax set the ground maximum X coordinate
  101641. * @param zmax set the ground maximum Z coordinate
  101642. * @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
  101643. * @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
  101644. * @param scene defines the hosting scene
  101645. * @param updatable defines if the mesh must be flagged as updatable
  101646. * @returns a new Mesh
  101647. */
  101648. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  101649. w: number;
  101650. h: number;
  101651. }, precision: {
  101652. w: number;
  101653. h: number;
  101654. }, scene: Scene, updatable?: boolean): Mesh;
  101655. /**
  101656. * Creates a ground mesh from a height map.
  101657. * Please consider using the same method from the MeshBuilder class instead
  101658. * @see http://doc.babylonjs.com/babylon101/height_map
  101659. * @param name defines the name of the mesh to create
  101660. * @param url sets the URL of the height map image resource
  101661. * @param width set the ground width size
  101662. * @param height set the ground height size
  101663. * @param subdivisions sets the number of subdivision per side
  101664. * @param minHeight is the minimum altitude on the ground
  101665. * @param maxHeight is the maximum altitude on the ground
  101666. * @param scene defines the hosting scene
  101667. * @param updatable defines if the mesh must be flagged as updatable
  101668. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  101669. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  101670. * @returns a new Mesh
  101671. */
  101672. 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;
  101673. /**
  101674. * Creates a tube mesh.
  101675. * The tube is a parametric shape.
  101676. * It has no predefined shape. Its final shape will depend on the input parameters.
  101677. * Please consider using the same method from the MeshBuilder class instead
  101678. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  101679. * @param name defines the name of the mesh to create
  101680. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  101681. * @param radius sets the tube radius size
  101682. * @param tessellation is the number of sides on the tubular surface
  101683. * @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
  101684. * @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
  101685. * @param scene defines the hosting scene
  101686. * @param updatable defines if the mesh must be flagged as updatable
  101687. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  101688. * @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)
  101689. * @returns a new Mesh
  101690. */
  101691. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  101692. (i: number, distance: number): number;
  101693. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  101694. /**
  101695. * Creates a polyhedron mesh.
  101696. * Please consider using the same method from the MeshBuilder class instead.
  101697. * * 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
  101698. * * The parameter `size` (positive float, default 1) sets the polygon size
  101699. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  101700. * * 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`
  101701. * * 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
  101702. * * 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)`)
  101703. * * 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
  101704. * * 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
  101705. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  101706. * * If you create a double-sided mesh, you can choose what parts of 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
  101707. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  101708. * @param name defines the name of the mesh to create
  101709. * @param options defines the options used to create the mesh
  101710. * @param scene defines the hosting scene
  101711. * @returns a new Mesh
  101712. */
  101713. static CreatePolyhedron(name: string, options: {
  101714. type?: number;
  101715. size?: number;
  101716. sizeX?: number;
  101717. sizeY?: number;
  101718. sizeZ?: number;
  101719. custom?: any;
  101720. faceUV?: Vector4[];
  101721. faceColors?: Color4[];
  101722. updatable?: boolean;
  101723. sideOrientation?: number;
  101724. }, scene: Scene): Mesh;
  101725. /**
  101726. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  101727. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  101728. * * 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`)
  101729. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  101730. * * 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
  101731. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  101732. * * If you create a double-sided mesh, you can choose what parts of 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
  101733. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  101734. * @param name defines the name of the mesh
  101735. * @param options defines the options used to create the mesh
  101736. * @param scene defines the hosting scene
  101737. * @returns a new Mesh
  101738. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  101739. */
  101740. static CreateIcoSphere(name: string, options: {
  101741. radius?: number;
  101742. flat?: boolean;
  101743. subdivisions?: number;
  101744. sideOrientation?: number;
  101745. updatable?: boolean;
  101746. }, scene: Scene): Mesh;
  101747. /**
  101748. * Creates a decal mesh.
  101749. * Please consider using the same method from the MeshBuilder class instead.
  101750. * A decal is a mesh usually applied as a model onto the surface of another mesh
  101751. * @param name defines the name of the mesh
  101752. * @param sourceMesh defines the mesh receiving the decal
  101753. * @param position sets the position of the decal in world coordinates
  101754. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  101755. * @param size sets the decal scaling
  101756. * @param angle sets the angle to rotate the decal
  101757. * @returns a new Mesh
  101758. */
  101759. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  101760. /**
  101761. * Prepare internal position array for software CPU skinning
  101762. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  101763. */
  101764. setPositionsForCPUSkinning(): Float32Array;
  101765. /**
  101766. * Prepare internal normal array for software CPU skinning
  101767. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  101768. */
  101769. setNormalsForCPUSkinning(): Float32Array;
  101770. /**
  101771. * Updates the vertex buffer by applying transformation from the bones
  101772. * @param skeleton defines the skeleton to apply to current mesh
  101773. * @returns the current mesh
  101774. */
  101775. applySkeleton(skeleton: Skeleton): Mesh;
  101776. /**
  101777. * 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
  101778. * @param meshes defines the list of meshes to scan
  101779. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  101780. */
  101781. static MinMax(meshes: AbstractMesh[]): {
  101782. min: Vector3;
  101783. max: Vector3;
  101784. };
  101785. /**
  101786. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  101787. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  101788. * @returns a vector3
  101789. */
  101790. static Center(meshesOrMinMaxVector: {
  101791. min: Vector3;
  101792. max: Vector3;
  101793. } | AbstractMesh[]): Vector3;
  101794. /**
  101795. * Merge the array of meshes into a single mesh for performance reasons.
  101796. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  101797. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  101798. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  101799. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  101800. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  101801. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  101802. * @returns a new mesh
  101803. */
  101804. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  101805. /** @hidden */
  101806. addInstance(instance: InstancedMesh): void;
  101807. /** @hidden */
  101808. removeInstance(instance: InstancedMesh): void;
  101809. }
  101810. }
  101811. declare module BABYLON {
  101812. /**
  101813. * This is the base class of all the camera used in the application.
  101814. * @see http://doc.babylonjs.com/features/cameras
  101815. */
  101816. export class Camera extends Node {
  101817. /** @hidden */
  101818. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  101819. /**
  101820. * This is the default projection mode used by the cameras.
  101821. * It helps recreating a feeling of perspective and better appreciate depth.
  101822. * This is the best way to simulate real life cameras.
  101823. */
  101824. static readonly PERSPECTIVE_CAMERA: number;
  101825. /**
  101826. * This helps creating camera with an orthographic mode.
  101827. * 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.
  101828. */
  101829. static readonly ORTHOGRAPHIC_CAMERA: number;
  101830. /**
  101831. * This is the default FOV mode for perspective cameras.
  101832. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  101833. */
  101834. static readonly FOVMODE_VERTICAL_FIXED: number;
  101835. /**
  101836. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  101837. */
  101838. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  101839. /**
  101840. * This specifies ther is no need for a camera rig.
  101841. * Basically only one eye is rendered corresponding to the camera.
  101842. */
  101843. static readonly RIG_MODE_NONE: number;
  101844. /**
  101845. * Simulates a camera Rig with one blue eye and one red eye.
  101846. * This can be use with 3d blue and red glasses.
  101847. */
  101848. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  101849. /**
  101850. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  101851. */
  101852. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  101853. /**
  101854. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  101855. */
  101856. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  101857. /**
  101858. * Defines that both eyes of the camera will be rendered over under each other.
  101859. */
  101860. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  101861. /**
  101862. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  101863. */
  101864. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  101865. /**
  101866. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  101867. */
  101868. static readonly RIG_MODE_VR: number;
  101869. /**
  101870. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  101871. */
  101872. static readonly RIG_MODE_WEBVR: number;
  101873. /**
  101874. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  101875. */
  101876. static readonly RIG_MODE_CUSTOM: number;
  101877. /**
  101878. * Defines if by default attaching controls should prevent the default javascript event to continue.
  101879. */
  101880. static ForceAttachControlToAlwaysPreventDefault: boolean;
  101881. /**
  101882. * Define the input manager associated with the camera.
  101883. */
  101884. inputs: CameraInputsManager<Camera>;
  101885. /** @hidden */
  101886. _position: Vector3;
  101887. /**
  101888. * Define the current local position of the camera in the scene
  101889. */
  101890. get position(): Vector3;
  101891. set position(newPosition: Vector3);
  101892. /**
  101893. * The vector the camera should consider as up.
  101894. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  101895. */
  101896. upVector: Vector3;
  101897. /**
  101898. * Define the current limit on the left side for an orthographic camera
  101899. * In scene unit
  101900. */
  101901. orthoLeft: Nullable<number>;
  101902. /**
  101903. * Define the current limit on the right side for an orthographic camera
  101904. * In scene unit
  101905. */
  101906. orthoRight: Nullable<number>;
  101907. /**
  101908. * Define the current limit on the bottom side for an orthographic camera
  101909. * In scene unit
  101910. */
  101911. orthoBottom: Nullable<number>;
  101912. /**
  101913. * Define the current limit on the top side for an orthographic camera
  101914. * In scene unit
  101915. */
  101916. orthoTop: Nullable<number>;
  101917. /**
  101918. * Field Of View is set in Radians. (default is 0.8)
  101919. */
  101920. fov: number;
  101921. /**
  101922. * Define the minimum distance the camera can see from.
  101923. * This is important to note that the depth buffer are not infinite and the closer it starts
  101924. * the more your scene might encounter depth fighting issue.
  101925. */
  101926. minZ: number;
  101927. /**
  101928. * Define the maximum distance the camera can see to.
  101929. * This is important to note that the depth buffer are not infinite and the further it end
  101930. * the more your scene might encounter depth fighting issue.
  101931. */
  101932. maxZ: number;
  101933. /**
  101934. * Define the default inertia of the camera.
  101935. * This helps giving a smooth feeling to the camera movement.
  101936. */
  101937. inertia: number;
  101938. /**
  101939. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  101940. */
  101941. mode: number;
  101942. /**
  101943. * Define whether the camera is intermediate.
  101944. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  101945. */
  101946. isIntermediate: boolean;
  101947. /**
  101948. * Define the viewport of the camera.
  101949. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  101950. */
  101951. viewport: Viewport;
  101952. /**
  101953. * Restricts the camera to viewing objects with the same layerMask.
  101954. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  101955. */
  101956. layerMask: number;
  101957. /**
  101958. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  101959. */
  101960. fovMode: number;
  101961. /**
  101962. * Rig mode of the camera.
  101963. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  101964. * This is normally controlled byt the camera themselves as internal use.
  101965. */
  101966. cameraRigMode: number;
  101967. /**
  101968. * Defines the distance between both "eyes" in case of a RIG
  101969. */
  101970. interaxialDistance: number;
  101971. /**
  101972. * Defines if stereoscopic rendering is done side by side or over under.
  101973. */
  101974. isStereoscopicSideBySide: boolean;
  101975. /**
  101976. * 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
  101977. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  101978. * else in the scene. (Eg. security camera)
  101979. *
  101980. * 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)
  101981. */
  101982. customRenderTargets: RenderTargetTexture[];
  101983. /**
  101984. * When set, the camera will render to this render target instead of the default canvas
  101985. *
  101986. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  101987. */
  101988. outputRenderTarget: Nullable<RenderTargetTexture>;
  101989. /**
  101990. * Observable triggered when the camera view matrix has changed.
  101991. */
  101992. onViewMatrixChangedObservable: Observable<Camera>;
  101993. /**
  101994. * Observable triggered when the camera Projection matrix has changed.
  101995. */
  101996. onProjectionMatrixChangedObservable: Observable<Camera>;
  101997. /**
  101998. * Observable triggered when the inputs have been processed.
  101999. */
  102000. onAfterCheckInputsObservable: Observable<Camera>;
  102001. /**
  102002. * Observable triggered when reset has been called and applied to the camera.
  102003. */
  102004. onRestoreStateObservable: Observable<Camera>;
  102005. /**
  102006. * Is this camera a part of a rig system?
  102007. */
  102008. isRigCamera: boolean;
  102009. /**
  102010. * If isRigCamera set to true this will be set with the parent camera.
  102011. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  102012. */
  102013. rigParent?: Camera;
  102014. /** @hidden */
  102015. _cameraRigParams: any;
  102016. /** @hidden */
  102017. _rigCameras: Camera[];
  102018. /** @hidden */
  102019. _rigPostProcess: Nullable<PostProcess>;
  102020. protected _webvrViewMatrix: Matrix;
  102021. /** @hidden */
  102022. _skipRendering: boolean;
  102023. /** @hidden */
  102024. _projectionMatrix: Matrix;
  102025. /** @hidden */
  102026. _postProcesses: Nullable<PostProcess>[];
  102027. /** @hidden */
  102028. _activeMeshes: SmartArray<AbstractMesh>;
  102029. protected _globalPosition: Vector3;
  102030. /** @hidden */
  102031. _computedViewMatrix: Matrix;
  102032. private _doNotComputeProjectionMatrix;
  102033. private _transformMatrix;
  102034. private _frustumPlanes;
  102035. private _refreshFrustumPlanes;
  102036. private _storedFov;
  102037. private _stateStored;
  102038. /**
  102039. * Instantiates a new camera object.
  102040. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  102041. * @see http://doc.babylonjs.com/features/cameras
  102042. * @param name Defines the name of the camera in the scene
  102043. * @param position Defines the position of the camera
  102044. * @param scene Defines the scene the camera belongs too
  102045. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  102046. */
  102047. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  102048. /**
  102049. * Store current camera state (fov, position, etc..)
  102050. * @returns the camera
  102051. */
  102052. storeState(): Camera;
  102053. /**
  102054. * Restores the camera state values if it has been stored. You must call storeState() first
  102055. */
  102056. protected _restoreStateValues(): boolean;
  102057. /**
  102058. * Restored camera state. You must call storeState() first.
  102059. * @returns true if restored and false otherwise
  102060. */
  102061. restoreState(): boolean;
  102062. /**
  102063. * Gets the class name of the camera.
  102064. * @returns the class name
  102065. */
  102066. getClassName(): string;
  102067. /** @hidden */
  102068. readonly _isCamera: boolean;
  102069. /**
  102070. * Gets a string representation of the camera useful for debug purpose.
  102071. * @param fullDetails Defines that a more verboe level of logging is required
  102072. * @returns the string representation
  102073. */
  102074. toString(fullDetails?: boolean): string;
  102075. /**
  102076. * Gets the current world space position of the camera.
  102077. */
  102078. get globalPosition(): Vector3;
  102079. /**
  102080. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  102081. * @returns the active meshe list
  102082. */
  102083. getActiveMeshes(): SmartArray<AbstractMesh>;
  102084. /**
  102085. * Check whether a mesh is part of the current active mesh list of the camera
  102086. * @param mesh Defines the mesh to check
  102087. * @returns true if active, false otherwise
  102088. */
  102089. isActiveMesh(mesh: Mesh): boolean;
  102090. /**
  102091. * Is this camera ready to be used/rendered
  102092. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  102093. * @return true if the camera is ready
  102094. */
  102095. isReady(completeCheck?: boolean): boolean;
  102096. /** @hidden */
  102097. _initCache(): void;
  102098. /** @hidden */
  102099. _updateCache(ignoreParentClass?: boolean): void;
  102100. /** @hidden */
  102101. _isSynchronized(): boolean;
  102102. /** @hidden */
  102103. _isSynchronizedViewMatrix(): boolean;
  102104. /** @hidden */
  102105. _isSynchronizedProjectionMatrix(): boolean;
  102106. /**
  102107. * Attach the input controls to a specific dom element to get the input from.
  102108. * @param element Defines the element the controls should be listened from
  102109. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  102110. */
  102111. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  102112. /**
  102113. * Detach the current controls from the specified dom element.
  102114. * @param element Defines the element to stop listening the inputs from
  102115. */
  102116. detachControl(element: HTMLElement): void;
  102117. /**
  102118. * Update the camera state according to the different inputs gathered during the frame.
  102119. */
  102120. update(): void;
  102121. /** @hidden */
  102122. _checkInputs(): void;
  102123. /** @hidden */
  102124. get rigCameras(): Camera[];
  102125. /**
  102126. * Gets the post process used by the rig cameras
  102127. */
  102128. get rigPostProcess(): Nullable<PostProcess>;
  102129. /**
  102130. * Internal, gets the first post proces.
  102131. * @returns the first post process to be run on this camera.
  102132. */
  102133. _getFirstPostProcess(): Nullable<PostProcess>;
  102134. private _cascadePostProcessesToRigCams;
  102135. /**
  102136. * Attach a post process to the camera.
  102137. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  102138. * @param postProcess The post process to attach to the camera
  102139. * @param insertAt The position of the post process in case several of them are in use in the scene
  102140. * @returns the position the post process has been inserted at
  102141. */
  102142. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  102143. /**
  102144. * Detach a post process to the camera.
  102145. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  102146. * @param postProcess The post process to detach from the camera
  102147. */
  102148. detachPostProcess(postProcess: PostProcess): void;
  102149. /**
  102150. * Gets the current world matrix of the camera
  102151. */
  102152. getWorldMatrix(): Matrix;
  102153. /** @hidden */
  102154. _getViewMatrix(): Matrix;
  102155. /**
  102156. * Gets the current view matrix of the camera.
  102157. * @param force forces the camera to recompute the matrix without looking at the cached state
  102158. * @returns the view matrix
  102159. */
  102160. getViewMatrix(force?: boolean): Matrix;
  102161. /**
  102162. * Freeze the projection matrix.
  102163. * It will prevent the cache check of the camera projection compute and can speed up perf
  102164. * if no parameter of the camera are meant to change
  102165. * @param projection Defines manually a projection if necessary
  102166. */
  102167. freezeProjectionMatrix(projection?: Matrix): void;
  102168. /**
  102169. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  102170. */
  102171. unfreezeProjectionMatrix(): void;
  102172. /**
  102173. * Gets the current projection matrix of the camera.
  102174. * @param force forces the camera to recompute the matrix without looking at the cached state
  102175. * @returns the projection matrix
  102176. */
  102177. getProjectionMatrix(force?: boolean): Matrix;
  102178. /**
  102179. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  102180. * @returns a Matrix
  102181. */
  102182. getTransformationMatrix(): Matrix;
  102183. private _updateFrustumPlanes;
  102184. /**
  102185. * Checks if a cullable object (mesh...) is in the camera frustum
  102186. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  102187. * @param target The object to check
  102188. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  102189. * @returns true if the object is in frustum otherwise false
  102190. */
  102191. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  102192. /**
  102193. * Checks if a cullable object (mesh...) is in the camera frustum
  102194. * Unlike isInFrustum this cheks the full bounding box
  102195. * @param target The object to check
  102196. * @returns true if the object is in frustum otherwise false
  102197. */
  102198. isCompletelyInFrustum(target: ICullable): boolean;
  102199. /**
  102200. * Gets a ray in the forward direction from the camera.
  102201. * @param length Defines the length of the ray to create
  102202. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  102203. * @param origin Defines the start point of the ray which defaults to the camera position
  102204. * @returns the forward ray
  102205. */
  102206. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  102207. /**
  102208. * Releases resources associated with this node.
  102209. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  102210. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  102211. */
  102212. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  102213. /** @hidden */
  102214. _isLeftCamera: boolean;
  102215. /**
  102216. * Gets the left camera of a rig setup in case of Rigged Camera
  102217. */
  102218. get isLeftCamera(): boolean;
  102219. /** @hidden */
  102220. _isRightCamera: boolean;
  102221. /**
  102222. * Gets the right camera of a rig setup in case of Rigged Camera
  102223. */
  102224. get isRightCamera(): boolean;
  102225. /**
  102226. * Gets the left camera of a rig setup in case of Rigged Camera
  102227. */
  102228. get leftCamera(): Nullable<FreeCamera>;
  102229. /**
  102230. * Gets the right camera of a rig setup in case of Rigged Camera
  102231. */
  102232. get rightCamera(): Nullable<FreeCamera>;
  102233. /**
  102234. * Gets the left camera target of a rig setup in case of Rigged Camera
  102235. * @returns the target position
  102236. */
  102237. getLeftTarget(): Nullable<Vector3>;
  102238. /**
  102239. * Gets the right camera target of a rig setup in case of Rigged Camera
  102240. * @returns the target position
  102241. */
  102242. getRightTarget(): Nullable<Vector3>;
  102243. /**
  102244. * @hidden
  102245. */
  102246. setCameraRigMode(mode: number, rigParams: any): void;
  102247. /** @hidden */
  102248. static _setStereoscopicRigMode(camera: Camera): void;
  102249. /** @hidden */
  102250. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  102251. /** @hidden */
  102252. static _setVRRigMode(camera: Camera, rigParams: any): void;
  102253. /** @hidden */
  102254. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  102255. /** @hidden */
  102256. _getVRProjectionMatrix(): Matrix;
  102257. protected _updateCameraRotationMatrix(): void;
  102258. protected _updateWebVRCameraRotationMatrix(): void;
  102259. /**
  102260. * This function MUST be overwritten by the different WebVR cameras available.
  102261. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  102262. * @hidden
  102263. */
  102264. _getWebVRProjectionMatrix(): Matrix;
  102265. /**
  102266. * This function MUST be overwritten by the different WebVR cameras available.
  102267. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  102268. * @hidden
  102269. */
  102270. _getWebVRViewMatrix(): Matrix;
  102271. /** @hidden */
  102272. setCameraRigParameter(name: string, value: any): void;
  102273. /**
  102274. * needs to be overridden by children so sub has required properties to be copied
  102275. * @hidden
  102276. */
  102277. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  102278. /**
  102279. * May need to be overridden by children
  102280. * @hidden
  102281. */
  102282. _updateRigCameras(): void;
  102283. /** @hidden */
  102284. _setupInputs(): void;
  102285. /**
  102286. * Serialiaze the camera setup to a json represention
  102287. * @returns the JSON representation
  102288. */
  102289. serialize(): any;
  102290. /**
  102291. * Clones the current camera.
  102292. * @param name The cloned camera name
  102293. * @returns the cloned camera
  102294. */
  102295. clone(name: string): Camera;
  102296. /**
  102297. * Gets the direction of the camera relative to a given local axis.
  102298. * @param localAxis Defines the reference axis to provide a relative direction.
  102299. * @return the direction
  102300. */
  102301. getDirection(localAxis: Vector3): Vector3;
  102302. /**
  102303. * Returns the current camera absolute rotation
  102304. */
  102305. get absoluteRotation(): Quaternion;
  102306. /**
  102307. * Gets the direction of the camera relative to a given local axis into a passed vector.
  102308. * @param localAxis Defines the reference axis to provide a relative direction.
  102309. * @param result Defines the vector to store the result in
  102310. */
  102311. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  102312. /**
  102313. * Gets a camera constructor for a given camera type
  102314. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  102315. * @param name The name of the camera the result will be able to instantiate
  102316. * @param scene The scene the result will construct the camera in
  102317. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  102318. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  102319. * @returns a factory method to construc the camera
  102320. */
  102321. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  102322. /**
  102323. * Compute the world matrix of the camera.
  102324. * @returns the camera world matrix
  102325. */
  102326. computeWorldMatrix(): Matrix;
  102327. /**
  102328. * Parse a JSON and creates the camera from the parsed information
  102329. * @param parsedCamera The JSON to parse
  102330. * @param scene The scene to instantiate the camera in
  102331. * @returns the newly constructed camera
  102332. */
  102333. static Parse(parsedCamera: any, scene: Scene): Camera;
  102334. }
  102335. }
  102336. declare module BABYLON {
  102337. /**
  102338. * Class containing static functions to help procedurally build meshes
  102339. */
  102340. export class DiscBuilder {
  102341. /**
  102342. * Creates a plane polygonal mesh. By default, this is a disc
  102343. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  102344. * * 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
  102345. * * 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
  102346. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  102347. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  102348. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  102349. * @param name defines the name of the mesh
  102350. * @param options defines the options used to create the mesh
  102351. * @param scene defines the hosting scene
  102352. * @returns the plane polygonal mesh
  102353. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  102354. */
  102355. static CreateDisc(name: string, options: {
  102356. radius?: number;
  102357. tessellation?: number;
  102358. arc?: number;
  102359. updatable?: boolean;
  102360. sideOrientation?: number;
  102361. frontUVs?: Vector4;
  102362. backUVs?: Vector4;
  102363. }, scene?: Nullable<Scene>): Mesh;
  102364. }
  102365. }
  102366. declare module BABYLON {
  102367. /**
  102368. * Options to be used when creating a FresnelParameters.
  102369. */
  102370. export type IFresnelParametersCreationOptions = {
  102371. /**
  102372. * Define the color used on edges (grazing angle)
  102373. */
  102374. leftColor?: Color3;
  102375. /**
  102376. * Define the color used on center
  102377. */
  102378. rightColor?: Color3;
  102379. /**
  102380. * Define bias applied to computed fresnel term
  102381. */
  102382. bias?: number;
  102383. /**
  102384. * Defined the power exponent applied to fresnel term
  102385. */
  102386. power?: number;
  102387. /**
  102388. * Define if the fresnel effect is enable or not.
  102389. */
  102390. isEnabled?: boolean;
  102391. };
  102392. /**
  102393. * Serialized format for FresnelParameters.
  102394. */
  102395. export type IFresnelParametersSerialized = {
  102396. /**
  102397. * Define the color used on edges (grazing angle) [as an array]
  102398. */
  102399. leftColor: number[];
  102400. /**
  102401. * Define the color used on center [as an array]
  102402. */
  102403. rightColor: number[];
  102404. /**
  102405. * Define bias applied to computed fresnel term
  102406. */
  102407. bias: number;
  102408. /**
  102409. * Defined the power exponent applied to fresnel term
  102410. */
  102411. power?: number;
  102412. /**
  102413. * Define if the fresnel effect is enable or not.
  102414. */
  102415. isEnabled: boolean;
  102416. };
  102417. /**
  102418. * This represents all the required information to add a fresnel effect on a material:
  102419. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  102420. */
  102421. export class FresnelParameters {
  102422. private _isEnabled;
  102423. /**
  102424. * Define if the fresnel effect is enable or not.
  102425. */
  102426. get isEnabled(): boolean;
  102427. set isEnabled(value: boolean);
  102428. /**
  102429. * Define the color used on edges (grazing angle)
  102430. */
  102431. leftColor: Color3;
  102432. /**
  102433. * Define the color used on center
  102434. */
  102435. rightColor: Color3;
  102436. /**
  102437. * Define bias applied to computed fresnel term
  102438. */
  102439. bias: number;
  102440. /**
  102441. * Defined the power exponent applied to fresnel term
  102442. */
  102443. power: number;
  102444. /**
  102445. * Creates a new FresnelParameters object.
  102446. *
  102447. * @param options provide your own settings to optionally to override defaults
  102448. */
  102449. constructor(options?: IFresnelParametersCreationOptions);
  102450. /**
  102451. * Clones the current fresnel and its valuues
  102452. * @returns a clone fresnel configuration
  102453. */
  102454. clone(): FresnelParameters;
  102455. /**
  102456. * Determines equality between FresnelParameters objects
  102457. * @param otherFresnelParameters defines the second operand
  102458. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  102459. */
  102460. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  102461. /**
  102462. * Serializes the current fresnel parameters to a JSON representation.
  102463. * @return the JSON serialization
  102464. */
  102465. serialize(): IFresnelParametersSerialized;
  102466. /**
  102467. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  102468. * @param parsedFresnelParameters Define the JSON representation
  102469. * @returns the parsed parameters
  102470. */
  102471. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  102472. }
  102473. }
  102474. declare module BABYLON {
  102475. /**
  102476. * Base class of materials working in push mode in babylon JS
  102477. * @hidden
  102478. */
  102479. export class PushMaterial extends Material {
  102480. protected _activeEffect: Effect;
  102481. protected _normalMatrix: Matrix;
  102482. /**
  102483. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  102484. * This means that the material can keep using a previous shader while a new one is being compiled.
  102485. * This is mostly used when shader parallel compilation is supported (true by default)
  102486. */
  102487. allowShaderHotSwapping: boolean;
  102488. constructor(name: string, scene: Scene);
  102489. getEffect(): Effect;
  102490. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  102491. protected _isReadyForSubMesh(subMesh: SubMesh): boolean;
  102492. /**
  102493. * Binds the given world matrix to the active effect
  102494. *
  102495. * @param world the matrix to bind
  102496. */
  102497. bindOnlyWorldMatrix(world: Matrix): void;
  102498. /**
  102499. * Binds the given normal matrix to the active effect
  102500. *
  102501. * @param normalMatrix the matrix to bind
  102502. */
  102503. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  102504. bind(world: Matrix, mesh?: Mesh): void;
  102505. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  102506. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  102507. }
  102508. }
  102509. declare module BABYLON {
  102510. /**
  102511. * This groups all the flags used to control the materials channel.
  102512. */
  102513. export class MaterialFlags {
  102514. private static _DiffuseTextureEnabled;
  102515. /**
  102516. * Are diffuse textures enabled in the application.
  102517. */
  102518. static get DiffuseTextureEnabled(): boolean;
  102519. static set DiffuseTextureEnabled(value: boolean);
  102520. private static _AmbientTextureEnabled;
  102521. /**
  102522. * Are ambient textures enabled in the application.
  102523. */
  102524. static get AmbientTextureEnabled(): boolean;
  102525. static set AmbientTextureEnabled(value: boolean);
  102526. private static _OpacityTextureEnabled;
  102527. /**
  102528. * Are opacity textures enabled in the application.
  102529. */
  102530. static get OpacityTextureEnabled(): boolean;
  102531. static set OpacityTextureEnabled(value: boolean);
  102532. private static _ReflectionTextureEnabled;
  102533. /**
  102534. * Are reflection textures enabled in the application.
  102535. */
  102536. static get ReflectionTextureEnabled(): boolean;
  102537. static set ReflectionTextureEnabled(value: boolean);
  102538. private static _EmissiveTextureEnabled;
  102539. /**
  102540. * Are emissive textures enabled in the application.
  102541. */
  102542. static get EmissiveTextureEnabled(): boolean;
  102543. static set EmissiveTextureEnabled(value: boolean);
  102544. private static _SpecularTextureEnabled;
  102545. /**
  102546. * Are specular textures enabled in the application.
  102547. */
  102548. static get SpecularTextureEnabled(): boolean;
  102549. static set SpecularTextureEnabled(value: boolean);
  102550. private static _BumpTextureEnabled;
  102551. /**
  102552. * Are bump textures enabled in the application.
  102553. */
  102554. static get BumpTextureEnabled(): boolean;
  102555. static set BumpTextureEnabled(value: boolean);
  102556. private static _LightmapTextureEnabled;
  102557. /**
  102558. * Are lightmap textures enabled in the application.
  102559. */
  102560. static get LightmapTextureEnabled(): boolean;
  102561. static set LightmapTextureEnabled(value: boolean);
  102562. private static _RefractionTextureEnabled;
  102563. /**
  102564. * Are refraction textures enabled in the application.
  102565. */
  102566. static get RefractionTextureEnabled(): boolean;
  102567. static set RefractionTextureEnabled(value: boolean);
  102568. private static _ColorGradingTextureEnabled;
  102569. /**
  102570. * Are color grading textures enabled in the application.
  102571. */
  102572. static get ColorGradingTextureEnabled(): boolean;
  102573. static set ColorGradingTextureEnabled(value: boolean);
  102574. private static _FresnelEnabled;
  102575. /**
  102576. * Are fresnels enabled in the application.
  102577. */
  102578. static get FresnelEnabled(): boolean;
  102579. static set FresnelEnabled(value: boolean);
  102580. private static _ClearCoatTextureEnabled;
  102581. /**
  102582. * Are clear coat textures enabled in the application.
  102583. */
  102584. static get ClearCoatTextureEnabled(): boolean;
  102585. static set ClearCoatTextureEnabled(value: boolean);
  102586. private static _ClearCoatBumpTextureEnabled;
  102587. /**
  102588. * Are clear coat bump textures enabled in the application.
  102589. */
  102590. static get ClearCoatBumpTextureEnabled(): boolean;
  102591. static set ClearCoatBumpTextureEnabled(value: boolean);
  102592. private static _ClearCoatTintTextureEnabled;
  102593. /**
  102594. * Are clear coat tint textures enabled in the application.
  102595. */
  102596. static get ClearCoatTintTextureEnabled(): boolean;
  102597. static set ClearCoatTintTextureEnabled(value: boolean);
  102598. private static _SheenTextureEnabled;
  102599. /**
  102600. * Are sheen textures enabled in the application.
  102601. */
  102602. static get SheenTextureEnabled(): boolean;
  102603. static set SheenTextureEnabled(value: boolean);
  102604. private static _AnisotropicTextureEnabled;
  102605. /**
  102606. * Are anisotropic textures enabled in the application.
  102607. */
  102608. static get AnisotropicTextureEnabled(): boolean;
  102609. static set AnisotropicTextureEnabled(value: boolean);
  102610. private static _ThicknessTextureEnabled;
  102611. /**
  102612. * Are thickness textures enabled in the application.
  102613. */
  102614. static get ThicknessTextureEnabled(): boolean;
  102615. static set ThicknessTextureEnabled(value: boolean);
  102616. }
  102617. }
  102618. declare module BABYLON {
  102619. /** @hidden */
  102620. export var defaultFragmentDeclaration: {
  102621. name: string;
  102622. shader: string;
  102623. };
  102624. }
  102625. declare module BABYLON {
  102626. /** @hidden */
  102627. export var defaultUboDeclaration: {
  102628. name: string;
  102629. shader: string;
  102630. };
  102631. }
  102632. declare module BABYLON {
  102633. /** @hidden */
  102634. export var lightFragmentDeclaration: {
  102635. name: string;
  102636. shader: string;
  102637. };
  102638. }
  102639. declare module BABYLON {
  102640. /** @hidden */
  102641. export var lightUboDeclaration: {
  102642. name: string;
  102643. shader: string;
  102644. };
  102645. }
  102646. declare module BABYLON {
  102647. /** @hidden */
  102648. export var lightsFragmentFunctions: {
  102649. name: string;
  102650. shader: string;
  102651. };
  102652. }
  102653. declare module BABYLON {
  102654. /** @hidden */
  102655. export var shadowsFragmentFunctions: {
  102656. name: string;
  102657. shader: string;
  102658. };
  102659. }
  102660. declare module BABYLON {
  102661. /** @hidden */
  102662. export var fresnelFunction: {
  102663. name: string;
  102664. shader: string;
  102665. };
  102666. }
  102667. declare module BABYLON {
  102668. /** @hidden */
  102669. export var reflectionFunction: {
  102670. name: string;
  102671. shader: string;
  102672. };
  102673. }
  102674. declare module BABYLON {
  102675. /** @hidden */
  102676. export var bumpFragmentMainFunctions: {
  102677. name: string;
  102678. shader: string;
  102679. };
  102680. }
  102681. declare module BABYLON {
  102682. /** @hidden */
  102683. export var bumpFragmentFunctions: {
  102684. name: string;
  102685. shader: string;
  102686. };
  102687. }
  102688. declare module BABYLON {
  102689. /** @hidden */
  102690. export var logDepthDeclaration: {
  102691. name: string;
  102692. shader: string;
  102693. };
  102694. }
  102695. declare module BABYLON {
  102696. /** @hidden */
  102697. export var bumpFragment: {
  102698. name: string;
  102699. shader: string;
  102700. };
  102701. }
  102702. declare module BABYLON {
  102703. /** @hidden */
  102704. export var depthPrePass: {
  102705. name: string;
  102706. shader: string;
  102707. };
  102708. }
  102709. declare module BABYLON {
  102710. /** @hidden */
  102711. export var lightFragment: {
  102712. name: string;
  102713. shader: string;
  102714. };
  102715. }
  102716. declare module BABYLON {
  102717. /** @hidden */
  102718. export var logDepthFragment: {
  102719. name: string;
  102720. shader: string;
  102721. };
  102722. }
  102723. declare module BABYLON {
  102724. /** @hidden */
  102725. export var defaultPixelShader: {
  102726. name: string;
  102727. shader: string;
  102728. };
  102729. }
  102730. declare module BABYLON {
  102731. /** @hidden */
  102732. export var defaultVertexDeclaration: {
  102733. name: string;
  102734. shader: string;
  102735. };
  102736. }
  102737. declare module BABYLON {
  102738. /** @hidden */
  102739. export var bumpVertexDeclaration: {
  102740. name: string;
  102741. shader: string;
  102742. };
  102743. }
  102744. declare module BABYLON {
  102745. /** @hidden */
  102746. export var bumpVertex: {
  102747. name: string;
  102748. shader: string;
  102749. };
  102750. }
  102751. declare module BABYLON {
  102752. /** @hidden */
  102753. export var fogVertex: {
  102754. name: string;
  102755. shader: string;
  102756. };
  102757. }
  102758. declare module BABYLON {
  102759. /** @hidden */
  102760. export var shadowsVertex: {
  102761. name: string;
  102762. shader: string;
  102763. };
  102764. }
  102765. declare module BABYLON {
  102766. /** @hidden */
  102767. export var pointCloudVertex: {
  102768. name: string;
  102769. shader: string;
  102770. };
  102771. }
  102772. declare module BABYLON {
  102773. /** @hidden */
  102774. export var logDepthVertex: {
  102775. name: string;
  102776. shader: string;
  102777. };
  102778. }
  102779. declare module BABYLON {
  102780. /** @hidden */
  102781. export var defaultVertexShader: {
  102782. name: string;
  102783. shader: string;
  102784. };
  102785. }
  102786. declare module BABYLON {
  102787. /** @hidden */
  102788. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  102789. MAINUV1: boolean;
  102790. MAINUV2: boolean;
  102791. DIFFUSE: boolean;
  102792. DIFFUSEDIRECTUV: number;
  102793. AMBIENT: boolean;
  102794. AMBIENTDIRECTUV: number;
  102795. OPACITY: boolean;
  102796. OPACITYDIRECTUV: number;
  102797. OPACITYRGB: boolean;
  102798. REFLECTION: boolean;
  102799. EMISSIVE: boolean;
  102800. EMISSIVEDIRECTUV: number;
  102801. SPECULAR: boolean;
  102802. SPECULARDIRECTUV: number;
  102803. BUMP: boolean;
  102804. BUMPDIRECTUV: number;
  102805. PARALLAX: boolean;
  102806. PARALLAXOCCLUSION: boolean;
  102807. SPECULAROVERALPHA: boolean;
  102808. CLIPPLANE: boolean;
  102809. CLIPPLANE2: boolean;
  102810. CLIPPLANE3: boolean;
  102811. CLIPPLANE4: boolean;
  102812. CLIPPLANE5: boolean;
  102813. CLIPPLANE6: boolean;
  102814. ALPHATEST: boolean;
  102815. DEPTHPREPASS: boolean;
  102816. ALPHAFROMDIFFUSE: boolean;
  102817. POINTSIZE: boolean;
  102818. FOG: boolean;
  102819. SPECULARTERM: boolean;
  102820. DIFFUSEFRESNEL: boolean;
  102821. OPACITYFRESNEL: boolean;
  102822. REFLECTIONFRESNEL: boolean;
  102823. REFRACTIONFRESNEL: boolean;
  102824. EMISSIVEFRESNEL: boolean;
  102825. FRESNEL: boolean;
  102826. NORMAL: boolean;
  102827. UV1: boolean;
  102828. UV2: boolean;
  102829. VERTEXCOLOR: boolean;
  102830. VERTEXALPHA: boolean;
  102831. NUM_BONE_INFLUENCERS: number;
  102832. BonesPerMesh: number;
  102833. BONETEXTURE: boolean;
  102834. INSTANCES: boolean;
  102835. GLOSSINESS: boolean;
  102836. ROUGHNESS: boolean;
  102837. EMISSIVEASILLUMINATION: boolean;
  102838. LINKEMISSIVEWITHDIFFUSE: boolean;
  102839. REFLECTIONFRESNELFROMSPECULAR: boolean;
  102840. LIGHTMAP: boolean;
  102841. LIGHTMAPDIRECTUV: number;
  102842. OBJECTSPACE_NORMALMAP: boolean;
  102843. USELIGHTMAPASSHADOWMAP: boolean;
  102844. REFLECTIONMAP_3D: boolean;
  102845. REFLECTIONMAP_SPHERICAL: boolean;
  102846. REFLECTIONMAP_PLANAR: boolean;
  102847. REFLECTIONMAP_CUBIC: boolean;
  102848. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  102849. REFLECTIONMAP_PROJECTION: boolean;
  102850. REFLECTIONMAP_SKYBOX: boolean;
  102851. REFLECTIONMAP_EXPLICIT: boolean;
  102852. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  102853. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  102854. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  102855. INVERTCUBICMAP: boolean;
  102856. LOGARITHMICDEPTH: boolean;
  102857. REFRACTION: boolean;
  102858. REFRACTIONMAP_3D: boolean;
  102859. REFLECTIONOVERALPHA: boolean;
  102860. TWOSIDEDLIGHTING: boolean;
  102861. SHADOWFLOAT: boolean;
  102862. MORPHTARGETS: boolean;
  102863. MORPHTARGETS_NORMAL: boolean;
  102864. MORPHTARGETS_TANGENT: boolean;
  102865. MORPHTARGETS_UV: boolean;
  102866. NUM_MORPH_INFLUENCERS: number;
  102867. NONUNIFORMSCALING: boolean;
  102868. PREMULTIPLYALPHA: boolean;
  102869. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  102870. ALPHABLEND: boolean;
  102871. IMAGEPROCESSING: boolean;
  102872. VIGNETTE: boolean;
  102873. VIGNETTEBLENDMODEMULTIPLY: boolean;
  102874. VIGNETTEBLENDMODEOPAQUE: boolean;
  102875. TONEMAPPING: boolean;
  102876. TONEMAPPING_ACES: boolean;
  102877. CONTRAST: boolean;
  102878. COLORCURVES: boolean;
  102879. COLORGRADING: boolean;
  102880. COLORGRADING3D: boolean;
  102881. SAMPLER3DGREENDEPTH: boolean;
  102882. SAMPLER3DBGRMAP: boolean;
  102883. IMAGEPROCESSINGPOSTPROCESS: boolean;
  102884. MULTIVIEW: boolean;
  102885. /**
  102886. * If the reflection texture on this material is in linear color space
  102887. * @hidden
  102888. */
  102889. IS_REFLECTION_LINEAR: boolean;
  102890. /**
  102891. * If the refraction texture on this material is in linear color space
  102892. * @hidden
  102893. */
  102894. IS_REFRACTION_LINEAR: boolean;
  102895. EXPOSURE: boolean;
  102896. constructor();
  102897. setReflectionMode(modeToEnable: string): void;
  102898. }
  102899. /**
  102900. * This is the default material used in Babylon. It is the best trade off between quality
  102901. * and performances.
  102902. * @see http://doc.babylonjs.com/babylon101/materials
  102903. */
  102904. export class StandardMaterial extends PushMaterial {
  102905. private _diffuseTexture;
  102906. /**
  102907. * The basic texture of the material as viewed under a light.
  102908. */
  102909. diffuseTexture: Nullable<BaseTexture>;
  102910. private _ambientTexture;
  102911. /**
  102912. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  102913. */
  102914. ambientTexture: Nullable<BaseTexture>;
  102915. private _opacityTexture;
  102916. /**
  102917. * Define the transparency of the material from a texture.
  102918. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  102919. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  102920. */
  102921. opacityTexture: Nullable<BaseTexture>;
  102922. private _reflectionTexture;
  102923. /**
  102924. * Define the texture used to display the reflection.
  102925. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  102926. */
  102927. reflectionTexture: Nullable<BaseTexture>;
  102928. private _emissiveTexture;
  102929. /**
  102930. * Define texture of the material as if self lit.
  102931. * This will be mixed in the final result even in the absence of light.
  102932. */
  102933. emissiveTexture: Nullable<BaseTexture>;
  102934. private _specularTexture;
  102935. /**
  102936. * Define how the color and intensity of the highlight given by the light in the material.
  102937. */
  102938. specularTexture: Nullable<BaseTexture>;
  102939. private _bumpTexture;
  102940. /**
  102941. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  102942. * 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.
  102943. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  102944. */
  102945. bumpTexture: Nullable<BaseTexture>;
  102946. private _lightmapTexture;
  102947. /**
  102948. * Complex lighting can be computationally expensive to compute at runtime.
  102949. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  102950. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  102951. */
  102952. lightmapTexture: Nullable<BaseTexture>;
  102953. private _refractionTexture;
  102954. /**
  102955. * Define the texture used to display the refraction.
  102956. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  102957. */
  102958. refractionTexture: Nullable<BaseTexture>;
  102959. /**
  102960. * The color of the material lit by the environmental background lighting.
  102961. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  102962. */
  102963. ambientColor: Color3;
  102964. /**
  102965. * The basic color of the material as viewed under a light.
  102966. */
  102967. diffuseColor: Color3;
  102968. /**
  102969. * Define how the color and intensity of the highlight given by the light in the material.
  102970. */
  102971. specularColor: Color3;
  102972. /**
  102973. * Define the color of the material as if self lit.
  102974. * This will be mixed in the final result even in the absence of light.
  102975. */
  102976. emissiveColor: Color3;
  102977. /**
  102978. * Defines how sharp are the highlights in the material.
  102979. * The bigger the value the sharper giving a more glossy feeling to the result.
  102980. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  102981. */
  102982. specularPower: number;
  102983. private _useAlphaFromDiffuseTexture;
  102984. /**
  102985. * Does the transparency come from the diffuse texture alpha channel.
  102986. */
  102987. useAlphaFromDiffuseTexture: boolean;
  102988. private _useEmissiveAsIllumination;
  102989. /**
  102990. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  102991. */
  102992. useEmissiveAsIllumination: boolean;
  102993. private _linkEmissiveWithDiffuse;
  102994. /**
  102995. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  102996. * the emissive level when the final color is close to one.
  102997. */
  102998. linkEmissiveWithDiffuse: boolean;
  102999. private _useSpecularOverAlpha;
  103000. /**
  103001. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  103002. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  103003. */
  103004. useSpecularOverAlpha: boolean;
  103005. private _useReflectionOverAlpha;
  103006. /**
  103007. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  103008. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  103009. */
  103010. useReflectionOverAlpha: boolean;
  103011. private _disableLighting;
  103012. /**
  103013. * Does lights from the scene impacts this material.
  103014. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  103015. */
  103016. disableLighting: boolean;
  103017. private _useObjectSpaceNormalMap;
  103018. /**
  103019. * Allows using an object space normal map (instead of tangent space).
  103020. */
  103021. useObjectSpaceNormalMap: boolean;
  103022. private _useParallax;
  103023. /**
  103024. * Is parallax enabled or not.
  103025. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  103026. */
  103027. useParallax: boolean;
  103028. private _useParallaxOcclusion;
  103029. /**
  103030. * Is parallax occlusion enabled or not.
  103031. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  103032. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  103033. */
  103034. useParallaxOcclusion: boolean;
  103035. /**
  103036. * 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.
  103037. */
  103038. parallaxScaleBias: number;
  103039. private _roughness;
  103040. /**
  103041. * Helps to define how blurry the reflections should appears in the material.
  103042. */
  103043. roughness: number;
  103044. /**
  103045. * In case of refraction, define the value of the index of refraction.
  103046. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  103047. */
  103048. indexOfRefraction: number;
  103049. /**
  103050. * Invert the refraction texture alongside the y axis.
  103051. * It can be useful with procedural textures or probe for instance.
  103052. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  103053. */
  103054. invertRefractionY: boolean;
  103055. /**
  103056. * Defines the alpha limits in alpha test mode.
  103057. */
  103058. alphaCutOff: number;
  103059. private _useLightmapAsShadowmap;
  103060. /**
  103061. * In case of light mapping, define whether the map contains light or shadow informations.
  103062. */
  103063. useLightmapAsShadowmap: boolean;
  103064. private _diffuseFresnelParameters;
  103065. /**
  103066. * Define the diffuse fresnel parameters of the material.
  103067. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  103068. */
  103069. diffuseFresnelParameters: FresnelParameters;
  103070. private _opacityFresnelParameters;
  103071. /**
  103072. * Define the opacity fresnel parameters of the material.
  103073. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  103074. */
  103075. opacityFresnelParameters: FresnelParameters;
  103076. private _reflectionFresnelParameters;
  103077. /**
  103078. * Define the reflection fresnel parameters of the material.
  103079. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  103080. */
  103081. reflectionFresnelParameters: FresnelParameters;
  103082. private _refractionFresnelParameters;
  103083. /**
  103084. * Define the refraction fresnel parameters of the material.
  103085. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  103086. */
  103087. refractionFresnelParameters: FresnelParameters;
  103088. private _emissiveFresnelParameters;
  103089. /**
  103090. * Define the emissive fresnel parameters of the material.
  103091. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  103092. */
  103093. emissiveFresnelParameters: FresnelParameters;
  103094. private _useReflectionFresnelFromSpecular;
  103095. /**
  103096. * If true automatically deducts the fresnels values from the material specularity.
  103097. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  103098. */
  103099. useReflectionFresnelFromSpecular: boolean;
  103100. private _useGlossinessFromSpecularMapAlpha;
  103101. /**
  103102. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  103103. */
  103104. useGlossinessFromSpecularMapAlpha: boolean;
  103105. private _maxSimultaneousLights;
  103106. /**
  103107. * Defines the maximum number of lights that can be used in the material
  103108. */
  103109. maxSimultaneousLights: number;
  103110. private _invertNormalMapX;
  103111. /**
  103112. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  103113. */
  103114. invertNormalMapX: boolean;
  103115. private _invertNormalMapY;
  103116. /**
  103117. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  103118. */
  103119. invertNormalMapY: boolean;
  103120. private _twoSidedLighting;
  103121. /**
  103122. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  103123. */
  103124. twoSidedLighting: boolean;
  103125. /**
  103126. * Default configuration related to image processing available in the standard Material.
  103127. */
  103128. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  103129. /**
  103130. * Gets the image processing configuration used either in this material.
  103131. */
  103132. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  103133. /**
  103134. * Sets the Default image processing configuration used either in the this material.
  103135. *
  103136. * If sets to null, the scene one is in use.
  103137. */
  103138. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  103139. /**
  103140. * Keep track of the image processing observer to allow dispose and replace.
  103141. */
  103142. private _imageProcessingObserver;
  103143. /**
  103144. * Attaches a new image processing configuration to the Standard Material.
  103145. * @param configuration
  103146. */
  103147. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  103148. /**
  103149. * Gets wether the color curves effect is enabled.
  103150. */
  103151. get cameraColorCurvesEnabled(): boolean;
  103152. /**
  103153. * Sets wether the color curves effect is enabled.
  103154. */
  103155. set cameraColorCurvesEnabled(value: boolean);
  103156. /**
  103157. * Gets wether the color grading effect is enabled.
  103158. */
  103159. get cameraColorGradingEnabled(): boolean;
  103160. /**
  103161. * Gets wether the color grading effect is enabled.
  103162. */
  103163. set cameraColorGradingEnabled(value: boolean);
  103164. /**
  103165. * Gets wether tonemapping is enabled or not.
  103166. */
  103167. get cameraToneMappingEnabled(): boolean;
  103168. /**
  103169. * Sets wether tonemapping is enabled or not
  103170. */
  103171. set cameraToneMappingEnabled(value: boolean);
  103172. /**
  103173. * The camera exposure used on this material.
  103174. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  103175. * This corresponds to a photographic exposure.
  103176. */
  103177. get cameraExposure(): number;
  103178. /**
  103179. * The camera exposure used on this material.
  103180. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  103181. * This corresponds to a photographic exposure.
  103182. */
  103183. set cameraExposure(value: number);
  103184. /**
  103185. * Gets The camera contrast used on this material.
  103186. */
  103187. get cameraContrast(): number;
  103188. /**
  103189. * Sets The camera contrast used on this material.
  103190. */
  103191. set cameraContrast(value: number);
  103192. /**
  103193. * Gets the Color Grading 2D Lookup Texture.
  103194. */
  103195. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  103196. /**
  103197. * Sets the Color Grading 2D Lookup Texture.
  103198. */
  103199. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  103200. /**
  103201. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  103202. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  103203. * 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;
  103204. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  103205. */
  103206. get cameraColorCurves(): Nullable<ColorCurves>;
  103207. /**
  103208. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  103209. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  103210. * 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;
  103211. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  103212. */
  103213. set cameraColorCurves(value: Nullable<ColorCurves>);
  103214. protected _renderTargets: SmartArray<RenderTargetTexture>;
  103215. protected _worldViewProjectionMatrix: Matrix;
  103216. protected _globalAmbientColor: Color3;
  103217. protected _useLogarithmicDepth: boolean;
  103218. protected _rebuildInParallel: boolean;
  103219. /**
  103220. * Instantiates a new standard material.
  103221. * This is the default material used in Babylon. It is the best trade off between quality
  103222. * and performances.
  103223. * @see http://doc.babylonjs.com/babylon101/materials
  103224. * @param name Define the name of the material in the scene
  103225. * @param scene Define the scene the material belong to
  103226. */
  103227. constructor(name: string, scene: Scene);
  103228. /**
  103229. * Gets a boolean indicating that current material needs to register RTT
  103230. */
  103231. get hasRenderTargetTextures(): boolean;
  103232. /**
  103233. * Gets the current class name of the material e.g. "StandardMaterial"
  103234. * Mainly use in serialization.
  103235. * @returns the class name
  103236. */
  103237. getClassName(): string;
  103238. /**
  103239. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  103240. * You can try switching to logarithmic depth.
  103241. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  103242. */
  103243. get useLogarithmicDepth(): boolean;
  103244. set useLogarithmicDepth(value: boolean);
  103245. /**
  103246. * Specifies if the material will require alpha blending
  103247. * @returns a boolean specifying if alpha blending is needed
  103248. */
  103249. needAlphaBlending(): boolean;
  103250. /**
  103251. * Specifies if this material should be rendered in alpha test mode
  103252. * @returns a boolean specifying if an alpha test is needed.
  103253. */
  103254. needAlphaTesting(): boolean;
  103255. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  103256. /**
  103257. * Get the texture used for alpha test purpose.
  103258. * @returns the diffuse texture in case of the standard material.
  103259. */
  103260. getAlphaTestTexture(): Nullable<BaseTexture>;
  103261. /**
  103262. * Get if the submesh is ready to be used and all its information available.
  103263. * Child classes can use it to update shaders
  103264. * @param mesh defines the mesh to check
  103265. * @param subMesh defines which submesh to check
  103266. * @param useInstances specifies that instances should be used
  103267. * @returns a boolean indicating that the submesh is ready or not
  103268. */
  103269. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  103270. /**
  103271. * Builds the material UBO layouts.
  103272. * Used internally during the effect preparation.
  103273. */
  103274. buildUniformLayout(): void;
  103275. /**
  103276. * Unbinds the material from the mesh
  103277. */
  103278. unbind(): void;
  103279. /**
  103280. * Binds the submesh to this material by preparing the effect and shader to draw
  103281. * @param world defines the world transformation matrix
  103282. * @param mesh defines the mesh containing the submesh
  103283. * @param subMesh defines the submesh to bind the material to
  103284. */
  103285. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  103286. /**
  103287. * Get the list of animatables in the material.
  103288. * @returns the list of animatables object used in the material
  103289. */
  103290. getAnimatables(): IAnimatable[];
  103291. /**
  103292. * Gets the active textures from the material
  103293. * @returns an array of textures
  103294. */
  103295. getActiveTextures(): BaseTexture[];
  103296. /**
  103297. * Specifies if the material uses a texture
  103298. * @param texture defines the texture to check against the material
  103299. * @returns a boolean specifying if the material uses the texture
  103300. */
  103301. hasTexture(texture: BaseTexture): boolean;
  103302. /**
  103303. * Disposes the material
  103304. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  103305. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  103306. */
  103307. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  103308. /**
  103309. * Makes a duplicate of the material, and gives it a new name
  103310. * @param name defines the new name for the duplicated material
  103311. * @returns the cloned material
  103312. */
  103313. clone(name: string): StandardMaterial;
  103314. /**
  103315. * Serializes this material in a JSON representation
  103316. * @returns the serialized material object
  103317. */
  103318. serialize(): any;
  103319. /**
  103320. * Creates a standard material from parsed material data
  103321. * @param source defines the JSON representation of the material
  103322. * @param scene defines the hosting scene
  103323. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  103324. * @returns a new standard material
  103325. */
  103326. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  103327. /**
  103328. * Are diffuse textures enabled in the application.
  103329. */
  103330. static get DiffuseTextureEnabled(): boolean;
  103331. static set DiffuseTextureEnabled(value: boolean);
  103332. /**
  103333. * Are ambient textures enabled in the application.
  103334. */
  103335. static get AmbientTextureEnabled(): boolean;
  103336. static set AmbientTextureEnabled(value: boolean);
  103337. /**
  103338. * Are opacity textures enabled in the application.
  103339. */
  103340. static get OpacityTextureEnabled(): boolean;
  103341. static set OpacityTextureEnabled(value: boolean);
  103342. /**
  103343. * Are reflection textures enabled in the application.
  103344. */
  103345. static get ReflectionTextureEnabled(): boolean;
  103346. static set ReflectionTextureEnabled(value: boolean);
  103347. /**
  103348. * Are emissive textures enabled in the application.
  103349. */
  103350. static get EmissiveTextureEnabled(): boolean;
  103351. static set EmissiveTextureEnabled(value: boolean);
  103352. /**
  103353. * Are specular textures enabled in the application.
  103354. */
  103355. static get SpecularTextureEnabled(): boolean;
  103356. static set SpecularTextureEnabled(value: boolean);
  103357. /**
  103358. * Are bump textures enabled in the application.
  103359. */
  103360. static get BumpTextureEnabled(): boolean;
  103361. static set BumpTextureEnabled(value: boolean);
  103362. /**
  103363. * Are lightmap textures enabled in the application.
  103364. */
  103365. static get LightmapTextureEnabled(): boolean;
  103366. static set LightmapTextureEnabled(value: boolean);
  103367. /**
  103368. * Are refraction textures enabled in the application.
  103369. */
  103370. static get RefractionTextureEnabled(): boolean;
  103371. static set RefractionTextureEnabled(value: boolean);
  103372. /**
  103373. * Are color grading textures enabled in the application.
  103374. */
  103375. static get ColorGradingTextureEnabled(): boolean;
  103376. static set ColorGradingTextureEnabled(value: boolean);
  103377. /**
  103378. * Are fresnels enabled in the application.
  103379. */
  103380. static get FresnelEnabled(): boolean;
  103381. static set FresnelEnabled(value: boolean);
  103382. }
  103383. }
  103384. declare module BABYLON {
  103385. /**
  103386. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  103387. *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.
  103388. * The SPS is also a particle system. It provides some methods to manage the particles.
  103389. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  103390. *
  103391. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  103392. */
  103393. export class SolidParticleSystem implements IDisposable {
  103394. /**
  103395. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  103396. * Example : var p = SPS.particles[i];
  103397. */
  103398. particles: SolidParticle[];
  103399. /**
  103400. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  103401. */
  103402. nbParticles: number;
  103403. /**
  103404. * If the particles must ever face the camera (default false). Useful for planar particles.
  103405. */
  103406. billboard: boolean;
  103407. /**
  103408. * Recompute normals when adding a shape
  103409. */
  103410. recomputeNormals: boolean;
  103411. /**
  103412. * This a counter ofr your own usage. It's not set by any SPS functions.
  103413. */
  103414. counter: number;
  103415. /**
  103416. * The SPS name. This name is also given to the underlying mesh.
  103417. */
  103418. name: string;
  103419. /**
  103420. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  103421. */
  103422. mesh: Mesh;
  103423. /**
  103424. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  103425. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  103426. */
  103427. vars: any;
  103428. /**
  103429. * This array is populated when the SPS is set as 'pickable'.
  103430. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  103431. * Each element of this array is an object `{idx: int, faceId: int}`.
  103432. * `idx` is the picked particle index in the `SPS.particles` array
  103433. * `faceId` is the picked face index counted within this particle.
  103434. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  103435. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  103436. * Use the method SPS.pickedParticle(pickingInfo) instead.
  103437. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  103438. */
  103439. pickedParticles: {
  103440. idx: number;
  103441. faceId: number;
  103442. }[];
  103443. /**
  103444. * This array is populated when the SPS is set as 'pickable'
  103445. * Each key of this array is a submesh index.
  103446. * Each element of this array is a second array defined like this :
  103447. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  103448. * Each element of this second array is an object `{idx: int, faceId: int}`.
  103449. * `idx` is the picked particle index in the `SPS.particles` array
  103450. * `faceId` is the picked face index counted within this particle.
  103451. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  103452. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  103453. */
  103454. pickedBySubMesh: {
  103455. idx: number;
  103456. faceId: number;
  103457. }[][];
  103458. /**
  103459. * This array is populated when `enableDepthSort` is set to true.
  103460. * Each element of this array is an instance of the class DepthSortedParticle.
  103461. */
  103462. depthSortedParticles: DepthSortedParticle[];
  103463. /**
  103464. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  103465. * @hidden
  103466. */
  103467. _bSphereOnly: boolean;
  103468. /**
  103469. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  103470. * @hidden
  103471. */
  103472. _bSphereRadiusFactor: number;
  103473. private _scene;
  103474. private _positions;
  103475. private _indices;
  103476. private _normals;
  103477. private _colors;
  103478. private _uvs;
  103479. private _indices32;
  103480. private _positions32;
  103481. private _normals32;
  103482. private _fixedNormal32;
  103483. private _colors32;
  103484. private _uvs32;
  103485. private _index;
  103486. private _updatable;
  103487. private _pickable;
  103488. private _isVisibilityBoxLocked;
  103489. private _alwaysVisible;
  103490. private _depthSort;
  103491. private _expandable;
  103492. private _shapeCounter;
  103493. private _copy;
  103494. private _color;
  103495. private _computeParticleColor;
  103496. private _computeParticleTexture;
  103497. private _computeParticleRotation;
  103498. private _computeParticleVertex;
  103499. private _computeBoundingBox;
  103500. private _depthSortParticles;
  103501. private _camera;
  103502. private _mustUnrotateFixedNormals;
  103503. private _particlesIntersect;
  103504. private _needs32Bits;
  103505. private _isNotBuilt;
  103506. private _lastParticleId;
  103507. private _idxOfId;
  103508. private _multimaterialEnabled;
  103509. private _useModelMaterial;
  103510. private _indicesByMaterial;
  103511. private _materialIndexes;
  103512. private _depthSortFunction;
  103513. private _materialSortFunction;
  103514. private _materials;
  103515. private _multimaterial;
  103516. private _materialIndexesById;
  103517. private _defaultMaterial;
  103518. private _autoUpdateSubMeshes;
  103519. private _tmpVertex;
  103520. /**
  103521. * Creates a SPS (Solid Particle System) object.
  103522. * @param name (String) is the SPS name, this will be the underlying mesh name.
  103523. * @param scene (Scene) is the scene in which the SPS is added.
  103524. * @param options defines the options of the sps e.g.
  103525. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  103526. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  103527. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  103528. * * 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.
  103529. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  103530. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  103531. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  103532. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  103533. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  103534. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  103535. */
  103536. constructor(name: string, scene: Scene, options?: {
  103537. updatable?: boolean;
  103538. isPickable?: boolean;
  103539. enableDepthSort?: boolean;
  103540. particleIntersection?: boolean;
  103541. boundingSphereOnly?: boolean;
  103542. bSphereRadiusFactor?: number;
  103543. expandable?: boolean;
  103544. useModelMaterial?: boolean;
  103545. enableMultiMaterial?: boolean;
  103546. });
  103547. /**
  103548. * Builds the SPS underlying mesh. Returns a standard Mesh.
  103549. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  103550. * @returns the created mesh
  103551. */
  103552. buildMesh(): Mesh;
  103553. /**
  103554. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  103555. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  103556. * Thus the particles generated from `digest()` have their property `position` set yet.
  103557. * @param mesh ( Mesh ) is the mesh to be digested
  103558. * @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
  103559. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  103560. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  103561. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  103562. * @returns the current SPS
  103563. */
  103564. digest(mesh: Mesh, options?: {
  103565. facetNb?: number;
  103566. number?: number;
  103567. delta?: number;
  103568. storage?: [];
  103569. }): SolidParticleSystem;
  103570. /**
  103571. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  103572. * @hidden
  103573. */
  103574. private _unrotateFixedNormals;
  103575. /**
  103576. * Resets the temporary working copy particle
  103577. * @hidden
  103578. */
  103579. private _resetCopy;
  103580. /**
  103581. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  103582. * @param p the current index in the positions array to be updated
  103583. * @param ind the current index in the indices array
  103584. * @param shape a Vector3 array, the shape geometry
  103585. * @param positions the positions array to be updated
  103586. * @param meshInd the shape indices array
  103587. * @param indices the indices array to be updated
  103588. * @param meshUV the shape uv array
  103589. * @param uvs the uv array to be updated
  103590. * @param meshCol the shape color array
  103591. * @param colors the color array to be updated
  103592. * @param meshNor the shape normals array
  103593. * @param normals the normals array to be updated
  103594. * @param idx the particle index
  103595. * @param idxInShape the particle index in its shape
  103596. * @param options the addShape() method passed options
  103597. * @model the particle model
  103598. * @hidden
  103599. */
  103600. private _meshBuilder;
  103601. /**
  103602. * Returns a shape Vector3 array from positions float array
  103603. * @param positions float array
  103604. * @returns a vector3 array
  103605. * @hidden
  103606. */
  103607. private _posToShape;
  103608. /**
  103609. * Returns a shapeUV array from a float uvs (array deep copy)
  103610. * @param uvs as a float array
  103611. * @returns a shapeUV array
  103612. * @hidden
  103613. */
  103614. private _uvsToShapeUV;
  103615. /**
  103616. * Adds a new particle object in the particles array
  103617. * @param idx particle index in particles array
  103618. * @param id particle id
  103619. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  103620. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  103621. * @param model particle ModelShape object
  103622. * @param shapeId model shape identifier
  103623. * @param idxInShape index of the particle in the current model
  103624. * @param bInfo model bounding info object
  103625. * @param storage target storage array, if any
  103626. * @hidden
  103627. */
  103628. private _addParticle;
  103629. /**
  103630. * Adds some particles to the SPS from the model shape. Returns the shape id.
  103631. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  103632. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  103633. * @param nb (positive integer) the number of particles to be created from this model
  103634. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  103635. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  103636. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  103637. * @returns the number of shapes in the system
  103638. */
  103639. addShape(mesh: Mesh, nb: number, options?: {
  103640. positionFunction?: any;
  103641. vertexFunction?: any;
  103642. storage?: [];
  103643. }): number;
  103644. /**
  103645. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  103646. * @hidden
  103647. */
  103648. private _rebuildParticle;
  103649. /**
  103650. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  103651. * @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.
  103652. * @returns the SPS.
  103653. */
  103654. rebuildMesh(reset?: boolean): SolidParticleSystem;
  103655. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  103656. * Returns an array with the removed particles.
  103657. * 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.
  103658. * The SPS can't be empty so at least one particle needs to remain in place.
  103659. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  103660. * @param start index of the first particle to remove
  103661. * @param end index of the last particle to remove (included)
  103662. * @returns an array populated with the removed particles
  103663. */
  103664. removeParticles(start: number, end: number): SolidParticle[];
  103665. /**
  103666. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  103667. * @param solidParticleArray an array populated with Solid Particles objects
  103668. * @returns the SPS
  103669. */
  103670. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  103671. /**
  103672. * Creates a new particle and modifies the SPS mesh geometry :
  103673. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  103674. * - calls _addParticle() to populate the particle array
  103675. * factorized code from addShape() and insertParticlesFromArray()
  103676. * @param idx particle index in the particles array
  103677. * @param i particle index in its shape
  103678. * @param modelShape particle ModelShape object
  103679. * @param shape shape vertex array
  103680. * @param meshInd shape indices array
  103681. * @param meshUV shape uv array
  103682. * @param meshCol shape color array
  103683. * @param meshNor shape normals array
  103684. * @param bbInfo shape bounding info
  103685. * @param storage target particle storage
  103686. * @options addShape() passed options
  103687. * @hidden
  103688. */
  103689. private _insertNewParticle;
  103690. /**
  103691. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  103692. * This method calls `updateParticle()` for each particle of the SPS.
  103693. * For an animated SPS, it is usually called within the render loop.
  103694. * 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.
  103695. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  103696. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  103697. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  103698. * @returns the SPS.
  103699. */
  103700. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  103701. /**
  103702. * Disposes the SPS.
  103703. */
  103704. dispose(): void;
  103705. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  103706. * idx is the particle index in the SPS
  103707. * faceId is the picked face index counted within this particle.
  103708. * Returns null if the pickInfo can't identify a picked particle.
  103709. * @param pickingInfo (PickingInfo object)
  103710. * @returns {idx: number, faceId: number} or null
  103711. */
  103712. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  103713. idx: number;
  103714. faceId: number;
  103715. }>;
  103716. /**
  103717. * Returns a SolidParticle object from its identifier : particle.id
  103718. * @param id (integer) the particle Id
  103719. * @returns the searched particle or null if not found in the SPS.
  103720. */
  103721. getParticleById(id: number): Nullable<SolidParticle>;
  103722. /**
  103723. * Returns a new array populated with the particles having the passed shapeId.
  103724. * @param shapeId (integer) the shape identifier
  103725. * @returns a new solid particle array
  103726. */
  103727. getParticlesByShapeId(shapeId: number): SolidParticle[];
  103728. /**
  103729. * Populates the passed array "ref" with the particles having the passed shapeId.
  103730. * @param shapeId the shape identifier
  103731. * @returns the SPS
  103732. * @param ref
  103733. */
  103734. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  103735. /**
  103736. * Computes the required SubMeshes according the materials assigned to the particles.
  103737. * @returns the solid particle system.
  103738. * Does nothing if called before the SPS mesh is built.
  103739. */
  103740. computeSubMeshes(): SolidParticleSystem;
  103741. /**
  103742. * Sorts the solid particles by material when MultiMaterial is enabled.
  103743. * Updates the indices32 array.
  103744. * Updates the indicesByMaterial array.
  103745. * Updates the mesh indices array.
  103746. * @returns the SPS
  103747. * @hidden
  103748. */
  103749. private _sortParticlesByMaterial;
  103750. /**
  103751. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  103752. * @hidden
  103753. */
  103754. private _setMaterialIndexesById;
  103755. /**
  103756. * Returns an array with unique values of Materials from the passed array
  103757. * @param array the material array to be checked and filtered
  103758. * @hidden
  103759. */
  103760. private _filterUniqueMaterialId;
  103761. /**
  103762. * Sets a new Standard Material as _defaultMaterial if not already set.
  103763. * @hidden
  103764. */
  103765. private _setDefaultMaterial;
  103766. /**
  103767. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  103768. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  103769. * @returns the SPS.
  103770. */
  103771. refreshVisibleSize(): SolidParticleSystem;
  103772. /**
  103773. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  103774. * @param size the size (float) of the visibility box
  103775. * note : this doesn't lock the SPS mesh bounding box.
  103776. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  103777. */
  103778. setVisibilityBox(size: number): void;
  103779. /**
  103780. * Gets whether the SPS as always visible or not
  103781. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  103782. */
  103783. get isAlwaysVisible(): boolean;
  103784. /**
  103785. * Sets the SPS as always visible or not
  103786. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  103787. */
  103788. set isAlwaysVisible(val: boolean);
  103789. /**
  103790. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  103791. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  103792. */
  103793. set isVisibilityBoxLocked(val: boolean);
  103794. /**
  103795. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  103796. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  103797. */
  103798. get isVisibilityBoxLocked(): boolean;
  103799. /**
  103800. * Tells to `setParticles()` to compute the particle rotations or not.
  103801. * Default value : true. The SPS is faster when it's set to false.
  103802. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  103803. */
  103804. set computeParticleRotation(val: boolean);
  103805. /**
  103806. * Tells to `setParticles()` to compute the particle colors or not.
  103807. * Default value : true. The SPS is faster when it's set to false.
  103808. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  103809. */
  103810. set computeParticleColor(val: boolean);
  103811. set computeParticleTexture(val: boolean);
  103812. /**
  103813. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  103814. * Default value : false. The SPS is faster when it's set to false.
  103815. * Note : the particle custom vertex positions aren't stored values.
  103816. */
  103817. set computeParticleVertex(val: boolean);
  103818. /**
  103819. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  103820. */
  103821. set computeBoundingBox(val: boolean);
  103822. /**
  103823. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  103824. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  103825. * Default : `true`
  103826. */
  103827. set depthSortParticles(val: boolean);
  103828. /**
  103829. * Gets if `setParticles()` computes the particle rotations or not.
  103830. * Default value : true. The SPS is faster when it's set to false.
  103831. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  103832. */
  103833. get computeParticleRotation(): boolean;
  103834. /**
  103835. * Gets if `setParticles()` computes the particle colors or not.
  103836. * Default value : true. The SPS is faster when it's set to false.
  103837. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  103838. */
  103839. get computeParticleColor(): boolean;
  103840. /**
  103841. * Gets if `setParticles()` computes the particle textures or not.
  103842. * Default value : true. The SPS is faster when it's set to false.
  103843. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  103844. */
  103845. get computeParticleTexture(): boolean;
  103846. /**
  103847. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  103848. * Default value : false. The SPS is faster when it's set to false.
  103849. * Note : the particle custom vertex positions aren't stored values.
  103850. */
  103851. get computeParticleVertex(): boolean;
  103852. /**
  103853. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  103854. */
  103855. get computeBoundingBox(): boolean;
  103856. /**
  103857. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  103858. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  103859. * Default : `true`
  103860. */
  103861. get depthSortParticles(): boolean;
  103862. /**
  103863. * Gets if the SPS is created as expandable at construction time.
  103864. * Default : `false`
  103865. */
  103866. get expandable(): boolean;
  103867. /**
  103868. * Gets if the SPS supports the Multi Materials
  103869. */
  103870. get multimaterialEnabled(): boolean;
  103871. /**
  103872. * Gets if the SPS uses the model materials for its own multimaterial.
  103873. */
  103874. get useModelMaterial(): boolean;
  103875. /**
  103876. * The SPS used material array.
  103877. */
  103878. get materials(): Material[];
  103879. /**
  103880. * Sets the SPS MultiMaterial from the passed materials.
  103881. * Note : the passed array is internally copied and not used then by reference.
  103882. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  103883. */
  103884. setMultiMaterial(materials: Material[]): void;
  103885. /**
  103886. * The SPS computed multimaterial object
  103887. */
  103888. get multimaterial(): MultiMaterial;
  103889. set multimaterial(mm: MultiMaterial);
  103890. /**
  103891. * If the subMeshes must be updated on the next call to setParticles()
  103892. */
  103893. get autoUpdateSubMeshes(): boolean;
  103894. set autoUpdateSubMeshes(val: boolean);
  103895. /**
  103896. * This function does nothing. It may be overwritten to set all the particle first values.
  103897. * The SPS doesn't call this function, you may have to call it by your own.
  103898. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  103899. */
  103900. initParticles(): void;
  103901. /**
  103902. * This function does nothing. It may be overwritten to recycle a particle.
  103903. * The SPS doesn't call this function, you may have to call it by your own.
  103904. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  103905. * @param particle The particle to recycle
  103906. * @returns the recycled particle
  103907. */
  103908. recycleParticle(particle: SolidParticle): SolidParticle;
  103909. /**
  103910. * Updates a particle : this function should be overwritten by the user.
  103911. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  103912. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  103913. * @example : just set a particle position or velocity and recycle conditions
  103914. * @param particle The particle to update
  103915. * @returns the updated particle
  103916. */
  103917. updateParticle(particle: SolidParticle): SolidParticle;
  103918. /**
  103919. * Updates a vertex of a particle : it can be overwritten by the user.
  103920. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  103921. * @param particle the current particle
  103922. * @param vertex the current vertex of the current particle : a SolidParticleVertex object
  103923. * @param pt the index of the current vertex in the particle shape
  103924. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  103925. * @example : just set a vertex particle position or color
  103926. * @returns the sps
  103927. */
  103928. updateParticleVertex(particle: SolidParticle, vertex: SolidParticleVertex, pt: number): SolidParticleSystem;
  103929. /**
  103930. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  103931. * This does nothing and may be overwritten by the user.
  103932. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  103933. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  103934. * @param update the boolean update value actually passed to setParticles()
  103935. */
  103936. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  103937. /**
  103938. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  103939. * This will be passed three parameters.
  103940. * This does nothing and may be overwritten by the user.
  103941. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  103942. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  103943. * @param update the boolean update value actually passed to setParticles()
  103944. */
  103945. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  103946. }
  103947. }
  103948. declare module BABYLON {
  103949. /**
  103950. * Represents one particle of a solid particle system.
  103951. */
  103952. export class SolidParticle {
  103953. /**
  103954. * particle global index
  103955. */
  103956. idx: number;
  103957. /**
  103958. * particle identifier
  103959. */
  103960. id: number;
  103961. /**
  103962. * The color of the particle
  103963. */
  103964. color: Nullable<Color4>;
  103965. /**
  103966. * The world space position of the particle.
  103967. */
  103968. position: Vector3;
  103969. /**
  103970. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  103971. */
  103972. rotation: Vector3;
  103973. /**
  103974. * The world space rotation quaternion of the particle.
  103975. */
  103976. rotationQuaternion: Nullable<Quaternion>;
  103977. /**
  103978. * The scaling of the particle.
  103979. */
  103980. scaling: Vector3;
  103981. /**
  103982. * The uvs of the particle.
  103983. */
  103984. uvs: Vector4;
  103985. /**
  103986. * The current speed of the particle.
  103987. */
  103988. velocity: Vector3;
  103989. /**
  103990. * The pivot point in the particle local space.
  103991. */
  103992. pivot: Vector3;
  103993. /**
  103994. * Must the particle be translated from its pivot point in its local space ?
  103995. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  103996. * Default : false
  103997. */
  103998. translateFromPivot: boolean;
  103999. /**
  104000. * Is the particle active or not ?
  104001. */
  104002. alive: boolean;
  104003. /**
  104004. * Is the particle visible or not ?
  104005. */
  104006. isVisible: boolean;
  104007. /**
  104008. * Index of this particle in the global "positions" array (Internal use)
  104009. * @hidden
  104010. */
  104011. _pos: number;
  104012. /**
  104013. * @hidden Index of this particle in the global "indices" array (Internal use)
  104014. */
  104015. _ind: number;
  104016. /**
  104017. * @hidden ModelShape of this particle (Internal use)
  104018. */
  104019. _model: ModelShape;
  104020. /**
  104021. * ModelShape id of this particle
  104022. */
  104023. shapeId: number;
  104024. /**
  104025. * Index of the particle in its shape id
  104026. */
  104027. idxInShape: number;
  104028. /**
  104029. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  104030. */
  104031. _modelBoundingInfo: BoundingInfo;
  104032. /**
  104033. * @hidden Particle BoundingInfo object (Internal use)
  104034. */
  104035. _boundingInfo: BoundingInfo;
  104036. /**
  104037. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  104038. */
  104039. _sps: SolidParticleSystem;
  104040. /**
  104041. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  104042. */
  104043. _stillInvisible: boolean;
  104044. /**
  104045. * @hidden Last computed particle rotation matrix
  104046. */
  104047. _rotationMatrix: number[];
  104048. /**
  104049. * Parent particle Id, if any.
  104050. * Default null.
  104051. */
  104052. parentId: Nullable<number>;
  104053. /**
  104054. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  104055. */
  104056. materialIndex: Nullable<number>;
  104057. /**
  104058. * Custom object or properties.
  104059. */
  104060. props: Nullable<any>;
  104061. /**
  104062. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  104063. * The possible values are :
  104064. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  104065. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  104066. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  104067. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  104068. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  104069. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  104070. * */
  104071. cullingStrategy: number;
  104072. /**
  104073. * @hidden Internal global position in the SPS.
  104074. */
  104075. _globalPosition: Vector3;
  104076. /**
  104077. * Creates a Solid Particle object.
  104078. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  104079. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  104080. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  104081. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  104082. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  104083. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  104084. * @param shapeId (integer) is the model shape identifier in the SPS.
  104085. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  104086. * @param sps defines the sps it is associated to
  104087. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  104088. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  104089. */
  104090. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  104091. /**
  104092. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  104093. * @param target the particle target
  104094. * @returns the current particle
  104095. */
  104096. copyToRef(target: SolidParticle): SolidParticle;
  104097. /**
  104098. * Legacy support, changed scale to scaling
  104099. */
  104100. get scale(): Vector3;
  104101. /**
  104102. * Legacy support, changed scale to scaling
  104103. */
  104104. set scale(scale: Vector3);
  104105. /**
  104106. * Legacy support, changed quaternion to rotationQuaternion
  104107. */
  104108. get quaternion(): Nullable<Quaternion>;
  104109. /**
  104110. * Legacy support, changed quaternion to rotationQuaternion
  104111. */
  104112. set quaternion(q: Nullable<Quaternion>);
  104113. /**
  104114. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  104115. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  104116. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  104117. * @returns true if it intersects
  104118. */
  104119. intersectsMesh(target: Mesh | SolidParticle): boolean;
  104120. /**
  104121. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  104122. * A particle is in the frustum if its bounding box intersects the frustum
  104123. * @param frustumPlanes defines the frustum to test
  104124. * @returns true if the particle is in the frustum planes
  104125. */
  104126. isInFrustum(frustumPlanes: Plane[]): boolean;
  104127. /**
  104128. * get the rotation matrix of the particle
  104129. * @hidden
  104130. */
  104131. getRotationMatrix(m: Matrix): void;
  104132. }
  104133. /**
  104134. * Represents the shape of the model used by one particle of a solid particle system.
  104135. * SPS internal tool, don't use it manually.
  104136. */
  104137. export class ModelShape {
  104138. /**
  104139. * The shape id
  104140. * @hidden
  104141. */
  104142. shapeID: number;
  104143. /**
  104144. * flat array of model positions (internal use)
  104145. * @hidden
  104146. */
  104147. _shape: Vector3[];
  104148. /**
  104149. * flat array of model UVs (internal use)
  104150. * @hidden
  104151. */
  104152. _shapeUV: number[];
  104153. /**
  104154. * color array of the model
  104155. * @hidden
  104156. */
  104157. _shapeColors: number[];
  104158. /**
  104159. * indices array of the model
  104160. * @hidden
  104161. */
  104162. _indices: number[];
  104163. /**
  104164. * normals array of the model
  104165. * @hidden
  104166. */
  104167. _normals: number[];
  104168. /**
  104169. * length of the shape in the model indices array (internal use)
  104170. * @hidden
  104171. */
  104172. _indicesLength: number;
  104173. /**
  104174. * Custom position function (internal use)
  104175. * @hidden
  104176. */
  104177. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  104178. /**
  104179. * Custom vertex function (internal use)
  104180. * @hidden
  104181. */
  104182. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  104183. /**
  104184. * Model material (internal use)
  104185. * @hidden
  104186. */
  104187. _material: Nullable<Material>;
  104188. /**
  104189. * 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.
  104190. * SPS internal tool, don't use it manually.
  104191. * @hidden
  104192. */
  104193. 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>);
  104194. }
  104195. /**
  104196. * Represents a Depth Sorted Particle in the solid particle system.
  104197. * @hidden
  104198. */
  104199. export class DepthSortedParticle {
  104200. /**
  104201. * Particle index
  104202. */
  104203. idx: number;
  104204. /**
  104205. * Index of the particle in the "indices" array
  104206. */
  104207. ind: number;
  104208. /**
  104209. * Length of the particle shape in the "indices" array
  104210. */
  104211. indicesLength: number;
  104212. /**
  104213. * Squared distance from the particle to the camera
  104214. */
  104215. sqDistance: number;
  104216. /**
  104217. * Material index when used with MultiMaterials
  104218. */
  104219. materialIndex: number;
  104220. /**
  104221. * Creates a new sorted particle
  104222. * @param materialIndex
  104223. */
  104224. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  104225. }
  104226. /**
  104227. * Represents a solid particle vertex
  104228. */
  104229. export class SolidParticleVertex {
  104230. /**
  104231. * Vertex position
  104232. */
  104233. position: Vector3;
  104234. /**
  104235. * Vertex color
  104236. */
  104237. color: Color4;
  104238. /**
  104239. * Vertex UV
  104240. */
  104241. uv: Vector2;
  104242. /**
  104243. * Creates a new solid particle vertex
  104244. */
  104245. constructor();
  104246. /** Vertex x coordinate */
  104247. get x(): number;
  104248. set x(val: number);
  104249. /** Vertex y coordinate */
  104250. get y(): number;
  104251. set y(val: number);
  104252. /** Vertex z coordinate */
  104253. get z(): number;
  104254. set z(val: number);
  104255. }
  104256. }
  104257. declare module BABYLON {
  104258. /**
  104259. * @hidden
  104260. */
  104261. export class _MeshCollisionData {
  104262. _checkCollisions: boolean;
  104263. _collisionMask: number;
  104264. _collisionGroup: number;
  104265. _surroundingMeshes: Nullable<AbstractMesh[]>;
  104266. _collider: Nullable<Collider>;
  104267. _oldPositionForCollisions: Vector3;
  104268. _diffPositionForCollisions: Vector3;
  104269. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  104270. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  104271. }
  104272. }
  104273. declare module BABYLON {
  104274. /** @hidden */
  104275. class _FacetDataStorage {
  104276. facetPositions: Vector3[];
  104277. facetNormals: Vector3[];
  104278. facetPartitioning: number[][];
  104279. facetNb: number;
  104280. partitioningSubdivisions: number;
  104281. partitioningBBoxRatio: number;
  104282. facetDataEnabled: boolean;
  104283. facetParameters: any;
  104284. bbSize: Vector3;
  104285. subDiv: {
  104286. max: number;
  104287. X: number;
  104288. Y: number;
  104289. Z: number;
  104290. };
  104291. facetDepthSort: boolean;
  104292. facetDepthSortEnabled: boolean;
  104293. depthSortedIndices: IndicesArray;
  104294. depthSortedFacets: {
  104295. ind: number;
  104296. sqDistance: number;
  104297. }[];
  104298. facetDepthSortFunction: (f1: {
  104299. ind: number;
  104300. sqDistance: number;
  104301. }, f2: {
  104302. ind: number;
  104303. sqDistance: number;
  104304. }) => number;
  104305. facetDepthSortFrom: Vector3;
  104306. facetDepthSortOrigin: Vector3;
  104307. invertedMatrix: Matrix;
  104308. }
  104309. /**
  104310. * @hidden
  104311. **/
  104312. class _InternalAbstractMeshDataInfo {
  104313. _hasVertexAlpha: boolean;
  104314. _useVertexColors: boolean;
  104315. _numBoneInfluencers: number;
  104316. _applyFog: boolean;
  104317. _receiveShadows: boolean;
  104318. _facetData: _FacetDataStorage;
  104319. _visibility: number;
  104320. _skeleton: Nullable<Skeleton>;
  104321. _layerMask: number;
  104322. _computeBonesUsingShaders: boolean;
  104323. _isActive: boolean;
  104324. _onlyForInstances: boolean;
  104325. _isActiveIntermediate: boolean;
  104326. _onlyForInstancesIntermediate: boolean;
  104327. _actAsRegularMesh: boolean;
  104328. }
  104329. /**
  104330. * Class used to store all common mesh properties
  104331. */
  104332. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  104333. /** No occlusion */
  104334. static OCCLUSION_TYPE_NONE: number;
  104335. /** Occlusion set to optimisitic */
  104336. static OCCLUSION_TYPE_OPTIMISTIC: number;
  104337. /** Occlusion set to strict */
  104338. static OCCLUSION_TYPE_STRICT: number;
  104339. /** Use an accurante occlusion algorithm */
  104340. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  104341. /** Use a conservative occlusion algorithm */
  104342. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  104343. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  104344. * Test order :
  104345. * Is the bounding sphere outside the frustum ?
  104346. * If not, are the bounding box vertices outside the frustum ?
  104347. * It not, then the cullable object is in the frustum.
  104348. */
  104349. static readonly CULLINGSTRATEGY_STANDARD: number;
  104350. /** Culling strategy : Bounding Sphere Only.
  104351. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  104352. * It's also less accurate than the standard because some not visible objects can still be selected.
  104353. * Test : is the bounding sphere outside the frustum ?
  104354. * If not, then the cullable object is in the frustum.
  104355. */
  104356. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  104357. /** Culling strategy : Optimistic Inclusion.
  104358. * This in an inclusion test first, then the standard exclusion test.
  104359. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  104360. * 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.
  104361. * Anyway, it's as accurate as the standard strategy.
  104362. * Test :
  104363. * Is the cullable object bounding sphere center in the frustum ?
  104364. * If not, apply the default culling strategy.
  104365. */
  104366. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  104367. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  104368. * This in an inclusion test first, then the bounding sphere only exclusion test.
  104369. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  104370. * 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.
  104371. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  104372. * Test :
  104373. * Is the cullable object bounding sphere center in the frustum ?
  104374. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  104375. */
  104376. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  104377. /**
  104378. * No billboard
  104379. */
  104380. static get BILLBOARDMODE_NONE(): number;
  104381. /** Billboard on X axis */
  104382. static get BILLBOARDMODE_X(): number;
  104383. /** Billboard on Y axis */
  104384. static get BILLBOARDMODE_Y(): number;
  104385. /** Billboard on Z axis */
  104386. static get BILLBOARDMODE_Z(): number;
  104387. /** Billboard on all axes */
  104388. static get BILLBOARDMODE_ALL(): number;
  104389. /** Billboard on using position instead of orientation */
  104390. static get BILLBOARDMODE_USE_POSITION(): number;
  104391. /** @hidden */
  104392. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  104393. /**
  104394. * The culling strategy to use to check whether the mesh must be rendered or not.
  104395. * This value can be changed at any time and will be used on the next render mesh selection.
  104396. * The possible values are :
  104397. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  104398. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  104399. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  104400. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  104401. * Please read each static variable documentation to get details about the culling process.
  104402. * */
  104403. cullingStrategy: number;
  104404. /**
  104405. * Gets the number of facets in the mesh
  104406. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  104407. */
  104408. get facetNb(): number;
  104409. /**
  104410. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  104411. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  104412. */
  104413. get partitioningSubdivisions(): number;
  104414. set partitioningSubdivisions(nb: number);
  104415. /**
  104416. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  104417. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  104418. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  104419. */
  104420. get partitioningBBoxRatio(): number;
  104421. set partitioningBBoxRatio(ratio: number);
  104422. /**
  104423. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  104424. * Works only for updatable meshes.
  104425. * Doesn't work with multi-materials
  104426. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  104427. */
  104428. get mustDepthSortFacets(): boolean;
  104429. set mustDepthSortFacets(sort: boolean);
  104430. /**
  104431. * The location (Vector3) where the facet depth sort must be computed from.
  104432. * By default, the active camera position.
  104433. * Used only when facet depth sort is enabled
  104434. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  104435. */
  104436. get facetDepthSortFrom(): Vector3;
  104437. set facetDepthSortFrom(location: Vector3);
  104438. /**
  104439. * gets a boolean indicating if facetData is enabled
  104440. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  104441. */
  104442. get isFacetDataEnabled(): boolean;
  104443. /** @hidden */
  104444. _updateNonUniformScalingState(value: boolean): boolean;
  104445. /**
  104446. * An event triggered when this mesh collides with another one
  104447. */
  104448. onCollideObservable: Observable<AbstractMesh>;
  104449. /** Set a function to call when this mesh collides with another one */
  104450. set onCollide(callback: () => void);
  104451. /**
  104452. * An event triggered when the collision's position changes
  104453. */
  104454. onCollisionPositionChangeObservable: Observable<Vector3>;
  104455. /** Set a function to call when the collision's position changes */
  104456. set onCollisionPositionChange(callback: () => void);
  104457. /**
  104458. * An event triggered when material is changed
  104459. */
  104460. onMaterialChangedObservable: Observable<AbstractMesh>;
  104461. /**
  104462. * Gets or sets the orientation for POV movement & rotation
  104463. */
  104464. definedFacingForward: boolean;
  104465. /** @hidden */
  104466. _occlusionQuery: Nullable<WebGLQuery>;
  104467. /** @hidden */
  104468. _renderingGroup: Nullable<RenderingGroup>;
  104469. /**
  104470. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  104471. */
  104472. get visibility(): number;
  104473. /**
  104474. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  104475. */
  104476. set visibility(value: number);
  104477. /** Gets or sets the alpha index used to sort transparent meshes
  104478. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  104479. */
  104480. alphaIndex: number;
  104481. /**
  104482. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  104483. */
  104484. isVisible: boolean;
  104485. /**
  104486. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  104487. */
  104488. isPickable: boolean;
  104489. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  104490. showSubMeshesBoundingBox: boolean;
  104491. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  104492. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  104493. */
  104494. isBlocker: boolean;
  104495. /**
  104496. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  104497. */
  104498. enablePointerMoveEvents: boolean;
  104499. /**
  104500. * Specifies the rendering group id for this mesh (0 by default)
  104501. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  104502. */
  104503. renderingGroupId: number;
  104504. private _material;
  104505. /** Gets or sets current material */
  104506. get material(): Nullable<Material>;
  104507. set material(value: Nullable<Material>);
  104508. /**
  104509. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  104510. * @see http://doc.babylonjs.com/babylon101/shadows
  104511. */
  104512. get receiveShadows(): boolean;
  104513. set receiveShadows(value: boolean);
  104514. /** Defines color to use when rendering outline */
  104515. outlineColor: Color3;
  104516. /** Define width to use when rendering outline */
  104517. outlineWidth: number;
  104518. /** Defines color to use when rendering overlay */
  104519. overlayColor: Color3;
  104520. /** Defines alpha to use when rendering overlay */
  104521. overlayAlpha: number;
  104522. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  104523. get hasVertexAlpha(): boolean;
  104524. set hasVertexAlpha(value: boolean);
  104525. /** 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) */
  104526. get useVertexColors(): boolean;
  104527. set useVertexColors(value: boolean);
  104528. /**
  104529. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  104530. */
  104531. get computeBonesUsingShaders(): boolean;
  104532. set computeBonesUsingShaders(value: boolean);
  104533. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  104534. get numBoneInfluencers(): number;
  104535. set numBoneInfluencers(value: number);
  104536. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  104537. get applyFog(): boolean;
  104538. set applyFog(value: boolean);
  104539. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  104540. useOctreeForRenderingSelection: boolean;
  104541. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  104542. useOctreeForPicking: boolean;
  104543. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  104544. useOctreeForCollisions: boolean;
  104545. /**
  104546. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  104547. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  104548. */
  104549. get layerMask(): number;
  104550. set layerMask(value: number);
  104551. /**
  104552. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  104553. */
  104554. alwaysSelectAsActiveMesh: boolean;
  104555. /**
  104556. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  104557. */
  104558. doNotSyncBoundingInfo: boolean;
  104559. /**
  104560. * Gets or sets the current action manager
  104561. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  104562. */
  104563. actionManager: Nullable<AbstractActionManager>;
  104564. private _meshCollisionData;
  104565. /**
  104566. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  104567. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  104568. */
  104569. ellipsoid: Vector3;
  104570. /**
  104571. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  104572. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  104573. */
  104574. ellipsoidOffset: Vector3;
  104575. /**
  104576. * Gets or sets a collision mask used to mask collisions (default is -1).
  104577. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  104578. */
  104579. get collisionMask(): number;
  104580. set collisionMask(mask: number);
  104581. /**
  104582. * Gets or sets the current collision group mask (-1 by default).
  104583. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  104584. */
  104585. get collisionGroup(): number;
  104586. set collisionGroup(mask: number);
  104587. /**
  104588. * Gets or sets current surrounding meshes (null by default).
  104589. *
  104590. * By default collision detection is tested against every mesh in the scene.
  104591. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  104592. * meshes will be tested for the collision.
  104593. *
  104594. * Note: if set to an empty array no collision will happen when this mesh is moved.
  104595. */
  104596. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  104597. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  104598. /**
  104599. * Defines edge width used when edgesRenderer is enabled
  104600. * @see https://www.babylonjs-playground.com/#10OJSG#13
  104601. */
  104602. edgesWidth: number;
  104603. /**
  104604. * Defines edge color used when edgesRenderer is enabled
  104605. * @see https://www.babylonjs-playground.com/#10OJSG#13
  104606. */
  104607. edgesColor: Color4;
  104608. /** @hidden */
  104609. _edgesRenderer: Nullable<IEdgesRenderer>;
  104610. /** @hidden */
  104611. _masterMesh: Nullable<AbstractMesh>;
  104612. /** @hidden */
  104613. _boundingInfo: Nullable<BoundingInfo>;
  104614. /** @hidden */
  104615. _renderId: number;
  104616. /**
  104617. * Gets or sets the list of subMeshes
  104618. * @see http://doc.babylonjs.com/how_to/multi_materials
  104619. */
  104620. subMeshes: SubMesh[];
  104621. /** @hidden */
  104622. _intersectionsInProgress: AbstractMesh[];
  104623. /** @hidden */
  104624. _unIndexed: boolean;
  104625. /** @hidden */
  104626. _lightSources: Light[];
  104627. /** Gets the list of lights affecting that mesh */
  104628. get lightSources(): Light[];
  104629. /** @hidden */
  104630. get _positions(): Nullable<Vector3[]>;
  104631. /** @hidden */
  104632. _waitingData: {
  104633. lods: Nullable<any>;
  104634. actions: Nullable<any>;
  104635. freezeWorldMatrix: Nullable<boolean>;
  104636. };
  104637. /** @hidden */
  104638. _bonesTransformMatrices: Nullable<Float32Array>;
  104639. /** @hidden */
  104640. _transformMatrixTexture: Nullable<RawTexture>;
  104641. /**
  104642. * Gets or sets a skeleton to apply skining transformations
  104643. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  104644. */
  104645. set skeleton(value: Nullable<Skeleton>);
  104646. get skeleton(): Nullable<Skeleton>;
  104647. /**
  104648. * An event triggered when the mesh is rebuilt.
  104649. */
  104650. onRebuildObservable: Observable<AbstractMesh>;
  104651. /**
  104652. * Creates a new AbstractMesh
  104653. * @param name defines the name of the mesh
  104654. * @param scene defines the hosting scene
  104655. */
  104656. constructor(name: string, scene?: Nullable<Scene>);
  104657. /**
  104658. * Returns the string "AbstractMesh"
  104659. * @returns "AbstractMesh"
  104660. */
  104661. getClassName(): string;
  104662. /**
  104663. * Gets a string representation of the current mesh
  104664. * @param fullDetails defines a boolean indicating if full details must be included
  104665. * @returns a string representation of the current mesh
  104666. */
  104667. toString(fullDetails?: boolean): string;
  104668. /**
  104669. * @hidden
  104670. */
  104671. protected _getEffectiveParent(): Nullable<Node>;
  104672. /** @hidden */
  104673. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  104674. /** @hidden */
  104675. _rebuild(): void;
  104676. /** @hidden */
  104677. _resyncLightSources(): void;
  104678. /** @hidden */
  104679. _resyncLightSource(light: Light): void;
  104680. /** @hidden */
  104681. _unBindEffect(): void;
  104682. /** @hidden */
  104683. _removeLightSource(light: Light, dispose: boolean): void;
  104684. private _markSubMeshesAsDirty;
  104685. /** @hidden */
  104686. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  104687. /** @hidden */
  104688. _markSubMeshesAsAttributesDirty(): void;
  104689. /** @hidden */
  104690. _markSubMeshesAsMiscDirty(): void;
  104691. /**
  104692. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  104693. */
  104694. get scaling(): Vector3;
  104695. set scaling(newScaling: Vector3);
  104696. /**
  104697. * Returns true if the mesh is blocked. Implemented by child classes
  104698. */
  104699. get isBlocked(): boolean;
  104700. /**
  104701. * Returns the mesh itself by default. Implemented by child classes
  104702. * @param camera defines the camera to use to pick the right LOD level
  104703. * @returns the currentAbstractMesh
  104704. */
  104705. getLOD(camera: Camera): Nullable<AbstractMesh>;
  104706. /**
  104707. * Returns 0 by default. Implemented by child classes
  104708. * @returns an integer
  104709. */
  104710. getTotalVertices(): number;
  104711. /**
  104712. * Returns a positive integer : the total number of indices in this mesh geometry.
  104713. * @returns the numner of indices or zero if the mesh has no geometry.
  104714. */
  104715. getTotalIndices(): number;
  104716. /**
  104717. * Returns null by default. Implemented by child classes
  104718. * @returns null
  104719. */
  104720. getIndices(): Nullable<IndicesArray>;
  104721. /**
  104722. * Returns the array of the requested vertex data kind. Implemented by child classes
  104723. * @param kind defines the vertex data kind to use
  104724. * @returns null
  104725. */
  104726. getVerticesData(kind: string): Nullable<FloatArray>;
  104727. /**
  104728. * Sets the vertex data of the mesh geometry for the requested `kind`.
  104729. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  104730. * Note that a new underlying VertexBuffer object is created each call.
  104731. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  104732. * @param kind defines vertex data kind:
  104733. * * VertexBuffer.PositionKind
  104734. * * VertexBuffer.UVKind
  104735. * * VertexBuffer.UV2Kind
  104736. * * VertexBuffer.UV3Kind
  104737. * * VertexBuffer.UV4Kind
  104738. * * VertexBuffer.UV5Kind
  104739. * * VertexBuffer.UV6Kind
  104740. * * VertexBuffer.ColorKind
  104741. * * VertexBuffer.MatricesIndicesKind
  104742. * * VertexBuffer.MatricesIndicesExtraKind
  104743. * * VertexBuffer.MatricesWeightsKind
  104744. * * VertexBuffer.MatricesWeightsExtraKind
  104745. * @param data defines the data source
  104746. * @param updatable defines if the data must be flagged as updatable (or static)
  104747. * @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
  104748. * @returns the current mesh
  104749. */
  104750. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  104751. /**
  104752. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  104753. * If the mesh has no geometry, it is simply returned as it is.
  104754. * @param kind defines vertex data kind:
  104755. * * VertexBuffer.PositionKind
  104756. * * VertexBuffer.UVKind
  104757. * * VertexBuffer.UV2Kind
  104758. * * VertexBuffer.UV3Kind
  104759. * * VertexBuffer.UV4Kind
  104760. * * VertexBuffer.UV5Kind
  104761. * * VertexBuffer.UV6Kind
  104762. * * VertexBuffer.ColorKind
  104763. * * VertexBuffer.MatricesIndicesKind
  104764. * * VertexBuffer.MatricesIndicesExtraKind
  104765. * * VertexBuffer.MatricesWeightsKind
  104766. * * VertexBuffer.MatricesWeightsExtraKind
  104767. * @param data defines the data source
  104768. * @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
  104769. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  104770. * @returns the current mesh
  104771. */
  104772. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  104773. /**
  104774. * Sets the mesh indices,
  104775. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  104776. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  104777. * @param totalVertices Defines the total number of vertices
  104778. * @returns the current mesh
  104779. */
  104780. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  104781. /**
  104782. * Gets a boolean indicating if specific vertex data is present
  104783. * @param kind defines the vertex data kind to use
  104784. * @returns true is data kind is present
  104785. */
  104786. isVerticesDataPresent(kind: string): boolean;
  104787. /**
  104788. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  104789. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  104790. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  104791. * @returns a BoundingInfo
  104792. */
  104793. getBoundingInfo(): BoundingInfo;
  104794. /**
  104795. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  104796. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  104797. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  104798. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  104799. * @returns the current mesh
  104800. */
  104801. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  104802. /**
  104803. * Overwrite the current bounding info
  104804. * @param boundingInfo defines the new bounding info
  104805. * @returns the current mesh
  104806. */
  104807. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  104808. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  104809. get useBones(): boolean;
  104810. /** @hidden */
  104811. _preActivate(): void;
  104812. /** @hidden */
  104813. _preActivateForIntermediateRendering(renderId: number): void;
  104814. /** @hidden */
  104815. _activate(renderId: number, intermediateRendering: boolean): boolean;
  104816. /** @hidden */
  104817. _postActivate(): void;
  104818. /** @hidden */
  104819. _freeze(): void;
  104820. /** @hidden */
  104821. _unFreeze(): void;
  104822. /**
  104823. * Gets the current world matrix
  104824. * @returns a Matrix
  104825. */
  104826. getWorldMatrix(): Matrix;
  104827. /** @hidden */
  104828. _getWorldMatrixDeterminant(): number;
  104829. /**
  104830. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  104831. */
  104832. get isAnInstance(): boolean;
  104833. /**
  104834. * Gets a boolean indicating if this mesh has instances
  104835. */
  104836. get hasInstances(): boolean;
  104837. /**
  104838. * Perform relative position change from the point of view of behind the front of the mesh.
  104839. * This is performed taking into account the meshes current rotation, so you do not have to care.
  104840. * Supports definition of mesh facing forward or backward
  104841. * @param amountRight defines the distance on the right axis
  104842. * @param amountUp defines the distance on the up axis
  104843. * @param amountForward defines the distance on the forward axis
  104844. * @returns the current mesh
  104845. */
  104846. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  104847. /**
  104848. * Calculate relative position change from the point of view of behind the front of the mesh.
  104849. * This is performed taking into account the meshes current rotation, so you do not have to care.
  104850. * Supports definition of mesh facing forward or backward
  104851. * @param amountRight defines the distance on the right axis
  104852. * @param amountUp defines the distance on the up axis
  104853. * @param amountForward defines the distance on the forward axis
  104854. * @returns the new displacement vector
  104855. */
  104856. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  104857. /**
  104858. * Perform relative rotation change from the point of view of behind the front of the mesh.
  104859. * Supports definition of mesh facing forward or backward
  104860. * @param flipBack defines the flip
  104861. * @param twirlClockwise defines the twirl
  104862. * @param tiltRight defines the tilt
  104863. * @returns the current mesh
  104864. */
  104865. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  104866. /**
  104867. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  104868. * Supports definition of mesh facing forward or backward.
  104869. * @param flipBack defines the flip
  104870. * @param twirlClockwise defines the twirl
  104871. * @param tiltRight defines the tilt
  104872. * @returns the new rotation vector
  104873. */
  104874. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  104875. /**
  104876. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  104877. * This means the mesh underlying bounding box and sphere are recomputed.
  104878. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  104879. * @returns the current mesh
  104880. */
  104881. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  104882. /** @hidden */
  104883. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  104884. /** @hidden */
  104885. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  104886. /** @hidden */
  104887. _updateBoundingInfo(): AbstractMesh;
  104888. /** @hidden */
  104889. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  104890. /** @hidden */
  104891. protected _afterComputeWorldMatrix(): void;
  104892. /** @hidden */
  104893. get _effectiveMesh(): AbstractMesh;
  104894. /**
  104895. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  104896. * A mesh is in the frustum if its bounding box intersects the frustum
  104897. * @param frustumPlanes defines the frustum to test
  104898. * @returns true if the mesh is in the frustum planes
  104899. */
  104900. isInFrustum(frustumPlanes: Plane[]): boolean;
  104901. /**
  104902. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  104903. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  104904. * @param frustumPlanes defines the frustum to test
  104905. * @returns true if the mesh is completely in the frustum planes
  104906. */
  104907. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  104908. /**
  104909. * True if the mesh intersects another mesh or a SolidParticle object
  104910. * @param mesh defines a target mesh or SolidParticle to test
  104911. * @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)
  104912. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  104913. * @returns true if there is an intersection
  104914. */
  104915. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  104916. /**
  104917. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  104918. * @param point defines the point to test
  104919. * @returns true if there is an intersection
  104920. */
  104921. intersectsPoint(point: Vector3): boolean;
  104922. /**
  104923. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  104924. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  104925. */
  104926. get checkCollisions(): boolean;
  104927. set checkCollisions(collisionEnabled: boolean);
  104928. /**
  104929. * Gets Collider object used to compute collisions (not physics)
  104930. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  104931. */
  104932. get collider(): Nullable<Collider>;
  104933. /**
  104934. * Move the mesh using collision engine
  104935. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  104936. * @param displacement defines the requested displacement vector
  104937. * @returns the current mesh
  104938. */
  104939. moveWithCollisions(displacement: Vector3): AbstractMesh;
  104940. private _onCollisionPositionChange;
  104941. /** @hidden */
  104942. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  104943. /** @hidden */
  104944. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  104945. /** @hidden */
  104946. _checkCollision(collider: Collider): AbstractMesh;
  104947. /** @hidden */
  104948. _generatePointsArray(): boolean;
  104949. /**
  104950. * Checks if the passed Ray intersects with the mesh
  104951. * @param ray defines the ray to use
  104952. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  104953. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  104954. * @param onlyBoundingInfo defines a boolean indicating if picking should only happen using bounding info (false by default)
  104955. * @returns the picking info
  104956. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  104957. */
  104958. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate, onlyBoundingInfo?: boolean): PickingInfo;
  104959. /**
  104960. * Clones the current mesh
  104961. * @param name defines the mesh name
  104962. * @param newParent defines the new mesh parent
  104963. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  104964. * @returns the new mesh
  104965. */
  104966. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  104967. /**
  104968. * Disposes all the submeshes of the current meshnp
  104969. * @returns the current mesh
  104970. */
  104971. releaseSubMeshes(): AbstractMesh;
  104972. /**
  104973. * Releases resources associated with this abstract mesh.
  104974. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  104975. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  104976. */
  104977. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  104978. /**
  104979. * Adds the passed mesh as a child to the current mesh
  104980. * @param mesh defines the child mesh
  104981. * @returns the current mesh
  104982. */
  104983. addChild(mesh: AbstractMesh): AbstractMesh;
  104984. /**
  104985. * Removes the passed mesh from the current mesh children list
  104986. * @param mesh defines the child mesh
  104987. * @returns the current mesh
  104988. */
  104989. removeChild(mesh: AbstractMesh): AbstractMesh;
  104990. /** @hidden */
  104991. private _initFacetData;
  104992. /**
  104993. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  104994. * This method can be called within the render loop.
  104995. * 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
  104996. * @returns the current mesh
  104997. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  104998. */
  104999. updateFacetData(): AbstractMesh;
  105000. /**
  105001. * Returns the facetLocalNormals array.
  105002. * The normals are expressed in the mesh local spac
  105003. * @returns an array of Vector3
  105004. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  105005. */
  105006. getFacetLocalNormals(): Vector3[];
  105007. /**
  105008. * Returns the facetLocalPositions array.
  105009. * The facet positions are expressed in the mesh local space
  105010. * @returns an array of Vector3
  105011. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  105012. */
  105013. getFacetLocalPositions(): Vector3[];
  105014. /**
  105015. * Returns the facetLocalPartioning array
  105016. * @returns an array of array of numbers
  105017. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  105018. */
  105019. getFacetLocalPartitioning(): number[][];
  105020. /**
  105021. * Returns the i-th facet position in the world system.
  105022. * This method allocates a new Vector3 per call
  105023. * @param i defines the facet index
  105024. * @returns a new Vector3
  105025. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  105026. */
  105027. getFacetPosition(i: number): Vector3;
  105028. /**
  105029. * Sets the reference Vector3 with the i-th facet position in the world system
  105030. * @param i defines the facet index
  105031. * @param ref defines the target vector
  105032. * @returns the current mesh
  105033. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  105034. */
  105035. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  105036. /**
  105037. * Returns the i-th facet normal in the world system.
  105038. * This method allocates a new Vector3 per call
  105039. * @param i defines the facet index
  105040. * @returns a new Vector3
  105041. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  105042. */
  105043. getFacetNormal(i: number): Vector3;
  105044. /**
  105045. * Sets the reference Vector3 with the i-th facet normal in the world system
  105046. * @param i defines the facet index
  105047. * @param ref defines the target vector
  105048. * @returns the current mesh
  105049. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  105050. */
  105051. getFacetNormalToRef(i: number, ref: Vector3): this;
  105052. /**
  105053. * 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)
  105054. * @param x defines x coordinate
  105055. * @param y defines y coordinate
  105056. * @param z defines z coordinate
  105057. * @returns the array of facet indexes
  105058. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  105059. */
  105060. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  105061. /**
  105062. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  105063. * @param projected sets as the (x,y,z) world projection on the facet
  105064. * @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
  105065. * @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
  105066. * @param x defines x coordinate
  105067. * @param y defines y coordinate
  105068. * @param z defines z coordinate
  105069. * @returns the face index if found (or null instead)
  105070. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  105071. */
  105072. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  105073. /**
  105074. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  105075. * @param projected sets as the (x,y,z) local projection on the facet
  105076. * @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
  105077. * @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
  105078. * @param x defines x coordinate
  105079. * @param y defines y coordinate
  105080. * @param z defines z coordinate
  105081. * @returns the face index if found (or null instead)
  105082. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  105083. */
  105084. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  105085. /**
  105086. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  105087. * @returns the parameters
  105088. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  105089. */
  105090. getFacetDataParameters(): any;
  105091. /**
  105092. * Disables the feature FacetData and frees the related memory
  105093. * @returns the current mesh
  105094. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  105095. */
  105096. disableFacetData(): AbstractMesh;
  105097. /**
  105098. * Updates the AbstractMesh indices array
  105099. * @param indices defines the data source
  105100. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  105101. * @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)
  105102. * @returns the current mesh
  105103. */
  105104. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  105105. /**
  105106. * Creates new normals data for the mesh
  105107. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  105108. * @returns the current mesh
  105109. */
  105110. createNormals(updatable: boolean): AbstractMesh;
  105111. /**
  105112. * Align the mesh with a normal
  105113. * @param normal defines the normal to use
  105114. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  105115. * @returns the current mesh
  105116. */
  105117. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  105118. /** @hidden */
  105119. _checkOcclusionQuery(): boolean;
  105120. /**
  105121. * Disables the mesh edge rendering mode
  105122. * @returns the currentAbstractMesh
  105123. */
  105124. disableEdgesRendering(): AbstractMesh;
  105125. /**
  105126. * Enables the edge rendering mode on the mesh.
  105127. * This mode makes the mesh edges visible
  105128. * @param epsilon defines the maximal distance between two angles to detect a face
  105129. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  105130. * @returns the currentAbstractMesh
  105131. * @see https://www.babylonjs-playground.com/#19O9TU#0
  105132. */
  105133. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  105134. }
  105135. }
  105136. declare module BABYLON {
  105137. /**
  105138. * Interface used to define ActionEvent
  105139. */
  105140. export interface IActionEvent {
  105141. /** The mesh or sprite that triggered the action */
  105142. source: any;
  105143. /** The X mouse cursor position at the time of the event */
  105144. pointerX: number;
  105145. /** The Y mouse cursor position at the time of the event */
  105146. pointerY: number;
  105147. /** The mesh that is currently pointed at (can be null) */
  105148. meshUnderPointer: Nullable<AbstractMesh>;
  105149. /** the original (browser) event that triggered the ActionEvent */
  105150. sourceEvent?: any;
  105151. /** additional data for the event */
  105152. additionalData?: any;
  105153. }
  105154. /**
  105155. * ActionEvent is the event being sent when an action is triggered.
  105156. */
  105157. export class ActionEvent implements IActionEvent {
  105158. /** The mesh or sprite that triggered the action */
  105159. source: any;
  105160. /** The X mouse cursor position at the time of the event */
  105161. pointerX: number;
  105162. /** The Y mouse cursor position at the time of the event */
  105163. pointerY: number;
  105164. /** The mesh that is currently pointed at (can be null) */
  105165. meshUnderPointer: Nullable<AbstractMesh>;
  105166. /** the original (browser) event that triggered the ActionEvent */
  105167. sourceEvent?: any;
  105168. /** additional data for the event */
  105169. additionalData?: any;
  105170. /**
  105171. * Creates a new ActionEvent
  105172. * @param source The mesh or sprite that triggered the action
  105173. * @param pointerX The X mouse cursor position at the time of the event
  105174. * @param pointerY The Y mouse cursor position at the time of the event
  105175. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  105176. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  105177. * @param additionalData additional data for the event
  105178. */
  105179. constructor(
  105180. /** The mesh or sprite that triggered the action */
  105181. source: any,
  105182. /** The X mouse cursor position at the time of the event */
  105183. pointerX: number,
  105184. /** The Y mouse cursor position at the time of the event */
  105185. pointerY: number,
  105186. /** The mesh that is currently pointed at (can be null) */
  105187. meshUnderPointer: Nullable<AbstractMesh>,
  105188. /** the original (browser) event that triggered the ActionEvent */
  105189. sourceEvent?: any,
  105190. /** additional data for the event */
  105191. additionalData?: any);
  105192. /**
  105193. * Helper function to auto-create an ActionEvent from a source mesh.
  105194. * @param source The source mesh that triggered the event
  105195. * @param evt The original (browser) event
  105196. * @param additionalData additional data for the event
  105197. * @returns the new ActionEvent
  105198. */
  105199. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  105200. /**
  105201. * Helper function to auto-create an ActionEvent from a source sprite
  105202. * @param source The source sprite that triggered the event
  105203. * @param scene Scene associated with the sprite
  105204. * @param evt The original (browser) event
  105205. * @param additionalData additional data for the event
  105206. * @returns the new ActionEvent
  105207. */
  105208. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  105209. /**
  105210. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  105211. * @param scene the scene where the event occurred
  105212. * @param evt The original (browser) event
  105213. * @returns the new ActionEvent
  105214. */
  105215. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  105216. /**
  105217. * Helper function to auto-create an ActionEvent from a primitive
  105218. * @param prim defines the target primitive
  105219. * @param pointerPos defines the pointer position
  105220. * @param evt The original (browser) event
  105221. * @param additionalData additional data for the event
  105222. * @returns the new ActionEvent
  105223. */
  105224. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  105225. }
  105226. }
  105227. declare module BABYLON {
  105228. /**
  105229. * Abstract class used to decouple action Manager from scene and meshes.
  105230. * Do not instantiate.
  105231. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  105232. */
  105233. export abstract class AbstractActionManager implements IDisposable {
  105234. /** Gets the list of active triggers */
  105235. static Triggers: {
  105236. [key: string]: number;
  105237. };
  105238. /** Gets the cursor to use when hovering items */
  105239. hoverCursor: string;
  105240. /** Gets the list of actions */
  105241. actions: IAction[];
  105242. /**
  105243. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  105244. */
  105245. isRecursive: boolean;
  105246. /**
  105247. * Releases all associated resources
  105248. */
  105249. abstract dispose(): void;
  105250. /**
  105251. * Does this action manager has pointer triggers
  105252. */
  105253. abstract get hasPointerTriggers(): boolean;
  105254. /**
  105255. * Does this action manager has pick triggers
  105256. */
  105257. abstract get hasPickTriggers(): boolean;
  105258. /**
  105259. * Process a specific trigger
  105260. * @param trigger defines the trigger to process
  105261. * @param evt defines the event details to be processed
  105262. */
  105263. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  105264. /**
  105265. * Does this action manager handles actions of any of the given triggers
  105266. * @param triggers defines the triggers to be tested
  105267. * @return a boolean indicating whether one (or more) of the triggers is handled
  105268. */
  105269. abstract hasSpecificTriggers(triggers: number[]): boolean;
  105270. /**
  105271. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  105272. * speed.
  105273. * @param triggerA defines the trigger to be tested
  105274. * @param triggerB defines the trigger to be tested
  105275. * @return a boolean indicating whether one (or more) of the triggers is handled
  105276. */
  105277. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  105278. /**
  105279. * Does this action manager handles actions of a given trigger
  105280. * @param trigger defines the trigger to be tested
  105281. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  105282. * @return whether the trigger is handled
  105283. */
  105284. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  105285. /**
  105286. * Serialize this manager to a JSON object
  105287. * @param name defines the property name to store this manager
  105288. * @returns a JSON representation of this manager
  105289. */
  105290. abstract serialize(name: string): any;
  105291. /**
  105292. * Registers an action to this action manager
  105293. * @param action defines the action to be registered
  105294. * @return the action amended (prepared) after registration
  105295. */
  105296. abstract registerAction(action: IAction): Nullable<IAction>;
  105297. /**
  105298. * Unregisters an action to this action manager
  105299. * @param action defines the action to be unregistered
  105300. * @return a boolean indicating whether the action has been unregistered
  105301. */
  105302. abstract unregisterAction(action: IAction): Boolean;
  105303. /**
  105304. * Does exist one action manager with at least one trigger
  105305. **/
  105306. static get HasTriggers(): boolean;
  105307. /**
  105308. * Does exist one action manager with at least one pick trigger
  105309. **/
  105310. static get HasPickTriggers(): boolean;
  105311. /**
  105312. * Does exist one action manager that handles actions of a given trigger
  105313. * @param trigger defines the trigger to be tested
  105314. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  105315. **/
  105316. static HasSpecificTrigger(trigger: number): boolean;
  105317. }
  105318. }
  105319. declare module BABYLON {
  105320. /**
  105321. * Defines how a node can be built from a string name.
  105322. */
  105323. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  105324. /**
  105325. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  105326. */
  105327. export class Node implements IBehaviorAware<Node> {
  105328. /** @hidden */
  105329. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  105330. private static _NodeConstructors;
  105331. /**
  105332. * Add a new node constructor
  105333. * @param type defines the type name of the node to construct
  105334. * @param constructorFunc defines the constructor function
  105335. */
  105336. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  105337. /**
  105338. * Returns a node constructor based on type name
  105339. * @param type defines the type name
  105340. * @param name defines the new node name
  105341. * @param scene defines the hosting scene
  105342. * @param options defines optional options to transmit to constructors
  105343. * @returns the new constructor or null
  105344. */
  105345. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  105346. /**
  105347. * Gets or sets the name of the node
  105348. */
  105349. name: string;
  105350. /**
  105351. * Gets or sets the id of the node
  105352. */
  105353. id: string;
  105354. /**
  105355. * Gets or sets the unique id of the node
  105356. */
  105357. uniqueId: number;
  105358. /**
  105359. * Gets or sets a string used to store user defined state for the node
  105360. */
  105361. state: string;
  105362. /**
  105363. * Gets or sets an object used to store user defined information for the node
  105364. */
  105365. metadata: any;
  105366. /**
  105367. * For internal use only. Please do not use.
  105368. */
  105369. reservedDataStore: any;
  105370. /**
  105371. * List of inspectable custom properties (used by the Inspector)
  105372. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  105373. */
  105374. inspectableCustomProperties: IInspectable[];
  105375. private _doNotSerialize;
  105376. /**
  105377. * Gets or sets a boolean used to define if the node must be serialized
  105378. */
  105379. get doNotSerialize(): boolean;
  105380. set doNotSerialize(value: boolean);
  105381. /** @hidden */
  105382. _isDisposed: boolean;
  105383. /**
  105384. * Gets a list of Animations associated with the node
  105385. */
  105386. animations: Animation[];
  105387. protected _ranges: {
  105388. [name: string]: Nullable<AnimationRange>;
  105389. };
  105390. /**
  105391. * Callback raised when the node is ready to be used
  105392. */
  105393. onReady: Nullable<(node: Node) => void>;
  105394. private _isEnabled;
  105395. private _isParentEnabled;
  105396. private _isReady;
  105397. /** @hidden */
  105398. _currentRenderId: number;
  105399. private _parentUpdateId;
  105400. /** @hidden */
  105401. _childUpdateId: number;
  105402. /** @hidden */
  105403. _waitingParentId: Nullable<string>;
  105404. /** @hidden */
  105405. _scene: Scene;
  105406. /** @hidden */
  105407. _cache: any;
  105408. private _parentNode;
  105409. private _children;
  105410. /** @hidden */
  105411. _worldMatrix: Matrix;
  105412. /** @hidden */
  105413. _worldMatrixDeterminant: number;
  105414. /** @hidden */
  105415. _worldMatrixDeterminantIsDirty: boolean;
  105416. /** @hidden */
  105417. private _sceneRootNodesIndex;
  105418. /**
  105419. * Gets a boolean indicating if the node has been disposed
  105420. * @returns true if the node was disposed
  105421. */
  105422. isDisposed(): boolean;
  105423. /**
  105424. * Gets or sets the parent of the node (without keeping the current position in the scene)
  105425. * @see https://doc.babylonjs.com/how_to/parenting
  105426. */
  105427. set parent(parent: Nullable<Node>);
  105428. get parent(): Nullable<Node>;
  105429. /** @hidden */
  105430. _addToSceneRootNodes(): void;
  105431. /** @hidden */
  105432. _removeFromSceneRootNodes(): void;
  105433. private _animationPropertiesOverride;
  105434. /**
  105435. * Gets or sets the animation properties override
  105436. */
  105437. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  105438. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  105439. /**
  105440. * Gets a string idenfifying the name of the class
  105441. * @returns "Node" string
  105442. */
  105443. getClassName(): string;
  105444. /** @hidden */
  105445. readonly _isNode: boolean;
  105446. /**
  105447. * An event triggered when the mesh is disposed
  105448. */
  105449. onDisposeObservable: Observable<Node>;
  105450. private _onDisposeObserver;
  105451. /**
  105452. * Sets a callback that will be raised when the node will be disposed
  105453. */
  105454. set onDispose(callback: () => void);
  105455. /**
  105456. * Creates a new Node
  105457. * @param name the name and id to be given to this node
  105458. * @param scene the scene this node will be added to
  105459. */
  105460. constructor(name: string, scene?: Nullable<Scene>);
  105461. /**
  105462. * Gets the scene of the node
  105463. * @returns a scene
  105464. */
  105465. getScene(): Scene;
  105466. /**
  105467. * Gets the engine of the node
  105468. * @returns a Engine
  105469. */
  105470. getEngine(): Engine;
  105471. private _behaviors;
  105472. /**
  105473. * Attach a behavior to the node
  105474. * @see http://doc.babylonjs.com/features/behaviour
  105475. * @param behavior defines the behavior to attach
  105476. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  105477. * @returns the current Node
  105478. */
  105479. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  105480. /**
  105481. * Remove an attached behavior
  105482. * @see http://doc.babylonjs.com/features/behaviour
  105483. * @param behavior defines the behavior to attach
  105484. * @returns the current Node
  105485. */
  105486. removeBehavior(behavior: Behavior<Node>): Node;
  105487. /**
  105488. * Gets the list of attached behaviors
  105489. * @see http://doc.babylonjs.com/features/behaviour
  105490. */
  105491. get behaviors(): Behavior<Node>[];
  105492. /**
  105493. * Gets an attached behavior by name
  105494. * @param name defines the name of the behavior to look for
  105495. * @see http://doc.babylonjs.com/features/behaviour
  105496. * @returns null if behavior was not found else the requested behavior
  105497. */
  105498. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  105499. /**
  105500. * Returns the latest update of the World matrix
  105501. * @returns a Matrix
  105502. */
  105503. getWorldMatrix(): Matrix;
  105504. /** @hidden */
  105505. _getWorldMatrixDeterminant(): number;
  105506. /**
  105507. * Returns directly the latest state of the mesh World matrix.
  105508. * A Matrix is returned.
  105509. */
  105510. get worldMatrixFromCache(): Matrix;
  105511. /** @hidden */
  105512. _initCache(): void;
  105513. /** @hidden */
  105514. updateCache(force?: boolean): void;
  105515. /** @hidden */
  105516. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  105517. /** @hidden */
  105518. _updateCache(ignoreParentClass?: boolean): void;
  105519. /** @hidden */
  105520. _isSynchronized(): boolean;
  105521. /** @hidden */
  105522. _markSyncedWithParent(): void;
  105523. /** @hidden */
  105524. isSynchronizedWithParent(): boolean;
  105525. /** @hidden */
  105526. isSynchronized(): boolean;
  105527. /**
  105528. * Is this node ready to be used/rendered
  105529. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  105530. * @return true if the node is ready
  105531. */
  105532. isReady(completeCheck?: boolean): boolean;
  105533. /**
  105534. * Is this node enabled?
  105535. * 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
  105536. * @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
  105537. * @return whether this node (and its parent) is enabled
  105538. */
  105539. isEnabled(checkAncestors?: boolean): boolean;
  105540. /** @hidden */
  105541. protected _syncParentEnabledState(): void;
  105542. /**
  105543. * Set the enabled state of this node
  105544. * @param value defines the new enabled state
  105545. */
  105546. setEnabled(value: boolean): void;
  105547. /**
  105548. * Is this node a descendant of the given node?
  105549. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  105550. * @param ancestor defines the parent node to inspect
  105551. * @returns a boolean indicating if this node is a descendant of the given node
  105552. */
  105553. isDescendantOf(ancestor: Node): boolean;
  105554. /** @hidden */
  105555. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  105556. /**
  105557. * Will return all nodes that have this node as ascendant
  105558. * @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
  105559. * @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
  105560. * @return all children nodes of all types
  105561. */
  105562. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  105563. /**
  105564. * Get all child-meshes of this node
  105565. * @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)
  105566. * @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
  105567. * @returns an array of AbstractMesh
  105568. */
  105569. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  105570. /**
  105571. * Get all direct children of this node
  105572. * @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
  105573. * @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)
  105574. * @returns an array of Node
  105575. */
  105576. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  105577. /** @hidden */
  105578. _setReady(state: boolean): void;
  105579. /**
  105580. * Get an animation by name
  105581. * @param name defines the name of the animation to look for
  105582. * @returns null if not found else the requested animation
  105583. */
  105584. getAnimationByName(name: string): Nullable<Animation>;
  105585. /**
  105586. * Creates an animation range for this node
  105587. * @param name defines the name of the range
  105588. * @param from defines the starting key
  105589. * @param to defines the end key
  105590. */
  105591. createAnimationRange(name: string, from: number, to: number): void;
  105592. /**
  105593. * Delete a specific animation range
  105594. * @param name defines the name of the range to delete
  105595. * @param deleteFrames defines if animation frames from the range must be deleted as well
  105596. */
  105597. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  105598. /**
  105599. * Get an animation range by name
  105600. * @param name defines the name of the animation range to look for
  105601. * @returns null if not found else the requested animation range
  105602. */
  105603. getAnimationRange(name: string): Nullable<AnimationRange>;
  105604. /**
  105605. * Gets the list of all animation ranges defined on this node
  105606. * @returns an array
  105607. */
  105608. getAnimationRanges(): Nullable<AnimationRange>[];
  105609. /**
  105610. * Will start the animation sequence
  105611. * @param name defines the range frames for animation sequence
  105612. * @param loop defines if the animation should loop (false by default)
  105613. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  105614. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  105615. * @returns the object created for this animation. If range does not exist, it will return null
  105616. */
  105617. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  105618. /**
  105619. * Serialize animation ranges into a JSON compatible object
  105620. * @returns serialization object
  105621. */
  105622. serializeAnimationRanges(): any;
  105623. /**
  105624. * Computes the world matrix of the node
  105625. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  105626. * @returns the world matrix
  105627. */
  105628. computeWorldMatrix(force?: boolean): Matrix;
  105629. /**
  105630. * Releases resources associated with this node.
  105631. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  105632. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  105633. */
  105634. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  105635. /**
  105636. * Parse animation range data from a serialization object and store them into a given node
  105637. * @param node defines where to store the animation ranges
  105638. * @param parsedNode defines the serialization object to read data from
  105639. * @param scene defines the hosting scene
  105640. */
  105641. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  105642. /**
  105643. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  105644. * @param includeDescendants Include bounding info from descendants as well (true by default)
  105645. * @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
  105646. * @returns the new bounding vectors
  105647. */
  105648. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  105649. min: Vector3;
  105650. max: Vector3;
  105651. };
  105652. }
  105653. }
  105654. declare module BABYLON {
  105655. /**
  105656. * @hidden
  105657. */
  105658. export class _IAnimationState {
  105659. key: number;
  105660. repeatCount: number;
  105661. workValue?: any;
  105662. loopMode?: number;
  105663. offsetValue?: any;
  105664. highLimitValue?: any;
  105665. }
  105666. /**
  105667. * Class used to store any kind of animation
  105668. */
  105669. export class Animation {
  105670. /**Name of the animation */
  105671. name: string;
  105672. /**Property to animate */
  105673. targetProperty: string;
  105674. /**The frames per second of the animation */
  105675. framePerSecond: number;
  105676. /**The data type of the animation */
  105677. dataType: number;
  105678. /**The loop mode of the animation */
  105679. loopMode?: number | undefined;
  105680. /**Specifies if blending should be enabled */
  105681. enableBlending?: boolean | undefined;
  105682. /**
  105683. * Use matrix interpolation instead of using direct key value when animating matrices
  105684. */
  105685. static AllowMatricesInterpolation: boolean;
  105686. /**
  105687. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  105688. */
  105689. static AllowMatrixDecomposeForInterpolation: boolean;
  105690. /**
  105691. * Stores the key frames of the animation
  105692. */
  105693. private _keys;
  105694. /**
  105695. * Stores the easing function of the animation
  105696. */
  105697. private _easingFunction;
  105698. /**
  105699. * @hidden Internal use only
  105700. */
  105701. _runtimeAnimations: RuntimeAnimation[];
  105702. /**
  105703. * The set of event that will be linked to this animation
  105704. */
  105705. private _events;
  105706. /**
  105707. * Stores an array of target property paths
  105708. */
  105709. targetPropertyPath: string[];
  105710. /**
  105711. * Stores the blending speed of the animation
  105712. */
  105713. blendingSpeed: number;
  105714. /**
  105715. * Stores the animation ranges for the animation
  105716. */
  105717. private _ranges;
  105718. /**
  105719. * @hidden Internal use
  105720. */
  105721. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  105722. /**
  105723. * Sets up an animation
  105724. * @param property The property to animate
  105725. * @param animationType The animation type to apply
  105726. * @param framePerSecond The frames per second of the animation
  105727. * @param easingFunction The easing function used in the animation
  105728. * @returns The created animation
  105729. */
  105730. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  105731. /**
  105732. * Create and start an animation on a node
  105733. * @param name defines the name of the global animation that will be run on all nodes
  105734. * @param node defines the root node where the animation will take place
  105735. * @param targetProperty defines property to animate
  105736. * @param framePerSecond defines the number of frame per second yo use
  105737. * @param totalFrame defines the number of frames in total
  105738. * @param from defines the initial value
  105739. * @param to defines the final value
  105740. * @param loopMode defines which loop mode you want to use (off by default)
  105741. * @param easingFunction defines the easing function to use (linear by default)
  105742. * @param onAnimationEnd defines the callback to call when animation end
  105743. * @returns the animatable created for this animation
  105744. */
  105745. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  105746. /**
  105747. * Create and start an animation on a node and its descendants
  105748. * @param name defines the name of the global animation that will be run on all nodes
  105749. * @param node defines the root node where the animation will take place
  105750. * @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
  105751. * @param targetProperty defines property to animate
  105752. * @param framePerSecond defines the number of frame per second to use
  105753. * @param totalFrame defines the number of frames in total
  105754. * @param from defines the initial value
  105755. * @param to defines the final value
  105756. * @param loopMode defines which loop mode you want to use (off by default)
  105757. * @param easingFunction defines the easing function to use (linear by default)
  105758. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  105759. * @returns the list of animatables created for all nodes
  105760. * @example https://www.babylonjs-playground.com/#MH0VLI
  105761. */
  105762. 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[]>;
  105763. /**
  105764. * Creates a new animation, merges it with the existing animations and starts it
  105765. * @param name Name of the animation
  105766. * @param node Node which contains the scene that begins the animations
  105767. * @param targetProperty Specifies which property to animate
  105768. * @param framePerSecond The frames per second of the animation
  105769. * @param totalFrame The total number of frames
  105770. * @param from The frame at the beginning of the animation
  105771. * @param to The frame at the end of the animation
  105772. * @param loopMode Specifies the loop mode of the animation
  105773. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  105774. * @param onAnimationEnd Callback to run once the animation is complete
  105775. * @returns Nullable animation
  105776. */
  105777. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  105778. /**
  105779. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  105780. * @param sourceAnimation defines the Animation containing keyframes to convert
  105781. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  105782. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  105783. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  105784. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  105785. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  105786. */
  105787. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  105788. /**
  105789. * Transition property of an host to the target Value
  105790. * @param property The property to transition
  105791. * @param targetValue The target Value of the property
  105792. * @param host The object where the property to animate belongs
  105793. * @param scene Scene used to run the animation
  105794. * @param frameRate Framerate (in frame/s) to use
  105795. * @param transition The transition type we want to use
  105796. * @param duration The duration of the animation, in milliseconds
  105797. * @param onAnimationEnd Callback trigger at the end of the animation
  105798. * @returns Nullable animation
  105799. */
  105800. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  105801. /**
  105802. * Return the array of runtime animations currently using this animation
  105803. */
  105804. get runtimeAnimations(): RuntimeAnimation[];
  105805. /**
  105806. * Specifies if any of the runtime animations are currently running
  105807. */
  105808. get hasRunningRuntimeAnimations(): boolean;
  105809. /**
  105810. * Initializes the animation
  105811. * @param name Name of the animation
  105812. * @param targetProperty Property to animate
  105813. * @param framePerSecond The frames per second of the animation
  105814. * @param dataType The data type of the animation
  105815. * @param loopMode The loop mode of the animation
  105816. * @param enableBlending Specifies if blending should be enabled
  105817. */
  105818. constructor(
  105819. /**Name of the animation */
  105820. name: string,
  105821. /**Property to animate */
  105822. targetProperty: string,
  105823. /**The frames per second of the animation */
  105824. framePerSecond: number,
  105825. /**The data type of the animation */
  105826. dataType: number,
  105827. /**The loop mode of the animation */
  105828. loopMode?: number | undefined,
  105829. /**Specifies if blending should be enabled */
  105830. enableBlending?: boolean | undefined);
  105831. /**
  105832. * Converts the animation to a string
  105833. * @param fullDetails support for multiple levels of logging within scene loading
  105834. * @returns String form of the animation
  105835. */
  105836. toString(fullDetails?: boolean): string;
  105837. /**
  105838. * Add an event to this animation
  105839. * @param event Event to add
  105840. */
  105841. addEvent(event: AnimationEvent): void;
  105842. /**
  105843. * Remove all events found at the given frame
  105844. * @param frame The frame to remove events from
  105845. */
  105846. removeEvents(frame: number): void;
  105847. /**
  105848. * Retrieves all the events from the animation
  105849. * @returns Events from the animation
  105850. */
  105851. getEvents(): AnimationEvent[];
  105852. /**
  105853. * Creates an animation range
  105854. * @param name Name of the animation range
  105855. * @param from Starting frame of the animation range
  105856. * @param to Ending frame of the animation
  105857. */
  105858. createRange(name: string, from: number, to: number): void;
  105859. /**
  105860. * Deletes an animation range by name
  105861. * @param name Name of the animation range to delete
  105862. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  105863. */
  105864. deleteRange(name: string, deleteFrames?: boolean): void;
  105865. /**
  105866. * Gets the animation range by name, or null if not defined
  105867. * @param name Name of the animation range
  105868. * @returns Nullable animation range
  105869. */
  105870. getRange(name: string): Nullable<AnimationRange>;
  105871. /**
  105872. * Gets the key frames from the animation
  105873. * @returns The key frames of the animation
  105874. */
  105875. getKeys(): Array<IAnimationKey>;
  105876. /**
  105877. * Gets the highest frame rate of the animation
  105878. * @returns Highest frame rate of the animation
  105879. */
  105880. getHighestFrame(): number;
  105881. /**
  105882. * Gets the easing function of the animation
  105883. * @returns Easing function of the animation
  105884. */
  105885. getEasingFunction(): IEasingFunction;
  105886. /**
  105887. * Sets the easing function of the animation
  105888. * @param easingFunction A custom mathematical formula for animation
  105889. */
  105890. setEasingFunction(easingFunction: EasingFunction): void;
  105891. /**
  105892. * Interpolates a scalar linearly
  105893. * @param startValue Start value of the animation curve
  105894. * @param endValue End value of the animation curve
  105895. * @param gradient Scalar amount to interpolate
  105896. * @returns Interpolated scalar value
  105897. */
  105898. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  105899. /**
  105900. * Interpolates a scalar cubically
  105901. * @param startValue Start value of the animation curve
  105902. * @param outTangent End tangent of the animation
  105903. * @param endValue End value of the animation curve
  105904. * @param inTangent Start tangent of the animation curve
  105905. * @param gradient Scalar amount to interpolate
  105906. * @returns Interpolated scalar value
  105907. */
  105908. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  105909. /**
  105910. * Interpolates a quaternion using a spherical linear interpolation
  105911. * @param startValue Start value of the animation curve
  105912. * @param endValue End value of the animation curve
  105913. * @param gradient Scalar amount to interpolate
  105914. * @returns Interpolated quaternion value
  105915. */
  105916. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  105917. /**
  105918. * Interpolates a quaternion cubically
  105919. * @param startValue Start value of the animation curve
  105920. * @param outTangent End tangent of the animation curve
  105921. * @param endValue End value of the animation curve
  105922. * @param inTangent Start tangent of the animation curve
  105923. * @param gradient Scalar amount to interpolate
  105924. * @returns Interpolated quaternion value
  105925. */
  105926. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  105927. /**
  105928. * Interpolates a Vector3 linearl
  105929. * @param startValue Start value of the animation curve
  105930. * @param endValue End value of the animation curve
  105931. * @param gradient Scalar amount to interpolate
  105932. * @returns Interpolated scalar value
  105933. */
  105934. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  105935. /**
  105936. * Interpolates a Vector3 cubically
  105937. * @param startValue Start value of the animation curve
  105938. * @param outTangent End tangent of the animation
  105939. * @param endValue End value of the animation curve
  105940. * @param inTangent Start tangent of the animation curve
  105941. * @param gradient Scalar amount to interpolate
  105942. * @returns InterpolatedVector3 value
  105943. */
  105944. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  105945. /**
  105946. * Interpolates a Vector2 linearly
  105947. * @param startValue Start value of the animation curve
  105948. * @param endValue End value of the animation curve
  105949. * @param gradient Scalar amount to interpolate
  105950. * @returns Interpolated Vector2 value
  105951. */
  105952. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  105953. /**
  105954. * Interpolates a Vector2 cubically
  105955. * @param startValue Start value of the animation curve
  105956. * @param outTangent End tangent of the animation
  105957. * @param endValue End value of the animation curve
  105958. * @param inTangent Start tangent of the animation curve
  105959. * @param gradient Scalar amount to interpolate
  105960. * @returns Interpolated Vector2 value
  105961. */
  105962. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  105963. /**
  105964. * Interpolates a size linearly
  105965. * @param startValue Start value of the animation curve
  105966. * @param endValue End value of the animation curve
  105967. * @param gradient Scalar amount to interpolate
  105968. * @returns Interpolated Size value
  105969. */
  105970. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  105971. /**
  105972. * Interpolates a Color3 linearly
  105973. * @param startValue Start value of the animation curve
  105974. * @param endValue End value of the animation curve
  105975. * @param gradient Scalar amount to interpolate
  105976. * @returns Interpolated Color3 value
  105977. */
  105978. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  105979. /**
  105980. * Interpolates a Color4 linearly
  105981. * @param startValue Start value of the animation curve
  105982. * @param endValue End value of the animation curve
  105983. * @param gradient Scalar amount to interpolate
  105984. * @returns Interpolated Color3 value
  105985. */
  105986. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  105987. /**
  105988. * @hidden Internal use only
  105989. */
  105990. _getKeyValue(value: any): any;
  105991. /**
  105992. * @hidden Internal use only
  105993. */
  105994. _interpolate(currentFrame: number, state: _IAnimationState): any;
  105995. /**
  105996. * Defines the function to use to interpolate matrices
  105997. * @param startValue defines the start matrix
  105998. * @param endValue defines the end matrix
  105999. * @param gradient defines the gradient between both matrices
  106000. * @param result defines an optional target matrix where to store the interpolation
  106001. * @returns the interpolated matrix
  106002. */
  106003. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  106004. /**
  106005. * Makes a copy of the animation
  106006. * @returns Cloned animation
  106007. */
  106008. clone(): Animation;
  106009. /**
  106010. * Sets the key frames of the animation
  106011. * @param values The animation key frames to set
  106012. */
  106013. setKeys(values: Array<IAnimationKey>): void;
  106014. /**
  106015. * Serializes the animation to an object
  106016. * @returns Serialized object
  106017. */
  106018. serialize(): any;
  106019. /**
  106020. * Float animation type
  106021. */
  106022. static readonly ANIMATIONTYPE_FLOAT: number;
  106023. /**
  106024. * Vector3 animation type
  106025. */
  106026. static readonly ANIMATIONTYPE_VECTOR3: number;
  106027. /**
  106028. * Quaternion animation type
  106029. */
  106030. static readonly ANIMATIONTYPE_QUATERNION: number;
  106031. /**
  106032. * Matrix animation type
  106033. */
  106034. static readonly ANIMATIONTYPE_MATRIX: number;
  106035. /**
  106036. * Color3 animation type
  106037. */
  106038. static readonly ANIMATIONTYPE_COLOR3: number;
  106039. /**
  106040. * Color3 animation type
  106041. */
  106042. static readonly ANIMATIONTYPE_COLOR4: number;
  106043. /**
  106044. * Vector2 animation type
  106045. */
  106046. static readonly ANIMATIONTYPE_VECTOR2: number;
  106047. /**
  106048. * Size animation type
  106049. */
  106050. static readonly ANIMATIONTYPE_SIZE: number;
  106051. /**
  106052. * Relative Loop Mode
  106053. */
  106054. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  106055. /**
  106056. * Cycle Loop Mode
  106057. */
  106058. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  106059. /**
  106060. * Constant Loop Mode
  106061. */
  106062. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  106063. /** @hidden */
  106064. static _UniversalLerp(left: any, right: any, amount: number): any;
  106065. /**
  106066. * Parses an animation object and creates an animation
  106067. * @param parsedAnimation Parsed animation object
  106068. * @returns Animation object
  106069. */
  106070. static Parse(parsedAnimation: any): Animation;
  106071. /**
  106072. * Appends the serialized animations from the source animations
  106073. * @param source Source containing the animations
  106074. * @param destination Target to store the animations
  106075. */
  106076. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  106077. }
  106078. }
  106079. declare module BABYLON {
  106080. /**
  106081. * Interface containing an array of animations
  106082. */
  106083. export interface IAnimatable {
  106084. /**
  106085. * Array of animations
  106086. */
  106087. animations: Nullable<Array<Animation>>;
  106088. }
  106089. }
  106090. declare module BABYLON {
  106091. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  106092. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  106093. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  106094. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  106095. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  106096. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  106097. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  106098. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  106099. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  106100. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  106101. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  106102. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  106103. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  106104. /**
  106105. * Decorator used to define property that can be serialized as reference to a camera
  106106. * @param sourceName defines the name of the property to decorate
  106107. */
  106108. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  106109. /**
  106110. * Class used to help serialization objects
  106111. */
  106112. export class SerializationHelper {
  106113. /** @hidden */
  106114. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  106115. /** @hidden */
  106116. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  106117. /** @hidden */
  106118. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  106119. /** @hidden */
  106120. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  106121. /**
  106122. * Appends the serialized animations from the source animations
  106123. * @param source Source containing the animations
  106124. * @param destination Target to store the animations
  106125. */
  106126. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  106127. /**
  106128. * Static function used to serialized a specific entity
  106129. * @param entity defines the entity to serialize
  106130. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  106131. * @returns a JSON compatible object representing the serialization of the entity
  106132. */
  106133. static Serialize<T>(entity: T, serializationObject?: any): any;
  106134. /**
  106135. * Creates a new entity from a serialization data object
  106136. * @param creationFunction defines a function used to instanciated the new entity
  106137. * @param source defines the source serialization data
  106138. * @param scene defines the hosting scene
  106139. * @param rootUrl defines the root url for resources
  106140. * @returns a new entity
  106141. */
  106142. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  106143. /**
  106144. * Clones an object
  106145. * @param creationFunction defines the function used to instanciate the new object
  106146. * @param source defines the source object
  106147. * @returns the cloned object
  106148. */
  106149. static Clone<T>(creationFunction: () => T, source: T): T;
  106150. /**
  106151. * Instanciates a new object based on a source one (some data will be shared between both object)
  106152. * @param creationFunction defines the function used to instanciate the new object
  106153. * @param source defines the source object
  106154. * @returns the new object
  106155. */
  106156. static Instanciate<T>(creationFunction: () => T, source: T): T;
  106157. }
  106158. }
  106159. declare module BABYLON {
  106160. /**
  106161. * Base class of all the textures in babylon.
  106162. * It groups all the common properties the materials, post process, lights... might need
  106163. * in order to make a correct use of the texture.
  106164. */
  106165. export class BaseTexture implements IAnimatable {
  106166. /**
  106167. * Default anisotropic filtering level for the application.
  106168. * It is set to 4 as a good tradeoff between perf and quality.
  106169. */
  106170. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  106171. /**
  106172. * Gets or sets the unique id of the texture
  106173. */
  106174. uniqueId: number;
  106175. /**
  106176. * Define the name of the texture.
  106177. */
  106178. name: string;
  106179. /**
  106180. * Gets or sets an object used to store user defined information.
  106181. */
  106182. metadata: any;
  106183. /**
  106184. * For internal use only. Please do not use.
  106185. */
  106186. reservedDataStore: any;
  106187. private _hasAlpha;
  106188. /**
  106189. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  106190. */
  106191. set hasAlpha(value: boolean);
  106192. get hasAlpha(): boolean;
  106193. /**
  106194. * Defines if the alpha value should be determined via the rgb values.
  106195. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  106196. */
  106197. getAlphaFromRGB: boolean;
  106198. /**
  106199. * Intensity or strength of the texture.
  106200. * It is commonly used by materials to fine tune the intensity of the texture
  106201. */
  106202. level: number;
  106203. /**
  106204. * Define the UV chanel to use starting from 0 and defaulting to 0.
  106205. * This is part of the texture as textures usually maps to one uv set.
  106206. */
  106207. coordinatesIndex: number;
  106208. private _coordinatesMode;
  106209. /**
  106210. * How a texture is mapped.
  106211. *
  106212. * | Value | Type | Description |
  106213. * | ----- | ----------------------------------- | ----------- |
  106214. * | 0 | EXPLICIT_MODE | |
  106215. * | 1 | SPHERICAL_MODE | |
  106216. * | 2 | PLANAR_MODE | |
  106217. * | 3 | CUBIC_MODE | |
  106218. * | 4 | PROJECTION_MODE | |
  106219. * | 5 | SKYBOX_MODE | |
  106220. * | 6 | INVCUBIC_MODE | |
  106221. * | 7 | EQUIRECTANGULAR_MODE | |
  106222. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  106223. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  106224. */
  106225. set coordinatesMode(value: number);
  106226. get coordinatesMode(): number;
  106227. /**
  106228. * | Value | Type | Description |
  106229. * | ----- | ------------------ | ----------- |
  106230. * | 0 | CLAMP_ADDRESSMODE | |
  106231. * | 1 | WRAP_ADDRESSMODE | |
  106232. * | 2 | MIRROR_ADDRESSMODE | |
  106233. */
  106234. wrapU: number;
  106235. /**
  106236. * | Value | Type | Description |
  106237. * | ----- | ------------------ | ----------- |
  106238. * | 0 | CLAMP_ADDRESSMODE | |
  106239. * | 1 | WRAP_ADDRESSMODE | |
  106240. * | 2 | MIRROR_ADDRESSMODE | |
  106241. */
  106242. wrapV: number;
  106243. /**
  106244. * | Value | Type | Description |
  106245. * | ----- | ------------------ | ----------- |
  106246. * | 0 | CLAMP_ADDRESSMODE | |
  106247. * | 1 | WRAP_ADDRESSMODE | |
  106248. * | 2 | MIRROR_ADDRESSMODE | |
  106249. */
  106250. wrapR: number;
  106251. /**
  106252. * With compliant hardware and browser (supporting anisotropic filtering)
  106253. * this defines the level of anisotropic filtering in the texture.
  106254. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  106255. */
  106256. anisotropicFilteringLevel: number;
  106257. /**
  106258. * Define if the texture is a cube texture or if false a 2d texture.
  106259. */
  106260. get isCube(): boolean;
  106261. set isCube(value: boolean);
  106262. /**
  106263. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  106264. */
  106265. get is3D(): boolean;
  106266. set is3D(value: boolean);
  106267. /**
  106268. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  106269. */
  106270. get is2DArray(): boolean;
  106271. set is2DArray(value: boolean);
  106272. /**
  106273. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  106274. * HDR texture are usually stored in linear space.
  106275. * This only impacts the PBR and Background materials
  106276. */
  106277. gammaSpace: boolean;
  106278. /**
  106279. * Gets or sets whether or not the texture contains RGBD data.
  106280. */
  106281. get isRGBD(): boolean;
  106282. set isRGBD(value: boolean);
  106283. /**
  106284. * Is Z inverted in the texture (useful in a cube texture).
  106285. */
  106286. invertZ: boolean;
  106287. /**
  106288. * Are mip maps generated for this texture or not.
  106289. */
  106290. get noMipmap(): boolean;
  106291. /**
  106292. * @hidden
  106293. */
  106294. lodLevelInAlpha: boolean;
  106295. /**
  106296. * With prefiltered texture, defined the offset used during the prefiltering steps.
  106297. */
  106298. get lodGenerationOffset(): number;
  106299. set lodGenerationOffset(value: number);
  106300. /**
  106301. * With prefiltered texture, defined the scale used during the prefiltering steps.
  106302. */
  106303. get lodGenerationScale(): number;
  106304. set lodGenerationScale(value: number);
  106305. /**
  106306. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  106307. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  106308. * average roughness values.
  106309. */
  106310. get linearSpecularLOD(): boolean;
  106311. set linearSpecularLOD(value: boolean);
  106312. /**
  106313. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  106314. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  106315. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  106316. */
  106317. get irradianceTexture(): Nullable<BaseTexture>;
  106318. set irradianceTexture(value: Nullable<BaseTexture>);
  106319. /**
  106320. * Define if the texture is a render target.
  106321. */
  106322. isRenderTarget: boolean;
  106323. /**
  106324. * Define the unique id of the texture in the scene.
  106325. */
  106326. get uid(): string;
  106327. /**
  106328. * Return a string representation of the texture.
  106329. * @returns the texture as a string
  106330. */
  106331. toString(): string;
  106332. /**
  106333. * Get the class name of the texture.
  106334. * @returns "BaseTexture"
  106335. */
  106336. getClassName(): string;
  106337. /**
  106338. * Define the list of animation attached to the texture.
  106339. */
  106340. animations: Animation[];
  106341. /**
  106342. * An event triggered when the texture is disposed.
  106343. */
  106344. onDisposeObservable: Observable<BaseTexture>;
  106345. private _onDisposeObserver;
  106346. /**
  106347. * Callback triggered when the texture has been disposed.
  106348. * Kept for back compatibility, you can use the onDisposeObservable instead.
  106349. */
  106350. set onDispose(callback: () => void);
  106351. /**
  106352. * Define the current state of the loading sequence when in delayed load mode.
  106353. */
  106354. delayLoadState: number;
  106355. private _scene;
  106356. private _engine;
  106357. /** @hidden */
  106358. _texture: Nullable<InternalTexture>;
  106359. private _uid;
  106360. /**
  106361. * Define if the texture is preventinga material to render or not.
  106362. * If not and the texture is not ready, the engine will use a default black texture instead.
  106363. */
  106364. get isBlocking(): boolean;
  106365. /**
  106366. * Instantiates a new BaseTexture.
  106367. * Base class of all the textures in babylon.
  106368. * It groups all the common properties the materials, post process, lights... might need
  106369. * in order to make a correct use of the texture.
  106370. * @param sceneOrEngine Define the scene or engine the texture blongs to
  106371. */
  106372. constructor(sceneOrEngine: Nullable<Scene | ThinEngine>);
  106373. /**
  106374. * Get the scene the texture belongs to.
  106375. * @returns the scene or null if undefined
  106376. */
  106377. getScene(): Nullable<Scene>;
  106378. /** @hidden */
  106379. protected _getEngine(): Nullable<ThinEngine>;
  106380. /**
  106381. * Get the texture transform matrix used to offset tile the texture for istance.
  106382. * @returns the transformation matrix
  106383. */
  106384. getTextureMatrix(): Matrix;
  106385. /**
  106386. * Get the texture reflection matrix used to rotate/transform the reflection.
  106387. * @returns the reflection matrix
  106388. */
  106389. getReflectionTextureMatrix(): Matrix;
  106390. /**
  106391. * Get the underlying lower level texture from Babylon.
  106392. * @returns the insternal texture
  106393. */
  106394. getInternalTexture(): Nullable<InternalTexture>;
  106395. /**
  106396. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  106397. * @returns true if ready or not blocking
  106398. */
  106399. isReadyOrNotBlocking(): boolean;
  106400. /**
  106401. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  106402. * @returns true if fully ready
  106403. */
  106404. isReady(): boolean;
  106405. private _cachedSize;
  106406. /**
  106407. * Get the size of the texture.
  106408. * @returns the texture size.
  106409. */
  106410. getSize(): ISize;
  106411. /**
  106412. * Get the base size of the texture.
  106413. * It can be different from the size if the texture has been resized for POT for instance
  106414. * @returns the base size
  106415. */
  106416. getBaseSize(): ISize;
  106417. /**
  106418. * Update the sampling mode of the texture.
  106419. * Default is Trilinear mode.
  106420. *
  106421. * | Value | Type | Description |
  106422. * | ----- | ------------------ | ----------- |
  106423. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  106424. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  106425. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  106426. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  106427. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  106428. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  106429. * | 7 | NEAREST_LINEAR | |
  106430. * | 8 | NEAREST_NEAREST | |
  106431. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  106432. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  106433. * | 11 | LINEAR_LINEAR | |
  106434. * | 12 | LINEAR_NEAREST | |
  106435. *
  106436. * > _mag_: magnification filter (close to the viewer)
  106437. * > _min_: minification filter (far from the viewer)
  106438. * > _mip_: filter used between mip map levels
  106439. *@param samplingMode Define the new sampling mode of the texture
  106440. */
  106441. updateSamplingMode(samplingMode: number): void;
  106442. /**
  106443. * Scales the texture if is `canRescale()`
  106444. * @param ratio the resize factor we want to use to rescale
  106445. */
  106446. scale(ratio: number): void;
  106447. /**
  106448. * Get if the texture can rescale.
  106449. */
  106450. get canRescale(): boolean;
  106451. /** @hidden */
  106452. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  106453. /** @hidden */
  106454. _rebuild(): void;
  106455. /**
  106456. * Triggers the load sequence in delayed load mode.
  106457. */
  106458. delayLoad(): void;
  106459. /**
  106460. * Clones the texture.
  106461. * @returns the cloned texture
  106462. */
  106463. clone(): Nullable<BaseTexture>;
  106464. /**
  106465. * Get the texture underlying type (INT, FLOAT...)
  106466. */
  106467. get textureType(): number;
  106468. /**
  106469. * Get the texture underlying format (RGB, RGBA...)
  106470. */
  106471. get textureFormat(): number;
  106472. /**
  106473. * Indicates that textures need to be re-calculated for all materials
  106474. */
  106475. protected _markAllSubMeshesAsTexturesDirty(): void;
  106476. /**
  106477. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  106478. * This will returns an RGBA array buffer containing either in values (0-255) or
  106479. * float values (0-1) depending of the underlying buffer type.
  106480. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  106481. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  106482. * @param buffer defines a user defined buffer to fill with data (can be null)
  106483. * @returns The Array buffer containing the pixels data.
  106484. */
  106485. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  106486. /**
  106487. * Release and destroy the underlying lower level texture aka internalTexture.
  106488. */
  106489. releaseInternalTexture(): void;
  106490. /** @hidden */
  106491. get _lodTextureHigh(): Nullable<BaseTexture>;
  106492. /** @hidden */
  106493. get _lodTextureMid(): Nullable<BaseTexture>;
  106494. /** @hidden */
  106495. get _lodTextureLow(): Nullable<BaseTexture>;
  106496. /**
  106497. * Dispose the texture and release its associated resources.
  106498. */
  106499. dispose(): void;
  106500. /**
  106501. * Serialize the texture into a JSON representation that can be parsed later on.
  106502. * @returns the JSON representation of the texture
  106503. */
  106504. serialize(): any;
  106505. /**
  106506. * Helper function to be called back once a list of texture contains only ready textures.
  106507. * @param textures Define the list of textures to wait for
  106508. * @param callback Define the callback triggered once the entire list will be ready
  106509. */
  106510. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  106511. private static _isScene;
  106512. }
  106513. }
  106514. declare module BABYLON {
  106515. /**
  106516. * Options to be used when creating an effect.
  106517. */
  106518. export interface IEffectCreationOptions {
  106519. /**
  106520. * Atrributes that will be used in the shader.
  106521. */
  106522. attributes: string[];
  106523. /**
  106524. * Uniform varible names that will be set in the shader.
  106525. */
  106526. uniformsNames: string[];
  106527. /**
  106528. * Uniform buffer variable names that will be set in the shader.
  106529. */
  106530. uniformBuffersNames: string[];
  106531. /**
  106532. * Sampler texture variable names that will be set in the shader.
  106533. */
  106534. samplers: string[];
  106535. /**
  106536. * Define statements that will be set in the shader.
  106537. */
  106538. defines: any;
  106539. /**
  106540. * Possible fallbacks for this effect to improve performance when needed.
  106541. */
  106542. fallbacks: Nullable<IEffectFallbacks>;
  106543. /**
  106544. * Callback that will be called when the shader is compiled.
  106545. */
  106546. onCompiled: Nullable<(effect: Effect) => void>;
  106547. /**
  106548. * Callback that will be called if an error occurs during shader compilation.
  106549. */
  106550. onError: Nullable<(effect: Effect, errors: string) => void>;
  106551. /**
  106552. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  106553. */
  106554. indexParameters?: any;
  106555. /**
  106556. * Max number of lights that can be used in the shader.
  106557. */
  106558. maxSimultaneousLights?: number;
  106559. /**
  106560. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  106561. */
  106562. transformFeedbackVaryings?: Nullable<string[]>;
  106563. }
  106564. /**
  106565. * Effect containing vertex and fragment shader that can be executed on an object.
  106566. */
  106567. export class Effect implements IDisposable {
  106568. /**
  106569. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  106570. */
  106571. static ShadersRepository: string;
  106572. /**
  106573. * Enable logging of the shader code when a compilation error occurs
  106574. */
  106575. static LogShaderCodeOnCompilationError: boolean;
  106576. /**
  106577. * Name of the effect.
  106578. */
  106579. name: any;
  106580. /**
  106581. * String container all the define statements that should be set on the shader.
  106582. */
  106583. defines: string;
  106584. /**
  106585. * Callback that will be called when the shader is compiled.
  106586. */
  106587. onCompiled: Nullable<(effect: Effect) => void>;
  106588. /**
  106589. * Callback that will be called if an error occurs during shader compilation.
  106590. */
  106591. onError: Nullable<(effect: Effect, errors: string) => void>;
  106592. /**
  106593. * Callback that will be called when effect is bound.
  106594. */
  106595. onBind: Nullable<(effect: Effect) => void>;
  106596. /**
  106597. * Unique ID of the effect.
  106598. */
  106599. uniqueId: number;
  106600. /**
  106601. * Observable that will be called when the shader is compiled.
  106602. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  106603. */
  106604. onCompileObservable: Observable<Effect>;
  106605. /**
  106606. * Observable that will be called if an error occurs during shader compilation.
  106607. */
  106608. onErrorObservable: Observable<Effect>;
  106609. /** @hidden */
  106610. _onBindObservable: Nullable<Observable<Effect>>;
  106611. /**
  106612. * @hidden
  106613. * Specifies if the effect was previously ready
  106614. */
  106615. _wasPreviouslyReady: boolean;
  106616. /**
  106617. * Observable that will be called when effect is bound.
  106618. */
  106619. get onBindObservable(): Observable<Effect>;
  106620. /** @hidden */
  106621. _bonesComputationForcedToCPU: boolean;
  106622. private static _uniqueIdSeed;
  106623. private _engine;
  106624. private _uniformBuffersNames;
  106625. private _uniformBuffersNamesList;
  106626. private _uniformsNames;
  106627. private _samplerList;
  106628. private _samplers;
  106629. private _isReady;
  106630. private _compilationError;
  106631. private _allFallbacksProcessed;
  106632. private _attributesNames;
  106633. private _attributes;
  106634. private _attributeLocationByName;
  106635. private _uniforms;
  106636. /**
  106637. * Key for the effect.
  106638. * @hidden
  106639. */
  106640. _key: string;
  106641. private _indexParameters;
  106642. private _fallbacks;
  106643. private _vertexSourceCode;
  106644. private _fragmentSourceCode;
  106645. private _vertexSourceCodeOverride;
  106646. private _fragmentSourceCodeOverride;
  106647. private _transformFeedbackVaryings;
  106648. /**
  106649. * Compiled shader to webGL program.
  106650. * @hidden
  106651. */
  106652. _pipelineContext: Nullable<IPipelineContext>;
  106653. private _valueCache;
  106654. private static _baseCache;
  106655. /**
  106656. * Instantiates an effect.
  106657. * An effect can be used to create/manage/execute vertex and fragment shaders.
  106658. * @param baseName Name of the effect.
  106659. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  106660. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  106661. * @param samplers List of sampler variables that will be passed to the shader.
  106662. * @param engine Engine to be used to render the effect
  106663. * @param defines Define statements to be added to the shader.
  106664. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  106665. * @param onCompiled Callback that will be called when the shader is compiled.
  106666. * @param onError Callback that will be called if an error occurs during shader compilation.
  106667. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  106668. */
  106669. 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);
  106670. private _useFinalCode;
  106671. /**
  106672. * Unique key for this effect
  106673. */
  106674. get key(): string;
  106675. /**
  106676. * If the effect has been compiled and prepared.
  106677. * @returns if the effect is compiled and prepared.
  106678. */
  106679. isReady(): boolean;
  106680. private _isReadyInternal;
  106681. /**
  106682. * The engine the effect was initialized with.
  106683. * @returns the engine.
  106684. */
  106685. getEngine(): Engine;
  106686. /**
  106687. * The pipeline context for this effect
  106688. * @returns the associated pipeline context
  106689. */
  106690. getPipelineContext(): Nullable<IPipelineContext>;
  106691. /**
  106692. * The set of names of attribute variables for the shader.
  106693. * @returns An array of attribute names.
  106694. */
  106695. getAttributesNames(): string[];
  106696. /**
  106697. * Returns the attribute at the given index.
  106698. * @param index The index of the attribute.
  106699. * @returns The location of the attribute.
  106700. */
  106701. getAttributeLocation(index: number): number;
  106702. /**
  106703. * Returns the attribute based on the name of the variable.
  106704. * @param name of the attribute to look up.
  106705. * @returns the attribute location.
  106706. */
  106707. getAttributeLocationByName(name: string): number;
  106708. /**
  106709. * The number of attributes.
  106710. * @returns the numnber of attributes.
  106711. */
  106712. getAttributesCount(): number;
  106713. /**
  106714. * Gets the index of a uniform variable.
  106715. * @param uniformName of the uniform to look up.
  106716. * @returns the index.
  106717. */
  106718. getUniformIndex(uniformName: string): number;
  106719. /**
  106720. * Returns the attribute based on the name of the variable.
  106721. * @param uniformName of the uniform to look up.
  106722. * @returns the location of the uniform.
  106723. */
  106724. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  106725. /**
  106726. * Returns an array of sampler variable names
  106727. * @returns The array of sampler variable names.
  106728. */
  106729. getSamplers(): string[];
  106730. /**
  106731. * Returns an array of uniform variable names
  106732. * @returns The array of uniform variable names.
  106733. */
  106734. getUniformNames(): string[];
  106735. /**
  106736. * Returns an array of uniform buffer variable names
  106737. * @returns The array of uniform buffer variable names.
  106738. */
  106739. getUniformBuffersNames(): string[];
  106740. /**
  106741. * Returns the index parameters used to create the effect
  106742. * @returns The index parameters object
  106743. */
  106744. getIndexParameters(): any;
  106745. /**
  106746. * The error from the last compilation.
  106747. * @returns the error string.
  106748. */
  106749. getCompilationError(): string;
  106750. /**
  106751. * Gets a boolean indicating that all fallbacks were used during compilation
  106752. * @returns true if all fallbacks were used
  106753. */
  106754. allFallbacksProcessed(): boolean;
  106755. /**
  106756. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  106757. * @param func The callback to be used.
  106758. */
  106759. executeWhenCompiled(func: (effect: Effect) => void): void;
  106760. private _checkIsReady;
  106761. private _loadShader;
  106762. /**
  106763. * Gets the vertex shader source code of this effect
  106764. */
  106765. get vertexSourceCode(): string;
  106766. /**
  106767. * Gets the fragment shader source code of this effect
  106768. */
  106769. get fragmentSourceCode(): string;
  106770. /**
  106771. * Recompiles the webGL program
  106772. * @param vertexSourceCode The source code for the vertex shader.
  106773. * @param fragmentSourceCode The source code for the fragment shader.
  106774. * @param onCompiled Callback called when completed.
  106775. * @param onError Callback called on error.
  106776. * @hidden
  106777. */
  106778. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  106779. /**
  106780. * Prepares the effect
  106781. * @hidden
  106782. */
  106783. _prepareEffect(): void;
  106784. private _getShaderCodeAndErrorLine;
  106785. private _processCompilationErrors;
  106786. /**
  106787. * Checks if the effect is supported. (Must be called after compilation)
  106788. */
  106789. get isSupported(): boolean;
  106790. /**
  106791. * Binds a texture to the engine to be used as output of the shader.
  106792. * @param channel Name of the output variable.
  106793. * @param texture Texture to bind.
  106794. * @hidden
  106795. */
  106796. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  106797. /**
  106798. * Sets a texture on the engine to be used in the shader.
  106799. * @param channel Name of the sampler variable.
  106800. * @param texture Texture to set.
  106801. */
  106802. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  106803. /**
  106804. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  106805. * @param channel Name of the sampler variable.
  106806. * @param texture Texture to set.
  106807. */
  106808. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  106809. /**
  106810. * Sets an array of textures on the engine to be used in the shader.
  106811. * @param channel Name of the variable.
  106812. * @param textures Textures to set.
  106813. */
  106814. setTextureArray(channel: string, textures: BaseTexture[]): void;
  106815. /**
  106816. * 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)
  106817. * @param channel Name of the sampler variable.
  106818. * @param postProcess Post process to get the input texture from.
  106819. */
  106820. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  106821. /**
  106822. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  106823. * 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)
  106824. * @param channel Name of the sampler variable.
  106825. * @param postProcess Post process to get the output texture from.
  106826. */
  106827. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  106828. /** @hidden */
  106829. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  106830. /** @hidden */
  106831. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  106832. /** @hidden */
  106833. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  106834. /** @hidden */
  106835. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  106836. /**
  106837. * Binds a buffer to a uniform.
  106838. * @param buffer Buffer to bind.
  106839. * @param name Name of the uniform variable to bind to.
  106840. */
  106841. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  106842. /**
  106843. * Binds block to a uniform.
  106844. * @param blockName Name of the block to bind.
  106845. * @param index Index to bind.
  106846. */
  106847. bindUniformBlock(blockName: string, index: number): void;
  106848. /**
  106849. * Sets an interger value on a uniform variable.
  106850. * @param uniformName Name of the variable.
  106851. * @param value Value to be set.
  106852. * @returns this effect.
  106853. */
  106854. setInt(uniformName: string, value: number): Effect;
  106855. /**
  106856. * Sets an int array on a uniform variable.
  106857. * @param uniformName Name of the variable.
  106858. * @param array array to be set.
  106859. * @returns this effect.
  106860. */
  106861. setIntArray(uniformName: string, array: Int32Array): Effect;
  106862. /**
  106863. * 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)
  106864. * @param uniformName Name of the variable.
  106865. * @param array array to be set.
  106866. * @returns this effect.
  106867. */
  106868. setIntArray2(uniformName: string, array: Int32Array): Effect;
  106869. /**
  106870. * 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)
  106871. * @param uniformName Name of the variable.
  106872. * @param array array to be set.
  106873. * @returns this effect.
  106874. */
  106875. setIntArray3(uniformName: string, array: Int32Array): Effect;
  106876. /**
  106877. * 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)
  106878. * @param uniformName Name of the variable.
  106879. * @param array array to be set.
  106880. * @returns this effect.
  106881. */
  106882. setIntArray4(uniformName: string, array: Int32Array): Effect;
  106883. /**
  106884. * Sets an float array on a uniform variable.
  106885. * @param uniformName Name of the variable.
  106886. * @param array array to be set.
  106887. * @returns this effect.
  106888. */
  106889. setFloatArray(uniformName: string, array: Float32Array): Effect;
  106890. /**
  106891. * 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)
  106892. * @param uniformName Name of the variable.
  106893. * @param array array to be set.
  106894. * @returns this effect.
  106895. */
  106896. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  106897. /**
  106898. * 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)
  106899. * @param uniformName Name of the variable.
  106900. * @param array array to be set.
  106901. * @returns this effect.
  106902. */
  106903. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  106904. /**
  106905. * 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)
  106906. * @param uniformName Name of the variable.
  106907. * @param array array to be set.
  106908. * @returns this effect.
  106909. */
  106910. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  106911. /**
  106912. * Sets an array on a uniform variable.
  106913. * @param uniformName Name of the variable.
  106914. * @param array array to be set.
  106915. * @returns this effect.
  106916. */
  106917. setArray(uniformName: string, array: number[]): Effect;
  106918. /**
  106919. * 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)
  106920. * @param uniformName Name of the variable.
  106921. * @param array array to be set.
  106922. * @returns this effect.
  106923. */
  106924. setArray2(uniformName: string, array: number[]): Effect;
  106925. /**
  106926. * 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)
  106927. * @param uniformName Name of the variable.
  106928. * @param array array to be set.
  106929. * @returns this effect.
  106930. */
  106931. setArray3(uniformName: string, array: number[]): Effect;
  106932. /**
  106933. * 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)
  106934. * @param uniformName Name of the variable.
  106935. * @param array array to be set.
  106936. * @returns this effect.
  106937. */
  106938. setArray4(uniformName: string, array: number[]): Effect;
  106939. /**
  106940. * Sets matrices on a uniform variable.
  106941. * @param uniformName Name of the variable.
  106942. * @param matrices matrices to be set.
  106943. * @returns this effect.
  106944. */
  106945. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  106946. /**
  106947. * Sets matrix on a uniform variable.
  106948. * @param uniformName Name of the variable.
  106949. * @param matrix matrix to be set.
  106950. * @returns this effect.
  106951. */
  106952. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  106953. /**
  106954. * 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)
  106955. * @param uniformName Name of the variable.
  106956. * @param matrix matrix to be set.
  106957. * @returns this effect.
  106958. */
  106959. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  106960. /**
  106961. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  106962. * @param uniformName Name of the variable.
  106963. * @param matrix matrix to be set.
  106964. * @returns this effect.
  106965. */
  106966. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  106967. /**
  106968. * Sets a float on a uniform variable.
  106969. * @param uniformName Name of the variable.
  106970. * @param value value to be set.
  106971. * @returns this effect.
  106972. */
  106973. setFloat(uniformName: string, value: number): Effect;
  106974. /**
  106975. * Sets a boolean on a uniform variable.
  106976. * @param uniformName Name of the variable.
  106977. * @param bool value to be set.
  106978. * @returns this effect.
  106979. */
  106980. setBool(uniformName: string, bool: boolean): Effect;
  106981. /**
  106982. * Sets a Vector2 on a uniform variable.
  106983. * @param uniformName Name of the variable.
  106984. * @param vector2 vector2 to be set.
  106985. * @returns this effect.
  106986. */
  106987. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  106988. /**
  106989. * Sets a float2 on a uniform variable.
  106990. * @param uniformName Name of the variable.
  106991. * @param x First float in float2.
  106992. * @param y Second float in float2.
  106993. * @returns this effect.
  106994. */
  106995. setFloat2(uniformName: string, x: number, y: number): Effect;
  106996. /**
  106997. * Sets a Vector3 on a uniform variable.
  106998. * @param uniformName Name of the variable.
  106999. * @param vector3 Value to be set.
  107000. * @returns this effect.
  107001. */
  107002. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  107003. /**
  107004. * Sets a float3 on a uniform variable.
  107005. * @param uniformName Name of the variable.
  107006. * @param x First float in float3.
  107007. * @param y Second float in float3.
  107008. * @param z Third float in float3.
  107009. * @returns this effect.
  107010. */
  107011. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  107012. /**
  107013. * Sets a Vector4 on a uniform variable.
  107014. * @param uniformName Name of the variable.
  107015. * @param vector4 Value to be set.
  107016. * @returns this effect.
  107017. */
  107018. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  107019. /**
  107020. * Sets a float4 on a uniform variable.
  107021. * @param uniformName Name of the variable.
  107022. * @param x First float in float4.
  107023. * @param y Second float in float4.
  107024. * @param z Third float in float4.
  107025. * @param w Fourth float in float4.
  107026. * @returns this effect.
  107027. */
  107028. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  107029. /**
  107030. * Sets a Color3 on a uniform variable.
  107031. * @param uniformName Name of the variable.
  107032. * @param color3 Value to be set.
  107033. * @returns this effect.
  107034. */
  107035. setColor3(uniformName: string, color3: IColor3Like): Effect;
  107036. /**
  107037. * Sets a Color4 on a uniform variable.
  107038. * @param uniformName Name of the variable.
  107039. * @param color3 Value to be set.
  107040. * @param alpha Alpha value to be set.
  107041. * @returns this effect.
  107042. */
  107043. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  107044. /**
  107045. * Sets a Color4 on a uniform variable
  107046. * @param uniformName defines the name of the variable
  107047. * @param color4 defines the value to be set
  107048. * @returns this effect.
  107049. */
  107050. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  107051. /** Release all associated resources */
  107052. dispose(): void;
  107053. /**
  107054. * This function will add a new shader to the shader store
  107055. * @param name the name of the shader
  107056. * @param pixelShader optional pixel shader content
  107057. * @param vertexShader optional vertex shader content
  107058. */
  107059. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  107060. /**
  107061. * Store of each shader (The can be looked up using effect.key)
  107062. */
  107063. static ShadersStore: {
  107064. [key: string]: string;
  107065. };
  107066. /**
  107067. * Store of each included file for a shader (The can be looked up using effect.key)
  107068. */
  107069. static IncludesShadersStore: {
  107070. [key: string]: string;
  107071. };
  107072. /**
  107073. * Resets the cache of effects.
  107074. */
  107075. static ResetCache(): void;
  107076. }
  107077. }
  107078. declare module BABYLON {
  107079. /**
  107080. * Interface used to describe the capabilities of the engine relatively to the current browser
  107081. */
  107082. export interface EngineCapabilities {
  107083. /** Maximum textures units per fragment shader */
  107084. maxTexturesImageUnits: number;
  107085. /** Maximum texture units per vertex shader */
  107086. maxVertexTextureImageUnits: number;
  107087. /** Maximum textures units in the entire pipeline */
  107088. maxCombinedTexturesImageUnits: number;
  107089. /** Maximum texture size */
  107090. maxTextureSize: number;
  107091. /** Maximum texture samples */
  107092. maxSamples?: number;
  107093. /** Maximum cube texture size */
  107094. maxCubemapTextureSize: number;
  107095. /** Maximum render texture size */
  107096. maxRenderTextureSize: number;
  107097. /** Maximum number of vertex attributes */
  107098. maxVertexAttribs: number;
  107099. /** Maximum number of varyings */
  107100. maxVaryingVectors: number;
  107101. /** Maximum number of uniforms per vertex shader */
  107102. maxVertexUniformVectors: number;
  107103. /** Maximum number of uniforms per fragment shader */
  107104. maxFragmentUniformVectors: number;
  107105. /** Defines if standard derivates (dx/dy) are supported */
  107106. standardDerivatives: boolean;
  107107. /** Defines if s3tc texture compression is supported */
  107108. s3tc?: WEBGL_compressed_texture_s3tc;
  107109. /** Defines if pvrtc texture compression is supported */
  107110. pvrtc: any;
  107111. /** Defines if etc1 texture compression is supported */
  107112. etc1: any;
  107113. /** Defines if etc2 texture compression is supported */
  107114. etc2: any;
  107115. /** Defines if astc texture compression is supported */
  107116. astc: any;
  107117. /** Defines if float textures are supported */
  107118. textureFloat: boolean;
  107119. /** Defines if vertex array objects are supported */
  107120. vertexArrayObject: boolean;
  107121. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  107122. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  107123. /** Gets the maximum level of anisotropy supported */
  107124. maxAnisotropy: number;
  107125. /** Defines if instancing is supported */
  107126. instancedArrays: boolean;
  107127. /** Defines if 32 bits indices are supported */
  107128. uintIndices: boolean;
  107129. /** Defines if high precision shaders are supported */
  107130. highPrecisionShaderSupported: boolean;
  107131. /** Defines if depth reading in the fragment shader is supported */
  107132. fragmentDepthSupported: boolean;
  107133. /** Defines if float texture linear filtering is supported*/
  107134. textureFloatLinearFiltering: boolean;
  107135. /** Defines if rendering to float textures is supported */
  107136. textureFloatRender: boolean;
  107137. /** Defines if half float textures are supported*/
  107138. textureHalfFloat: boolean;
  107139. /** Defines if half float texture linear filtering is supported*/
  107140. textureHalfFloatLinearFiltering: boolean;
  107141. /** Defines if rendering to half float textures is supported */
  107142. textureHalfFloatRender: boolean;
  107143. /** Defines if textureLOD shader command is supported */
  107144. textureLOD: boolean;
  107145. /** Defines if draw buffers extension is supported */
  107146. drawBuffersExtension: boolean;
  107147. /** Defines if depth textures are supported */
  107148. depthTextureExtension: boolean;
  107149. /** Defines if float color buffer are supported */
  107150. colorBufferFloat: boolean;
  107151. /** Gets disjoint timer query extension (null if not supported) */
  107152. timerQuery?: EXT_disjoint_timer_query;
  107153. /** Defines if timestamp can be used with timer query */
  107154. canUseTimestampForTimerQuery: boolean;
  107155. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  107156. multiview?: any;
  107157. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  107158. oculusMultiview?: any;
  107159. /** Function used to let the system compiles shaders in background */
  107160. parallelShaderCompile?: {
  107161. COMPLETION_STATUS_KHR: number;
  107162. };
  107163. /** Max number of texture samples for MSAA */
  107164. maxMSAASamples: number;
  107165. /** Defines if the blend min max extension is supported */
  107166. blendMinMax: boolean;
  107167. }
  107168. }
  107169. declare module BABYLON {
  107170. /**
  107171. * @hidden
  107172. **/
  107173. export class DepthCullingState {
  107174. private _isDepthTestDirty;
  107175. private _isDepthMaskDirty;
  107176. private _isDepthFuncDirty;
  107177. private _isCullFaceDirty;
  107178. private _isCullDirty;
  107179. private _isZOffsetDirty;
  107180. private _isFrontFaceDirty;
  107181. private _depthTest;
  107182. private _depthMask;
  107183. private _depthFunc;
  107184. private _cull;
  107185. private _cullFace;
  107186. private _zOffset;
  107187. private _frontFace;
  107188. /**
  107189. * Initializes the state.
  107190. */
  107191. constructor();
  107192. get isDirty(): boolean;
  107193. get zOffset(): number;
  107194. set zOffset(value: number);
  107195. get cullFace(): Nullable<number>;
  107196. set cullFace(value: Nullable<number>);
  107197. get cull(): Nullable<boolean>;
  107198. set cull(value: Nullable<boolean>);
  107199. get depthFunc(): Nullable<number>;
  107200. set depthFunc(value: Nullable<number>);
  107201. get depthMask(): boolean;
  107202. set depthMask(value: boolean);
  107203. get depthTest(): boolean;
  107204. set depthTest(value: boolean);
  107205. get frontFace(): Nullable<number>;
  107206. set frontFace(value: Nullable<number>);
  107207. reset(): void;
  107208. apply(gl: WebGLRenderingContext): void;
  107209. }
  107210. }
  107211. declare module BABYLON {
  107212. /**
  107213. * @hidden
  107214. **/
  107215. export class StencilState {
  107216. /** 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 */
  107217. static readonly ALWAYS: number;
  107218. /** Passed to stencilOperation to specify that stencil value must be kept */
  107219. static readonly KEEP: number;
  107220. /** Passed to stencilOperation to specify that stencil value must be replaced */
  107221. static readonly REPLACE: number;
  107222. private _isStencilTestDirty;
  107223. private _isStencilMaskDirty;
  107224. private _isStencilFuncDirty;
  107225. private _isStencilOpDirty;
  107226. private _stencilTest;
  107227. private _stencilMask;
  107228. private _stencilFunc;
  107229. private _stencilFuncRef;
  107230. private _stencilFuncMask;
  107231. private _stencilOpStencilFail;
  107232. private _stencilOpDepthFail;
  107233. private _stencilOpStencilDepthPass;
  107234. get isDirty(): boolean;
  107235. get stencilFunc(): number;
  107236. set stencilFunc(value: number);
  107237. get stencilFuncRef(): number;
  107238. set stencilFuncRef(value: number);
  107239. get stencilFuncMask(): number;
  107240. set stencilFuncMask(value: number);
  107241. get stencilOpStencilFail(): number;
  107242. set stencilOpStencilFail(value: number);
  107243. get stencilOpDepthFail(): number;
  107244. set stencilOpDepthFail(value: number);
  107245. get stencilOpStencilDepthPass(): number;
  107246. set stencilOpStencilDepthPass(value: number);
  107247. get stencilMask(): number;
  107248. set stencilMask(value: number);
  107249. get stencilTest(): boolean;
  107250. set stencilTest(value: boolean);
  107251. constructor();
  107252. reset(): void;
  107253. apply(gl: WebGLRenderingContext): void;
  107254. }
  107255. }
  107256. declare module BABYLON {
  107257. /**
  107258. * @hidden
  107259. **/
  107260. export class AlphaState {
  107261. private _isAlphaBlendDirty;
  107262. private _isBlendFunctionParametersDirty;
  107263. private _isBlendEquationParametersDirty;
  107264. private _isBlendConstantsDirty;
  107265. private _alphaBlend;
  107266. private _blendFunctionParameters;
  107267. private _blendEquationParameters;
  107268. private _blendConstants;
  107269. /**
  107270. * Initializes the state.
  107271. */
  107272. constructor();
  107273. get isDirty(): boolean;
  107274. get alphaBlend(): boolean;
  107275. set alphaBlend(value: boolean);
  107276. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  107277. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  107278. setAlphaEquationParameters(rgb: number, alpha: number): void;
  107279. reset(): void;
  107280. apply(gl: WebGLRenderingContext): void;
  107281. }
  107282. }
  107283. declare module BABYLON {
  107284. /** @hidden */
  107285. export class WebGL2ShaderProcessor implements IShaderProcessor {
  107286. attributeProcessor(attribute: string): string;
  107287. varyingProcessor(varying: string, isFragment: boolean): string;
  107288. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  107289. }
  107290. }
  107291. declare module BABYLON {
  107292. /**
  107293. * Interface for attribute information associated with buffer instanciation
  107294. */
  107295. export interface InstancingAttributeInfo {
  107296. /**
  107297. * Name of the GLSL attribute
  107298. * if attribute index is not specified, this is used to retrieve the index from the effect
  107299. */
  107300. attributeName: string;
  107301. /**
  107302. * Index/offset of the attribute in the vertex shader
  107303. * if not specified, this will be computes from the name.
  107304. */
  107305. index?: number;
  107306. /**
  107307. * size of the attribute, 1, 2, 3 or 4
  107308. */
  107309. attributeSize: number;
  107310. /**
  107311. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  107312. */
  107313. offset: number;
  107314. /**
  107315. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  107316. * default to 1
  107317. */
  107318. divisor?: number;
  107319. /**
  107320. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  107321. * default is FLOAT
  107322. */
  107323. attributeType?: number;
  107324. /**
  107325. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  107326. */
  107327. normalized?: boolean;
  107328. }
  107329. }
  107330. declare module BABYLON {
  107331. interface ThinEngine {
  107332. /**
  107333. * Update a video texture
  107334. * @param texture defines the texture to update
  107335. * @param video defines the video element to use
  107336. * @param invertY defines if data must be stored with Y axis inverted
  107337. */
  107338. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  107339. }
  107340. }
  107341. declare module BABYLON {
  107342. /**
  107343. * Settings for finer control over video usage
  107344. */
  107345. export interface VideoTextureSettings {
  107346. /**
  107347. * Applies `autoplay` to video, if specified
  107348. */
  107349. autoPlay?: boolean;
  107350. /**
  107351. * Applies `loop` to video, if specified
  107352. */
  107353. loop?: boolean;
  107354. /**
  107355. * Automatically updates internal texture from video at every frame in the render loop
  107356. */
  107357. autoUpdateTexture: boolean;
  107358. /**
  107359. * Image src displayed during the video loading or until the user interacts with the video.
  107360. */
  107361. poster?: string;
  107362. }
  107363. /**
  107364. * If you want to display a video in your scene, this is the special texture for that.
  107365. * This special texture works similar to other textures, with the exception of a few parameters.
  107366. * @see https://doc.babylonjs.com/how_to/video_texture
  107367. */
  107368. export class VideoTexture extends Texture {
  107369. /**
  107370. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  107371. */
  107372. readonly autoUpdateTexture: boolean;
  107373. /**
  107374. * The video instance used by the texture internally
  107375. */
  107376. readonly video: HTMLVideoElement;
  107377. private _onUserActionRequestedObservable;
  107378. /**
  107379. * Event triggerd when a dom action is required by the user to play the video.
  107380. * This happens due to recent changes in browser policies preventing video to auto start.
  107381. */
  107382. get onUserActionRequestedObservable(): Observable<Texture>;
  107383. private _generateMipMaps;
  107384. private _stillImageCaptured;
  107385. private _displayingPosterTexture;
  107386. private _settings;
  107387. private _createInternalTextureOnEvent;
  107388. private _frameId;
  107389. private _currentSrc;
  107390. /**
  107391. * Creates a video texture.
  107392. * If you want to display a video in your scene, this is the special texture for that.
  107393. * This special texture works similar to other textures, with the exception of a few parameters.
  107394. * @see https://doc.babylonjs.com/how_to/video_texture
  107395. * @param name optional name, will detect from video source, if not defined
  107396. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  107397. * @param scene is obviously the current scene.
  107398. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  107399. * @param invertY is false by default but can be used to invert video on Y axis
  107400. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  107401. * @param settings allows finer control over video usage
  107402. */
  107403. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  107404. private _getName;
  107405. private _getVideo;
  107406. private _createInternalTexture;
  107407. private reset;
  107408. /**
  107409. * @hidden Internal method to initiate `update`.
  107410. */
  107411. _rebuild(): void;
  107412. /**
  107413. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  107414. */
  107415. update(): void;
  107416. /**
  107417. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  107418. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  107419. */
  107420. updateTexture(isVisible: boolean): void;
  107421. protected _updateInternalTexture: () => void;
  107422. /**
  107423. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  107424. * @param url New url.
  107425. */
  107426. updateURL(url: string): void;
  107427. /**
  107428. * Clones the texture.
  107429. * @returns the cloned texture
  107430. */
  107431. clone(): VideoTexture;
  107432. /**
  107433. * Dispose the texture and release its associated resources.
  107434. */
  107435. dispose(): void;
  107436. /**
  107437. * Creates a video texture straight from a stream.
  107438. * @param scene Define the scene the texture should be created in
  107439. * @param stream Define the stream the texture should be created from
  107440. * @returns The created video texture as a promise
  107441. */
  107442. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  107443. /**
  107444. * Creates a video texture straight from your WebCam video feed.
  107445. * @param scene Define the scene the texture should be created in
  107446. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  107447. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  107448. * @returns The created video texture as a promise
  107449. */
  107450. static CreateFromWebCamAsync(scene: Scene, constraints: {
  107451. minWidth: number;
  107452. maxWidth: number;
  107453. minHeight: number;
  107454. maxHeight: number;
  107455. deviceId: string;
  107456. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  107457. /**
  107458. * Creates a video texture straight from your WebCam video feed.
  107459. * @param scene Define the scene the texture should be created in
  107460. * @param onReady Define a callback to triggered once the texture will be ready
  107461. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  107462. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  107463. */
  107464. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  107465. minWidth: number;
  107466. maxWidth: number;
  107467. minHeight: number;
  107468. maxHeight: number;
  107469. deviceId: string;
  107470. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  107471. }
  107472. }
  107473. declare module BABYLON {
  107474. /**
  107475. * Defines the interface used by objects working like Scene
  107476. * @hidden
  107477. */
  107478. export interface ISceneLike {
  107479. _addPendingData(data: any): void;
  107480. _removePendingData(data: any): void;
  107481. offlineProvider: IOfflineProvider;
  107482. }
  107483. /** Interface defining initialization parameters for Engine class */
  107484. export interface EngineOptions extends WebGLContextAttributes {
  107485. /**
  107486. * Defines if the engine should no exceed a specified device ratio
  107487. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  107488. */
  107489. limitDeviceRatio?: number;
  107490. /**
  107491. * Defines if webvr should be enabled automatically
  107492. * @see http://doc.babylonjs.com/how_to/webvr_camera
  107493. */
  107494. autoEnableWebVR?: boolean;
  107495. /**
  107496. * Defines if webgl2 should be turned off even if supported
  107497. * @see http://doc.babylonjs.com/features/webgl2
  107498. */
  107499. disableWebGL2Support?: boolean;
  107500. /**
  107501. * Defines if webaudio should be initialized as well
  107502. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  107503. */
  107504. audioEngine?: boolean;
  107505. /**
  107506. * Defines if animations should run using a deterministic lock step
  107507. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  107508. */
  107509. deterministicLockstep?: boolean;
  107510. /** Defines the maximum steps to use with deterministic lock step mode */
  107511. lockstepMaxSteps?: number;
  107512. /** Defines the seconds between each deterministic lock step */
  107513. timeStep?: number;
  107514. /**
  107515. * Defines that engine should ignore context lost events
  107516. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  107517. */
  107518. doNotHandleContextLost?: boolean;
  107519. /**
  107520. * Defines that engine should ignore modifying touch action attribute and style
  107521. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  107522. */
  107523. doNotHandleTouchAction?: boolean;
  107524. /**
  107525. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  107526. */
  107527. useHighPrecisionFloats?: boolean;
  107528. }
  107529. /**
  107530. * The base engine class (root of all engines)
  107531. */
  107532. export class ThinEngine {
  107533. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  107534. static ExceptionList: ({
  107535. key: string;
  107536. capture: string;
  107537. captureConstraint: number;
  107538. targets: string[];
  107539. } | {
  107540. key: string;
  107541. capture: null;
  107542. captureConstraint: null;
  107543. targets: string[];
  107544. })[];
  107545. /** @hidden */
  107546. static _TextureLoaders: IInternalTextureLoader[];
  107547. /**
  107548. * Returns the current npm package of the sdk
  107549. */
  107550. static get NpmPackage(): string;
  107551. /**
  107552. * Returns the current version of the framework
  107553. */
  107554. static get Version(): string;
  107555. /**
  107556. * Returns a string describing the current engine
  107557. */
  107558. get description(): string;
  107559. /**
  107560. * Gets or sets the epsilon value used by collision engine
  107561. */
  107562. static CollisionsEpsilon: number;
  107563. /**
  107564. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  107565. */
  107566. static get ShadersRepository(): string;
  107567. static set ShadersRepository(value: string);
  107568. /** @hidden */
  107569. _shaderProcessor: IShaderProcessor;
  107570. /**
  107571. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  107572. */
  107573. forcePOTTextures: boolean;
  107574. /**
  107575. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  107576. */
  107577. isFullscreen: boolean;
  107578. /**
  107579. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  107580. */
  107581. cullBackFaces: boolean;
  107582. /**
  107583. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  107584. */
  107585. renderEvenInBackground: boolean;
  107586. /**
  107587. * Gets or sets a boolean indicating that cache can be kept between frames
  107588. */
  107589. preventCacheWipeBetweenFrames: boolean;
  107590. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  107591. validateShaderPrograms: boolean;
  107592. /**
  107593. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  107594. * This can provide greater z depth for distant objects.
  107595. */
  107596. useReverseDepthBuffer: boolean;
  107597. /**
  107598. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  107599. */
  107600. disableUniformBuffers: boolean;
  107601. /** @hidden */
  107602. _uniformBuffers: UniformBuffer[];
  107603. /**
  107604. * Gets a boolean indicating that the engine supports uniform buffers
  107605. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  107606. */
  107607. get supportsUniformBuffers(): boolean;
  107608. /** @hidden */
  107609. _gl: WebGLRenderingContext;
  107610. /** @hidden */
  107611. _webGLVersion: number;
  107612. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  107613. protected _windowIsBackground: boolean;
  107614. protected _creationOptions: EngineOptions;
  107615. protected _highPrecisionShadersAllowed: boolean;
  107616. /** @hidden */
  107617. get _shouldUseHighPrecisionShader(): boolean;
  107618. /**
  107619. * Gets a boolean indicating that only power of 2 textures are supported
  107620. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  107621. */
  107622. get needPOTTextures(): boolean;
  107623. /** @hidden */
  107624. _badOS: boolean;
  107625. /** @hidden */
  107626. _badDesktopOS: boolean;
  107627. private _hardwareScalingLevel;
  107628. /** @hidden */
  107629. _caps: EngineCapabilities;
  107630. private _isStencilEnable;
  107631. private _glVersion;
  107632. private _glRenderer;
  107633. private _glVendor;
  107634. /** @hidden */
  107635. _videoTextureSupported: boolean;
  107636. protected _renderingQueueLaunched: boolean;
  107637. protected _activeRenderLoops: (() => void)[];
  107638. /**
  107639. * Observable signaled when a context lost event is raised
  107640. */
  107641. onContextLostObservable: Observable<ThinEngine>;
  107642. /**
  107643. * Observable signaled when a context restored event is raised
  107644. */
  107645. onContextRestoredObservable: Observable<ThinEngine>;
  107646. private _onContextLost;
  107647. private _onContextRestored;
  107648. protected _contextWasLost: boolean;
  107649. /** @hidden */
  107650. _doNotHandleContextLost: boolean;
  107651. /**
  107652. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  107653. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  107654. */
  107655. get doNotHandleContextLost(): boolean;
  107656. set doNotHandleContextLost(value: boolean);
  107657. /**
  107658. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  107659. */
  107660. disableVertexArrayObjects: boolean;
  107661. /** @hidden */
  107662. protected _colorWrite: boolean;
  107663. /** @hidden */
  107664. protected _colorWriteChanged: boolean;
  107665. /** @hidden */
  107666. protected _depthCullingState: DepthCullingState;
  107667. /** @hidden */
  107668. protected _stencilState: StencilState;
  107669. /** @hidden */
  107670. _alphaState: AlphaState;
  107671. /** @hidden */
  107672. _alphaMode: number;
  107673. /** @hidden */
  107674. _alphaEquation: number;
  107675. /** @hidden */
  107676. _internalTexturesCache: InternalTexture[];
  107677. /** @hidden */
  107678. protected _activeChannel: number;
  107679. private _currentTextureChannel;
  107680. /** @hidden */
  107681. protected _boundTexturesCache: {
  107682. [key: string]: Nullable<InternalTexture>;
  107683. };
  107684. /** @hidden */
  107685. protected _currentEffect: Nullable<Effect>;
  107686. /** @hidden */
  107687. protected _currentProgram: Nullable<WebGLProgram>;
  107688. private _compiledEffects;
  107689. private _vertexAttribArraysEnabled;
  107690. /** @hidden */
  107691. protected _cachedViewport: Nullable<IViewportLike>;
  107692. private _cachedVertexArrayObject;
  107693. /** @hidden */
  107694. protected _cachedVertexBuffers: any;
  107695. /** @hidden */
  107696. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  107697. /** @hidden */
  107698. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  107699. /** @hidden */
  107700. _currentRenderTarget: Nullable<InternalTexture>;
  107701. private _uintIndicesCurrentlySet;
  107702. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  107703. /** @hidden */
  107704. _currentFramebuffer: Nullable<WebGLFramebuffer>;
  107705. /** @hidden */
  107706. _dummyFramebuffer: Nullable<WebGLFramebuffer>;
  107707. private _currentBufferPointers;
  107708. private _currentInstanceLocations;
  107709. private _currentInstanceBuffers;
  107710. private _textureUnits;
  107711. /** @hidden */
  107712. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  107713. /** @hidden */
  107714. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  107715. /** @hidden */
  107716. _boundRenderFunction: any;
  107717. private _vaoRecordInProgress;
  107718. private _mustWipeVertexAttributes;
  107719. private _emptyTexture;
  107720. private _emptyCubeTexture;
  107721. private _emptyTexture3D;
  107722. private _emptyTexture2DArray;
  107723. /** @hidden */
  107724. _frameHandler: number;
  107725. private _nextFreeTextureSlots;
  107726. private _maxSimultaneousTextures;
  107727. private _activeRequests;
  107728. /** @hidden */
  107729. _transformTextureUrl: Nullable<(url: string) => string>;
  107730. protected get _supportsHardwareTextureRescaling(): boolean;
  107731. private _framebufferDimensionsObject;
  107732. /**
  107733. * sets the object from which width and height will be taken from when getting render width and height
  107734. * Will fallback to the gl object
  107735. * @param dimensions the framebuffer width and height that will be used.
  107736. */
  107737. set framebufferDimensionsObject(dimensions: Nullable<{
  107738. framebufferWidth: number;
  107739. framebufferHeight: number;
  107740. }>);
  107741. /**
  107742. * Gets the current viewport
  107743. */
  107744. get currentViewport(): Nullable<IViewportLike>;
  107745. /**
  107746. * Gets the default empty texture
  107747. */
  107748. get emptyTexture(): InternalTexture;
  107749. /**
  107750. * Gets the default empty 3D texture
  107751. */
  107752. get emptyTexture3D(): InternalTexture;
  107753. /**
  107754. * Gets the default empty 2D array texture
  107755. */
  107756. get emptyTexture2DArray(): InternalTexture;
  107757. /**
  107758. * Gets the default empty cube texture
  107759. */
  107760. get emptyCubeTexture(): InternalTexture;
  107761. /**
  107762. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  107763. */
  107764. readonly premultipliedAlpha: boolean;
  107765. /**
  107766. * Observable event triggered before each texture is initialized
  107767. */
  107768. onBeforeTextureInitObservable: Observable<Texture>;
  107769. /**
  107770. * Creates a new engine
  107771. * @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
  107772. * @param antialias defines enable antialiasing (default: false)
  107773. * @param options defines further options to be sent to the getContext() function
  107774. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  107775. */
  107776. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  107777. private _rebuildInternalTextures;
  107778. private _rebuildEffects;
  107779. /**
  107780. * Gets a boolean indicating if all created effects are ready
  107781. * @returns true if all effects are ready
  107782. */
  107783. areAllEffectsReady(): boolean;
  107784. protected _rebuildBuffers(): void;
  107785. protected _initGLContext(): void;
  107786. /**
  107787. * Gets version of the current webGL context
  107788. */
  107789. get webGLVersion(): number;
  107790. /**
  107791. * Gets a string idenfifying the name of the class
  107792. * @returns "Engine" string
  107793. */
  107794. getClassName(): string;
  107795. /**
  107796. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  107797. */
  107798. get isStencilEnable(): boolean;
  107799. /** @hidden */
  107800. _prepareWorkingCanvas(): void;
  107801. /**
  107802. * Reset the texture cache to empty state
  107803. */
  107804. resetTextureCache(): void;
  107805. /**
  107806. * Gets an object containing information about the current webGL context
  107807. * @returns an object containing the vender, the renderer and the version of the current webGL context
  107808. */
  107809. getGlInfo(): {
  107810. vendor: string;
  107811. renderer: string;
  107812. version: string;
  107813. };
  107814. /**
  107815. * Defines the hardware scaling level.
  107816. * By default the hardware scaling level is computed from the window device ratio.
  107817. * 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.
  107818. * @param level defines the level to use
  107819. */
  107820. setHardwareScalingLevel(level: number): void;
  107821. /**
  107822. * Gets the current hardware scaling level.
  107823. * By default the hardware scaling level is computed from the window device ratio.
  107824. * 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.
  107825. * @returns a number indicating the current hardware scaling level
  107826. */
  107827. getHardwareScalingLevel(): number;
  107828. /**
  107829. * Gets the list of loaded textures
  107830. * @returns an array containing all loaded textures
  107831. */
  107832. getLoadedTexturesCache(): InternalTexture[];
  107833. /**
  107834. * Gets the object containing all engine capabilities
  107835. * @returns the EngineCapabilities object
  107836. */
  107837. getCaps(): EngineCapabilities;
  107838. /**
  107839. * stop executing a render loop function and remove it from the execution array
  107840. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  107841. */
  107842. stopRenderLoop(renderFunction?: () => void): void;
  107843. /** @hidden */
  107844. _renderLoop(): void;
  107845. /**
  107846. * Gets the HTML canvas attached with the current webGL context
  107847. * @returns a HTML canvas
  107848. */
  107849. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  107850. /**
  107851. * Gets host window
  107852. * @returns the host window object
  107853. */
  107854. getHostWindow(): Nullable<Window>;
  107855. /**
  107856. * Gets the current render width
  107857. * @param useScreen defines if screen size must be used (or the current render target if any)
  107858. * @returns a number defining the current render width
  107859. */
  107860. getRenderWidth(useScreen?: boolean): number;
  107861. /**
  107862. * Gets the current render height
  107863. * @param useScreen defines if screen size must be used (or the current render target if any)
  107864. * @returns a number defining the current render height
  107865. */
  107866. getRenderHeight(useScreen?: boolean): number;
  107867. /**
  107868. * Can be used to override the current requestAnimationFrame requester.
  107869. * @hidden
  107870. */
  107871. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  107872. /**
  107873. * Register and execute a render loop. The engine can have more than one render function
  107874. * @param renderFunction defines the function to continuously execute
  107875. */
  107876. runRenderLoop(renderFunction: () => void): void;
  107877. /**
  107878. * Clear the current render buffer or the current render target (if any is set up)
  107879. * @param color defines the color to use
  107880. * @param backBuffer defines if the back buffer must be cleared
  107881. * @param depth defines if the depth buffer must be cleared
  107882. * @param stencil defines if the stencil buffer must be cleared
  107883. */
  107884. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  107885. private _viewportCached;
  107886. /** @hidden */
  107887. _viewport(x: number, y: number, width: number, height: number): void;
  107888. /**
  107889. * Set the WebGL's viewport
  107890. * @param viewport defines the viewport element to be used
  107891. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  107892. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  107893. */
  107894. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  107895. /**
  107896. * Begin a new frame
  107897. */
  107898. beginFrame(): void;
  107899. /**
  107900. * Enf the current frame
  107901. */
  107902. endFrame(): void;
  107903. /**
  107904. * Resize the view according to the canvas' size
  107905. */
  107906. resize(): void;
  107907. /**
  107908. * Force a specific size of the canvas
  107909. * @param width defines the new canvas' width
  107910. * @param height defines the new canvas' height
  107911. */
  107912. setSize(width: number, height: number): void;
  107913. /**
  107914. * Binds the frame buffer to the specified texture.
  107915. * @param texture The texture to render to or null for the default canvas
  107916. * @param faceIndex The face of the texture to render to in case of cube texture
  107917. * @param requiredWidth The width of the target to render to
  107918. * @param requiredHeight The height of the target to render to
  107919. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  107920. * @param lodLevel defines the lod level to bind to the frame buffer
  107921. * @param layer defines the 2d array index to bind to frame buffer to
  107922. */
  107923. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  107924. /** @hidden */
  107925. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  107926. /**
  107927. * Unbind the current render target texture from the webGL context
  107928. * @param texture defines the render target texture to unbind
  107929. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  107930. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  107931. */
  107932. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  107933. /**
  107934. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  107935. */
  107936. flushFramebuffer(): void;
  107937. /**
  107938. * Unbind the current render target and bind the default framebuffer
  107939. */
  107940. restoreDefaultFramebuffer(): void;
  107941. /** @hidden */
  107942. protected _resetVertexBufferBinding(): void;
  107943. /**
  107944. * Creates a vertex buffer
  107945. * @param data the data for the vertex buffer
  107946. * @returns the new WebGL static buffer
  107947. */
  107948. createVertexBuffer(data: DataArray): DataBuffer;
  107949. private _createVertexBuffer;
  107950. /**
  107951. * Creates a dynamic vertex buffer
  107952. * @param data the data for the dynamic vertex buffer
  107953. * @returns the new WebGL dynamic buffer
  107954. */
  107955. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  107956. protected _resetIndexBufferBinding(): void;
  107957. /**
  107958. * Creates a new index buffer
  107959. * @param indices defines the content of the index buffer
  107960. * @param updatable defines if the index buffer must be updatable
  107961. * @returns a new webGL buffer
  107962. */
  107963. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  107964. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  107965. /**
  107966. * Bind a webGL buffer to the webGL context
  107967. * @param buffer defines the buffer to bind
  107968. */
  107969. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  107970. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  107971. private bindBuffer;
  107972. /**
  107973. * update the bound buffer with the given data
  107974. * @param data defines the data to update
  107975. */
  107976. updateArrayBuffer(data: Float32Array): void;
  107977. private _vertexAttribPointer;
  107978. /** @hidden */
  107979. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  107980. private _bindVertexBuffersAttributes;
  107981. /**
  107982. * Records a vertex array object
  107983. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  107984. * @param vertexBuffers defines the list of vertex buffers to store
  107985. * @param indexBuffer defines the index buffer to store
  107986. * @param effect defines the effect to store
  107987. * @returns the new vertex array object
  107988. */
  107989. recordVertexArrayObject(vertexBuffers: {
  107990. [key: string]: VertexBuffer;
  107991. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  107992. /**
  107993. * Bind a specific vertex array object
  107994. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  107995. * @param vertexArrayObject defines the vertex array object to bind
  107996. * @param indexBuffer defines the index buffer to bind
  107997. */
  107998. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  107999. /**
  108000. * Bind webGl buffers directly to the webGL context
  108001. * @param vertexBuffer defines the vertex buffer to bind
  108002. * @param indexBuffer defines the index buffer to bind
  108003. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  108004. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  108005. * @param effect defines the effect associated with the vertex buffer
  108006. */
  108007. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  108008. private _unbindVertexArrayObject;
  108009. /**
  108010. * Bind a list of vertex buffers to the webGL context
  108011. * @param vertexBuffers defines the list of vertex buffers to bind
  108012. * @param indexBuffer defines the index buffer to bind
  108013. * @param effect defines the effect associated with the vertex buffers
  108014. */
  108015. bindBuffers(vertexBuffers: {
  108016. [key: string]: Nullable<VertexBuffer>;
  108017. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  108018. /**
  108019. * Unbind all instance attributes
  108020. */
  108021. unbindInstanceAttributes(): void;
  108022. /**
  108023. * Release and free the memory of a vertex array object
  108024. * @param vao defines the vertex array object to delete
  108025. */
  108026. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  108027. /** @hidden */
  108028. _releaseBuffer(buffer: DataBuffer): boolean;
  108029. protected _deleteBuffer(buffer: DataBuffer): void;
  108030. /**
  108031. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  108032. * @param instancesBuffer defines the webGL buffer to update and bind
  108033. * @param data defines the data to store in the buffer
  108034. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  108035. */
  108036. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  108037. /**
  108038. * Bind the content of a webGL buffer used with instantiation
  108039. * @param instancesBuffer defines the webGL buffer to bind
  108040. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  108041. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  108042. */
  108043. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  108044. /**
  108045. * Disable the instance attribute corresponding to the name in parameter
  108046. * @param name defines the name of the attribute to disable
  108047. */
  108048. disableInstanceAttributeByName(name: string): void;
  108049. /**
  108050. * Disable the instance attribute corresponding to the location in parameter
  108051. * @param attributeLocation defines the attribute location of the attribute to disable
  108052. */
  108053. disableInstanceAttribute(attributeLocation: number): void;
  108054. /**
  108055. * Disable the attribute corresponding to the location in parameter
  108056. * @param attributeLocation defines the attribute location of the attribute to disable
  108057. */
  108058. disableAttributeByIndex(attributeLocation: number): void;
  108059. /**
  108060. * Send a draw order
  108061. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  108062. * @param indexStart defines the starting index
  108063. * @param indexCount defines the number of index to draw
  108064. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  108065. */
  108066. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  108067. /**
  108068. * Draw a list of points
  108069. * @param verticesStart defines the index of first vertex to draw
  108070. * @param verticesCount defines the count of vertices to draw
  108071. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  108072. */
  108073. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  108074. /**
  108075. * Draw a list of unindexed primitives
  108076. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  108077. * @param verticesStart defines the index of first vertex to draw
  108078. * @param verticesCount defines the count of vertices to draw
  108079. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  108080. */
  108081. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  108082. /**
  108083. * Draw a list of indexed primitives
  108084. * @param fillMode defines the primitive to use
  108085. * @param indexStart defines the starting index
  108086. * @param indexCount defines the number of index to draw
  108087. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  108088. */
  108089. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  108090. /**
  108091. * Draw a list of unindexed primitives
  108092. * @param fillMode defines the primitive to use
  108093. * @param verticesStart defines the index of first vertex to draw
  108094. * @param verticesCount defines the count of vertices to draw
  108095. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  108096. */
  108097. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  108098. private _drawMode;
  108099. /** @hidden */
  108100. protected _reportDrawCall(): void;
  108101. /** @hidden */
  108102. _releaseEffect(effect: Effect): void;
  108103. /** @hidden */
  108104. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  108105. /**
  108106. * Create a new effect (used to store vertex/fragment shaders)
  108107. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  108108. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  108109. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  108110. * @param samplers defines an array of string used to represent textures
  108111. * @param defines defines the string containing the defines to use to compile the shaders
  108112. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  108113. * @param onCompiled defines a function to call when the effect creation is successful
  108114. * @param onError defines a function to call when the effect creation has failed
  108115. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  108116. * @returns the new Effect
  108117. */
  108118. 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;
  108119. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  108120. private _compileShader;
  108121. private _compileRawShader;
  108122. /** @hidden */
  108123. _getShaderSource(shader: WebGLShader): Nullable<string>;
  108124. /**
  108125. * Directly creates a webGL program
  108126. * @param pipelineContext defines the pipeline context to attach to
  108127. * @param vertexCode defines the vertex shader code to use
  108128. * @param fragmentCode defines the fragment shader code to use
  108129. * @param context defines the webGL context to use (if not set, the current one will be used)
  108130. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  108131. * @returns the new webGL program
  108132. */
  108133. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  108134. /**
  108135. * Creates a webGL program
  108136. * @param pipelineContext defines the pipeline context to attach to
  108137. * @param vertexCode defines the vertex shader code to use
  108138. * @param fragmentCode defines the fragment shader code to use
  108139. * @param defines defines the string containing the defines to use to compile the shaders
  108140. * @param context defines the webGL context to use (if not set, the current one will be used)
  108141. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  108142. * @returns the new webGL program
  108143. */
  108144. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  108145. /**
  108146. * Creates a new pipeline context
  108147. * @returns the new pipeline
  108148. */
  108149. createPipelineContext(): IPipelineContext;
  108150. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  108151. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  108152. /** @hidden */
  108153. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  108154. /** @hidden */
  108155. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  108156. /** @hidden */
  108157. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  108158. /**
  108159. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  108160. * @param pipelineContext defines the pipeline context to use
  108161. * @param uniformsNames defines the list of uniform names
  108162. * @returns an array of webGL uniform locations
  108163. */
  108164. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  108165. /**
  108166. * Gets the lsit of active attributes for a given webGL program
  108167. * @param pipelineContext defines the pipeline context to use
  108168. * @param attributesNames defines the list of attribute names to get
  108169. * @returns an array of indices indicating the offset of each attribute
  108170. */
  108171. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  108172. /**
  108173. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  108174. * @param effect defines the effect to activate
  108175. */
  108176. enableEffect(effect: Nullable<Effect>): void;
  108177. /**
  108178. * Set the value of an uniform to a number (int)
  108179. * @param uniform defines the webGL uniform location where to store the value
  108180. * @param value defines the int number to store
  108181. */
  108182. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  108183. /**
  108184. * Set the value of an uniform to an array of int32
  108185. * @param uniform defines the webGL uniform location where to store the value
  108186. * @param array defines the array of int32 to store
  108187. */
  108188. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  108189. /**
  108190. * Set the value of an uniform to an array of int32 (stored as vec2)
  108191. * @param uniform defines the webGL uniform location where to store the value
  108192. * @param array defines the array of int32 to store
  108193. */
  108194. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  108195. /**
  108196. * Set the value of an uniform to an array of int32 (stored as vec3)
  108197. * @param uniform defines the webGL uniform location where to store the value
  108198. * @param array defines the array of int32 to store
  108199. */
  108200. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  108201. /**
  108202. * Set the value of an uniform to an array of int32 (stored as vec4)
  108203. * @param uniform defines the webGL uniform location where to store the value
  108204. * @param array defines the array of int32 to store
  108205. */
  108206. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  108207. /**
  108208. * Set the value of an uniform to an array of number
  108209. * @param uniform defines the webGL uniform location where to store the value
  108210. * @param array defines the array of number to store
  108211. */
  108212. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  108213. /**
  108214. * Set the value of an uniform to an array of number (stored as vec2)
  108215. * @param uniform defines the webGL uniform location where to store the value
  108216. * @param array defines the array of number to store
  108217. */
  108218. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  108219. /**
  108220. * Set the value of an uniform to an array of number (stored as vec3)
  108221. * @param uniform defines the webGL uniform location where to store the value
  108222. * @param array defines the array of number to store
  108223. */
  108224. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  108225. /**
  108226. * Set the value of an uniform to an array of number (stored as vec4)
  108227. * @param uniform defines the webGL uniform location where to store the value
  108228. * @param array defines the array of number to store
  108229. */
  108230. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  108231. /**
  108232. * Set the value of an uniform to an array of float32 (stored as matrices)
  108233. * @param uniform defines the webGL uniform location where to store the value
  108234. * @param matrices defines the array of float32 to store
  108235. */
  108236. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  108237. /**
  108238. * Set the value of an uniform to a matrix (3x3)
  108239. * @param uniform defines the webGL uniform location where to store the value
  108240. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  108241. */
  108242. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  108243. /**
  108244. * Set the value of an uniform to a matrix (2x2)
  108245. * @param uniform defines the webGL uniform location where to store the value
  108246. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  108247. */
  108248. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  108249. /**
  108250. * Set the value of an uniform to a number (float)
  108251. * @param uniform defines the webGL uniform location where to store the value
  108252. * @param value defines the float number to store
  108253. */
  108254. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  108255. /**
  108256. * Set the value of an uniform to a vec2
  108257. * @param uniform defines the webGL uniform location where to store the value
  108258. * @param x defines the 1st component of the value
  108259. * @param y defines the 2nd component of the value
  108260. */
  108261. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  108262. /**
  108263. * Set the value of an uniform to a vec3
  108264. * @param uniform defines the webGL uniform location where to store the value
  108265. * @param x defines the 1st component of the value
  108266. * @param y defines the 2nd component of the value
  108267. * @param z defines the 3rd component of the value
  108268. */
  108269. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  108270. /**
  108271. * Set the value of an uniform to a vec4
  108272. * @param uniform defines the webGL uniform location where to store the value
  108273. * @param x defines the 1st component of the value
  108274. * @param y defines the 2nd component of the value
  108275. * @param z defines the 3rd component of the value
  108276. * @param w defines the 4th component of the value
  108277. */
  108278. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  108279. /**
  108280. * Apply all cached states (depth, culling, stencil and alpha)
  108281. */
  108282. applyStates(): void;
  108283. /**
  108284. * Enable or disable color writing
  108285. * @param enable defines the state to set
  108286. */
  108287. setColorWrite(enable: boolean): void;
  108288. /**
  108289. * Gets a boolean indicating if color writing is enabled
  108290. * @returns the current color writing state
  108291. */
  108292. getColorWrite(): boolean;
  108293. /**
  108294. * Gets the depth culling state manager
  108295. */
  108296. get depthCullingState(): DepthCullingState;
  108297. /**
  108298. * Gets the alpha state manager
  108299. */
  108300. get alphaState(): AlphaState;
  108301. /**
  108302. * Gets the stencil state manager
  108303. */
  108304. get stencilState(): StencilState;
  108305. /**
  108306. * Clears the list of texture accessible through engine.
  108307. * This can help preventing texture load conflict due to name collision.
  108308. */
  108309. clearInternalTexturesCache(): void;
  108310. /**
  108311. * Force the entire cache to be cleared
  108312. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  108313. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  108314. */
  108315. wipeCaches(bruteForce?: boolean): void;
  108316. /** @hidden */
  108317. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  108318. min: number;
  108319. mag: number;
  108320. };
  108321. /** @hidden */
  108322. _createTexture(): WebGLTexture;
  108323. /**
  108324. * Usually called from Texture.ts.
  108325. * Passed information to create a WebGLTexture
  108326. * @param url defines a value which contains one of the following:
  108327. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  108328. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  108329. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  108330. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  108331. * @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)
  108332. * @param scene needed for loading to the correct scene
  108333. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  108334. * @param onLoad optional callback to be called upon successful completion
  108335. * @param onError optional callback to be called upon failure
  108336. * @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
  108337. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  108338. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  108339. * @param forcedExtension defines the extension to use to pick the right loader
  108340. * @param mimeType defines an optional mime type
  108341. * @returns a InternalTexture for assignment back into BABYLON.Texture
  108342. */
  108343. 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;
  108344. /**
  108345. * Loads an image as an HTMLImageElement.
  108346. * @param input url string, ArrayBuffer, or Blob to load
  108347. * @param onLoad callback called when the image successfully loads
  108348. * @param onError callback called when the image fails to load
  108349. * @param offlineProvider offline provider for caching
  108350. * @param mimeType optional mime type
  108351. * @returns the HTMLImageElement of the loaded image
  108352. * @hidden
  108353. */
  108354. 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>;
  108355. /**
  108356. * @hidden
  108357. */
  108358. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  108359. private _unpackFlipYCached;
  108360. /**
  108361. * In case you are sharing the context with other applications, it might
  108362. * be interested to not cache the unpack flip y state to ensure a consistent
  108363. * value would be set.
  108364. */
  108365. enableUnpackFlipYCached: boolean;
  108366. /** @hidden */
  108367. _unpackFlipY(value: boolean): void;
  108368. /** @hidden */
  108369. _getUnpackAlignement(): number;
  108370. private _getTextureTarget;
  108371. /**
  108372. * Update the sampling mode of a given texture
  108373. * @param samplingMode defines the required sampling mode
  108374. * @param texture defines the texture to update
  108375. * @param generateMipMaps defines whether to generate mipmaps for the texture
  108376. */
  108377. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  108378. /**
  108379. * Update the sampling mode of a given texture
  108380. * @param texture defines the texture to update
  108381. * @param wrapU defines the texture wrap mode of the u coordinates
  108382. * @param wrapV defines the texture wrap mode of the v coordinates
  108383. * @param wrapR defines the texture wrap mode of the r coordinates
  108384. */
  108385. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  108386. /** @hidden */
  108387. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  108388. width: number;
  108389. height: number;
  108390. layers?: number;
  108391. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  108392. /** @hidden */
  108393. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  108394. /** @hidden */
  108395. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  108396. /**
  108397. * Update a portion of an internal texture
  108398. * @param texture defines the texture to update
  108399. * @param imageData defines the data to store into the texture
  108400. * @param xOffset defines the x coordinates of the update rectangle
  108401. * @param yOffset defines the y coordinates of the update rectangle
  108402. * @param width defines the width of the update rectangle
  108403. * @param height defines the height of the update rectangle
  108404. * @param faceIndex defines the face index if texture is a cube (0 by default)
  108405. * @param lod defines the lod level to update (0 by default)
  108406. */
  108407. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  108408. /** @hidden */
  108409. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  108410. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  108411. private _prepareWebGLTexture;
  108412. /** @hidden */
  108413. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  108414. private _getDepthStencilBuffer;
  108415. /** @hidden */
  108416. _releaseFramebufferObjects(texture: InternalTexture): void;
  108417. /** @hidden */
  108418. _releaseTexture(texture: InternalTexture): void;
  108419. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  108420. protected _setProgram(program: WebGLProgram): void;
  108421. protected _boundUniforms: {
  108422. [key: number]: WebGLUniformLocation;
  108423. };
  108424. /**
  108425. * Binds an effect to the webGL context
  108426. * @param effect defines the effect to bind
  108427. */
  108428. bindSamplers(effect: Effect): void;
  108429. private _activateCurrentTexture;
  108430. /** @hidden */
  108431. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  108432. /** @hidden */
  108433. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  108434. /**
  108435. * Unbind all textures from the webGL context
  108436. */
  108437. unbindAllTextures(): void;
  108438. /**
  108439. * Sets a texture to the according uniform.
  108440. * @param channel The texture channel
  108441. * @param uniform The uniform to set
  108442. * @param texture The texture to apply
  108443. */
  108444. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  108445. private _bindSamplerUniformToChannel;
  108446. private _getTextureWrapMode;
  108447. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  108448. /**
  108449. * Sets an array of texture to the webGL context
  108450. * @param channel defines the channel where the texture array must be set
  108451. * @param uniform defines the associated uniform location
  108452. * @param textures defines the array of textures to bind
  108453. */
  108454. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  108455. /** @hidden */
  108456. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  108457. private _setTextureParameterFloat;
  108458. private _setTextureParameterInteger;
  108459. /**
  108460. * Unbind all vertex attributes from the webGL context
  108461. */
  108462. unbindAllAttributes(): void;
  108463. /**
  108464. * 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
  108465. */
  108466. releaseEffects(): void;
  108467. /**
  108468. * Dispose and release all associated resources
  108469. */
  108470. dispose(): void;
  108471. /**
  108472. * Attach a new callback raised when context lost event is fired
  108473. * @param callback defines the callback to call
  108474. */
  108475. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  108476. /**
  108477. * Attach a new callback raised when context restored event is fired
  108478. * @param callback defines the callback to call
  108479. */
  108480. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  108481. /**
  108482. * Get the current error code of the webGL context
  108483. * @returns the error code
  108484. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  108485. */
  108486. getError(): number;
  108487. private _canRenderToFloatFramebuffer;
  108488. private _canRenderToHalfFloatFramebuffer;
  108489. private _canRenderToFramebuffer;
  108490. /** @hidden */
  108491. _getWebGLTextureType(type: number): number;
  108492. /** @hidden */
  108493. _getInternalFormat(format: number): number;
  108494. /** @hidden */
  108495. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  108496. /** @hidden */
  108497. _getRGBAMultiSampleBufferFormat(type: number): number;
  108498. /** @hidden */
  108499. _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;
  108500. /**
  108501. * Loads a file from a url
  108502. * @param url url to load
  108503. * @param onSuccess callback called when the file successfully loads
  108504. * @param onProgress callback called while file is loading (if the server supports this mode)
  108505. * @param offlineProvider defines the offline provider for caching
  108506. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  108507. * @param onError callback called when the file fails to load
  108508. * @returns a file request object
  108509. * @hidden
  108510. */
  108511. 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;
  108512. /**
  108513. * Reads pixels from the current frame buffer. Please note that this function can be slow
  108514. * @param x defines the x coordinate of the rectangle where pixels must be read
  108515. * @param y defines the y coordinate of the rectangle where pixels must be read
  108516. * @param width defines the width of the rectangle where pixels must be read
  108517. * @param height defines the height of the rectangle where pixels must be read
  108518. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  108519. * @returns a Uint8Array containing RGBA colors
  108520. */
  108521. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  108522. private static _isSupported;
  108523. /**
  108524. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  108525. * @returns true if the engine can be created
  108526. * @ignorenaming
  108527. */
  108528. static isSupported(): boolean;
  108529. /**
  108530. * Find the next highest power of two.
  108531. * @param x Number to start search from.
  108532. * @return Next highest power of two.
  108533. */
  108534. static CeilingPOT(x: number): number;
  108535. /**
  108536. * Find the next lowest power of two.
  108537. * @param x Number to start search from.
  108538. * @return Next lowest power of two.
  108539. */
  108540. static FloorPOT(x: number): number;
  108541. /**
  108542. * Find the nearest power of two.
  108543. * @param x Number to start search from.
  108544. * @return Next nearest power of two.
  108545. */
  108546. static NearestPOT(x: number): number;
  108547. /**
  108548. * Get the closest exponent of two
  108549. * @param value defines the value to approximate
  108550. * @param max defines the maximum value to return
  108551. * @param mode defines how to define the closest value
  108552. * @returns closest exponent of two of the given value
  108553. */
  108554. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  108555. /**
  108556. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  108557. * @param func - the function to be called
  108558. * @param requester - the object that will request the next frame. Falls back to window.
  108559. * @returns frame number
  108560. */
  108561. static QueueNewFrame(func: () => void, requester?: any): number;
  108562. /**
  108563. * Gets host document
  108564. * @returns the host document object
  108565. */
  108566. getHostDocument(): Nullable<Document>;
  108567. }
  108568. }
  108569. declare module BABYLON {
  108570. /**
  108571. * Class representing spherical harmonics coefficients to the 3rd degree
  108572. */
  108573. export class SphericalHarmonics {
  108574. /**
  108575. * Defines whether or not the harmonics have been prescaled for rendering.
  108576. */
  108577. preScaled: boolean;
  108578. /**
  108579. * The l0,0 coefficients of the spherical harmonics
  108580. */
  108581. l00: Vector3;
  108582. /**
  108583. * The l1,-1 coefficients of the spherical harmonics
  108584. */
  108585. l1_1: Vector3;
  108586. /**
  108587. * The l1,0 coefficients of the spherical harmonics
  108588. */
  108589. l10: Vector3;
  108590. /**
  108591. * The l1,1 coefficients of the spherical harmonics
  108592. */
  108593. l11: Vector3;
  108594. /**
  108595. * The l2,-2 coefficients of the spherical harmonics
  108596. */
  108597. l2_2: Vector3;
  108598. /**
  108599. * The l2,-1 coefficients of the spherical harmonics
  108600. */
  108601. l2_1: Vector3;
  108602. /**
  108603. * The l2,0 coefficients of the spherical harmonics
  108604. */
  108605. l20: Vector3;
  108606. /**
  108607. * The l2,1 coefficients of the spherical harmonics
  108608. */
  108609. l21: Vector3;
  108610. /**
  108611. * The l2,2 coefficients of the spherical harmonics
  108612. */
  108613. l22: Vector3;
  108614. /**
  108615. * Adds a light to the spherical harmonics
  108616. * @param direction the direction of the light
  108617. * @param color the color of the light
  108618. * @param deltaSolidAngle the delta solid angle of the light
  108619. */
  108620. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  108621. /**
  108622. * Scales the spherical harmonics by the given amount
  108623. * @param scale the amount to scale
  108624. */
  108625. scaleInPlace(scale: number): void;
  108626. /**
  108627. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  108628. *
  108629. * ```
  108630. * E_lm = A_l * L_lm
  108631. * ```
  108632. *
  108633. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  108634. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  108635. * the scaling factors are given in equation 9.
  108636. */
  108637. convertIncidentRadianceToIrradiance(): void;
  108638. /**
  108639. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  108640. *
  108641. * ```
  108642. * L = (1/pi) * E * rho
  108643. * ```
  108644. *
  108645. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  108646. */
  108647. convertIrradianceToLambertianRadiance(): void;
  108648. /**
  108649. * Integrates the reconstruction coefficients directly in to the SH preventing further
  108650. * required operations at run time.
  108651. *
  108652. * This is simply done by scaling back the SH with Ylm constants parameter.
  108653. * The trigonometric part being applied by the shader at run time.
  108654. */
  108655. preScaleForRendering(): void;
  108656. /**
  108657. * Constructs a spherical harmonics from an array.
  108658. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  108659. * @returns the spherical harmonics
  108660. */
  108661. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  108662. /**
  108663. * Gets the spherical harmonics from polynomial
  108664. * @param polynomial the spherical polynomial
  108665. * @returns the spherical harmonics
  108666. */
  108667. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  108668. }
  108669. /**
  108670. * Class representing spherical polynomial coefficients to the 3rd degree
  108671. */
  108672. export class SphericalPolynomial {
  108673. private _harmonics;
  108674. /**
  108675. * The spherical harmonics used to create the polynomials.
  108676. */
  108677. get preScaledHarmonics(): SphericalHarmonics;
  108678. /**
  108679. * The x coefficients of the spherical polynomial
  108680. */
  108681. x: Vector3;
  108682. /**
  108683. * The y coefficients of the spherical polynomial
  108684. */
  108685. y: Vector3;
  108686. /**
  108687. * The z coefficients of the spherical polynomial
  108688. */
  108689. z: Vector3;
  108690. /**
  108691. * The xx coefficients of the spherical polynomial
  108692. */
  108693. xx: Vector3;
  108694. /**
  108695. * The yy coefficients of the spherical polynomial
  108696. */
  108697. yy: Vector3;
  108698. /**
  108699. * The zz coefficients of the spherical polynomial
  108700. */
  108701. zz: Vector3;
  108702. /**
  108703. * The xy coefficients of the spherical polynomial
  108704. */
  108705. xy: Vector3;
  108706. /**
  108707. * The yz coefficients of the spherical polynomial
  108708. */
  108709. yz: Vector3;
  108710. /**
  108711. * The zx coefficients of the spherical polynomial
  108712. */
  108713. zx: Vector3;
  108714. /**
  108715. * Adds an ambient color to the spherical polynomial
  108716. * @param color the color to add
  108717. */
  108718. addAmbient(color: Color3): void;
  108719. /**
  108720. * Scales the spherical polynomial by the given amount
  108721. * @param scale the amount to scale
  108722. */
  108723. scaleInPlace(scale: number): void;
  108724. /**
  108725. * Gets the spherical polynomial from harmonics
  108726. * @param harmonics the spherical harmonics
  108727. * @returns the spherical polynomial
  108728. */
  108729. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  108730. /**
  108731. * Constructs a spherical polynomial from an array.
  108732. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  108733. * @returns the spherical polynomial
  108734. */
  108735. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  108736. }
  108737. }
  108738. declare module BABYLON {
  108739. /**
  108740. * Defines the source of the internal texture
  108741. */
  108742. export enum InternalTextureSource {
  108743. /**
  108744. * The source of the texture data is unknown
  108745. */
  108746. Unknown = 0,
  108747. /**
  108748. * Texture data comes from an URL
  108749. */
  108750. Url = 1,
  108751. /**
  108752. * Texture data is only used for temporary storage
  108753. */
  108754. Temp = 2,
  108755. /**
  108756. * Texture data comes from raw data (ArrayBuffer)
  108757. */
  108758. Raw = 3,
  108759. /**
  108760. * Texture content is dynamic (video or dynamic texture)
  108761. */
  108762. Dynamic = 4,
  108763. /**
  108764. * Texture content is generated by rendering to it
  108765. */
  108766. RenderTarget = 5,
  108767. /**
  108768. * Texture content is part of a multi render target process
  108769. */
  108770. MultiRenderTarget = 6,
  108771. /**
  108772. * Texture data comes from a cube data file
  108773. */
  108774. Cube = 7,
  108775. /**
  108776. * Texture data comes from a raw cube data
  108777. */
  108778. CubeRaw = 8,
  108779. /**
  108780. * Texture data come from a prefiltered cube data file
  108781. */
  108782. CubePrefiltered = 9,
  108783. /**
  108784. * Texture content is raw 3D data
  108785. */
  108786. Raw3D = 10,
  108787. /**
  108788. * Texture content is raw 2D array data
  108789. */
  108790. Raw2DArray = 11,
  108791. /**
  108792. * Texture content is a depth texture
  108793. */
  108794. Depth = 12,
  108795. /**
  108796. * Texture data comes from a raw cube data encoded with RGBD
  108797. */
  108798. CubeRawRGBD = 13
  108799. }
  108800. /**
  108801. * Class used to store data associated with WebGL texture data for the engine
  108802. * This class should not be used directly
  108803. */
  108804. export class InternalTexture {
  108805. /** @hidden */
  108806. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  108807. /**
  108808. * Defines if the texture is ready
  108809. */
  108810. isReady: boolean;
  108811. /**
  108812. * Defines if the texture is a cube texture
  108813. */
  108814. isCube: boolean;
  108815. /**
  108816. * Defines if the texture contains 3D data
  108817. */
  108818. is3D: boolean;
  108819. /**
  108820. * Defines if the texture contains 2D array data
  108821. */
  108822. is2DArray: boolean;
  108823. /**
  108824. * Defines if the texture contains multiview data
  108825. */
  108826. isMultiview: boolean;
  108827. /**
  108828. * Gets the URL used to load this texture
  108829. */
  108830. url: string;
  108831. /**
  108832. * Gets the sampling mode of the texture
  108833. */
  108834. samplingMode: number;
  108835. /**
  108836. * Gets a boolean indicating if the texture needs mipmaps generation
  108837. */
  108838. generateMipMaps: boolean;
  108839. /**
  108840. * Gets the number of samples used by the texture (WebGL2+ only)
  108841. */
  108842. samples: number;
  108843. /**
  108844. * Gets the type of the texture (int, float...)
  108845. */
  108846. type: number;
  108847. /**
  108848. * Gets the format of the texture (RGB, RGBA...)
  108849. */
  108850. format: number;
  108851. /**
  108852. * Observable called when the texture is loaded
  108853. */
  108854. onLoadedObservable: Observable<InternalTexture>;
  108855. /**
  108856. * Gets the width of the texture
  108857. */
  108858. width: number;
  108859. /**
  108860. * Gets the height of the texture
  108861. */
  108862. height: number;
  108863. /**
  108864. * Gets the depth of the texture
  108865. */
  108866. depth: number;
  108867. /**
  108868. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  108869. */
  108870. baseWidth: number;
  108871. /**
  108872. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  108873. */
  108874. baseHeight: number;
  108875. /**
  108876. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  108877. */
  108878. baseDepth: number;
  108879. /**
  108880. * Gets a boolean indicating if the texture is inverted on Y axis
  108881. */
  108882. invertY: boolean;
  108883. /** @hidden */
  108884. _invertVScale: boolean;
  108885. /** @hidden */
  108886. _associatedChannel: number;
  108887. /** @hidden */
  108888. _source: InternalTextureSource;
  108889. /** @hidden */
  108890. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  108891. /** @hidden */
  108892. _bufferView: Nullable<ArrayBufferView>;
  108893. /** @hidden */
  108894. _bufferViewArray: Nullable<ArrayBufferView[]>;
  108895. /** @hidden */
  108896. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  108897. /** @hidden */
  108898. _size: number;
  108899. /** @hidden */
  108900. _extension: string;
  108901. /** @hidden */
  108902. _files: Nullable<string[]>;
  108903. /** @hidden */
  108904. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  108905. /** @hidden */
  108906. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  108907. /** @hidden */
  108908. _framebuffer: Nullable<WebGLFramebuffer>;
  108909. /** @hidden */
  108910. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  108911. /** @hidden */
  108912. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  108913. /** @hidden */
  108914. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  108915. /** @hidden */
  108916. _attachments: Nullable<number[]>;
  108917. /** @hidden */
  108918. _cachedCoordinatesMode: Nullable<number>;
  108919. /** @hidden */
  108920. _cachedWrapU: Nullable<number>;
  108921. /** @hidden */
  108922. _cachedWrapV: Nullable<number>;
  108923. /** @hidden */
  108924. _cachedWrapR: Nullable<number>;
  108925. /** @hidden */
  108926. _cachedAnisotropicFilteringLevel: Nullable<number>;
  108927. /** @hidden */
  108928. _isDisabled: boolean;
  108929. /** @hidden */
  108930. _compression: Nullable<string>;
  108931. /** @hidden */
  108932. _generateStencilBuffer: boolean;
  108933. /** @hidden */
  108934. _generateDepthBuffer: boolean;
  108935. /** @hidden */
  108936. _comparisonFunction: number;
  108937. /** @hidden */
  108938. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  108939. /** @hidden */
  108940. _lodGenerationScale: number;
  108941. /** @hidden */
  108942. _lodGenerationOffset: number;
  108943. /** @hidden */
  108944. _depthStencilTexture: Nullable<InternalTexture>;
  108945. /** @hidden */
  108946. _colorTextureArray: Nullable<WebGLTexture>;
  108947. /** @hidden */
  108948. _depthStencilTextureArray: Nullable<WebGLTexture>;
  108949. /** @hidden */
  108950. _lodTextureHigh: Nullable<BaseTexture>;
  108951. /** @hidden */
  108952. _lodTextureMid: Nullable<BaseTexture>;
  108953. /** @hidden */
  108954. _lodTextureLow: Nullable<BaseTexture>;
  108955. /** @hidden */
  108956. _isRGBD: boolean;
  108957. /** @hidden */
  108958. _linearSpecularLOD: boolean;
  108959. /** @hidden */
  108960. _irradianceTexture: Nullable<BaseTexture>;
  108961. /** @hidden */
  108962. _webGLTexture: Nullable<WebGLTexture>;
  108963. /** @hidden */
  108964. _references: number;
  108965. private _engine;
  108966. /**
  108967. * Gets the Engine the texture belongs to.
  108968. * @returns The babylon engine
  108969. */
  108970. getEngine(): ThinEngine;
  108971. /**
  108972. * Gets the data source type of the texture
  108973. */
  108974. get source(): InternalTextureSource;
  108975. /**
  108976. * Creates a new InternalTexture
  108977. * @param engine defines the engine to use
  108978. * @param source defines the type of data that will be used
  108979. * @param delayAllocation if the texture allocation should be delayed (default: false)
  108980. */
  108981. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  108982. /**
  108983. * Increments the number of references (ie. the number of Texture that point to it)
  108984. */
  108985. incrementReferences(): void;
  108986. /**
  108987. * Change the size of the texture (not the size of the content)
  108988. * @param width defines the new width
  108989. * @param height defines the new height
  108990. * @param depth defines the new depth (1 by default)
  108991. */
  108992. updateSize(width: int, height: int, depth?: int): void;
  108993. /** @hidden */
  108994. _rebuild(): void;
  108995. /** @hidden */
  108996. _swapAndDie(target: InternalTexture): void;
  108997. /**
  108998. * Dispose the current allocated resources
  108999. */
  109000. dispose(): void;
  109001. }
  109002. }
  109003. declare module BABYLON {
  109004. /**
  109005. * Class used to work with sound analyzer using fast fourier transform (FFT)
  109006. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  109007. */
  109008. export class Analyser {
  109009. /**
  109010. * Gets or sets the smoothing
  109011. * @ignorenaming
  109012. */
  109013. SMOOTHING: number;
  109014. /**
  109015. * Gets or sets the FFT table size
  109016. * @ignorenaming
  109017. */
  109018. FFT_SIZE: number;
  109019. /**
  109020. * Gets or sets the bar graph amplitude
  109021. * @ignorenaming
  109022. */
  109023. BARGRAPHAMPLITUDE: number;
  109024. /**
  109025. * Gets or sets the position of the debug canvas
  109026. * @ignorenaming
  109027. */
  109028. DEBUGCANVASPOS: {
  109029. x: number;
  109030. y: number;
  109031. };
  109032. /**
  109033. * Gets or sets the debug canvas size
  109034. * @ignorenaming
  109035. */
  109036. DEBUGCANVASSIZE: {
  109037. width: number;
  109038. height: number;
  109039. };
  109040. private _byteFreqs;
  109041. private _byteTime;
  109042. private _floatFreqs;
  109043. private _webAudioAnalyser;
  109044. private _debugCanvas;
  109045. private _debugCanvasContext;
  109046. private _scene;
  109047. private _registerFunc;
  109048. private _audioEngine;
  109049. /**
  109050. * Creates a new analyser
  109051. * @param scene defines hosting scene
  109052. */
  109053. constructor(scene: Scene);
  109054. /**
  109055. * Get the number of data values you will have to play with for the visualization
  109056. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  109057. * @returns a number
  109058. */
  109059. getFrequencyBinCount(): number;
  109060. /**
  109061. * Gets the current frequency data as a byte array
  109062. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  109063. * @returns a Uint8Array
  109064. */
  109065. getByteFrequencyData(): Uint8Array;
  109066. /**
  109067. * Gets the current waveform as a byte array
  109068. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  109069. * @returns a Uint8Array
  109070. */
  109071. getByteTimeDomainData(): Uint8Array;
  109072. /**
  109073. * Gets the current frequency data as a float array
  109074. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  109075. * @returns a Float32Array
  109076. */
  109077. getFloatFrequencyData(): Float32Array;
  109078. /**
  109079. * Renders the debug canvas
  109080. */
  109081. drawDebugCanvas(): void;
  109082. /**
  109083. * Stops rendering the debug canvas and removes it
  109084. */
  109085. stopDebugCanvas(): void;
  109086. /**
  109087. * Connects two audio nodes
  109088. * @param inputAudioNode defines first node to connect
  109089. * @param outputAudioNode defines second node to connect
  109090. */
  109091. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  109092. /**
  109093. * Releases all associated resources
  109094. */
  109095. dispose(): void;
  109096. }
  109097. }
  109098. declare module BABYLON {
  109099. /**
  109100. * This represents an audio engine and it is responsible
  109101. * to play, synchronize and analyse sounds throughout the application.
  109102. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  109103. */
  109104. export interface IAudioEngine extends IDisposable {
  109105. /**
  109106. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  109107. */
  109108. readonly canUseWebAudio: boolean;
  109109. /**
  109110. * Gets the current AudioContext if available.
  109111. */
  109112. readonly audioContext: Nullable<AudioContext>;
  109113. /**
  109114. * The master gain node defines the global audio volume of your audio engine.
  109115. */
  109116. readonly masterGain: GainNode;
  109117. /**
  109118. * Gets whether or not mp3 are supported by your browser.
  109119. */
  109120. readonly isMP3supported: boolean;
  109121. /**
  109122. * Gets whether or not ogg are supported by your browser.
  109123. */
  109124. readonly isOGGsupported: boolean;
  109125. /**
  109126. * Defines if Babylon should emit a warning if WebAudio is not supported.
  109127. * @ignoreNaming
  109128. */
  109129. WarnedWebAudioUnsupported: boolean;
  109130. /**
  109131. * Defines if the audio engine relies on a custom unlocked button.
  109132. * In this case, the embedded button will not be displayed.
  109133. */
  109134. useCustomUnlockedButton: boolean;
  109135. /**
  109136. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  109137. */
  109138. readonly unlocked: boolean;
  109139. /**
  109140. * Event raised when audio has been unlocked on the browser.
  109141. */
  109142. onAudioUnlockedObservable: Observable<AudioEngine>;
  109143. /**
  109144. * Event raised when audio has been locked on the browser.
  109145. */
  109146. onAudioLockedObservable: Observable<AudioEngine>;
  109147. /**
  109148. * Flags the audio engine in Locked state.
  109149. * This happens due to new browser policies preventing audio to autoplay.
  109150. */
  109151. lock(): void;
  109152. /**
  109153. * Unlocks the audio engine once a user action has been done on the dom.
  109154. * This is helpful to resume play once browser policies have been satisfied.
  109155. */
  109156. unlock(): void;
  109157. /**
  109158. * Gets the global volume sets on the master gain.
  109159. * @returns the global volume if set or -1 otherwise
  109160. */
  109161. getGlobalVolume(): number;
  109162. /**
  109163. * Sets the global volume of your experience (sets on the master gain).
  109164. * @param newVolume Defines the new global volume of the application
  109165. */
  109166. setGlobalVolume(newVolume: number): void;
  109167. /**
  109168. * Connect the audio engine to an audio analyser allowing some amazing
  109169. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  109170. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  109171. * @param analyser The analyser to connect to the engine
  109172. */
  109173. connectToAnalyser(analyser: Analyser): void;
  109174. }
  109175. /**
  109176. * This represents the default audio engine used in babylon.
  109177. * It is responsible to play, synchronize and analyse sounds throughout the application.
  109178. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  109179. */
  109180. export class AudioEngine implements IAudioEngine {
  109181. private _audioContext;
  109182. private _audioContextInitialized;
  109183. private _muteButton;
  109184. private _hostElement;
  109185. /**
  109186. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  109187. */
  109188. canUseWebAudio: boolean;
  109189. /**
  109190. * The master gain node defines the global audio volume of your audio engine.
  109191. */
  109192. masterGain: GainNode;
  109193. /**
  109194. * Defines if Babylon should emit a warning if WebAudio is not supported.
  109195. * @ignoreNaming
  109196. */
  109197. WarnedWebAudioUnsupported: boolean;
  109198. /**
  109199. * Gets whether or not mp3 are supported by your browser.
  109200. */
  109201. isMP3supported: boolean;
  109202. /**
  109203. * Gets whether or not ogg are supported by your browser.
  109204. */
  109205. isOGGsupported: boolean;
  109206. /**
  109207. * Gets whether audio has been unlocked on the device.
  109208. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  109209. * a user interaction has happened.
  109210. */
  109211. unlocked: boolean;
  109212. /**
  109213. * Defines if the audio engine relies on a custom unlocked button.
  109214. * In this case, the embedded button will not be displayed.
  109215. */
  109216. useCustomUnlockedButton: boolean;
  109217. /**
  109218. * Event raised when audio has been unlocked on the browser.
  109219. */
  109220. onAudioUnlockedObservable: Observable<AudioEngine>;
  109221. /**
  109222. * Event raised when audio has been locked on the browser.
  109223. */
  109224. onAudioLockedObservable: Observable<AudioEngine>;
  109225. /**
  109226. * Gets the current AudioContext if available.
  109227. */
  109228. get audioContext(): Nullable<AudioContext>;
  109229. private _connectedAnalyser;
  109230. /**
  109231. * Instantiates a new audio engine.
  109232. *
  109233. * There should be only one per page as some browsers restrict the number
  109234. * of audio contexts you can create.
  109235. * @param hostElement defines the host element where to display the mute icon if necessary
  109236. */
  109237. constructor(hostElement?: Nullable<HTMLElement>);
  109238. /**
  109239. * Flags the audio engine in Locked state.
  109240. * This happens due to new browser policies preventing audio to autoplay.
  109241. */
  109242. lock(): void;
  109243. /**
  109244. * Unlocks the audio engine once a user action has been done on the dom.
  109245. * This is helpful to resume play once browser policies have been satisfied.
  109246. */
  109247. unlock(): void;
  109248. private _resumeAudioContext;
  109249. private _initializeAudioContext;
  109250. private _tryToRun;
  109251. private _triggerRunningState;
  109252. private _triggerSuspendedState;
  109253. private _displayMuteButton;
  109254. private _moveButtonToTopLeft;
  109255. private _onResize;
  109256. private _hideMuteButton;
  109257. /**
  109258. * Destroy and release the resources associated with the audio ccontext.
  109259. */
  109260. dispose(): void;
  109261. /**
  109262. * Gets the global volume sets on the master gain.
  109263. * @returns the global volume if set or -1 otherwise
  109264. */
  109265. getGlobalVolume(): number;
  109266. /**
  109267. * Sets the global volume of your experience (sets on the master gain).
  109268. * @param newVolume Defines the new global volume of the application
  109269. */
  109270. setGlobalVolume(newVolume: number): void;
  109271. /**
  109272. * Connect the audio engine to an audio analyser allowing some amazing
  109273. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  109274. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  109275. * @param analyser The analyser to connect to the engine
  109276. */
  109277. connectToAnalyser(analyser: Analyser): void;
  109278. }
  109279. }
  109280. declare module BABYLON {
  109281. /**
  109282. * Interface used to present a loading screen while loading a scene
  109283. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  109284. */
  109285. export interface ILoadingScreen {
  109286. /**
  109287. * Function called to display the loading screen
  109288. */
  109289. displayLoadingUI: () => void;
  109290. /**
  109291. * Function called to hide the loading screen
  109292. */
  109293. hideLoadingUI: () => void;
  109294. /**
  109295. * Gets or sets the color to use for the background
  109296. */
  109297. loadingUIBackgroundColor: string;
  109298. /**
  109299. * Gets or sets the text to display while loading
  109300. */
  109301. loadingUIText: string;
  109302. }
  109303. /**
  109304. * Class used for the default loading screen
  109305. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  109306. */
  109307. export class DefaultLoadingScreen implements ILoadingScreen {
  109308. private _renderingCanvas;
  109309. private _loadingText;
  109310. private _loadingDivBackgroundColor;
  109311. private _loadingDiv;
  109312. private _loadingTextDiv;
  109313. /** Gets or sets the logo url to use for the default loading screen */
  109314. static DefaultLogoUrl: string;
  109315. /** Gets or sets the spinner url to use for the default loading screen */
  109316. static DefaultSpinnerUrl: string;
  109317. /**
  109318. * Creates a new default loading screen
  109319. * @param _renderingCanvas defines the canvas used to render the scene
  109320. * @param _loadingText defines the default text to display
  109321. * @param _loadingDivBackgroundColor defines the default background color
  109322. */
  109323. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  109324. /**
  109325. * Function called to display the loading screen
  109326. */
  109327. displayLoadingUI(): void;
  109328. /**
  109329. * Function called to hide the loading screen
  109330. */
  109331. hideLoadingUI(): void;
  109332. /**
  109333. * Gets or sets the text to display while loading
  109334. */
  109335. set loadingUIText(text: string);
  109336. get loadingUIText(): string;
  109337. /**
  109338. * Gets or sets the color to use for the background
  109339. */
  109340. get loadingUIBackgroundColor(): string;
  109341. set loadingUIBackgroundColor(color: string);
  109342. private _resizeLoadingUI;
  109343. }
  109344. }
  109345. declare module BABYLON {
  109346. /**
  109347. * Interface for any object that can request an animation frame
  109348. */
  109349. export interface ICustomAnimationFrameRequester {
  109350. /**
  109351. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  109352. */
  109353. renderFunction?: Function;
  109354. /**
  109355. * Called to request the next frame to render to
  109356. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  109357. */
  109358. requestAnimationFrame: Function;
  109359. /**
  109360. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  109361. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  109362. */
  109363. requestID?: number;
  109364. }
  109365. }
  109366. declare module BABYLON {
  109367. /**
  109368. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  109369. */
  109370. export class PerformanceMonitor {
  109371. private _enabled;
  109372. private _rollingFrameTime;
  109373. private _lastFrameTimeMs;
  109374. /**
  109375. * constructor
  109376. * @param frameSampleSize The number of samples required to saturate the sliding window
  109377. */
  109378. constructor(frameSampleSize?: number);
  109379. /**
  109380. * Samples current frame
  109381. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  109382. */
  109383. sampleFrame(timeMs?: number): void;
  109384. /**
  109385. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  109386. */
  109387. get averageFrameTime(): number;
  109388. /**
  109389. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  109390. */
  109391. get averageFrameTimeVariance(): number;
  109392. /**
  109393. * Returns the frame time of the most recent frame
  109394. */
  109395. get instantaneousFrameTime(): number;
  109396. /**
  109397. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  109398. */
  109399. get averageFPS(): number;
  109400. /**
  109401. * Returns the average framerate in frames per second using the most recent frame time
  109402. */
  109403. get instantaneousFPS(): number;
  109404. /**
  109405. * Returns true if enough samples have been taken to completely fill the sliding window
  109406. */
  109407. get isSaturated(): boolean;
  109408. /**
  109409. * Enables contributions to the sliding window sample set
  109410. */
  109411. enable(): void;
  109412. /**
  109413. * Disables contributions to the sliding window sample set
  109414. * Samples will not be interpolated over the disabled period
  109415. */
  109416. disable(): void;
  109417. /**
  109418. * Returns true if sampling is enabled
  109419. */
  109420. get isEnabled(): boolean;
  109421. /**
  109422. * Resets performance monitor
  109423. */
  109424. reset(): void;
  109425. }
  109426. /**
  109427. * RollingAverage
  109428. *
  109429. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  109430. */
  109431. export class RollingAverage {
  109432. /**
  109433. * Current average
  109434. */
  109435. average: number;
  109436. /**
  109437. * Current variance
  109438. */
  109439. variance: number;
  109440. protected _samples: Array<number>;
  109441. protected _sampleCount: number;
  109442. protected _pos: number;
  109443. protected _m2: number;
  109444. /**
  109445. * constructor
  109446. * @param length The number of samples required to saturate the sliding window
  109447. */
  109448. constructor(length: number);
  109449. /**
  109450. * Adds a sample to the sample set
  109451. * @param v The sample value
  109452. */
  109453. add(v: number): void;
  109454. /**
  109455. * Returns previously added values or null if outside of history or outside the sliding window domain
  109456. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  109457. * @return Value previously recorded with add() or null if outside of range
  109458. */
  109459. history(i: number): number;
  109460. /**
  109461. * Returns true if enough samples have been taken to completely fill the sliding window
  109462. * @return true if sample-set saturated
  109463. */
  109464. isSaturated(): boolean;
  109465. /**
  109466. * Resets the rolling average (equivalent to 0 samples taken so far)
  109467. */
  109468. reset(): void;
  109469. /**
  109470. * Wraps a value around the sample range boundaries
  109471. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  109472. * @return Wrapped position in sample range
  109473. */
  109474. protected _wrapPosition(i: number): number;
  109475. }
  109476. }
  109477. declare module BABYLON {
  109478. /**
  109479. * This class is used to track a performance counter which is number based.
  109480. * The user has access to many properties which give statistics of different nature.
  109481. *
  109482. * The implementer can track two kinds of Performance Counter: time and count.
  109483. * 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.
  109484. * 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.
  109485. */
  109486. export class PerfCounter {
  109487. /**
  109488. * Gets or sets a global boolean to turn on and off all the counters
  109489. */
  109490. static Enabled: boolean;
  109491. /**
  109492. * Returns the smallest value ever
  109493. */
  109494. get min(): number;
  109495. /**
  109496. * Returns the biggest value ever
  109497. */
  109498. get max(): number;
  109499. /**
  109500. * Returns the average value since the performance counter is running
  109501. */
  109502. get average(): number;
  109503. /**
  109504. * Returns the average value of the last second the counter was monitored
  109505. */
  109506. get lastSecAverage(): number;
  109507. /**
  109508. * Returns the current value
  109509. */
  109510. get current(): number;
  109511. /**
  109512. * Gets the accumulated total
  109513. */
  109514. get total(): number;
  109515. /**
  109516. * Gets the total value count
  109517. */
  109518. get count(): number;
  109519. /**
  109520. * Creates a new counter
  109521. */
  109522. constructor();
  109523. /**
  109524. * Call this method to start monitoring a new frame.
  109525. * 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.
  109526. */
  109527. fetchNewFrame(): void;
  109528. /**
  109529. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  109530. * @param newCount the count value to add to the monitored count
  109531. * @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.
  109532. */
  109533. addCount(newCount: number, fetchResult: boolean): void;
  109534. /**
  109535. * Start monitoring this performance counter
  109536. */
  109537. beginMonitoring(): void;
  109538. /**
  109539. * Compute the time lapsed since the previous beginMonitoring() call.
  109540. * @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
  109541. */
  109542. endMonitoring(newFrame?: boolean): void;
  109543. private _fetchResult;
  109544. private _startMonitoringTime;
  109545. private _min;
  109546. private _max;
  109547. private _average;
  109548. private _current;
  109549. private _totalValueCount;
  109550. private _totalAccumulated;
  109551. private _lastSecAverage;
  109552. private _lastSecAccumulated;
  109553. private _lastSecTime;
  109554. private _lastSecValueCount;
  109555. }
  109556. }
  109557. declare module BABYLON {
  109558. interface ThinEngine {
  109559. /**
  109560. * Sets alpha constants used by some alpha blending modes
  109561. * @param r defines the red component
  109562. * @param g defines the green component
  109563. * @param b defines the blue component
  109564. * @param a defines the alpha component
  109565. */
  109566. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  109567. /**
  109568. * Sets the current alpha mode
  109569. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  109570. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  109571. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  109572. */
  109573. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  109574. /**
  109575. * Gets the current alpha mode
  109576. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  109577. * @returns the current alpha mode
  109578. */
  109579. getAlphaMode(): number;
  109580. /**
  109581. * Sets the current alpha equation
  109582. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  109583. */
  109584. setAlphaEquation(equation: number): void;
  109585. /**
  109586. * Gets the current alpha equation.
  109587. * @returns the current alpha equation
  109588. */
  109589. getAlphaEquation(): number;
  109590. }
  109591. }
  109592. declare module BABYLON {
  109593. interface ThinEngine {
  109594. /** @hidden */
  109595. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  109596. }
  109597. }
  109598. declare module BABYLON {
  109599. /**
  109600. * Defines the interface used by display changed events
  109601. */
  109602. export interface IDisplayChangedEventArgs {
  109603. /** Gets the vrDisplay object (if any) */
  109604. vrDisplay: Nullable<any>;
  109605. /** Gets a boolean indicating if webVR is supported */
  109606. vrSupported: boolean;
  109607. }
  109608. /**
  109609. * Defines the interface used by objects containing a viewport (like a camera)
  109610. */
  109611. interface IViewportOwnerLike {
  109612. /**
  109613. * Gets or sets the viewport
  109614. */
  109615. viewport: IViewportLike;
  109616. }
  109617. /**
  109618. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  109619. */
  109620. export class Engine extends ThinEngine {
  109621. /** Defines that alpha blending is disabled */
  109622. static readonly ALPHA_DISABLE: number;
  109623. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  109624. static readonly ALPHA_ADD: number;
  109625. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  109626. static readonly ALPHA_COMBINE: number;
  109627. /** Defines that alpha blending to DEST - SRC * DEST */
  109628. static readonly ALPHA_SUBTRACT: number;
  109629. /** Defines that alpha blending to SRC * DEST */
  109630. static readonly ALPHA_MULTIPLY: number;
  109631. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  109632. static readonly ALPHA_MAXIMIZED: number;
  109633. /** Defines that alpha blending to SRC + DEST */
  109634. static readonly ALPHA_ONEONE: number;
  109635. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  109636. static readonly ALPHA_PREMULTIPLIED: number;
  109637. /**
  109638. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  109639. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  109640. */
  109641. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  109642. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  109643. static readonly ALPHA_INTERPOLATE: number;
  109644. /**
  109645. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  109646. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  109647. */
  109648. static readonly ALPHA_SCREENMODE: number;
  109649. /** Defines that the ressource is not delayed*/
  109650. static readonly DELAYLOADSTATE_NONE: number;
  109651. /** Defines that the ressource was successfully delay loaded */
  109652. static readonly DELAYLOADSTATE_LOADED: number;
  109653. /** Defines that the ressource is currently delay loading */
  109654. static readonly DELAYLOADSTATE_LOADING: number;
  109655. /** Defines that the ressource is delayed and has not started loading */
  109656. static readonly DELAYLOADSTATE_NOTLOADED: number;
  109657. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  109658. static readonly NEVER: number;
  109659. /** 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 */
  109660. static readonly ALWAYS: number;
  109661. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  109662. static readonly LESS: number;
  109663. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  109664. static readonly EQUAL: number;
  109665. /** 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 */
  109666. static readonly LEQUAL: number;
  109667. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  109668. static readonly GREATER: number;
  109669. /** 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 */
  109670. static readonly GEQUAL: number;
  109671. /** 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 */
  109672. static readonly NOTEQUAL: number;
  109673. /** Passed to stencilOperation to specify that stencil value must be kept */
  109674. static readonly KEEP: number;
  109675. /** Passed to stencilOperation to specify that stencil value must be replaced */
  109676. static readonly REPLACE: number;
  109677. /** Passed to stencilOperation to specify that stencil value must be incremented */
  109678. static readonly INCR: number;
  109679. /** Passed to stencilOperation to specify that stencil value must be decremented */
  109680. static readonly DECR: number;
  109681. /** Passed to stencilOperation to specify that stencil value must be inverted */
  109682. static readonly INVERT: number;
  109683. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  109684. static readonly INCR_WRAP: number;
  109685. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  109686. static readonly DECR_WRAP: number;
  109687. /** Texture is not repeating outside of 0..1 UVs */
  109688. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  109689. /** Texture is repeating outside of 0..1 UVs */
  109690. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  109691. /** Texture is repeating and mirrored */
  109692. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  109693. /** ALPHA */
  109694. static readonly TEXTUREFORMAT_ALPHA: number;
  109695. /** LUMINANCE */
  109696. static readonly TEXTUREFORMAT_LUMINANCE: number;
  109697. /** LUMINANCE_ALPHA */
  109698. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  109699. /** RGB */
  109700. static readonly TEXTUREFORMAT_RGB: number;
  109701. /** RGBA */
  109702. static readonly TEXTUREFORMAT_RGBA: number;
  109703. /** RED */
  109704. static readonly TEXTUREFORMAT_RED: number;
  109705. /** RED (2nd reference) */
  109706. static readonly TEXTUREFORMAT_R: number;
  109707. /** RG */
  109708. static readonly TEXTUREFORMAT_RG: number;
  109709. /** RED_INTEGER */
  109710. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  109711. /** RED_INTEGER (2nd reference) */
  109712. static readonly TEXTUREFORMAT_R_INTEGER: number;
  109713. /** RG_INTEGER */
  109714. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  109715. /** RGB_INTEGER */
  109716. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  109717. /** RGBA_INTEGER */
  109718. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  109719. /** UNSIGNED_BYTE */
  109720. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  109721. /** UNSIGNED_BYTE (2nd reference) */
  109722. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  109723. /** FLOAT */
  109724. static readonly TEXTURETYPE_FLOAT: number;
  109725. /** HALF_FLOAT */
  109726. static readonly TEXTURETYPE_HALF_FLOAT: number;
  109727. /** BYTE */
  109728. static readonly TEXTURETYPE_BYTE: number;
  109729. /** SHORT */
  109730. static readonly TEXTURETYPE_SHORT: number;
  109731. /** UNSIGNED_SHORT */
  109732. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  109733. /** INT */
  109734. static readonly TEXTURETYPE_INT: number;
  109735. /** UNSIGNED_INT */
  109736. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  109737. /** UNSIGNED_SHORT_4_4_4_4 */
  109738. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  109739. /** UNSIGNED_SHORT_5_5_5_1 */
  109740. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  109741. /** UNSIGNED_SHORT_5_6_5 */
  109742. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  109743. /** UNSIGNED_INT_2_10_10_10_REV */
  109744. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  109745. /** UNSIGNED_INT_24_8 */
  109746. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  109747. /** UNSIGNED_INT_10F_11F_11F_REV */
  109748. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  109749. /** UNSIGNED_INT_5_9_9_9_REV */
  109750. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  109751. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  109752. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  109753. /** nearest is mag = nearest and min = nearest and mip = linear */
  109754. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  109755. /** Bilinear is mag = linear and min = linear and mip = nearest */
  109756. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  109757. /** Trilinear is mag = linear and min = linear and mip = linear */
  109758. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  109759. /** nearest is mag = nearest and min = nearest and mip = linear */
  109760. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  109761. /** Bilinear is mag = linear and min = linear and mip = nearest */
  109762. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  109763. /** Trilinear is mag = linear and min = linear and mip = linear */
  109764. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  109765. /** mag = nearest and min = nearest and mip = nearest */
  109766. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  109767. /** mag = nearest and min = linear and mip = nearest */
  109768. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  109769. /** mag = nearest and min = linear and mip = linear */
  109770. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  109771. /** mag = nearest and min = linear and mip = none */
  109772. static readonly TEXTURE_NEAREST_LINEAR: number;
  109773. /** mag = nearest and min = nearest and mip = none */
  109774. static readonly TEXTURE_NEAREST_NEAREST: number;
  109775. /** mag = linear and min = nearest and mip = nearest */
  109776. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  109777. /** mag = linear and min = nearest and mip = linear */
  109778. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  109779. /** mag = linear and min = linear and mip = none */
  109780. static readonly TEXTURE_LINEAR_LINEAR: number;
  109781. /** mag = linear and min = nearest and mip = none */
  109782. static readonly TEXTURE_LINEAR_NEAREST: number;
  109783. /** Explicit coordinates mode */
  109784. static readonly TEXTURE_EXPLICIT_MODE: number;
  109785. /** Spherical coordinates mode */
  109786. static readonly TEXTURE_SPHERICAL_MODE: number;
  109787. /** Planar coordinates mode */
  109788. static readonly TEXTURE_PLANAR_MODE: number;
  109789. /** Cubic coordinates mode */
  109790. static readonly TEXTURE_CUBIC_MODE: number;
  109791. /** Projection coordinates mode */
  109792. static readonly TEXTURE_PROJECTION_MODE: number;
  109793. /** Skybox coordinates mode */
  109794. static readonly TEXTURE_SKYBOX_MODE: number;
  109795. /** Inverse Cubic coordinates mode */
  109796. static readonly TEXTURE_INVCUBIC_MODE: number;
  109797. /** Equirectangular coordinates mode */
  109798. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  109799. /** Equirectangular Fixed coordinates mode */
  109800. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  109801. /** Equirectangular Fixed Mirrored coordinates mode */
  109802. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  109803. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  109804. static readonly SCALEMODE_FLOOR: number;
  109805. /** Defines that texture rescaling will look for the nearest power of 2 size */
  109806. static readonly SCALEMODE_NEAREST: number;
  109807. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  109808. static readonly SCALEMODE_CEILING: number;
  109809. /**
  109810. * Returns the current npm package of the sdk
  109811. */
  109812. static get NpmPackage(): string;
  109813. /**
  109814. * Returns the current version of the framework
  109815. */
  109816. static get Version(): string;
  109817. /** Gets the list of created engines */
  109818. static get Instances(): Engine[];
  109819. /**
  109820. * Gets the latest created engine
  109821. */
  109822. static get LastCreatedEngine(): Nullable<Engine>;
  109823. /**
  109824. * Gets the latest created scene
  109825. */
  109826. static get LastCreatedScene(): Nullable<Scene>;
  109827. /**
  109828. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  109829. * @param flag defines which part of the materials must be marked as dirty
  109830. * @param predicate defines a predicate used to filter which materials should be affected
  109831. */
  109832. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  109833. /**
  109834. * Method called to create the default loading screen.
  109835. * This can be overriden in your own app.
  109836. * @param canvas The rendering canvas element
  109837. * @returns The loading screen
  109838. */
  109839. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  109840. /**
  109841. * Method called to create the default rescale post process on each engine.
  109842. */
  109843. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  109844. /**
  109845. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  109846. **/
  109847. enableOfflineSupport: boolean;
  109848. /**
  109849. * 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)
  109850. **/
  109851. disableManifestCheck: boolean;
  109852. /**
  109853. * Gets the list of created scenes
  109854. */
  109855. scenes: Scene[];
  109856. /**
  109857. * Event raised when a new scene is created
  109858. */
  109859. onNewSceneAddedObservable: Observable<Scene>;
  109860. /**
  109861. * Gets the list of created postprocesses
  109862. */
  109863. postProcesses: PostProcess[];
  109864. /**
  109865. * Gets a boolean indicating if the pointer is currently locked
  109866. */
  109867. isPointerLock: boolean;
  109868. /**
  109869. * Observable event triggered each time the rendering canvas is resized
  109870. */
  109871. onResizeObservable: Observable<Engine>;
  109872. /**
  109873. * Observable event triggered each time the canvas loses focus
  109874. */
  109875. onCanvasBlurObservable: Observable<Engine>;
  109876. /**
  109877. * Observable event triggered each time the canvas gains focus
  109878. */
  109879. onCanvasFocusObservable: Observable<Engine>;
  109880. /**
  109881. * Observable event triggered each time the canvas receives pointerout event
  109882. */
  109883. onCanvasPointerOutObservable: Observable<PointerEvent>;
  109884. /**
  109885. * Observable raised when the engine begins a new frame
  109886. */
  109887. onBeginFrameObservable: Observable<Engine>;
  109888. /**
  109889. * If set, will be used to request the next animation frame for the render loop
  109890. */
  109891. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  109892. /**
  109893. * Observable raised when the engine ends the current frame
  109894. */
  109895. onEndFrameObservable: Observable<Engine>;
  109896. /**
  109897. * Observable raised when the engine is about to compile a shader
  109898. */
  109899. onBeforeShaderCompilationObservable: Observable<Engine>;
  109900. /**
  109901. * Observable raised when the engine has jsut compiled a shader
  109902. */
  109903. onAfterShaderCompilationObservable: Observable<Engine>;
  109904. /**
  109905. * Gets the audio engine
  109906. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  109907. * @ignorenaming
  109908. */
  109909. static audioEngine: IAudioEngine;
  109910. /**
  109911. * Default AudioEngine factory responsible of creating the Audio Engine.
  109912. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  109913. */
  109914. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  109915. /**
  109916. * Default offline support factory responsible of creating a tool used to store data locally.
  109917. * By default, this will create a Database object if the workload has been embedded.
  109918. */
  109919. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  109920. private _loadingScreen;
  109921. private _pointerLockRequested;
  109922. private _rescalePostProcess;
  109923. private _deterministicLockstep;
  109924. private _lockstepMaxSteps;
  109925. private _timeStep;
  109926. protected get _supportsHardwareTextureRescaling(): boolean;
  109927. private _fps;
  109928. private _deltaTime;
  109929. /** @hidden */
  109930. _drawCalls: PerfCounter;
  109931. /** 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 */
  109932. canvasTabIndex: number;
  109933. /**
  109934. * Turn this value on if you want to pause FPS computation when in background
  109935. */
  109936. disablePerformanceMonitorInBackground: boolean;
  109937. private _performanceMonitor;
  109938. /**
  109939. * Gets the performance monitor attached to this engine
  109940. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  109941. */
  109942. get performanceMonitor(): PerformanceMonitor;
  109943. private _onFocus;
  109944. private _onBlur;
  109945. private _onCanvasPointerOut;
  109946. private _onCanvasBlur;
  109947. private _onCanvasFocus;
  109948. private _onFullscreenChange;
  109949. private _onPointerLockChange;
  109950. /**
  109951. * Gets the HTML element used to attach event listeners
  109952. * @returns a HTML element
  109953. */
  109954. getInputElement(): Nullable<HTMLElement>;
  109955. /**
  109956. * Creates a new engine
  109957. * @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
  109958. * @param antialias defines enable antialiasing (default: false)
  109959. * @param options defines further options to be sent to the getContext() function
  109960. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  109961. */
  109962. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  109963. /**
  109964. * Gets current aspect ratio
  109965. * @param viewportOwner defines the camera to use to get the aspect ratio
  109966. * @param useScreen defines if screen size must be used (or the current render target if any)
  109967. * @returns a number defining the aspect ratio
  109968. */
  109969. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  109970. /**
  109971. * Gets current screen aspect ratio
  109972. * @returns a number defining the aspect ratio
  109973. */
  109974. getScreenAspectRatio(): number;
  109975. /**
  109976. * Gets the client rect of the HTML canvas attached with the current webGL context
  109977. * @returns a client rectanglee
  109978. */
  109979. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  109980. /**
  109981. * Gets the client rect of the HTML element used for events
  109982. * @returns a client rectanglee
  109983. */
  109984. getInputElementClientRect(): Nullable<ClientRect>;
  109985. /**
  109986. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  109987. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  109988. * @returns true if engine is in deterministic lock step mode
  109989. */
  109990. isDeterministicLockStep(): boolean;
  109991. /**
  109992. * Gets the max steps when engine is running in deterministic lock step
  109993. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  109994. * @returns the max steps
  109995. */
  109996. getLockstepMaxSteps(): number;
  109997. /**
  109998. * Returns the time in ms between steps when using deterministic lock step.
  109999. * @returns time step in (ms)
  110000. */
  110001. getTimeStep(): number;
  110002. /**
  110003. * Force the mipmap generation for the given render target texture
  110004. * @param texture defines the render target texture to use
  110005. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  110006. */
  110007. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  110008. /** States */
  110009. /**
  110010. * Set various states to the webGL context
  110011. * @param culling defines backface culling state
  110012. * @param zOffset defines the value to apply to zOffset (0 by default)
  110013. * @param force defines if states must be applied even if cache is up to date
  110014. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  110015. */
  110016. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  110017. /**
  110018. * Set the z offset to apply to current rendering
  110019. * @param value defines the offset to apply
  110020. */
  110021. setZOffset(value: number): void;
  110022. /**
  110023. * Gets the current value of the zOffset
  110024. * @returns the current zOffset state
  110025. */
  110026. getZOffset(): number;
  110027. /**
  110028. * Enable or disable depth buffering
  110029. * @param enable defines the state to set
  110030. */
  110031. setDepthBuffer(enable: boolean): void;
  110032. /**
  110033. * Gets a boolean indicating if depth writing is enabled
  110034. * @returns the current depth writing state
  110035. */
  110036. getDepthWrite(): boolean;
  110037. /**
  110038. * Enable or disable depth writing
  110039. * @param enable defines the state to set
  110040. */
  110041. setDepthWrite(enable: boolean): void;
  110042. /**
  110043. * Gets a boolean indicating if stencil buffer is enabled
  110044. * @returns the current stencil buffer state
  110045. */
  110046. getStencilBuffer(): boolean;
  110047. /**
  110048. * Enable or disable the stencil buffer
  110049. * @param enable defines if the stencil buffer must be enabled or disabled
  110050. */
  110051. setStencilBuffer(enable: boolean): void;
  110052. /**
  110053. * Gets the current stencil mask
  110054. * @returns a number defining the new stencil mask to use
  110055. */
  110056. getStencilMask(): number;
  110057. /**
  110058. * Sets the current stencil mask
  110059. * @param mask defines the new stencil mask to use
  110060. */
  110061. setStencilMask(mask: number): void;
  110062. /**
  110063. * Gets the current stencil function
  110064. * @returns a number defining the stencil function to use
  110065. */
  110066. getStencilFunction(): number;
  110067. /**
  110068. * Gets the current stencil reference value
  110069. * @returns a number defining the stencil reference value to use
  110070. */
  110071. getStencilFunctionReference(): number;
  110072. /**
  110073. * Gets the current stencil mask
  110074. * @returns a number defining the stencil mask to use
  110075. */
  110076. getStencilFunctionMask(): number;
  110077. /**
  110078. * Sets the current stencil function
  110079. * @param stencilFunc defines the new stencil function to use
  110080. */
  110081. setStencilFunction(stencilFunc: number): void;
  110082. /**
  110083. * Sets the current stencil reference
  110084. * @param reference defines the new stencil reference to use
  110085. */
  110086. setStencilFunctionReference(reference: number): void;
  110087. /**
  110088. * Sets the current stencil mask
  110089. * @param mask defines the new stencil mask to use
  110090. */
  110091. setStencilFunctionMask(mask: number): void;
  110092. /**
  110093. * Gets the current stencil operation when stencil fails
  110094. * @returns a number defining stencil operation to use when stencil fails
  110095. */
  110096. getStencilOperationFail(): number;
  110097. /**
  110098. * Gets the current stencil operation when depth fails
  110099. * @returns a number defining stencil operation to use when depth fails
  110100. */
  110101. getStencilOperationDepthFail(): number;
  110102. /**
  110103. * Gets the current stencil operation when stencil passes
  110104. * @returns a number defining stencil operation to use when stencil passes
  110105. */
  110106. getStencilOperationPass(): number;
  110107. /**
  110108. * Sets the stencil operation to use when stencil fails
  110109. * @param operation defines the stencil operation to use when stencil fails
  110110. */
  110111. setStencilOperationFail(operation: number): void;
  110112. /**
  110113. * Sets the stencil operation to use when depth fails
  110114. * @param operation defines the stencil operation to use when depth fails
  110115. */
  110116. setStencilOperationDepthFail(operation: number): void;
  110117. /**
  110118. * Sets the stencil operation to use when stencil passes
  110119. * @param operation defines the stencil operation to use when stencil passes
  110120. */
  110121. setStencilOperationPass(operation: number): void;
  110122. /**
  110123. * Sets a boolean indicating if the dithering state is enabled or disabled
  110124. * @param value defines the dithering state
  110125. */
  110126. setDitheringState(value: boolean): void;
  110127. /**
  110128. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  110129. * @param value defines the rasterizer state
  110130. */
  110131. setRasterizerState(value: boolean): void;
  110132. /**
  110133. * Gets the current depth function
  110134. * @returns a number defining the depth function
  110135. */
  110136. getDepthFunction(): Nullable<number>;
  110137. /**
  110138. * Sets the current depth function
  110139. * @param depthFunc defines the function to use
  110140. */
  110141. setDepthFunction(depthFunc: number): void;
  110142. /**
  110143. * Sets the current depth function to GREATER
  110144. */
  110145. setDepthFunctionToGreater(): void;
  110146. /**
  110147. * Sets the current depth function to GEQUAL
  110148. */
  110149. setDepthFunctionToGreaterOrEqual(): void;
  110150. /**
  110151. * Sets the current depth function to LESS
  110152. */
  110153. setDepthFunctionToLess(): void;
  110154. /**
  110155. * Sets the current depth function to LEQUAL
  110156. */
  110157. setDepthFunctionToLessOrEqual(): void;
  110158. private _cachedStencilBuffer;
  110159. private _cachedStencilFunction;
  110160. private _cachedStencilMask;
  110161. private _cachedStencilOperationPass;
  110162. private _cachedStencilOperationFail;
  110163. private _cachedStencilOperationDepthFail;
  110164. private _cachedStencilReference;
  110165. /**
  110166. * Caches the the state of the stencil buffer
  110167. */
  110168. cacheStencilState(): void;
  110169. /**
  110170. * Restores the state of the stencil buffer
  110171. */
  110172. restoreStencilState(): void;
  110173. /**
  110174. * Directly set the WebGL Viewport
  110175. * @param x defines the x coordinate of the viewport (in screen space)
  110176. * @param y defines the y coordinate of the viewport (in screen space)
  110177. * @param width defines the width of the viewport (in screen space)
  110178. * @param height defines the height of the viewport (in screen space)
  110179. * @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
  110180. */
  110181. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  110182. /**
  110183. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  110184. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  110185. * @param y defines the y-coordinate of the corner of the clear rectangle
  110186. * @param width defines the width of the clear rectangle
  110187. * @param height defines the height of the clear rectangle
  110188. * @param clearColor defines the clear color
  110189. */
  110190. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  110191. /**
  110192. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  110193. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  110194. * @param y defines the y-coordinate of the corner of the clear rectangle
  110195. * @param width defines the width of the clear rectangle
  110196. * @param height defines the height of the clear rectangle
  110197. */
  110198. enableScissor(x: number, y: number, width: number, height: number): void;
  110199. /**
  110200. * Disable previously set scissor test rectangle
  110201. */
  110202. disableScissor(): void;
  110203. protected _reportDrawCall(): void;
  110204. /**
  110205. * Initializes a webVR display and starts listening to display change events
  110206. * The onVRDisplayChangedObservable will be notified upon these changes
  110207. * @returns The onVRDisplayChangedObservable
  110208. */
  110209. initWebVR(): Observable<IDisplayChangedEventArgs>;
  110210. /** @hidden */
  110211. _prepareVRComponent(): void;
  110212. /** @hidden */
  110213. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  110214. /** @hidden */
  110215. _submitVRFrame(): void;
  110216. /**
  110217. * Call this function to leave webVR mode
  110218. * Will do nothing if webVR is not supported or if there is no webVR device
  110219. * @see http://doc.babylonjs.com/how_to/webvr_camera
  110220. */
  110221. disableVR(): void;
  110222. /**
  110223. * Gets a boolean indicating that the system is in VR mode and is presenting
  110224. * @returns true if VR mode is engaged
  110225. */
  110226. isVRPresenting(): boolean;
  110227. /** @hidden */
  110228. _requestVRFrame(): void;
  110229. /** @hidden */
  110230. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  110231. /**
  110232. * Gets the source code of the vertex shader associated with a specific webGL program
  110233. * @param program defines the program to use
  110234. * @returns a string containing the source code of the vertex shader associated with the program
  110235. */
  110236. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  110237. /**
  110238. * Gets the source code of the fragment shader associated with a specific webGL program
  110239. * @param program defines the program to use
  110240. * @returns a string containing the source code of the fragment shader associated with the program
  110241. */
  110242. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  110243. /**
  110244. * Sets a depth stencil texture from a render target to the according uniform.
  110245. * @param channel The texture channel
  110246. * @param uniform The uniform to set
  110247. * @param texture The render target texture containing the depth stencil texture to apply
  110248. */
  110249. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  110250. /**
  110251. * Sets a texture to the webGL context from a postprocess
  110252. * @param channel defines the channel to use
  110253. * @param postProcess defines the source postprocess
  110254. */
  110255. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  110256. /**
  110257. * Binds the output of the passed in post process to the texture channel specified
  110258. * @param channel The channel the texture should be bound to
  110259. * @param postProcess The post process which's output should be bound
  110260. */
  110261. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  110262. protected _rebuildBuffers(): void;
  110263. /** @hidden */
  110264. _renderFrame(): void;
  110265. _renderLoop(): void;
  110266. /** @hidden */
  110267. _renderViews(): boolean;
  110268. /**
  110269. * Toggle full screen mode
  110270. * @param requestPointerLock defines if a pointer lock should be requested from the user
  110271. */
  110272. switchFullscreen(requestPointerLock: boolean): void;
  110273. /**
  110274. * Enters full screen mode
  110275. * @param requestPointerLock defines if a pointer lock should be requested from the user
  110276. */
  110277. enterFullscreen(requestPointerLock: boolean): void;
  110278. /**
  110279. * Exits full screen mode
  110280. */
  110281. exitFullscreen(): void;
  110282. /**
  110283. * Enters Pointerlock mode
  110284. */
  110285. enterPointerlock(): void;
  110286. /**
  110287. * Exits Pointerlock mode
  110288. */
  110289. exitPointerlock(): void;
  110290. /**
  110291. * Begin a new frame
  110292. */
  110293. beginFrame(): void;
  110294. /**
  110295. * Enf the current frame
  110296. */
  110297. endFrame(): void;
  110298. resize(): void;
  110299. /**
  110300. * Force a specific size of the canvas
  110301. * @param width defines the new canvas' width
  110302. * @param height defines the new canvas' height
  110303. */
  110304. setSize(width: number, height: number): void;
  110305. /**
  110306. * Updates a dynamic vertex buffer.
  110307. * @param vertexBuffer the vertex buffer to update
  110308. * @param data the data used to update the vertex buffer
  110309. * @param byteOffset the byte offset of the data
  110310. * @param byteLength the byte length of the data
  110311. */
  110312. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  110313. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  110314. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  110315. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  110316. _releaseTexture(texture: InternalTexture): void;
  110317. /**
  110318. * @hidden
  110319. * Rescales a texture
  110320. * @param source input texutre
  110321. * @param destination destination texture
  110322. * @param scene scene to use to render the resize
  110323. * @param internalFormat format to use when resizing
  110324. * @param onComplete callback to be called when resize has completed
  110325. */
  110326. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  110327. /**
  110328. * Gets the current framerate
  110329. * @returns a number representing the framerate
  110330. */
  110331. getFps(): number;
  110332. /**
  110333. * Gets the time spent between current and previous frame
  110334. * @returns a number representing the delta time in ms
  110335. */
  110336. getDeltaTime(): number;
  110337. private _measureFps;
  110338. /** @hidden */
  110339. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  110340. /**
  110341. * Update a dynamic index buffer
  110342. * @param indexBuffer defines the target index buffer
  110343. * @param indices defines the data to update
  110344. * @param offset defines the offset in the target index buffer where update should start
  110345. */
  110346. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  110347. /**
  110348. * Updates the sample count of a render target texture
  110349. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  110350. * @param texture defines the texture to update
  110351. * @param samples defines the sample count to set
  110352. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  110353. */
  110354. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  110355. /**
  110356. * Updates a depth texture Comparison Mode and Function.
  110357. * If the comparison Function is equal to 0, the mode will be set to none.
  110358. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  110359. * @param texture The texture to set the comparison function for
  110360. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  110361. */
  110362. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  110363. /**
  110364. * Creates a webGL buffer to use with instanciation
  110365. * @param capacity defines the size of the buffer
  110366. * @returns the webGL buffer
  110367. */
  110368. createInstancesBuffer(capacity: number): DataBuffer;
  110369. /**
  110370. * Delete a webGL buffer used with instanciation
  110371. * @param buffer defines the webGL buffer to delete
  110372. */
  110373. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  110374. private _clientWaitAsync;
  110375. /** @hidden */
  110376. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  110377. dispose(): void;
  110378. private _disableTouchAction;
  110379. /**
  110380. * Display the loading screen
  110381. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  110382. */
  110383. displayLoadingUI(): void;
  110384. /**
  110385. * Hide the loading screen
  110386. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  110387. */
  110388. hideLoadingUI(): void;
  110389. /**
  110390. * Gets the current loading screen object
  110391. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  110392. */
  110393. get loadingScreen(): ILoadingScreen;
  110394. /**
  110395. * Sets the current loading screen object
  110396. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  110397. */
  110398. set loadingScreen(loadingScreen: ILoadingScreen);
  110399. /**
  110400. * Sets the current loading screen text
  110401. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  110402. */
  110403. set loadingUIText(text: string);
  110404. /**
  110405. * Sets the current loading screen background color
  110406. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  110407. */
  110408. set loadingUIBackgroundColor(color: string);
  110409. /** Pointerlock and fullscreen */
  110410. /**
  110411. * Ask the browser to promote the current element to pointerlock mode
  110412. * @param element defines the DOM element to promote
  110413. */
  110414. static _RequestPointerlock(element: HTMLElement): void;
  110415. /**
  110416. * Asks the browser to exit pointerlock mode
  110417. */
  110418. static _ExitPointerlock(): void;
  110419. /**
  110420. * Ask the browser to promote the current element to fullscreen rendering mode
  110421. * @param element defines the DOM element to promote
  110422. */
  110423. static _RequestFullscreen(element: HTMLElement): void;
  110424. /**
  110425. * Asks the browser to exit fullscreen mode
  110426. */
  110427. static _ExitFullscreen(): void;
  110428. }
  110429. }
  110430. declare module BABYLON {
  110431. /**
  110432. * The engine store class is responsible to hold all the instances of Engine and Scene created
  110433. * during the life time of the application.
  110434. */
  110435. export class EngineStore {
  110436. /** Gets the list of created engines */
  110437. static Instances: Engine[];
  110438. /** @hidden */
  110439. static _LastCreatedScene: Nullable<Scene>;
  110440. /**
  110441. * Gets the latest created engine
  110442. */
  110443. static get LastCreatedEngine(): Nullable<Engine>;
  110444. /**
  110445. * Gets the latest created scene
  110446. */
  110447. static get LastCreatedScene(): Nullable<Scene>;
  110448. /**
  110449. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  110450. * @ignorenaming
  110451. */
  110452. static UseFallbackTexture: boolean;
  110453. /**
  110454. * Texture content used if a texture cannot loaded
  110455. * @ignorenaming
  110456. */
  110457. static FallbackTexture: string;
  110458. }
  110459. }
  110460. declare module BABYLON {
  110461. /**
  110462. * Helper class that provides a small promise polyfill
  110463. */
  110464. export class PromisePolyfill {
  110465. /**
  110466. * Static function used to check if the polyfill is required
  110467. * If this is the case then the function will inject the polyfill to window.Promise
  110468. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  110469. */
  110470. static Apply(force?: boolean): void;
  110471. }
  110472. }
  110473. declare module BABYLON {
  110474. /**
  110475. * Interface for screenshot methods with describe argument called `size` as object with options
  110476. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  110477. */
  110478. export interface IScreenshotSize {
  110479. /**
  110480. * number in pixels for canvas height
  110481. */
  110482. height?: number;
  110483. /**
  110484. * multiplier allowing render at a higher or lower resolution
  110485. * If value is defined then height and width will be ignored and taken from camera
  110486. */
  110487. precision?: number;
  110488. /**
  110489. * number in pixels for canvas width
  110490. */
  110491. width?: number;
  110492. }
  110493. }
  110494. declare module BABYLON {
  110495. interface IColor4Like {
  110496. r: float;
  110497. g: float;
  110498. b: float;
  110499. a: float;
  110500. }
  110501. /**
  110502. * Class containing a set of static utilities functions
  110503. */
  110504. export class Tools {
  110505. /**
  110506. * Gets or sets the base URL to use to load assets
  110507. */
  110508. static get BaseUrl(): string;
  110509. static set BaseUrl(value: string);
  110510. /**
  110511. * Enable/Disable Custom HTTP Request Headers globally.
  110512. * default = false
  110513. * @see CustomRequestHeaders
  110514. */
  110515. static UseCustomRequestHeaders: boolean;
  110516. /**
  110517. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  110518. * i.e. when loading files, where the server/service expects an Authorization header
  110519. */
  110520. static CustomRequestHeaders: {
  110521. [key: string]: string;
  110522. };
  110523. /**
  110524. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  110525. */
  110526. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  110527. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  110528. /**
  110529. * Default behaviour for cors in the application.
  110530. * It can be a string if the expected behavior is identical in the entire app.
  110531. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  110532. */
  110533. static get CorsBehavior(): string | ((url: string | string[]) => string);
  110534. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  110535. /**
  110536. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  110537. * @ignorenaming
  110538. */
  110539. static get UseFallbackTexture(): boolean;
  110540. static set UseFallbackTexture(value: boolean);
  110541. /**
  110542. * Use this object to register external classes like custom textures or material
  110543. * to allow the laoders to instantiate them
  110544. */
  110545. static get RegisteredExternalClasses(): {
  110546. [key: string]: Object;
  110547. };
  110548. static set RegisteredExternalClasses(classes: {
  110549. [key: string]: Object;
  110550. });
  110551. /**
  110552. * Texture content used if a texture cannot loaded
  110553. * @ignorenaming
  110554. */
  110555. static get fallbackTexture(): string;
  110556. static set fallbackTexture(value: string);
  110557. /**
  110558. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  110559. * @param u defines the coordinate on X axis
  110560. * @param v defines the coordinate on Y axis
  110561. * @param width defines the width of the source data
  110562. * @param height defines the height of the source data
  110563. * @param pixels defines the source byte array
  110564. * @param color defines the output color
  110565. */
  110566. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  110567. /**
  110568. * Interpolates between a and b via alpha
  110569. * @param a The lower value (returned when alpha = 0)
  110570. * @param b The upper value (returned when alpha = 1)
  110571. * @param alpha The interpolation-factor
  110572. * @return The mixed value
  110573. */
  110574. static Mix(a: number, b: number, alpha: number): number;
  110575. /**
  110576. * Tries to instantiate a new object from a given class name
  110577. * @param className defines the class name to instantiate
  110578. * @returns the new object or null if the system was not able to do the instantiation
  110579. */
  110580. static Instantiate(className: string): any;
  110581. /**
  110582. * Provides a slice function that will work even on IE
  110583. * @param data defines the array to slice
  110584. * @param start defines the start of the data (optional)
  110585. * @param end defines the end of the data (optional)
  110586. * @returns the new sliced array
  110587. */
  110588. static Slice<T>(data: T, start?: number, end?: number): T;
  110589. /**
  110590. * Polyfill for setImmediate
  110591. * @param action defines the action to execute after the current execution block
  110592. */
  110593. static SetImmediate(action: () => void): void;
  110594. /**
  110595. * Function indicating if a number is an exponent of 2
  110596. * @param value defines the value to test
  110597. * @returns true if the value is an exponent of 2
  110598. */
  110599. static IsExponentOfTwo(value: number): boolean;
  110600. private static _tmpFloatArray;
  110601. /**
  110602. * Returns the nearest 32-bit single precision float representation of a Number
  110603. * @param value A Number. If the parameter is of a different type, it will get converted
  110604. * to a number or to NaN if it cannot be converted
  110605. * @returns number
  110606. */
  110607. static FloatRound(value: number): number;
  110608. /**
  110609. * Extracts the filename from a path
  110610. * @param path defines the path to use
  110611. * @returns the filename
  110612. */
  110613. static GetFilename(path: string): string;
  110614. /**
  110615. * Extracts the "folder" part of a path (everything before the filename).
  110616. * @param uri The URI to extract the info from
  110617. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  110618. * @returns The "folder" part of the path
  110619. */
  110620. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  110621. /**
  110622. * Extracts text content from a DOM element hierarchy
  110623. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  110624. */
  110625. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  110626. /**
  110627. * Convert an angle in radians to degrees
  110628. * @param angle defines the angle to convert
  110629. * @returns the angle in degrees
  110630. */
  110631. static ToDegrees(angle: number): number;
  110632. /**
  110633. * Convert an angle in degrees to radians
  110634. * @param angle defines the angle to convert
  110635. * @returns the angle in radians
  110636. */
  110637. static ToRadians(angle: number): number;
  110638. /**
  110639. * Returns an array if obj is not an array
  110640. * @param obj defines the object to evaluate as an array
  110641. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  110642. * @returns either obj directly if obj is an array or a new array containing obj
  110643. */
  110644. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  110645. /**
  110646. * Gets the pointer prefix to use
  110647. * @returns "pointer" if touch is enabled. Else returns "mouse"
  110648. */
  110649. static GetPointerPrefix(): string;
  110650. /**
  110651. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  110652. * @param url define the url we are trying
  110653. * @param element define the dom element where to configure the cors policy
  110654. */
  110655. static SetCorsBehavior(url: string | string[], element: {
  110656. crossOrigin: string | null;
  110657. }): void;
  110658. /**
  110659. * Removes unwanted characters from an url
  110660. * @param url defines the url to clean
  110661. * @returns the cleaned url
  110662. */
  110663. static CleanUrl(url: string): string;
  110664. /**
  110665. * Gets or sets a function used to pre-process url before using them to load assets
  110666. */
  110667. static get PreprocessUrl(): (url: string) => string;
  110668. static set PreprocessUrl(processor: (url: string) => string);
  110669. /**
  110670. * Loads an image as an HTMLImageElement.
  110671. * @param input url string, ArrayBuffer, or Blob to load
  110672. * @param onLoad callback called when the image successfully loads
  110673. * @param onError callback called when the image fails to load
  110674. * @param offlineProvider offline provider for caching
  110675. * @param mimeType optional mime type
  110676. * @returns the HTMLImageElement of the loaded image
  110677. */
  110678. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  110679. /**
  110680. * Loads a file from a url
  110681. * @param url url string, ArrayBuffer, or Blob to load
  110682. * @param onSuccess callback called when the file successfully loads
  110683. * @param onProgress callback called while file is loading (if the server supports this mode)
  110684. * @param offlineProvider defines the offline provider for caching
  110685. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  110686. * @param onError callback called when the file fails to load
  110687. * @returns a file request object
  110688. */
  110689. 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;
  110690. /**
  110691. * Loads a file from a url
  110692. * @param url the file url to load
  110693. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  110694. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  110695. */
  110696. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  110697. /**
  110698. * Load a script (identified by an url). When the url returns, the
  110699. * content of this file is added into a new script element, attached to the DOM (body element)
  110700. * @param scriptUrl defines the url of the script to laod
  110701. * @param onSuccess defines the callback called when the script is loaded
  110702. * @param onError defines the callback to call if an error occurs
  110703. * @param scriptId defines the id of the script element
  110704. */
  110705. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  110706. /**
  110707. * Load an asynchronous script (identified by an url). When the url returns, the
  110708. * content of this file is added into a new script element, attached to the DOM (body element)
  110709. * @param scriptUrl defines the url of the script to laod
  110710. * @param scriptId defines the id of the script element
  110711. * @returns a promise request object
  110712. */
  110713. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  110714. /**
  110715. * Loads a file from a blob
  110716. * @param fileToLoad defines the blob to use
  110717. * @param callback defines the callback to call when data is loaded
  110718. * @param progressCallback defines the callback to call during loading process
  110719. * @returns a file request object
  110720. */
  110721. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  110722. /**
  110723. * Reads a file from a File object
  110724. * @param file defines the file to load
  110725. * @param onSuccess defines the callback to call when data is loaded
  110726. * @param onProgress defines the callback to call during loading process
  110727. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  110728. * @param onError defines the callback to call when an error occurs
  110729. * @returns a file request object
  110730. */
  110731. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  110732. /**
  110733. * Creates a data url from a given string content
  110734. * @param content defines the content to convert
  110735. * @returns the new data url link
  110736. */
  110737. static FileAsURL(content: string): string;
  110738. /**
  110739. * Format the given number to a specific decimal format
  110740. * @param value defines the number to format
  110741. * @param decimals defines the number of decimals to use
  110742. * @returns the formatted string
  110743. */
  110744. static Format(value: number, decimals?: number): string;
  110745. /**
  110746. * Tries to copy an object by duplicating every property
  110747. * @param source defines the source object
  110748. * @param destination defines the target object
  110749. * @param doNotCopyList defines a list of properties to avoid
  110750. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  110751. */
  110752. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  110753. /**
  110754. * Gets a boolean indicating if the given object has no own property
  110755. * @param obj defines the object to test
  110756. * @returns true if object has no own property
  110757. */
  110758. static IsEmpty(obj: any): boolean;
  110759. /**
  110760. * Function used to register events at window level
  110761. * @param windowElement defines the Window object to use
  110762. * @param events defines the events to register
  110763. */
  110764. static RegisterTopRootEvents(windowElement: Window, events: {
  110765. name: string;
  110766. handler: Nullable<(e: FocusEvent) => any>;
  110767. }[]): void;
  110768. /**
  110769. * Function used to unregister events from window level
  110770. * @param windowElement defines the Window object to use
  110771. * @param events defines the events to unregister
  110772. */
  110773. static UnregisterTopRootEvents(windowElement: Window, events: {
  110774. name: string;
  110775. handler: Nullable<(e: FocusEvent) => any>;
  110776. }[]): void;
  110777. /**
  110778. * @ignore
  110779. */
  110780. static _ScreenshotCanvas: HTMLCanvasElement;
  110781. /**
  110782. * Dumps the current bound framebuffer
  110783. * @param width defines the rendering width
  110784. * @param height defines the rendering height
  110785. * @param engine defines the hosting engine
  110786. * @param successCallback defines the callback triggered once the data are available
  110787. * @param mimeType defines the mime type of the result
  110788. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  110789. */
  110790. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  110791. /**
  110792. * Converts the canvas data to blob.
  110793. * This acts as a polyfill for browsers not supporting the to blob function.
  110794. * @param canvas Defines the canvas to extract the data from
  110795. * @param successCallback Defines the callback triggered once the data are available
  110796. * @param mimeType Defines the mime type of the result
  110797. */
  110798. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  110799. /**
  110800. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  110801. * @param successCallback defines the callback triggered once the data are available
  110802. * @param mimeType defines the mime type of the result
  110803. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  110804. */
  110805. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  110806. /**
  110807. * Downloads a blob in the browser
  110808. * @param blob defines the blob to download
  110809. * @param fileName defines the name of the downloaded file
  110810. */
  110811. static Download(blob: Blob, fileName: string): void;
  110812. /**
  110813. * Captures a screenshot of the current rendering
  110814. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  110815. * @param engine defines the rendering engine
  110816. * @param camera defines the source camera
  110817. * @param size This parameter can be set to a single number or to an object with the
  110818. * following (optional) properties: precision, width, height. If a single number is passed,
  110819. * it will be used for both width and height. If an object is passed, the screenshot size
  110820. * will be derived from the parameters. The precision property is a multiplier allowing
  110821. * rendering at a higher or lower resolution
  110822. * @param successCallback defines the callback receives a single parameter which contains the
  110823. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  110824. * src parameter of an <img> to display it
  110825. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  110826. * Check your browser for supported MIME types
  110827. */
  110828. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  110829. /**
  110830. * Captures a screenshot of the current rendering
  110831. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  110832. * @param engine defines the rendering engine
  110833. * @param camera defines the source camera
  110834. * @param size This parameter can be set to a single number or to an object with the
  110835. * following (optional) properties: precision, width, height. If a single number is passed,
  110836. * it will be used for both width and height. If an object is passed, the screenshot size
  110837. * will be derived from the parameters. The precision property is a multiplier allowing
  110838. * rendering at a higher or lower resolution
  110839. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  110840. * Check your browser for supported MIME types
  110841. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  110842. * to the src parameter of an <img> to display it
  110843. */
  110844. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  110845. /**
  110846. * Generates an image screenshot from the specified camera.
  110847. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  110848. * @param engine The engine to use for rendering
  110849. * @param camera The camera to use for rendering
  110850. * @param size This parameter can be set to a single number or to an object with the
  110851. * following (optional) properties: precision, width, height. If a single number is passed,
  110852. * it will be used for both width and height. If an object is passed, the screenshot size
  110853. * will be derived from the parameters. The precision property is a multiplier allowing
  110854. * rendering at a higher or lower resolution
  110855. * @param successCallback The callback receives a single parameter which contains the
  110856. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  110857. * src parameter of an <img> to display it
  110858. * @param mimeType The MIME type of the screenshot image (default: image/png).
  110859. * Check your browser for supported MIME types
  110860. * @param samples Texture samples (default: 1)
  110861. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  110862. * @param fileName A name for for the downloaded file.
  110863. */
  110864. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  110865. /**
  110866. * Generates an image screenshot from the specified camera.
  110867. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  110868. * @param engine The engine to use for rendering
  110869. * @param camera The camera to use for rendering
  110870. * @param size This parameter can be set to a single number or to an object with the
  110871. * following (optional) properties: precision, width, height. If a single number is passed,
  110872. * it will be used for both width and height. If an object is passed, the screenshot size
  110873. * will be derived from the parameters. The precision property is a multiplier allowing
  110874. * rendering at a higher or lower resolution
  110875. * @param mimeType The MIME type of the screenshot image (default: image/png).
  110876. * Check your browser for supported MIME types
  110877. * @param samples Texture samples (default: 1)
  110878. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  110879. * @param fileName A name for for the downloaded file.
  110880. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  110881. * to the src parameter of an <img> to display it
  110882. */
  110883. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  110884. /**
  110885. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  110886. * Be aware Math.random() could cause collisions, but:
  110887. * "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"
  110888. * @returns a pseudo random id
  110889. */
  110890. static RandomId(): string;
  110891. /**
  110892. * Test if the given uri is a base64 string
  110893. * @param uri The uri to test
  110894. * @return True if the uri is a base64 string or false otherwise
  110895. */
  110896. static IsBase64(uri: string): boolean;
  110897. /**
  110898. * Decode the given base64 uri.
  110899. * @param uri The uri to decode
  110900. * @return The decoded base64 data.
  110901. */
  110902. static DecodeBase64(uri: string): ArrayBuffer;
  110903. /**
  110904. * Gets the absolute url.
  110905. * @param url the input url
  110906. * @return the absolute url
  110907. */
  110908. static GetAbsoluteUrl(url: string): string;
  110909. /**
  110910. * No log
  110911. */
  110912. static readonly NoneLogLevel: number;
  110913. /**
  110914. * Only message logs
  110915. */
  110916. static readonly MessageLogLevel: number;
  110917. /**
  110918. * Only warning logs
  110919. */
  110920. static readonly WarningLogLevel: number;
  110921. /**
  110922. * Only error logs
  110923. */
  110924. static readonly ErrorLogLevel: number;
  110925. /**
  110926. * All logs
  110927. */
  110928. static readonly AllLogLevel: number;
  110929. /**
  110930. * Gets a value indicating the number of loading errors
  110931. * @ignorenaming
  110932. */
  110933. static get errorsCount(): number;
  110934. /**
  110935. * Callback called when a new log is added
  110936. */
  110937. static OnNewCacheEntry: (entry: string) => void;
  110938. /**
  110939. * Log a message to the console
  110940. * @param message defines the message to log
  110941. */
  110942. static Log(message: string): void;
  110943. /**
  110944. * Write a warning message to the console
  110945. * @param message defines the message to log
  110946. */
  110947. static Warn(message: string): void;
  110948. /**
  110949. * Write an error message to the console
  110950. * @param message defines the message to log
  110951. */
  110952. static Error(message: string): void;
  110953. /**
  110954. * Gets current log cache (list of logs)
  110955. */
  110956. static get LogCache(): string;
  110957. /**
  110958. * Clears the log cache
  110959. */
  110960. static ClearLogCache(): void;
  110961. /**
  110962. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  110963. */
  110964. static set LogLevels(level: number);
  110965. /**
  110966. * Checks if the window object exists
  110967. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  110968. */
  110969. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  110970. /**
  110971. * No performance log
  110972. */
  110973. static readonly PerformanceNoneLogLevel: number;
  110974. /**
  110975. * Use user marks to log performance
  110976. */
  110977. static readonly PerformanceUserMarkLogLevel: number;
  110978. /**
  110979. * Log performance to the console
  110980. */
  110981. static readonly PerformanceConsoleLogLevel: number;
  110982. private static _performance;
  110983. /**
  110984. * Sets the current performance log level
  110985. */
  110986. static set PerformanceLogLevel(level: number);
  110987. private static _StartPerformanceCounterDisabled;
  110988. private static _EndPerformanceCounterDisabled;
  110989. private static _StartUserMark;
  110990. private static _EndUserMark;
  110991. private static _StartPerformanceConsole;
  110992. private static _EndPerformanceConsole;
  110993. /**
  110994. * Starts a performance counter
  110995. */
  110996. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  110997. /**
  110998. * Ends a specific performance coutner
  110999. */
  111000. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  111001. /**
  111002. * Gets either window.performance.now() if supported or Date.now() else
  111003. */
  111004. static get Now(): number;
  111005. /**
  111006. * This method will return the name of the class used to create the instance of the given object.
  111007. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  111008. * @param object the object to get the class name from
  111009. * @param isType defines if the object is actually a type
  111010. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  111011. */
  111012. static GetClassName(object: any, isType?: boolean): string;
  111013. /**
  111014. * Gets the first element of an array satisfying a given predicate
  111015. * @param array defines the array to browse
  111016. * @param predicate defines the predicate to use
  111017. * @returns null if not found or the element
  111018. */
  111019. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  111020. /**
  111021. * This method will return the name of the full name of the class, including its owning module (if any).
  111022. * 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).
  111023. * @param object the object to get the class name from
  111024. * @param isType defines if the object is actually a type
  111025. * @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.
  111026. * @ignorenaming
  111027. */
  111028. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  111029. /**
  111030. * Returns a promise that resolves after the given amount of time.
  111031. * @param delay Number of milliseconds to delay
  111032. * @returns Promise that resolves after the given amount of time
  111033. */
  111034. static DelayAsync(delay: number): Promise<void>;
  111035. /**
  111036. * Utility function to detect if the current user agent is Safari
  111037. * @returns whether or not the current user agent is safari
  111038. */
  111039. static IsSafari(): boolean;
  111040. }
  111041. /**
  111042. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  111043. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  111044. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  111045. * @param name The name of the class, case should be preserved
  111046. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  111047. */
  111048. export function className(name: string, module?: string): (target: Object) => void;
  111049. /**
  111050. * An implementation of a loop for asynchronous functions.
  111051. */
  111052. export class AsyncLoop {
  111053. /**
  111054. * Defines the number of iterations for the loop
  111055. */
  111056. iterations: number;
  111057. /**
  111058. * Defines the current index of the loop.
  111059. */
  111060. index: number;
  111061. private _done;
  111062. private _fn;
  111063. private _successCallback;
  111064. /**
  111065. * Constructor.
  111066. * @param iterations the number of iterations.
  111067. * @param func the function to run each iteration
  111068. * @param successCallback the callback that will be called upon succesful execution
  111069. * @param offset starting offset.
  111070. */
  111071. constructor(
  111072. /**
  111073. * Defines the number of iterations for the loop
  111074. */
  111075. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  111076. /**
  111077. * Execute the next iteration. Must be called after the last iteration was finished.
  111078. */
  111079. executeNext(): void;
  111080. /**
  111081. * Break the loop and run the success callback.
  111082. */
  111083. breakLoop(): void;
  111084. /**
  111085. * Create and run an async loop.
  111086. * @param iterations the number of iterations.
  111087. * @param fn the function to run each iteration
  111088. * @param successCallback the callback that will be called upon succesful execution
  111089. * @param offset starting offset.
  111090. * @returns the created async loop object
  111091. */
  111092. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  111093. /**
  111094. * A for-loop that will run a given number of iterations synchronous and the rest async.
  111095. * @param iterations total number of iterations
  111096. * @param syncedIterations number of synchronous iterations in each async iteration.
  111097. * @param fn the function to call each iteration.
  111098. * @param callback a success call back that will be called when iterating stops.
  111099. * @param breakFunction a break condition (optional)
  111100. * @param timeout timeout settings for the setTimeout function. default - 0.
  111101. * @returns the created async loop object
  111102. */
  111103. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  111104. }
  111105. }
  111106. declare module BABYLON {
  111107. /**
  111108. * This class implement a typical dictionary using a string as key and the generic type T as value.
  111109. * The underlying implementation relies on an associative array to ensure the best performances.
  111110. * The value can be anything including 'null' but except 'undefined'
  111111. */
  111112. export class StringDictionary<T> {
  111113. /**
  111114. * This will clear this dictionary and copy the content from the 'source' one.
  111115. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  111116. * @param source the dictionary to take the content from and copy to this dictionary
  111117. */
  111118. copyFrom(source: StringDictionary<T>): void;
  111119. /**
  111120. * Get a value based from its key
  111121. * @param key the given key to get the matching value from
  111122. * @return the value if found, otherwise undefined is returned
  111123. */
  111124. get(key: string): T | undefined;
  111125. /**
  111126. * Get a value from its key or add it if it doesn't exist.
  111127. * This method will ensure you that a given key/data will be present in the dictionary.
  111128. * @param key the given key to get the matching value from
  111129. * @param factory the factory that will create the value if the key is not present in the dictionary.
  111130. * The factory will only be invoked if there's no data for the given key.
  111131. * @return the value corresponding to the key.
  111132. */
  111133. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  111134. /**
  111135. * Get a value from its key if present in the dictionary otherwise add it
  111136. * @param key the key to get the value from
  111137. * @param val if there's no such key/value pair in the dictionary add it with this value
  111138. * @return the value corresponding to the key
  111139. */
  111140. getOrAdd(key: string, val: T): T;
  111141. /**
  111142. * Check if there's a given key in the dictionary
  111143. * @param key the key to check for
  111144. * @return true if the key is present, false otherwise
  111145. */
  111146. contains(key: string): boolean;
  111147. /**
  111148. * Add a new key and its corresponding value
  111149. * @param key the key to add
  111150. * @param value the value corresponding to the key
  111151. * @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
  111152. */
  111153. add(key: string, value: T): boolean;
  111154. /**
  111155. * Update a specific value associated to a key
  111156. * @param key defines the key to use
  111157. * @param value defines the value to store
  111158. * @returns true if the value was updated (or false if the key was not found)
  111159. */
  111160. set(key: string, value: T): boolean;
  111161. /**
  111162. * Get the element of the given key and remove it from the dictionary
  111163. * @param key defines the key to search
  111164. * @returns the value associated with the key or null if not found
  111165. */
  111166. getAndRemove(key: string): Nullable<T>;
  111167. /**
  111168. * Remove a key/value from the dictionary.
  111169. * @param key the key to remove
  111170. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  111171. */
  111172. remove(key: string): boolean;
  111173. /**
  111174. * Clear the whole content of the dictionary
  111175. */
  111176. clear(): void;
  111177. /**
  111178. * Gets the current count
  111179. */
  111180. get count(): number;
  111181. /**
  111182. * Execute a callback on each key/val of the dictionary.
  111183. * Note that you can remove any element in this dictionary in the callback implementation
  111184. * @param callback the callback to execute on a given key/value pair
  111185. */
  111186. forEach(callback: (key: string, val: T) => void): void;
  111187. /**
  111188. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  111189. * If the callback returns null or undefined the method will iterate to the next key/value pair
  111190. * Note that you can remove any element in this dictionary in the callback implementation
  111191. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  111192. * @returns the first item
  111193. */
  111194. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  111195. private _count;
  111196. private _data;
  111197. }
  111198. }
  111199. declare module BABYLON {
  111200. /** @hidden */
  111201. export interface ICollisionCoordinator {
  111202. createCollider(): Collider;
  111203. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  111204. init(scene: Scene): void;
  111205. }
  111206. /** @hidden */
  111207. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  111208. private _scene;
  111209. private _scaledPosition;
  111210. private _scaledVelocity;
  111211. private _finalPosition;
  111212. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  111213. createCollider(): Collider;
  111214. init(scene: Scene): void;
  111215. private _collideWithWorld;
  111216. }
  111217. }
  111218. declare module BABYLON {
  111219. /**
  111220. * Class used to manage all inputs for the scene.
  111221. */
  111222. export class InputManager {
  111223. /** The distance in pixel that you have to move to prevent some events */
  111224. static DragMovementThreshold: number;
  111225. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  111226. static LongPressDelay: number;
  111227. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  111228. static DoubleClickDelay: number;
  111229. /** If you need to check double click without raising a single click at first click, enable this flag */
  111230. static ExclusiveDoubleClickMode: boolean;
  111231. private _wheelEventName;
  111232. private _onPointerMove;
  111233. private _onPointerDown;
  111234. private _onPointerUp;
  111235. private _initClickEvent;
  111236. private _initActionManager;
  111237. private _delayedSimpleClick;
  111238. private _delayedSimpleClickTimeout;
  111239. private _previousDelayedSimpleClickTimeout;
  111240. private _meshPickProceed;
  111241. private _previousButtonPressed;
  111242. private _currentPickResult;
  111243. private _previousPickResult;
  111244. private _totalPointersPressed;
  111245. private _doubleClickOccured;
  111246. private _pointerOverMesh;
  111247. private _pickedDownMesh;
  111248. private _pickedUpMesh;
  111249. private _pointerX;
  111250. private _pointerY;
  111251. private _unTranslatedPointerX;
  111252. private _unTranslatedPointerY;
  111253. private _startingPointerPosition;
  111254. private _previousStartingPointerPosition;
  111255. private _startingPointerTime;
  111256. private _previousStartingPointerTime;
  111257. private _pointerCaptures;
  111258. private _onKeyDown;
  111259. private _onKeyUp;
  111260. private _onCanvasFocusObserver;
  111261. private _onCanvasBlurObserver;
  111262. private _scene;
  111263. /**
  111264. * Creates a new InputManager
  111265. * @param scene defines the hosting scene
  111266. */
  111267. constructor(scene: Scene);
  111268. /**
  111269. * Gets the mesh that is currently under the pointer
  111270. */
  111271. get meshUnderPointer(): Nullable<AbstractMesh>;
  111272. /**
  111273. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  111274. */
  111275. get unTranslatedPointer(): Vector2;
  111276. /**
  111277. * Gets or sets the current on-screen X position of the pointer
  111278. */
  111279. get pointerX(): number;
  111280. set pointerX(value: number);
  111281. /**
  111282. * Gets or sets the current on-screen Y position of the pointer
  111283. */
  111284. get pointerY(): number;
  111285. set pointerY(value: number);
  111286. private _updatePointerPosition;
  111287. private _processPointerMove;
  111288. private _setRayOnPointerInfo;
  111289. private _checkPrePointerObservable;
  111290. /**
  111291. * Use this method to simulate a pointer move on a mesh
  111292. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  111293. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  111294. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  111295. */
  111296. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  111297. /**
  111298. * Use this method to simulate a pointer down on a mesh
  111299. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  111300. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  111301. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  111302. */
  111303. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  111304. private _processPointerDown;
  111305. /** @hidden */
  111306. _isPointerSwiping(): boolean;
  111307. /**
  111308. * Use this method to simulate a pointer up on a mesh
  111309. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  111310. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  111311. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  111312. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  111313. */
  111314. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  111315. private _processPointerUp;
  111316. /**
  111317. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  111318. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  111319. * @returns true if the pointer was captured
  111320. */
  111321. isPointerCaptured(pointerId?: number): boolean;
  111322. /**
  111323. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  111324. * @param attachUp defines if you want to attach events to pointerup
  111325. * @param attachDown defines if you want to attach events to pointerdown
  111326. * @param attachMove defines if you want to attach events to pointermove
  111327. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  111328. */
  111329. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  111330. /**
  111331. * Detaches all event handlers
  111332. */
  111333. detachControl(): void;
  111334. /**
  111335. * Force the value of meshUnderPointer
  111336. * @param mesh defines the mesh to use
  111337. */
  111338. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  111339. /**
  111340. * Gets the mesh under the pointer
  111341. * @returns a Mesh or null if no mesh is under the pointer
  111342. */
  111343. getPointerOverMesh(): Nullable<AbstractMesh>;
  111344. }
  111345. }
  111346. declare module BABYLON {
  111347. /**
  111348. * Helper class used to generate session unique ID
  111349. */
  111350. export class UniqueIdGenerator {
  111351. private static _UniqueIdCounter;
  111352. /**
  111353. * Gets an unique (relatively to the current scene) Id
  111354. */
  111355. static get UniqueId(): number;
  111356. }
  111357. }
  111358. declare module BABYLON {
  111359. /**
  111360. * This class defines the direct association between an animation and a target
  111361. */
  111362. export class TargetedAnimation {
  111363. /**
  111364. * Animation to perform
  111365. */
  111366. animation: Animation;
  111367. /**
  111368. * Target to animate
  111369. */
  111370. target: any;
  111371. /**
  111372. * Serialize the object
  111373. * @returns the JSON object representing the current entity
  111374. */
  111375. serialize(): any;
  111376. }
  111377. /**
  111378. * Use this class to create coordinated animations on multiple targets
  111379. */
  111380. export class AnimationGroup implements IDisposable {
  111381. /** The name of the animation group */
  111382. name: string;
  111383. private _scene;
  111384. private _targetedAnimations;
  111385. private _animatables;
  111386. private _from;
  111387. private _to;
  111388. private _isStarted;
  111389. private _isPaused;
  111390. private _speedRatio;
  111391. private _loopAnimation;
  111392. private _isAdditive;
  111393. /**
  111394. * Gets or sets the unique id of the node
  111395. */
  111396. uniqueId: number;
  111397. /**
  111398. * This observable will notify when one animation have ended
  111399. */
  111400. onAnimationEndObservable: Observable<TargetedAnimation>;
  111401. /**
  111402. * Observer raised when one animation loops
  111403. */
  111404. onAnimationLoopObservable: Observable<TargetedAnimation>;
  111405. /**
  111406. * Observer raised when all animations have looped
  111407. */
  111408. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  111409. /**
  111410. * This observable will notify when all animations have ended.
  111411. */
  111412. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  111413. /**
  111414. * This observable will notify when all animations have paused.
  111415. */
  111416. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  111417. /**
  111418. * This observable will notify when all animations are playing.
  111419. */
  111420. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  111421. /**
  111422. * Gets the first frame
  111423. */
  111424. get from(): number;
  111425. /**
  111426. * Gets the last frame
  111427. */
  111428. get to(): number;
  111429. /**
  111430. * Define if the animations are started
  111431. */
  111432. get isStarted(): boolean;
  111433. /**
  111434. * Gets a value indicating that the current group is playing
  111435. */
  111436. get isPlaying(): boolean;
  111437. /**
  111438. * Gets or sets the speed ratio to use for all animations
  111439. */
  111440. get speedRatio(): number;
  111441. /**
  111442. * Gets or sets the speed ratio to use for all animations
  111443. */
  111444. set speedRatio(value: number);
  111445. /**
  111446. * Gets or sets if all animations should loop or not
  111447. */
  111448. get loopAnimation(): boolean;
  111449. set loopAnimation(value: boolean);
  111450. /**
  111451. * Gets or sets if all animations should be evaluated additively
  111452. */
  111453. get isAdditive(): boolean;
  111454. set isAdditive(value: boolean);
  111455. /**
  111456. * Gets the targeted animations for this animation group
  111457. */
  111458. get targetedAnimations(): Array<TargetedAnimation>;
  111459. /**
  111460. * returning the list of animatables controlled by this animation group.
  111461. */
  111462. get animatables(): Array<Animatable>;
  111463. /**
  111464. * Instantiates a new Animation Group.
  111465. * This helps managing several animations at once.
  111466. * @see http://doc.babylonjs.com/how_to/group
  111467. * @param name Defines the name of the group
  111468. * @param scene Defines the scene the group belongs to
  111469. */
  111470. constructor(
  111471. /** The name of the animation group */
  111472. name: string, scene?: Nullable<Scene>);
  111473. /**
  111474. * Add an animation (with its target) in the group
  111475. * @param animation defines the animation we want to add
  111476. * @param target defines the target of the animation
  111477. * @returns the TargetedAnimation object
  111478. */
  111479. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  111480. /**
  111481. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  111482. * It can add constant keys at begin or end
  111483. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  111484. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  111485. * @returns the animation group
  111486. */
  111487. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  111488. private _animationLoopCount;
  111489. private _animationLoopFlags;
  111490. private _processLoop;
  111491. /**
  111492. * Start all animations on given targets
  111493. * @param loop defines if animations must loop
  111494. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  111495. * @param from defines the from key (optional)
  111496. * @param to defines the to key (optional)
  111497. * @param isAdditive defines the additive state for the resulting animatables (optional)
  111498. * @returns the current animation group
  111499. */
  111500. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  111501. /**
  111502. * Pause all animations
  111503. * @returns the animation group
  111504. */
  111505. pause(): AnimationGroup;
  111506. /**
  111507. * Play all animations to initial state
  111508. * This function will start() the animations if they were not started or will restart() them if they were paused
  111509. * @param loop defines if animations must loop
  111510. * @returns the animation group
  111511. */
  111512. play(loop?: boolean): AnimationGroup;
  111513. /**
  111514. * Reset all animations to initial state
  111515. * @returns the animation group
  111516. */
  111517. reset(): AnimationGroup;
  111518. /**
  111519. * Restart animations from key 0
  111520. * @returns the animation group
  111521. */
  111522. restart(): AnimationGroup;
  111523. /**
  111524. * Stop all animations
  111525. * @returns the animation group
  111526. */
  111527. stop(): AnimationGroup;
  111528. /**
  111529. * Set animation weight for all animatables
  111530. * @param weight defines the weight to use
  111531. * @return the animationGroup
  111532. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  111533. */
  111534. setWeightForAllAnimatables(weight: number): AnimationGroup;
  111535. /**
  111536. * Synchronize and normalize all animatables with a source animatable
  111537. * @param root defines the root animatable to synchronize with
  111538. * @return the animationGroup
  111539. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  111540. */
  111541. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  111542. /**
  111543. * Goes to a specific frame in this animation group
  111544. * @param frame the frame number to go to
  111545. * @return the animationGroup
  111546. */
  111547. goToFrame(frame: number): AnimationGroup;
  111548. /**
  111549. * Dispose all associated resources
  111550. */
  111551. dispose(): void;
  111552. private _checkAnimationGroupEnded;
  111553. /**
  111554. * Clone the current animation group and returns a copy
  111555. * @param newName defines the name of the new group
  111556. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  111557. * @returns the new aniamtion group
  111558. */
  111559. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  111560. /**
  111561. * Serializes the animationGroup to an object
  111562. * @returns Serialized object
  111563. */
  111564. serialize(): any;
  111565. /**
  111566. * Returns a new AnimationGroup object parsed from the source provided.
  111567. * @param parsedAnimationGroup defines the source
  111568. * @param scene defines the scene that will receive the animationGroup
  111569. * @returns a new AnimationGroup
  111570. */
  111571. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  111572. /**
  111573. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  111574. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  111575. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  111576. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  111577. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  111578. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  111579. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  111580. */
  111581. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  111582. /**
  111583. * Returns the string "AnimationGroup"
  111584. * @returns "AnimationGroup"
  111585. */
  111586. getClassName(): string;
  111587. /**
  111588. * Creates a detailled string about the object
  111589. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  111590. * @returns a string representing the object
  111591. */
  111592. toString(fullDetails?: boolean): string;
  111593. }
  111594. }
  111595. declare module BABYLON {
  111596. /**
  111597. * Define an interface for all classes that will hold resources
  111598. */
  111599. export interface IDisposable {
  111600. /**
  111601. * Releases all held resources
  111602. */
  111603. dispose(): void;
  111604. }
  111605. /** Interface defining initialization parameters for Scene class */
  111606. export interface SceneOptions {
  111607. /**
  111608. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  111609. * It will improve performance when the number of geometries becomes important.
  111610. */
  111611. useGeometryUniqueIdsMap?: boolean;
  111612. /**
  111613. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  111614. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  111615. */
  111616. useMaterialMeshMap?: boolean;
  111617. /**
  111618. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  111619. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  111620. */
  111621. useClonedMeshMap?: boolean;
  111622. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  111623. virtual?: boolean;
  111624. }
  111625. /**
  111626. * Represents a scene to be rendered by the engine.
  111627. * @see http://doc.babylonjs.com/features/scene
  111628. */
  111629. export class Scene extends AbstractScene implements IAnimatable {
  111630. /** The fog is deactivated */
  111631. static readonly FOGMODE_NONE: number;
  111632. /** The fog density is following an exponential function */
  111633. static readonly FOGMODE_EXP: number;
  111634. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  111635. static readonly FOGMODE_EXP2: number;
  111636. /** The fog density is following a linear function. */
  111637. static readonly FOGMODE_LINEAR: number;
  111638. /**
  111639. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  111640. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  111641. */
  111642. static MinDeltaTime: number;
  111643. /**
  111644. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  111645. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  111646. */
  111647. static MaxDeltaTime: number;
  111648. /**
  111649. * Factory used to create the default material.
  111650. * @param name The name of the material to create
  111651. * @param scene The scene to create the material for
  111652. * @returns The default material
  111653. */
  111654. static DefaultMaterialFactory(scene: Scene): Material;
  111655. /**
  111656. * Factory used to create the a collision coordinator.
  111657. * @returns The collision coordinator
  111658. */
  111659. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  111660. /** @hidden */
  111661. _inputManager: InputManager;
  111662. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  111663. cameraToUseForPointers: Nullable<Camera>;
  111664. /** @hidden */
  111665. readonly _isScene: boolean;
  111666. /** @hidden */
  111667. _blockEntityCollection: boolean;
  111668. /**
  111669. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  111670. */
  111671. autoClear: boolean;
  111672. /**
  111673. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  111674. */
  111675. autoClearDepthAndStencil: boolean;
  111676. /**
  111677. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  111678. */
  111679. clearColor: Color4;
  111680. /**
  111681. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  111682. */
  111683. ambientColor: Color3;
  111684. /**
  111685. * This is use to store the default BRDF lookup for PBR materials in your scene.
  111686. * It should only be one of the following (if not the default embedded one):
  111687. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  111688. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  111689. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  111690. * The material properties need to be setup according to the type of texture in use.
  111691. */
  111692. environmentBRDFTexture: BaseTexture;
  111693. /** @hidden */
  111694. protected _environmentTexture: Nullable<BaseTexture>;
  111695. /**
  111696. * Texture used in all pbr material as the reflection texture.
  111697. * As in the majority of the scene they are the same (exception for multi room and so on),
  111698. * this is easier to reference from here than from all the materials.
  111699. */
  111700. get environmentTexture(): Nullable<BaseTexture>;
  111701. /**
  111702. * Texture used in all pbr material as the reflection texture.
  111703. * As in the majority of the scene they are the same (exception for multi room and so on),
  111704. * this is easier to set here than in all the materials.
  111705. */
  111706. set environmentTexture(value: Nullable<BaseTexture>);
  111707. /** @hidden */
  111708. protected _environmentIntensity: number;
  111709. /**
  111710. * Intensity of the environment in all pbr material.
  111711. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  111712. * As in the majority of the scene they are the same (exception for multi room and so on),
  111713. * this is easier to reference from here than from all the materials.
  111714. */
  111715. get environmentIntensity(): number;
  111716. /**
  111717. * Intensity of the environment in all pbr material.
  111718. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  111719. * As in the majority of the scene they are the same (exception for multi room and so on),
  111720. * this is easier to set here than in all the materials.
  111721. */
  111722. set environmentIntensity(value: number);
  111723. /** @hidden */
  111724. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  111725. /**
  111726. * Default image processing configuration used either in the rendering
  111727. * Forward main pass or through the imageProcessingPostProcess if present.
  111728. * As in the majority of the scene they are the same (exception for multi camera),
  111729. * this is easier to reference from here than from all the materials and post process.
  111730. *
  111731. * No setter as we it is a shared configuration, you can set the values instead.
  111732. */
  111733. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  111734. private _forceWireframe;
  111735. /**
  111736. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  111737. */
  111738. set forceWireframe(value: boolean);
  111739. get forceWireframe(): boolean;
  111740. private _skipFrustumClipping;
  111741. /**
  111742. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  111743. */
  111744. set skipFrustumClipping(value: boolean);
  111745. get skipFrustumClipping(): boolean;
  111746. private _forcePointsCloud;
  111747. /**
  111748. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  111749. */
  111750. set forcePointsCloud(value: boolean);
  111751. get forcePointsCloud(): boolean;
  111752. /**
  111753. * Gets or sets the active clipplane 1
  111754. */
  111755. clipPlane: Nullable<Plane>;
  111756. /**
  111757. * Gets or sets the active clipplane 2
  111758. */
  111759. clipPlane2: Nullable<Plane>;
  111760. /**
  111761. * Gets or sets the active clipplane 3
  111762. */
  111763. clipPlane3: Nullable<Plane>;
  111764. /**
  111765. * Gets or sets the active clipplane 4
  111766. */
  111767. clipPlane4: Nullable<Plane>;
  111768. /**
  111769. * Gets or sets the active clipplane 5
  111770. */
  111771. clipPlane5: Nullable<Plane>;
  111772. /**
  111773. * Gets or sets the active clipplane 6
  111774. */
  111775. clipPlane6: Nullable<Plane>;
  111776. /**
  111777. * Gets or sets a boolean indicating if animations are enabled
  111778. */
  111779. animationsEnabled: boolean;
  111780. private _animationPropertiesOverride;
  111781. /**
  111782. * Gets or sets the animation properties override
  111783. */
  111784. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  111785. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  111786. /**
  111787. * Gets or sets a boolean indicating if a constant deltatime has to be used
  111788. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  111789. */
  111790. useConstantAnimationDeltaTime: boolean;
  111791. /**
  111792. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  111793. * Please note that it requires to run a ray cast through the scene on every frame
  111794. */
  111795. constantlyUpdateMeshUnderPointer: boolean;
  111796. /**
  111797. * Defines the HTML cursor to use when hovering over interactive elements
  111798. */
  111799. hoverCursor: string;
  111800. /**
  111801. * Defines the HTML default cursor to use (empty by default)
  111802. */
  111803. defaultCursor: string;
  111804. /**
  111805. * Defines whether cursors are handled by the scene.
  111806. */
  111807. doNotHandleCursors: boolean;
  111808. /**
  111809. * This is used to call preventDefault() on pointer down
  111810. * in order to block unwanted artifacts like system double clicks
  111811. */
  111812. preventDefaultOnPointerDown: boolean;
  111813. /**
  111814. * This is used to call preventDefault() on pointer up
  111815. * in order to block unwanted artifacts like system double clicks
  111816. */
  111817. preventDefaultOnPointerUp: boolean;
  111818. /**
  111819. * Gets or sets user defined metadata
  111820. */
  111821. metadata: any;
  111822. /**
  111823. * For internal use only. Please do not use.
  111824. */
  111825. reservedDataStore: any;
  111826. /**
  111827. * Gets the name of the plugin used to load this scene (null by default)
  111828. */
  111829. loadingPluginName: string;
  111830. /**
  111831. * Use this array to add regular expressions used to disable offline support for specific urls
  111832. */
  111833. disableOfflineSupportExceptionRules: RegExp[];
  111834. /**
  111835. * An event triggered when the scene is disposed.
  111836. */
  111837. onDisposeObservable: Observable<Scene>;
  111838. private _onDisposeObserver;
  111839. /** Sets a function to be executed when this scene is disposed. */
  111840. set onDispose(callback: () => void);
  111841. /**
  111842. * An event triggered before rendering the scene (right after animations and physics)
  111843. */
  111844. onBeforeRenderObservable: Observable<Scene>;
  111845. private _onBeforeRenderObserver;
  111846. /** Sets a function to be executed before rendering this scene */
  111847. set beforeRender(callback: Nullable<() => void>);
  111848. /**
  111849. * An event triggered after rendering the scene
  111850. */
  111851. onAfterRenderObservable: Observable<Scene>;
  111852. /**
  111853. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  111854. */
  111855. onAfterRenderCameraObservable: Observable<Camera>;
  111856. private _onAfterRenderObserver;
  111857. /** Sets a function to be executed after rendering this scene */
  111858. set afterRender(callback: Nullable<() => void>);
  111859. /**
  111860. * An event triggered before animating the scene
  111861. */
  111862. onBeforeAnimationsObservable: Observable<Scene>;
  111863. /**
  111864. * An event triggered after animations processing
  111865. */
  111866. onAfterAnimationsObservable: Observable<Scene>;
  111867. /**
  111868. * An event triggered before draw calls are ready to be sent
  111869. */
  111870. onBeforeDrawPhaseObservable: Observable<Scene>;
  111871. /**
  111872. * An event triggered after draw calls have been sent
  111873. */
  111874. onAfterDrawPhaseObservable: Observable<Scene>;
  111875. /**
  111876. * An event triggered when the scene is ready
  111877. */
  111878. onReadyObservable: Observable<Scene>;
  111879. /**
  111880. * An event triggered before rendering a camera
  111881. */
  111882. onBeforeCameraRenderObservable: Observable<Camera>;
  111883. private _onBeforeCameraRenderObserver;
  111884. /** Sets a function to be executed before rendering a camera*/
  111885. set beforeCameraRender(callback: () => void);
  111886. /**
  111887. * An event triggered after rendering a camera
  111888. */
  111889. onAfterCameraRenderObservable: Observable<Camera>;
  111890. private _onAfterCameraRenderObserver;
  111891. /** Sets a function to be executed after rendering a camera*/
  111892. set afterCameraRender(callback: () => void);
  111893. /**
  111894. * An event triggered when active meshes evaluation is about to start
  111895. */
  111896. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  111897. /**
  111898. * An event triggered when active meshes evaluation is done
  111899. */
  111900. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  111901. /**
  111902. * An event triggered when particles rendering is about to start
  111903. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  111904. */
  111905. onBeforeParticlesRenderingObservable: Observable<Scene>;
  111906. /**
  111907. * An event triggered when particles rendering is done
  111908. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  111909. */
  111910. onAfterParticlesRenderingObservable: Observable<Scene>;
  111911. /**
  111912. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  111913. */
  111914. onDataLoadedObservable: Observable<Scene>;
  111915. /**
  111916. * An event triggered when a camera is created
  111917. */
  111918. onNewCameraAddedObservable: Observable<Camera>;
  111919. /**
  111920. * An event triggered when a camera is removed
  111921. */
  111922. onCameraRemovedObservable: Observable<Camera>;
  111923. /**
  111924. * An event triggered when a light is created
  111925. */
  111926. onNewLightAddedObservable: Observable<Light>;
  111927. /**
  111928. * An event triggered when a light is removed
  111929. */
  111930. onLightRemovedObservable: Observable<Light>;
  111931. /**
  111932. * An event triggered when a geometry is created
  111933. */
  111934. onNewGeometryAddedObservable: Observable<Geometry>;
  111935. /**
  111936. * An event triggered when a geometry is removed
  111937. */
  111938. onGeometryRemovedObservable: Observable<Geometry>;
  111939. /**
  111940. * An event triggered when a transform node is created
  111941. */
  111942. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  111943. /**
  111944. * An event triggered when a transform node is removed
  111945. */
  111946. onTransformNodeRemovedObservable: Observable<TransformNode>;
  111947. /**
  111948. * An event triggered when a mesh is created
  111949. */
  111950. onNewMeshAddedObservable: Observable<AbstractMesh>;
  111951. /**
  111952. * An event triggered when a mesh is removed
  111953. */
  111954. onMeshRemovedObservable: Observable<AbstractMesh>;
  111955. /**
  111956. * An event triggered when a skeleton is created
  111957. */
  111958. onNewSkeletonAddedObservable: Observable<Skeleton>;
  111959. /**
  111960. * An event triggered when a skeleton is removed
  111961. */
  111962. onSkeletonRemovedObservable: Observable<Skeleton>;
  111963. /**
  111964. * An event triggered when a material is created
  111965. */
  111966. onNewMaterialAddedObservable: Observable<Material>;
  111967. /**
  111968. * An event triggered when a material is removed
  111969. */
  111970. onMaterialRemovedObservable: Observable<Material>;
  111971. /**
  111972. * An event triggered when a texture is created
  111973. */
  111974. onNewTextureAddedObservable: Observable<BaseTexture>;
  111975. /**
  111976. * An event triggered when a texture is removed
  111977. */
  111978. onTextureRemovedObservable: Observable<BaseTexture>;
  111979. /**
  111980. * An event triggered when render targets are about to be rendered
  111981. * Can happen multiple times per frame.
  111982. */
  111983. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  111984. /**
  111985. * An event triggered when render targets were rendered.
  111986. * Can happen multiple times per frame.
  111987. */
  111988. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  111989. /**
  111990. * An event triggered before calculating deterministic simulation step
  111991. */
  111992. onBeforeStepObservable: Observable<Scene>;
  111993. /**
  111994. * An event triggered after calculating deterministic simulation step
  111995. */
  111996. onAfterStepObservable: Observable<Scene>;
  111997. /**
  111998. * An event triggered when the activeCamera property is updated
  111999. */
  112000. onActiveCameraChanged: Observable<Scene>;
  112001. /**
  112002. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  112003. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  112004. * 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)
  112005. */
  112006. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  112007. /**
  112008. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  112009. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  112010. * 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)
  112011. */
  112012. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  112013. /**
  112014. * This Observable will when a mesh has been imported into the scene.
  112015. */
  112016. onMeshImportedObservable: Observable<AbstractMesh>;
  112017. /**
  112018. * This Observable will when an animation file has been imported into the scene.
  112019. */
  112020. onAnimationFileImportedObservable: Observable<Scene>;
  112021. /**
  112022. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  112023. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  112024. */
  112025. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  112026. /** @hidden */
  112027. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  112028. /**
  112029. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  112030. */
  112031. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  112032. /**
  112033. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  112034. */
  112035. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  112036. /**
  112037. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  112038. */
  112039. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  112040. /** Callback called when a pointer move is detected */
  112041. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  112042. /** Callback called when a pointer down is detected */
  112043. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  112044. /** Callback called when a pointer up is detected */
  112045. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  112046. /** Callback called when a pointer pick is detected */
  112047. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  112048. /**
  112049. * 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).
  112050. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  112051. */
  112052. onPrePointerObservable: Observable<PointerInfoPre>;
  112053. /**
  112054. * Observable event triggered each time an input event is received from the rendering canvas
  112055. */
  112056. onPointerObservable: Observable<PointerInfo>;
  112057. /**
  112058. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  112059. */
  112060. get unTranslatedPointer(): Vector2;
  112061. /**
  112062. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  112063. */
  112064. static get DragMovementThreshold(): number;
  112065. static set DragMovementThreshold(value: number);
  112066. /**
  112067. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  112068. */
  112069. static get LongPressDelay(): number;
  112070. static set LongPressDelay(value: number);
  112071. /**
  112072. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  112073. */
  112074. static get DoubleClickDelay(): number;
  112075. static set DoubleClickDelay(value: number);
  112076. /** If you need to check double click without raising a single click at first click, enable this flag */
  112077. static get ExclusiveDoubleClickMode(): boolean;
  112078. static set ExclusiveDoubleClickMode(value: boolean);
  112079. /** @hidden */
  112080. _mirroredCameraPosition: Nullable<Vector3>;
  112081. /**
  112082. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  112083. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  112084. */
  112085. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  112086. /**
  112087. * Observable event triggered each time an keyboard event is received from the hosting window
  112088. */
  112089. onKeyboardObservable: Observable<KeyboardInfo>;
  112090. private _useRightHandedSystem;
  112091. /**
  112092. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  112093. */
  112094. set useRightHandedSystem(value: boolean);
  112095. get useRightHandedSystem(): boolean;
  112096. private _timeAccumulator;
  112097. private _currentStepId;
  112098. private _currentInternalStep;
  112099. /**
  112100. * Sets the step Id used by deterministic lock step
  112101. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  112102. * @param newStepId defines the step Id
  112103. */
  112104. setStepId(newStepId: number): void;
  112105. /**
  112106. * Gets the step Id used by deterministic lock step
  112107. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  112108. * @returns the step Id
  112109. */
  112110. getStepId(): number;
  112111. /**
  112112. * Gets the internal step used by deterministic lock step
  112113. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  112114. * @returns the internal step
  112115. */
  112116. getInternalStep(): number;
  112117. private _fogEnabled;
  112118. /**
  112119. * Gets or sets a boolean indicating if fog is enabled on this scene
  112120. * @see http://doc.babylonjs.com/babylon101/environment#fog
  112121. * (Default is true)
  112122. */
  112123. set fogEnabled(value: boolean);
  112124. get fogEnabled(): boolean;
  112125. private _fogMode;
  112126. /**
  112127. * Gets or sets the fog mode to use
  112128. * @see http://doc.babylonjs.com/babylon101/environment#fog
  112129. * | mode | value |
  112130. * | --- | --- |
  112131. * | FOGMODE_NONE | 0 |
  112132. * | FOGMODE_EXP | 1 |
  112133. * | FOGMODE_EXP2 | 2 |
  112134. * | FOGMODE_LINEAR | 3 |
  112135. */
  112136. set fogMode(value: number);
  112137. get fogMode(): number;
  112138. /**
  112139. * Gets or sets the fog color to use
  112140. * @see http://doc.babylonjs.com/babylon101/environment#fog
  112141. * (Default is Color3(0.2, 0.2, 0.3))
  112142. */
  112143. fogColor: Color3;
  112144. /**
  112145. * Gets or sets the fog density to use
  112146. * @see http://doc.babylonjs.com/babylon101/environment#fog
  112147. * (Default is 0.1)
  112148. */
  112149. fogDensity: number;
  112150. /**
  112151. * Gets or sets the fog start distance to use
  112152. * @see http://doc.babylonjs.com/babylon101/environment#fog
  112153. * (Default is 0)
  112154. */
  112155. fogStart: number;
  112156. /**
  112157. * Gets or sets the fog end distance to use
  112158. * @see http://doc.babylonjs.com/babylon101/environment#fog
  112159. * (Default is 1000)
  112160. */
  112161. fogEnd: number;
  112162. private _shadowsEnabled;
  112163. /**
  112164. * Gets or sets a boolean indicating if shadows are enabled on this scene
  112165. */
  112166. set shadowsEnabled(value: boolean);
  112167. get shadowsEnabled(): boolean;
  112168. private _lightsEnabled;
  112169. /**
  112170. * Gets or sets a boolean indicating if lights are enabled on this scene
  112171. */
  112172. set lightsEnabled(value: boolean);
  112173. get lightsEnabled(): boolean;
  112174. /** All of the active cameras added to this scene. */
  112175. activeCameras: Camera[];
  112176. /** @hidden */
  112177. _activeCamera: Nullable<Camera>;
  112178. /** Gets or sets the current active camera */
  112179. get activeCamera(): Nullable<Camera>;
  112180. set activeCamera(value: Nullable<Camera>);
  112181. private _defaultMaterial;
  112182. /** The default material used on meshes when no material is affected */
  112183. get defaultMaterial(): Material;
  112184. /** The default material used on meshes when no material is affected */
  112185. set defaultMaterial(value: Material);
  112186. private _texturesEnabled;
  112187. /**
  112188. * Gets or sets a boolean indicating if textures are enabled on this scene
  112189. */
  112190. set texturesEnabled(value: boolean);
  112191. get texturesEnabled(): boolean;
  112192. /**
  112193. * Gets or sets a boolean indicating if physic engines are enabled on this scene
  112194. */
  112195. physicsEnabled: boolean;
  112196. /**
  112197. * Gets or sets a boolean indicating if particles are enabled on this scene
  112198. */
  112199. particlesEnabled: boolean;
  112200. /**
  112201. * Gets or sets a boolean indicating if sprites are enabled on this scene
  112202. */
  112203. spritesEnabled: boolean;
  112204. private _skeletonsEnabled;
  112205. /**
  112206. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  112207. */
  112208. set skeletonsEnabled(value: boolean);
  112209. get skeletonsEnabled(): boolean;
  112210. /**
  112211. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  112212. */
  112213. lensFlaresEnabled: boolean;
  112214. /**
  112215. * Gets or sets a boolean indicating if collisions are enabled on this scene
  112216. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  112217. */
  112218. collisionsEnabled: boolean;
  112219. private _collisionCoordinator;
  112220. /** @hidden */
  112221. get collisionCoordinator(): ICollisionCoordinator;
  112222. /**
  112223. * Defines the gravity applied to this scene (used only for collisions)
  112224. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  112225. */
  112226. gravity: Vector3;
  112227. /**
  112228. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  112229. */
  112230. postProcessesEnabled: boolean;
  112231. /**
  112232. * The list of postprocesses added to the scene
  112233. */
  112234. postProcesses: PostProcess[];
  112235. /**
  112236. * Gets the current postprocess manager
  112237. */
  112238. postProcessManager: PostProcessManager;
  112239. /**
  112240. * Gets or sets a boolean indicating if render targets are enabled on this scene
  112241. */
  112242. renderTargetsEnabled: boolean;
  112243. /**
  112244. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  112245. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  112246. */
  112247. dumpNextRenderTargets: boolean;
  112248. /**
  112249. * The list of user defined render targets added to the scene
  112250. */
  112251. customRenderTargets: RenderTargetTexture[];
  112252. /**
  112253. * Defines if texture loading must be delayed
  112254. * If true, textures will only be loaded when they need to be rendered
  112255. */
  112256. useDelayedTextureLoading: boolean;
  112257. /**
  112258. * Gets the list of meshes imported to the scene through SceneLoader
  112259. */
  112260. importedMeshesFiles: String[];
  112261. /**
  112262. * Gets or sets a boolean indicating if probes are enabled on this scene
  112263. */
  112264. probesEnabled: boolean;
  112265. /**
  112266. * Gets or sets the current offline provider to use to store scene data
  112267. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  112268. */
  112269. offlineProvider: IOfflineProvider;
  112270. /**
  112271. * Gets or sets the action manager associated with the scene
  112272. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  112273. */
  112274. actionManager: AbstractActionManager;
  112275. private _meshesForIntersections;
  112276. /**
  112277. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  112278. */
  112279. proceduralTexturesEnabled: boolean;
  112280. private _engine;
  112281. private _totalVertices;
  112282. /** @hidden */
  112283. _activeIndices: PerfCounter;
  112284. /** @hidden */
  112285. _activeParticles: PerfCounter;
  112286. /** @hidden */
  112287. _activeBones: PerfCounter;
  112288. private _animationRatio;
  112289. /** @hidden */
  112290. _animationTimeLast: number;
  112291. /** @hidden */
  112292. _animationTime: number;
  112293. /**
  112294. * Gets or sets a general scale for animation speed
  112295. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  112296. */
  112297. animationTimeScale: number;
  112298. /** @hidden */
  112299. _cachedMaterial: Nullable<Material>;
  112300. /** @hidden */
  112301. _cachedEffect: Nullable<Effect>;
  112302. /** @hidden */
  112303. _cachedVisibility: Nullable<number>;
  112304. private _renderId;
  112305. private _frameId;
  112306. private _executeWhenReadyTimeoutId;
  112307. private _intermediateRendering;
  112308. private _viewUpdateFlag;
  112309. private _projectionUpdateFlag;
  112310. /** @hidden */
  112311. _toBeDisposed: Nullable<IDisposable>[];
  112312. private _activeRequests;
  112313. /** @hidden */
  112314. _pendingData: any[];
  112315. private _isDisposed;
  112316. /**
  112317. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  112318. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  112319. */
  112320. dispatchAllSubMeshesOfActiveMeshes: boolean;
  112321. private _activeMeshes;
  112322. private _processedMaterials;
  112323. private _renderTargets;
  112324. /** @hidden */
  112325. _activeParticleSystems: SmartArray<IParticleSystem>;
  112326. private _activeSkeletons;
  112327. private _softwareSkinnedMeshes;
  112328. private _renderingManager;
  112329. /** @hidden */
  112330. _activeAnimatables: Animatable[];
  112331. private _transformMatrix;
  112332. private _sceneUbo;
  112333. /** @hidden */
  112334. _viewMatrix: Matrix;
  112335. private _projectionMatrix;
  112336. /** @hidden */
  112337. _forcedViewPosition: Nullable<Vector3>;
  112338. /** @hidden */
  112339. _frustumPlanes: Plane[];
  112340. /**
  112341. * Gets the list of frustum planes (built from the active camera)
  112342. */
  112343. get frustumPlanes(): Plane[];
  112344. /**
  112345. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  112346. * This is useful if there are more lights that the maximum simulteanous authorized
  112347. */
  112348. requireLightSorting: boolean;
  112349. /** @hidden */
  112350. readonly useMaterialMeshMap: boolean;
  112351. /** @hidden */
  112352. readonly useClonedMeshMap: boolean;
  112353. private _externalData;
  112354. private _uid;
  112355. /**
  112356. * @hidden
  112357. * Backing store of defined scene components.
  112358. */
  112359. _components: ISceneComponent[];
  112360. /**
  112361. * @hidden
  112362. * Backing store of defined scene components.
  112363. */
  112364. _serializableComponents: ISceneSerializableComponent[];
  112365. /**
  112366. * List of components to register on the next registration step.
  112367. */
  112368. private _transientComponents;
  112369. /**
  112370. * Registers the transient components if needed.
  112371. */
  112372. private _registerTransientComponents;
  112373. /**
  112374. * @hidden
  112375. * Add a component to the scene.
  112376. * Note that the ccomponent could be registered on th next frame if this is called after
  112377. * the register component stage.
  112378. * @param component Defines the component to add to the scene
  112379. */
  112380. _addComponent(component: ISceneComponent): void;
  112381. /**
  112382. * @hidden
  112383. * Gets a component from the scene.
  112384. * @param name defines the name of the component to retrieve
  112385. * @returns the component or null if not present
  112386. */
  112387. _getComponent(name: string): Nullable<ISceneComponent>;
  112388. /**
  112389. * @hidden
  112390. * Defines the actions happening before camera updates.
  112391. */
  112392. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  112393. /**
  112394. * @hidden
  112395. * Defines the actions happening before clear the canvas.
  112396. */
  112397. _beforeClearStage: Stage<SimpleStageAction>;
  112398. /**
  112399. * @hidden
  112400. * Defines the actions when collecting render targets for the frame.
  112401. */
  112402. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  112403. /**
  112404. * @hidden
  112405. * Defines the actions happening for one camera in the frame.
  112406. */
  112407. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  112408. /**
  112409. * @hidden
  112410. * Defines the actions happening during the per mesh ready checks.
  112411. */
  112412. _isReadyForMeshStage: Stage<MeshStageAction>;
  112413. /**
  112414. * @hidden
  112415. * Defines the actions happening before evaluate active mesh checks.
  112416. */
  112417. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  112418. /**
  112419. * @hidden
  112420. * Defines the actions happening during the evaluate sub mesh checks.
  112421. */
  112422. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  112423. /**
  112424. * @hidden
  112425. * Defines the actions happening during the active mesh stage.
  112426. */
  112427. _activeMeshStage: Stage<ActiveMeshStageAction>;
  112428. /**
  112429. * @hidden
  112430. * Defines the actions happening during the per camera render target step.
  112431. */
  112432. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  112433. /**
  112434. * @hidden
  112435. * Defines the actions happening just before the active camera is drawing.
  112436. */
  112437. _beforeCameraDrawStage: Stage<CameraStageAction>;
  112438. /**
  112439. * @hidden
  112440. * Defines the actions happening just before a render target is drawing.
  112441. */
  112442. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  112443. /**
  112444. * @hidden
  112445. * Defines the actions happening just before a rendering group is drawing.
  112446. */
  112447. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  112448. /**
  112449. * @hidden
  112450. * Defines the actions happening just before a mesh is drawing.
  112451. */
  112452. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  112453. /**
  112454. * @hidden
  112455. * Defines the actions happening just after a mesh has been drawn.
  112456. */
  112457. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  112458. /**
  112459. * @hidden
  112460. * Defines the actions happening just after a rendering group has been drawn.
  112461. */
  112462. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  112463. /**
  112464. * @hidden
  112465. * Defines the actions happening just after the active camera has been drawn.
  112466. */
  112467. _afterCameraDrawStage: Stage<CameraStageAction>;
  112468. /**
  112469. * @hidden
  112470. * Defines the actions happening just after a render target has been drawn.
  112471. */
  112472. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  112473. /**
  112474. * @hidden
  112475. * Defines the actions happening just after rendering all cameras and computing intersections.
  112476. */
  112477. _afterRenderStage: Stage<SimpleStageAction>;
  112478. /**
  112479. * @hidden
  112480. * Defines the actions happening when a pointer move event happens.
  112481. */
  112482. _pointerMoveStage: Stage<PointerMoveStageAction>;
  112483. /**
  112484. * @hidden
  112485. * Defines the actions happening when a pointer down event happens.
  112486. */
  112487. _pointerDownStage: Stage<PointerUpDownStageAction>;
  112488. /**
  112489. * @hidden
  112490. * Defines the actions happening when a pointer up event happens.
  112491. */
  112492. _pointerUpStage: Stage<PointerUpDownStageAction>;
  112493. /**
  112494. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  112495. */
  112496. private geometriesByUniqueId;
  112497. /**
  112498. * Creates a new Scene
  112499. * @param engine defines the engine to use to render this scene
  112500. * @param options defines the scene options
  112501. */
  112502. constructor(engine: Engine, options?: SceneOptions);
  112503. /**
  112504. * Gets a string idenfifying the name of the class
  112505. * @returns "Scene" string
  112506. */
  112507. getClassName(): string;
  112508. private _defaultMeshCandidates;
  112509. /**
  112510. * @hidden
  112511. */
  112512. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  112513. private _defaultSubMeshCandidates;
  112514. /**
  112515. * @hidden
  112516. */
  112517. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  112518. /**
  112519. * Sets the default candidate providers for the scene.
  112520. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  112521. * and getCollidingSubMeshCandidates to their default function
  112522. */
  112523. setDefaultCandidateProviders(): void;
  112524. /**
  112525. * Gets the mesh that is currently under the pointer
  112526. */
  112527. get meshUnderPointer(): Nullable<AbstractMesh>;
  112528. /**
  112529. * Gets or sets the current on-screen X position of the pointer
  112530. */
  112531. get pointerX(): number;
  112532. set pointerX(value: number);
  112533. /**
  112534. * Gets or sets the current on-screen Y position of the pointer
  112535. */
  112536. get pointerY(): number;
  112537. set pointerY(value: number);
  112538. /**
  112539. * Gets the cached material (ie. the latest rendered one)
  112540. * @returns the cached material
  112541. */
  112542. getCachedMaterial(): Nullable<Material>;
  112543. /**
  112544. * Gets the cached effect (ie. the latest rendered one)
  112545. * @returns the cached effect
  112546. */
  112547. getCachedEffect(): Nullable<Effect>;
  112548. /**
  112549. * Gets the cached visibility state (ie. the latest rendered one)
  112550. * @returns the cached visibility state
  112551. */
  112552. getCachedVisibility(): Nullable<number>;
  112553. /**
  112554. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  112555. * @param material defines the current material
  112556. * @param effect defines the current effect
  112557. * @param visibility defines the current visibility state
  112558. * @returns true if one parameter is not cached
  112559. */
  112560. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  112561. /**
  112562. * Gets the engine associated with the scene
  112563. * @returns an Engine
  112564. */
  112565. getEngine(): Engine;
  112566. /**
  112567. * Gets the total number of vertices rendered per frame
  112568. * @returns the total number of vertices rendered per frame
  112569. */
  112570. getTotalVertices(): number;
  112571. /**
  112572. * Gets the performance counter for total vertices
  112573. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  112574. */
  112575. get totalVerticesPerfCounter(): PerfCounter;
  112576. /**
  112577. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  112578. * @returns the total number of active indices rendered per frame
  112579. */
  112580. getActiveIndices(): number;
  112581. /**
  112582. * Gets the performance counter for active indices
  112583. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  112584. */
  112585. get totalActiveIndicesPerfCounter(): PerfCounter;
  112586. /**
  112587. * Gets the total number of active particles rendered per frame
  112588. * @returns the total number of active particles rendered per frame
  112589. */
  112590. getActiveParticles(): number;
  112591. /**
  112592. * Gets the performance counter for active particles
  112593. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  112594. */
  112595. get activeParticlesPerfCounter(): PerfCounter;
  112596. /**
  112597. * Gets the total number of active bones rendered per frame
  112598. * @returns the total number of active bones rendered per frame
  112599. */
  112600. getActiveBones(): number;
  112601. /**
  112602. * Gets the performance counter for active bones
  112603. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  112604. */
  112605. get activeBonesPerfCounter(): PerfCounter;
  112606. /**
  112607. * Gets the array of active meshes
  112608. * @returns an array of AbstractMesh
  112609. */
  112610. getActiveMeshes(): SmartArray<AbstractMesh>;
  112611. /**
  112612. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  112613. * @returns a number
  112614. */
  112615. getAnimationRatio(): number;
  112616. /**
  112617. * Gets an unique Id for the current render phase
  112618. * @returns a number
  112619. */
  112620. getRenderId(): number;
  112621. /**
  112622. * Gets an unique Id for the current frame
  112623. * @returns a number
  112624. */
  112625. getFrameId(): number;
  112626. /** Call this function if you want to manually increment the render Id*/
  112627. incrementRenderId(): void;
  112628. private _createUbo;
  112629. /**
  112630. * Use this method to simulate a pointer move on a mesh
  112631. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  112632. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  112633. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  112634. * @returns the current scene
  112635. */
  112636. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  112637. /**
  112638. * Use this method to simulate a pointer down on a mesh
  112639. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  112640. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  112641. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  112642. * @returns the current scene
  112643. */
  112644. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  112645. /**
  112646. * Use this method to simulate a pointer up on a mesh
  112647. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  112648. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  112649. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  112650. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  112651. * @returns the current scene
  112652. */
  112653. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  112654. /**
  112655. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  112656. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  112657. * @returns true if the pointer was captured
  112658. */
  112659. isPointerCaptured(pointerId?: number): boolean;
  112660. /**
  112661. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  112662. * @param attachUp defines if you want to attach events to pointerup
  112663. * @param attachDown defines if you want to attach events to pointerdown
  112664. * @param attachMove defines if you want to attach events to pointermove
  112665. */
  112666. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  112667. /** Detaches all event handlers*/
  112668. detachControl(): void;
  112669. /**
  112670. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  112671. * Delay loaded resources are not taking in account
  112672. * @return true if all required resources are ready
  112673. */
  112674. isReady(): boolean;
  112675. /** Resets all cached information relative to material (including effect and visibility) */
  112676. resetCachedMaterial(): void;
  112677. /**
  112678. * Registers a function to be called before every frame render
  112679. * @param func defines the function to register
  112680. */
  112681. registerBeforeRender(func: () => void): void;
  112682. /**
  112683. * Unregisters a function called before every frame render
  112684. * @param func defines the function to unregister
  112685. */
  112686. unregisterBeforeRender(func: () => void): void;
  112687. /**
  112688. * Registers a function to be called after every frame render
  112689. * @param func defines the function to register
  112690. */
  112691. registerAfterRender(func: () => void): void;
  112692. /**
  112693. * Unregisters a function called after every frame render
  112694. * @param func defines the function to unregister
  112695. */
  112696. unregisterAfterRender(func: () => void): void;
  112697. private _executeOnceBeforeRender;
  112698. /**
  112699. * The provided function will run before render once and will be disposed afterwards.
  112700. * A timeout delay can be provided so that the function will be executed in N ms.
  112701. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  112702. * @param func The function to be executed.
  112703. * @param timeout optional delay in ms
  112704. */
  112705. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  112706. /** @hidden */
  112707. _addPendingData(data: any): void;
  112708. /** @hidden */
  112709. _removePendingData(data: any): void;
  112710. /**
  112711. * Returns the number of items waiting to be loaded
  112712. * @returns the number of items waiting to be loaded
  112713. */
  112714. getWaitingItemsCount(): number;
  112715. /**
  112716. * Returns a boolean indicating if the scene is still loading data
  112717. */
  112718. get isLoading(): boolean;
  112719. /**
  112720. * Registers a function to be executed when the scene is ready
  112721. * @param {Function} func - the function to be executed
  112722. */
  112723. executeWhenReady(func: () => void): void;
  112724. /**
  112725. * Returns a promise that resolves when the scene is ready
  112726. * @returns A promise that resolves when the scene is ready
  112727. */
  112728. whenReadyAsync(): Promise<void>;
  112729. /** @hidden */
  112730. _checkIsReady(): void;
  112731. /**
  112732. * Gets all animatable attached to the scene
  112733. */
  112734. get animatables(): Animatable[];
  112735. /**
  112736. * Resets the last animation time frame.
  112737. * Useful to override when animations start running when loading a scene for the first time.
  112738. */
  112739. resetLastAnimationTimeFrame(): void;
  112740. /**
  112741. * Gets the current view matrix
  112742. * @returns a Matrix
  112743. */
  112744. getViewMatrix(): Matrix;
  112745. /**
  112746. * Gets the current projection matrix
  112747. * @returns a Matrix
  112748. */
  112749. getProjectionMatrix(): Matrix;
  112750. /**
  112751. * Gets the current transform matrix
  112752. * @returns a Matrix made of View * Projection
  112753. */
  112754. getTransformMatrix(): Matrix;
  112755. /**
  112756. * Sets the current transform matrix
  112757. * @param viewL defines the View matrix to use
  112758. * @param projectionL defines the Projection matrix to use
  112759. * @param viewR defines the right View matrix to use (if provided)
  112760. * @param projectionR defines the right Projection matrix to use (if provided)
  112761. */
  112762. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  112763. /**
  112764. * Gets the uniform buffer used to store scene data
  112765. * @returns a UniformBuffer
  112766. */
  112767. getSceneUniformBuffer(): UniformBuffer;
  112768. /**
  112769. * Gets an unique (relatively to the current scene) Id
  112770. * @returns an unique number for the scene
  112771. */
  112772. getUniqueId(): number;
  112773. /**
  112774. * Add a mesh to the list of scene's meshes
  112775. * @param newMesh defines the mesh to add
  112776. * @param recursive if all child meshes should also be added to the scene
  112777. */
  112778. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  112779. /**
  112780. * Remove a mesh for the list of scene's meshes
  112781. * @param toRemove defines the mesh to remove
  112782. * @param recursive if all child meshes should also be removed from the scene
  112783. * @returns the index where the mesh was in the mesh list
  112784. */
  112785. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  112786. /**
  112787. * Add a transform node to the list of scene's transform nodes
  112788. * @param newTransformNode defines the transform node to add
  112789. */
  112790. addTransformNode(newTransformNode: TransformNode): void;
  112791. /**
  112792. * Remove a transform node for the list of scene's transform nodes
  112793. * @param toRemove defines the transform node to remove
  112794. * @returns the index where the transform node was in the transform node list
  112795. */
  112796. removeTransformNode(toRemove: TransformNode): number;
  112797. /**
  112798. * Remove a skeleton for the list of scene's skeletons
  112799. * @param toRemove defines the skeleton to remove
  112800. * @returns the index where the skeleton was in the skeleton list
  112801. */
  112802. removeSkeleton(toRemove: Skeleton): number;
  112803. /**
  112804. * Remove a morph target for the list of scene's morph targets
  112805. * @param toRemove defines the morph target to remove
  112806. * @returns the index where the morph target was in the morph target list
  112807. */
  112808. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  112809. /**
  112810. * Remove a light for the list of scene's lights
  112811. * @param toRemove defines the light to remove
  112812. * @returns the index where the light was in the light list
  112813. */
  112814. removeLight(toRemove: Light): number;
  112815. /**
  112816. * Remove a camera for the list of scene's cameras
  112817. * @param toRemove defines the camera to remove
  112818. * @returns the index where the camera was in the camera list
  112819. */
  112820. removeCamera(toRemove: Camera): number;
  112821. /**
  112822. * Remove a particle system for the list of scene's particle systems
  112823. * @param toRemove defines the particle system to remove
  112824. * @returns the index where the particle system was in the particle system list
  112825. */
  112826. removeParticleSystem(toRemove: IParticleSystem): number;
  112827. /**
  112828. * Remove a animation for the list of scene's animations
  112829. * @param toRemove defines the animation to remove
  112830. * @returns the index where the animation was in the animation list
  112831. */
  112832. removeAnimation(toRemove: Animation): number;
  112833. /**
  112834. * Will stop the animation of the given target
  112835. * @param target - the target
  112836. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  112837. * @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)
  112838. */
  112839. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  112840. /**
  112841. * Removes the given animation group from this scene.
  112842. * @param toRemove The animation group to remove
  112843. * @returns The index of the removed animation group
  112844. */
  112845. removeAnimationGroup(toRemove: AnimationGroup): number;
  112846. /**
  112847. * Removes the given multi-material from this scene.
  112848. * @param toRemove The multi-material to remove
  112849. * @returns The index of the removed multi-material
  112850. */
  112851. removeMultiMaterial(toRemove: MultiMaterial): number;
  112852. /**
  112853. * Removes the given material from this scene.
  112854. * @param toRemove The material to remove
  112855. * @returns The index of the removed material
  112856. */
  112857. removeMaterial(toRemove: Material): number;
  112858. /**
  112859. * Removes the given action manager from this scene.
  112860. * @param toRemove The action manager to remove
  112861. * @returns The index of the removed action manager
  112862. */
  112863. removeActionManager(toRemove: AbstractActionManager): number;
  112864. /**
  112865. * Removes the given texture from this scene.
  112866. * @param toRemove The texture to remove
  112867. * @returns The index of the removed texture
  112868. */
  112869. removeTexture(toRemove: BaseTexture): number;
  112870. /**
  112871. * Adds the given light to this scene
  112872. * @param newLight The light to add
  112873. */
  112874. addLight(newLight: Light): void;
  112875. /**
  112876. * Sorts the list list based on light priorities
  112877. */
  112878. sortLightsByPriority(): void;
  112879. /**
  112880. * Adds the given camera to this scene
  112881. * @param newCamera The camera to add
  112882. */
  112883. addCamera(newCamera: Camera): void;
  112884. /**
  112885. * Adds the given skeleton to this scene
  112886. * @param newSkeleton The skeleton to add
  112887. */
  112888. addSkeleton(newSkeleton: Skeleton): void;
  112889. /**
  112890. * Adds the given particle system to this scene
  112891. * @param newParticleSystem The particle system to add
  112892. */
  112893. addParticleSystem(newParticleSystem: IParticleSystem): void;
  112894. /**
  112895. * Adds the given animation to this scene
  112896. * @param newAnimation The animation to add
  112897. */
  112898. addAnimation(newAnimation: Animation): void;
  112899. /**
  112900. * Adds the given animation group to this scene.
  112901. * @param newAnimationGroup The animation group to add
  112902. */
  112903. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  112904. /**
  112905. * Adds the given multi-material to this scene
  112906. * @param newMultiMaterial The multi-material to add
  112907. */
  112908. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  112909. /**
  112910. * Adds the given material to this scene
  112911. * @param newMaterial The material to add
  112912. */
  112913. addMaterial(newMaterial: Material): void;
  112914. /**
  112915. * Adds the given morph target to this scene
  112916. * @param newMorphTargetManager The morph target to add
  112917. */
  112918. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  112919. /**
  112920. * Adds the given geometry to this scene
  112921. * @param newGeometry The geometry to add
  112922. */
  112923. addGeometry(newGeometry: Geometry): void;
  112924. /**
  112925. * Adds the given action manager to this scene
  112926. * @param newActionManager The action manager to add
  112927. */
  112928. addActionManager(newActionManager: AbstractActionManager): void;
  112929. /**
  112930. * Adds the given texture to this scene.
  112931. * @param newTexture The texture to add
  112932. */
  112933. addTexture(newTexture: BaseTexture): void;
  112934. /**
  112935. * Switch active camera
  112936. * @param newCamera defines the new active camera
  112937. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  112938. */
  112939. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  112940. /**
  112941. * sets the active camera of the scene using its ID
  112942. * @param id defines the camera's ID
  112943. * @return the new active camera or null if none found.
  112944. */
  112945. setActiveCameraByID(id: string): Nullable<Camera>;
  112946. /**
  112947. * sets the active camera of the scene using its name
  112948. * @param name defines the camera's name
  112949. * @returns the new active camera or null if none found.
  112950. */
  112951. setActiveCameraByName(name: string): Nullable<Camera>;
  112952. /**
  112953. * get an animation group using its name
  112954. * @param name defines the material's name
  112955. * @return the animation group or null if none found.
  112956. */
  112957. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  112958. /**
  112959. * Get a material using its unique id
  112960. * @param uniqueId defines the material's unique id
  112961. * @return the material or null if none found.
  112962. */
  112963. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  112964. /**
  112965. * get a material using its id
  112966. * @param id defines the material's ID
  112967. * @return the material or null if none found.
  112968. */
  112969. getMaterialByID(id: string): Nullable<Material>;
  112970. /**
  112971. * Gets a the last added material using a given id
  112972. * @param id defines the material's ID
  112973. * @return the last material with the given id or null if none found.
  112974. */
  112975. getLastMaterialByID(id: string): Nullable<Material>;
  112976. /**
  112977. * Gets a material using its name
  112978. * @param name defines the material's name
  112979. * @return the material or null if none found.
  112980. */
  112981. getMaterialByName(name: string): Nullable<Material>;
  112982. /**
  112983. * Get a texture using its unique id
  112984. * @param uniqueId defines the texture's unique id
  112985. * @return the texture or null if none found.
  112986. */
  112987. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  112988. /**
  112989. * Gets a camera using its id
  112990. * @param id defines the id to look for
  112991. * @returns the camera or null if not found
  112992. */
  112993. getCameraByID(id: string): Nullable<Camera>;
  112994. /**
  112995. * Gets a camera using its unique id
  112996. * @param uniqueId defines the unique id to look for
  112997. * @returns the camera or null if not found
  112998. */
  112999. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  113000. /**
  113001. * Gets a camera using its name
  113002. * @param name defines the camera's name
  113003. * @return the camera or null if none found.
  113004. */
  113005. getCameraByName(name: string): Nullable<Camera>;
  113006. /**
  113007. * Gets a bone using its id
  113008. * @param id defines the bone's id
  113009. * @return the bone or null if not found
  113010. */
  113011. getBoneByID(id: string): Nullable<Bone>;
  113012. /**
  113013. * Gets a bone using its id
  113014. * @param name defines the bone's name
  113015. * @return the bone or null if not found
  113016. */
  113017. getBoneByName(name: string): Nullable<Bone>;
  113018. /**
  113019. * Gets a light node using its name
  113020. * @param name defines the the light's name
  113021. * @return the light or null if none found.
  113022. */
  113023. getLightByName(name: string): Nullable<Light>;
  113024. /**
  113025. * Gets a light node using its id
  113026. * @param id defines the light's id
  113027. * @return the light or null if none found.
  113028. */
  113029. getLightByID(id: string): Nullable<Light>;
  113030. /**
  113031. * Gets a light node using its scene-generated unique ID
  113032. * @param uniqueId defines the light's unique id
  113033. * @return the light or null if none found.
  113034. */
  113035. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  113036. /**
  113037. * Gets a particle system by id
  113038. * @param id defines the particle system id
  113039. * @return the corresponding system or null if none found
  113040. */
  113041. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  113042. /**
  113043. * Gets a geometry using its ID
  113044. * @param id defines the geometry's id
  113045. * @return the geometry or null if none found.
  113046. */
  113047. getGeometryByID(id: string): Nullable<Geometry>;
  113048. private _getGeometryByUniqueID;
  113049. /**
  113050. * Add a new geometry to this scene
  113051. * @param geometry defines the geometry to be added to the scene.
  113052. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  113053. * @return a boolean defining if the geometry was added or not
  113054. */
  113055. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  113056. /**
  113057. * Removes an existing geometry
  113058. * @param geometry defines the geometry to be removed from the scene
  113059. * @return a boolean defining if the geometry was removed or not
  113060. */
  113061. removeGeometry(geometry: Geometry): boolean;
  113062. /**
  113063. * Gets the list of geometries attached to the scene
  113064. * @returns an array of Geometry
  113065. */
  113066. getGeometries(): Geometry[];
  113067. /**
  113068. * Gets the first added mesh found of a given ID
  113069. * @param id defines the id to search for
  113070. * @return the mesh found or null if not found at all
  113071. */
  113072. getMeshByID(id: string): Nullable<AbstractMesh>;
  113073. /**
  113074. * Gets a list of meshes using their id
  113075. * @param id defines the id to search for
  113076. * @returns a list of meshes
  113077. */
  113078. getMeshesByID(id: string): Array<AbstractMesh>;
  113079. /**
  113080. * Gets the first added transform node found of a given ID
  113081. * @param id defines the id to search for
  113082. * @return the found transform node or null if not found at all.
  113083. */
  113084. getTransformNodeByID(id: string): Nullable<TransformNode>;
  113085. /**
  113086. * Gets a transform node with its auto-generated unique id
  113087. * @param uniqueId efines the unique id to search for
  113088. * @return the found transform node or null if not found at all.
  113089. */
  113090. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  113091. /**
  113092. * Gets a list of transform nodes using their id
  113093. * @param id defines the id to search for
  113094. * @returns a list of transform nodes
  113095. */
  113096. getTransformNodesByID(id: string): Array<TransformNode>;
  113097. /**
  113098. * Gets a mesh with its auto-generated unique id
  113099. * @param uniqueId defines the unique id to search for
  113100. * @return the found mesh or null if not found at all.
  113101. */
  113102. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  113103. /**
  113104. * Gets a the last added mesh using a given id
  113105. * @param id defines the id to search for
  113106. * @return the found mesh or null if not found at all.
  113107. */
  113108. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  113109. /**
  113110. * Gets a the last added node (Mesh, Camera, Light) using a given id
  113111. * @param id defines the id to search for
  113112. * @return the found node or null if not found at all
  113113. */
  113114. getLastEntryByID(id: string): Nullable<Node>;
  113115. /**
  113116. * Gets a node (Mesh, Camera, Light) using a given id
  113117. * @param id defines the id to search for
  113118. * @return the found node or null if not found at all
  113119. */
  113120. getNodeByID(id: string): Nullable<Node>;
  113121. /**
  113122. * Gets a node (Mesh, Camera, Light) using a given name
  113123. * @param name defines the name to search for
  113124. * @return the found node or null if not found at all.
  113125. */
  113126. getNodeByName(name: string): Nullable<Node>;
  113127. /**
  113128. * Gets a mesh using a given name
  113129. * @param name defines the name to search for
  113130. * @return the found mesh or null if not found at all.
  113131. */
  113132. getMeshByName(name: string): Nullable<AbstractMesh>;
  113133. /**
  113134. * Gets a transform node using a given name
  113135. * @param name defines the name to search for
  113136. * @return the found transform node or null if not found at all.
  113137. */
  113138. getTransformNodeByName(name: string): Nullable<TransformNode>;
  113139. /**
  113140. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  113141. * @param id defines the id to search for
  113142. * @return the found skeleton or null if not found at all.
  113143. */
  113144. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  113145. /**
  113146. * Gets a skeleton using a given auto generated unique id
  113147. * @param uniqueId defines the unique id to search for
  113148. * @return the found skeleton or null if not found at all.
  113149. */
  113150. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  113151. /**
  113152. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  113153. * @param id defines the id to search for
  113154. * @return the found skeleton or null if not found at all.
  113155. */
  113156. getSkeletonById(id: string): Nullable<Skeleton>;
  113157. /**
  113158. * Gets a skeleton using a given name
  113159. * @param name defines the name to search for
  113160. * @return the found skeleton or null if not found at all.
  113161. */
  113162. getSkeletonByName(name: string): Nullable<Skeleton>;
  113163. /**
  113164. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  113165. * @param id defines the id to search for
  113166. * @return the found morph target manager or null if not found at all.
  113167. */
  113168. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  113169. /**
  113170. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  113171. * @param id defines the id to search for
  113172. * @return the found morph target or null if not found at all.
  113173. */
  113174. getMorphTargetById(id: string): Nullable<MorphTarget>;
  113175. /**
  113176. * Gets a morph target using a given name (if many are found, this function will pick the first one)
  113177. * @param name defines the name to search for
  113178. * @return the found morph target or null if not found at all.
  113179. */
  113180. getMorphTargetByName(name: string): Nullable<MorphTarget>;
  113181. /**
  113182. * Gets a boolean indicating if the given mesh is active
  113183. * @param mesh defines the mesh to look for
  113184. * @returns true if the mesh is in the active list
  113185. */
  113186. isActiveMesh(mesh: AbstractMesh): boolean;
  113187. /**
  113188. * Return a unique id as a string which can serve as an identifier for the scene
  113189. */
  113190. get uid(): string;
  113191. /**
  113192. * Add an externaly attached data from its key.
  113193. * This method call will fail and return false, if such key already exists.
  113194. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  113195. * @param key the unique key that identifies the data
  113196. * @param data the data object to associate to the key for this Engine instance
  113197. * @return true if no such key were already present and the data was added successfully, false otherwise
  113198. */
  113199. addExternalData<T>(key: string, data: T): boolean;
  113200. /**
  113201. * Get an externaly attached data from its key
  113202. * @param key the unique key that identifies the data
  113203. * @return the associated data, if present (can be null), or undefined if not present
  113204. */
  113205. getExternalData<T>(key: string): Nullable<T>;
  113206. /**
  113207. * Get an externaly attached data from its key, create it using a factory if it's not already present
  113208. * @param key the unique key that identifies the data
  113209. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  113210. * @return the associated data, can be null if the factory returned null.
  113211. */
  113212. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  113213. /**
  113214. * Remove an externaly attached data from the Engine instance
  113215. * @param key the unique key that identifies the data
  113216. * @return true if the data was successfully removed, false if it doesn't exist
  113217. */
  113218. removeExternalData(key: string): boolean;
  113219. private _evaluateSubMesh;
  113220. /**
  113221. * Clear the processed materials smart array preventing retention point in material dispose.
  113222. */
  113223. freeProcessedMaterials(): void;
  113224. private _preventFreeActiveMeshesAndRenderingGroups;
  113225. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  113226. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  113227. * when disposing several meshes in a row or a hierarchy of meshes.
  113228. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  113229. */
  113230. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  113231. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  113232. /**
  113233. * Clear the active meshes smart array preventing retention point in mesh dispose.
  113234. */
  113235. freeActiveMeshes(): void;
  113236. /**
  113237. * Clear the info related to rendering groups preventing retention points during dispose.
  113238. */
  113239. freeRenderingGroups(): void;
  113240. /** @hidden */
  113241. _isInIntermediateRendering(): boolean;
  113242. /**
  113243. * Lambda returning the list of potentially active meshes.
  113244. */
  113245. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  113246. /**
  113247. * Lambda returning the list of potentially active sub meshes.
  113248. */
  113249. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  113250. /**
  113251. * Lambda returning the list of potentially intersecting sub meshes.
  113252. */
  113253. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  113254. /**
  113255. * Lambda returning the list of potentially colliding sub meshes.
  113256. */
  113257. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  113258. private _activeMeshesFrozen;
  113259. private _skipEvaluateActiveMeshesCompletely;
  113260. /**
  113261. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  113262. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  113263. * @returns the current scene
  113264. */
  113265. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  113266. /**
  113267. * Use this function to restart evaluating active meshes on every frame
  113268. * @returns the current scene
  113269. */
  113270. unfreezeActiveMeshes(): Scene;
  113271. private _evaluateActiveMeshes;
  113272. private _activeMesh;
  113273. /**
  113274. * Update the transform matrix to update from the current active camera
  113275. * @param force defines a boolean used to force the update even if cache is up to date
  113276. */
  113277. updateTransformMatrix(force?: boolean): void;
  113278. private _bindFrameBuffer;
  113279. /** @hidden */
  113280. _allowPostProcessClearColor: boolean;
  113281. /** @hidden */
  113282. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  113283. private _processSubCameras;
  113284. private _checkIntersections;
  113285. /** @hidden */
  113286. _advancePhysicsEngineStep(step: number): void;
  113287. /**
  113288. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  113289. */
  113290. getDeterministicFrameTime: () => number;
  113291. /** @hidden */
  113292. _animate(): void;
  113293. /** Execute all animations (for a frame) */
  113294. animate(): void;
  113295. /**
  113296. * Render the scene
  113297. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  113298. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  113299. */
  113300. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  113301. /**
  113302. * Freeze all materials
  113303. * A frozen material will not be updatable but should be faster to render
  113304. */
  113305. freezeMaterials(): void;
  113306. /**
  113307. * Unfreeze all materials
  113308. * A frozen material will not be updatable but should be faster to render
  113309. */
  113310. unfreezeMaterials(): void;
  113311. /**
  113312. * Releases all held ressources
  113313. */
  113314. dispose(): void;
  113315. /**
  113316. * Gets if the scene is already disposed
  113317. */
  113318. get isDisposed(): boolean;
  113319. /**
  113320. * Call this function to reduce memory footprint of the scene.
  113321. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  113322. */
  113323. clearCachedVertexData(): void;
  113324. /**
  113325. * This function will remove the local cached buffer data from texture.
  113326. * It will save memory but will prevent the texture from being rebuilt
  113327. */
  113328. cleanCachedTextureBuffer(): void;
  113329. /**
  113330. * Get the world extend vectors with an optional filter
  113331. *
  113332. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  113333. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  113334. */
  113335. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  113336. min: Vector3;
  113337. max: Vector3;
  113338. };
  113339. /**
  113340. * Creates a ray that can be used to pick in the scene
  113341. * @param x defines the x coordinate of the origin (on-screen)
  113342. * @param y defines the y coordinate of the origin (on-screen)
  113343. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  113344. * @param camera defines the camera to use for the picking
  113345. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  113346. * @returns a Ray
  113347. */
  113348. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  113349. /**
  113350. * Creates a ray that can be used to pick in the scene
  113351. * @param x defines the x coordinate of the origin (on-screen)
  113352. * @param y defines the y coordinate of the origin (on-screen)
  113353. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  113354. * @param result defines the ray where to store the picking ray
  113355. * @param camera defines the camera to use for the picking
  113356. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  113357. * @returns the current scene
  113358. */
  113359. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  113360. /**
  113361. * Creates a ray that can be used to pick in the scene
  113362. * @param x defines the x coordinate of the origin (on-screen)
  113363. * @param y defines the y coordinate of the origin (on-screen)
  113364. * @param camera defines the camera to use for the picking
  113365. * @returns a Ray
  113366. */
  113367. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  113368. /**
  113369. * Creates a ray that can be used to pick in the scene
  113370. * @param x defines the x coordinate of the origin (on-screen)
  113371. * @param y defines the y coordinate of the origin (on-screen)
  113372. * @param result defines the ray where to store the picking ray
  113373. * @param camera defines the camera to use for the picking
  113374. * @returns the current scene
  113375. */
  113376. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  113377. /** Launch a ray to try to pick a mesh in the scene
  113378. * @param x position on screen
  113379. * @param y position on screen
  113380. * @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
  113381. * @param fastCheck defines if the first intersection will be used (and not the closest)
  113382. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  113383. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  113384. * @returns a PickingInfo
  113385. */
  113386. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  113387. /** Launch a ray to try to pick a mesh in the scene using only bounding information of the main mesh (not using submeshes)
  113388. * @param x position on screen
  113389. * @param y position on screen
  113390. * @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
  113391. * @param fastCheck defines if the first intersection will be used (and not the closest)
  113392. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  113393. * @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)
  113394. */
  113395. pickWithBoundingInfo(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  113396. /** Use the given ray to pick a mesh in the scene
  113397. * @param ray The ray to use to pick meshes
  113398. * @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
  113399. * @param fastCheck defines if the first intersection will be used (and not the closest)
  113400. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  113401. * @returns a PickingInfo
  113402. */
  113403. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  113404. /**
  113405. * Launch a ray to try to pick a mesh in the scene
  113406. * @param x X position on screen
  113407. * @param y Y position on screen
  113408. * @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
  113409. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  113410. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  113411. * @returns an array of PickingInfo
  113412. */
  113413. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  113414. /**
  113415. * Launch a ray to try to pick a mesh in the scene
  113416. * @param ray Ray to use
  113417. * @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
  113418. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  113419. * @returns an array of PickingInfo
  113420. */
  113421. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  113422. /**
  113423. * Force the value of meshUnderPointer
  113424. * @param mesh defines the mesh to use
  113425. */
  113426. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  113427. /**
  113428. * Gets the mesh under the pointer
  113429. * @returns a Mesh or null if no mesh is under the pointer
  113430. */
  113431. getPointerOverMesh(): Nullable<AbstractMesh>;
  113432. /** @hidden */
  113433. _rebuildGeometries(): void;
  113434. /** @hidden */
  113435. _rebuildTextures(): void;
  113436. private _getByTags;
  113437. /**
  113438. * Get a list of meshes by tags
  113439. * @param tagsQuery defines the tags query to use
  113440. * @param forEach defines a predicate used to filter results
  113441. * @returns an array of Mesh
  113442. */
  113443. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  113444. /**
  113445. * Get a list of cameras by tags
  113446. * @param tagsQuery defines the tags query to use
  113447. * @param forEach defines a predicate used to filter results
  113448. * @returns an array of Camera
  113449. */
  113450. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  113451. /**
  113452. * Get a list of lights by tags
  113453. * @param tagsQuery defines the tags query to use
  113454. * @param forEach defines a predicate used to filter results
  113455. * @returns an array of Light
  113456. */
  113457. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  113458. /**
  113459. * Get a list of materials by tags
  113460. * @param tagsQuery defines the tags query to use
  113461. * @param forEach defines a predicate used to filter results
  113462. * @returns an array of Material
  113463. */
  113464. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  113465. /**
  113466. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  113467. * This allowed control for front to back rendering or reversly depending of the special needs.
  113468. *
  113469. * @param renderingGroupId The rendering group id corresponding to its index
  113470. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  113471. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  113472. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  113473. */
  113474. 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;
  113475. /**
  113476. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  113477. *
  113478. * @param renderingGroupId The rendering group id corresponding to its index
  113479. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  113480. * @param depth Automatically clears depth between groups if true and autoClear is true.
  113481. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  113482. */
  113483. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  113484. /**
  113485. * Gets the current auto clear configuration for one rendering group of the rendering
  113486. * manager.
  113487. * @param index the rendering group index to get the information for
  113488. * @returns The auto clear setup for the requested rendering group
  113489. */
  113490. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  113491. private _blockMaterialDirtyMechanism;
  113492. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  113493. get blockMaterialDirtyMechanism(): boolean;
  113494. set blockMaterialDirtyMechanism(value: boolean);
  113495. /**
  113496. * Will flag all materials as dirty to trigger new shader compilation
  113497. * @param flag defines the flag used to specify which material part must be marked as dirty
  113498. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  113499. */
  113500. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  113501. /** @hidden */
  113502. _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;
  113503. /** @hidden */
  113504. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  113505. /** @hidden */
  113506. _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;
  113507. /** @hidden */
  113508. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  113509. /** @hidden */
  113510. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  113511. /** @hidden */
  113512. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  113513. }
  113514. }
  113515. declare module BABYLON {
  113516. /**
  113517. * Set of assets to keep when moving a scene into an asset container.
  113518. */
  113519. export class KeepAssets extends AbstractScene {
  113520. }
  113521. /**
  113522. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  113523. */
  113524. export class InstantiatedEntries {
  113525. /**
  113526. * List of new root nodes (eg. nodes with no parent)
  113527. */
  113528. rootNodes: TransformNode[];
  113529. /**
  113530. * List of new skeletons
  113531. */
  113532. skeletons: Skeleton[];
  113533. /**
  113534. * List of new animation groups
  113535. */
  113536. animationGroups: AnimationGroup[];
  113537. }
  113538. /**
  113539. * Container with a set of assets that can be added or removed from a scene.
  113540. */
  113541. export class AssetContainer extends AbstractScene {
  113542. private _wasAddedToScene;
  113543. /**
  113544. * The scene the AssetContainer belongs to.
  113545. */
  113546. scene: Scene;
  113547. /**
  113548. * Instantiates an AssetContainer.
  113549. * @param scene The scene the AssetContainer belongs to.
  113550. */
  113551. constructor(scene: Scene);
  113552. /**
  113553. * Instantiate or clone all meshes and add the new ones to the scene.
  113554. * Skeletons and animation groups will all be cloned
  113555. * @param nameFunction defines an optional function used to get new names for clones
  113556. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  113557. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  113558. */
  113559. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  113560. /**
  113561. * Adds all the assets from the container to the scene.
  113562. */
  113563. addAllToScene(): void;
  113564. /**
  113565. * Removes all the assets in the container from the scene
  113566. */
  113567. removeAllFromScene(): void;
  113568. /**
  113569. * Disposes all the assets in the container
  113570. */
  113571. dispose(): void;
  113572. private _moveAssets;
  113573. /**
  113574. * Removes all the assets contained in the scene and adds them to the container.
  113575. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  113576. */
  113577. moveAllFromScene(keepAssets?: KeepAssets): void;
  113578. /**
  113579. * 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.
  113580. * @returns the root mesh
  113581. */
  113582. createRootMesh(): Mesh;
  113583. /**
  113584. * Merge animations (direct and animation groups) from this asset container into a scene
  113585. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  113586. * @param animatables set of animatables to retarget to a node from the scene
  113587. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  113588. * @returns an array of the new AnimationGroup added to the scene (empty array if none)
  113589. */
  113590. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): AnimationGroup[];
  113591. }
  113592. }
  113593. declare module BABYLON {
  113594. /**
  113595. * Defines how the parser contract is defined.
  113596. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  113597. */
  113598. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  113599. /**
  113600. * Defines how the individual parser contract is defined.
  113601. * These parser can parse an individual asset
  113602. */
  113603. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  113604. /**
  113605. * Base class of the scene acting as a container for the different elements composing a scene.
  113606. * This class is dynamically extended by the different components of the scene increasing
  113607. * flexibility and reducing coupling
  113608. */
  113609. export abstract class AbstractScene {
  113610. /**
  113611. * Stores the list of available parsers in the application.
  113612. */
  113613. private static _BabylonFileParsers;
  113614. /**
  113615. * Stores the list of available individual parsers in the application.
  113616. */
  113617. private static _IndividualBabylonFileParsers;
  113618. /**
  113619. * Adds a parser in the list of available ones
  113620. * @param name Defines the name of the parser
  113621. * @param parser Defines the parser to add
  113622. */
  113623. static AddParser(name: string, parser: BabylonFileParser): void;
  113624. /**
  113625. * Gets a general parser from the list of avaialble ones
  113626. * @param name Defines the name of the parser
  113627. * @returns the requested parser or null
  113628. */
  113629. static GetParser(name: string): Nullable<BabylonFileParser>;
  113630. /**
  113631. * Adds n individual parser in the list of available ones
  113632. * @param name Defines the name of the parser
  113633. * @param parser Defines the parser to add
  113634. */
  113635. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  113636. /**
  113637. * Gets an individual parser from the list of avaialble ones
  113638. * @param name Defines the name of the parser
  113639. * @returns the requested parser or null
  113640. */
  113641. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  113642. /**
  113643. * Parser json data and populate both a scene and its associated container object
  113644. * @param jsonData Defines the data to parse
  113645. * @param scene Defines the scene to parse the data for
  113646. * @param container Defines the container attached to the parsing sequence
  113647. * @param rootUrl Defines the root url of the data
  113648. */
  113649. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  113650. /**
  113651. * Gets the list of root nodes (ie. nodes with no parent)
  113652. */
  113653. rootNodes: Node[];
  113654. /** All of the cameras added to this scene
  113655. * @see http://doc.babylonjs.com/babylon101/cameras
  113656. */
  113657. cameras: Camera[];
  113658. /**
  113659. * All of the lights added to this scene
  113660. * @see http://doc.babylonjs.com/babylon101/lights
  113661. */
  113662. lights: Light[];
  113663. /**
  113664. * All of the (abstract) meshes added to this scene
  113665. */
  113666. meshes: AbstractMesh[];
  113667. /**
  113668. * The list of skeletons added to the scene
  113669. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  113670. */
  113671. skeletons: Skeleton[];
  113672. /**
  113673. * All of the particle systems added to this scene
  113674. * @see http://doc.babylonjs.com/babylon101/particles
  113675. */
  113676. particleSystems: IParticleSystem[];
  113677. /**
  113678. * Gets a list of Animations associated with the scene
  113679. */
  113680. animations: Animation[];
  113681. /**
  113682. * All of the animation groups added to this scene
  113683. * @see http://doc.babylonjs.com/how_to/group
  113684. */
  113685. animationGroups: AnimationGroup[];
  113686. /**
  113687. * All of the multi-materials added to this scene
  113688. * @see http://doc.babylonjs.com/how_to/multi_materials
  113689. */
  113690. multiMaterials: MultiMaterial[];
  113691. /**
  113692. * All of the materials added to this scene
  113693. * In the context of a Scene, it is not supposed to be modified manually.
  113694. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  113695. * Note also that the order of the Material within the array is not significant and might change.
  113696. * @see http://doc.babylonjs.com/babylon101/materials
  113697. */
  113698. materials: Material[];
  113699. /**
  113700. * The list of morph target managers added to the scene
  113701. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  113702. */
  113703. morphTargetManagers: MorphTargetManager[];
  113704. /**
  113705. * The list of geometries used in the scene.
  113706. */
  113707. geometries: Geometry[];
  113708. /**
  113709. * All of the tranform nodes added to this scene
  113710. * In the context of a Scene, it is not supposed to be modified manually.
  113711. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  113712. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  113713. * @see http://doc.babylonjs.com/how_to/transformnode
  113714. */
  113715. transformNodes: TransformNode[];
  113716. /**
  113717. * ActionManagers available on the scene.
  113718. */
  113719. actionManagers: AbstractActionManager[];
  113720. /**
  113721. * Textures to keep.
  113722. */
  113723. textures: BaseTexture[];
  113724. /**
  113725. * Environment texture for the scene
  113726. */
  113727. environmentTexture: Nullable<BaseTexture>;
  113728. /**
  113729. * @returns all meshes, lights, cameras, transformNodes and bones
  113730. */
  113731. getNodes(): Array<Node>;
  113732. }
  113733. }
  113734. declare module BABYLON {
  113735. /**
  113736. * Interface used to define options for Sound class
  113737. */
  113738. export interface ISoundOptions {
  113739. /**
  113740. * Does the sound autoplay once loaded.
  113741. */
  113742. autoplay?: boolean;
  113743. /**
  113744. * Does the sound loop after it finishes playing once.
  113745. */
  113746. loop?: boolean;
  113747. /**
  113748. * Sound's volume
  113749. */
  113750. volume?: number;
  113751. /**
  113752. * Is it a spatial sound?
  113753. */
  113754. spatialSound?: boolean;
  113755. /**
  113756. * Maximum distance to hear that sound
  113757. */
  113758. maxDistance?: number;
  113759. /**
  113760. * Uses user defined attenuation function
  113761. */
  113762. useCustomAttenuation?: boolean;
  113763. /**
  113764. * Define the roll off factor of spatial sounds.
  113765. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  113766. */
  113767. rolloffFactor?: number;
  113768. /**
  113769. * Define the reference distance the sound should be heard perfectly.
  113770. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  113771. */
  113772. refDistance?: number;
  113773. /**
  113774. * Define the distance attenuation model the sound will follow.
  113775. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  113776. */
  113777. distanceModel?: string;
  113778. /**
  113779. * Defines the playback speed (1 by default)
  113780. */
  113781. playbackRate?: number;
  113782. /**
  113783. * Defines if the sound is from a streaming source
  113784. */
  113785. streaming?: boolean;
  113786. /**
  113787. * Defines an optional length (in seconds) inside the sound file
  113788. */
  113789. length?: number;
  113790. /**
  113791. * Defines an optional offset (in seconds) inside the sound file
  113792. */
  113793. offset?: number;
  113794. /**
  113795. * If true, URLs will not be required to state the audio file codec to use.
  113796. */
  113797. skipCodecCheck?: boolean;
  113798. }
  113799. /**
  113800. * Defines a sound that can be played in the application.
  113801. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  113802. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  113803. */
  113804. export class Sound {
  113805. /**
  113806. * The name of the sound in the scene.
  113807. */
  113808. name: string;
  113809. /**
  113810. * Does the sound autoplay once loaded.
  113811. */
  113812. autoplay: boolean;
  113813. /**
  113814. * Does the sound loop after it finishes playing once.
  113815. */
  113816. loop: boolean;
  113817. /**
  113818. * Does the sound use a custom attenuation curve to simulate the falloff
  113819. * happening when the source gets further away from the camera.
  113820. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  113821. */
  113822. useCustomAttenuation: boolean;
  113823. /**
  113824. * The sound track id this sound belongs to.
  113825. */
  113826. soundTrackId: number;
  113827. /**
  113828. * Is this sound currently played.
  113829. */
  113830. isPlaying: boolean;
  113831. /**
  113832. * Is this sound currently paused.
  113833. */
  113834. isPaused: boolean;
  113835. /**
  113836. * Does this sound enables spatial sound.
  113837. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  113838. */
  113839. spatialSound: boolean;
  113840. /**
  113841. * Define the reference distance the sound should be heard perfectly.
  113842. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  113843. */
  113844. refDistance: number;
  113845. /**
  113846. * Define the roll off factor of spatial sounds.
  113847. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  113848. */
  113849. rolloffFactor: number;
  113850. /**
  113851. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  113852. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  113853. */
  113854. maxDistance: number;
  113855. /**
  113856. * Define the distance attenuation model the sound will follow.
  113857. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  113858. */
  113859. distanceModel: string;
  113860. /**
  113861. * @hidden
  113862. * Back Compat
  113863. **/
  113864. onended: () => any;
  113865. /**
  113866. * Observable event when the current playing sound finishes.
  113867. */
  113868. onEndedObservable: Observable<Sound>;
  113869. private _panningModel;
  113870. private _playbackRate;
  113871. private _streaming;
  113872. private _startTime;
  113873. private _startOffset;
  113874. private _position;
  113875. /** @hidden */
  113876. _positionInEmitterSpace: boolean;
  113877. private _localDirection;
  113878. private _volume;
  113879. private _isReadyToPlay;
  113880. private _isDirectional;
  113881. private _readyToPlayCallback;
  113882. private _audioBuffer;
  113883. private _soundSource;
  113884. private _streamingSource;
  113885. private _soundPanner;
  113886. private _soundGain;
  113887. private _inputAudioNode;
  113888. private _outputAudioNode;
  113889. private _coneInnerAngle;
  113890. private _coneOuterAngle;
  113891. private _coneOuterGain;
  113892. private _scene;
  113893. private _connectedTransformNode;
  113894. private _customAttenuationFunction;
  113895. private _registerFunc;
  113896. private _isOutputConnected;
  113897. private _htmlAudioElement;
  113898. private _urlType;
  113899. private _length?;
  113900. private _offset?;
  113901. /** @hidden */
  113902. static _SceneComponentInitialization: (scene: Scene) => void;
  113903. /**
  113904. * Create a sound and attach it to a scene
  113905. * @param name Name of your sound
  113906. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  113907. * @param scene defines the scene the sound belongs to
  113908. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  113909. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  113910. */
  113911. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  113912. /**
  113913. * Release the sound and its associated resources
  113914. */
  113915. dispose(): void;
  113916. /**
  113917. * Gets if the sounds is ready to be played or not.
  113918. * @returns true if ready, otherwise false
  113919. */
  113920. isReady(): boolean;
  113921. private _soundLoaded;
  113922. /**
  113923. * Sets the data of the sound from an audiobuffer
  113924. * @param audioBuffer The audioBuffer containing the data
  113925. */
  113926. setAudioBuffer(audioBuffer: AudioBuffer): void;
  113927. /**
  113928. * Updates the current sounds options such as maxdistance, loop...
  113929. * @param options A JSON object containing values named as the object properties
  113930. */
  113931. updateOptions(options: ISoundOptions): void;
  113932. private _createSpatialParameters;
  113933. private _updateSpatialParameters;
  113934. /**
  113935. * Switch the panning model to HRTF:
  113936. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  113937. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  113938. */
  113939. switchPanningModelToHRTF(): void;
  113940. /**
  113941. * Switch the panning model to Equal Power:
  113942. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  113943. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  113944. */
  113945. switchPanningModelToEqualPower(): void;
  113946. private _switchPanningModel;
  113947. /**
  113948. * Connect this sound to a sound track audio node like gain...
  113949. * @param soundTrackAudioNode the sound track audio node to connect to
  113950. */
  113951. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  113952. /**
  113953. * Transform this sound into a directional source
  113954. * @param coneInnerAngle Size of the inner cone in degree
  113955. * @param coneOuterAngle Size of the outer cone in degree
  113956. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  113957. */
  113958. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  113959. /**
  113960. * Gets or sets the inner angle for the directional cone.
  113961. */
  113962. get directionalConeInnerAngle(): number;
  113963. /**
  113964. * Gets or sets the inner angle for the directional cone.
  113965. */
  113966. set directionalConeInnerAngle(value: number);
  113967. /**
  113968. * Gets or sets the outer angle for the directional cone.
  113969. */
  113970. get directionalConeOuterAngle(): number;
  113971. /**
  113972. * Gets or sets the outer angle for the directional cone.
  113973. */
  113974. set directionalConeOuterAngle(value: number);
  113975. /**
  113976. * Sets the position of the emitter if spatial sound is enabled
  113977. * @param newPosition Defines the new posisiton
  113978. */
  113979. setPosition(newPosition: Vector3): void;
  113980. /**
  113981. * Sets the local direction of the emitter if spatial sound is enabled
  113982. * @param newLocalDirection Defines the new local direction
  113983. */
  113984. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  113985. private _updateDirection;
  113986. /** @hidden */
  113987. updateDistanceFromListener(): void;
  113988. /**
  113989. * Sets a new custom attenuation function for the sound.
  113990. * @param callback Defines the function used for the attenuation
  113991. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  113992. */
  113993. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  113994. /**
  113995. * Play the sound
  113996. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  113997. * @param offset (optional) Start the sound at a specific time in seconds
  113998. * @param length (optional) Sound duration (in seconds)
  113999. */
  114000. play(time?: number, offset?: number, length?: number): void;
  114001. private _onended;
  114002. /**
  114003. * Stop the sound
  114004. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  114005. */
  114006. stop(time?: number): void;
  114007. /**
  114008. * Put the sound in pause
  114009. */
  114010. pause(): void;
  114011. /**
  114012. * Sets a dedicated volume for this sounds
  114013. * @param newVolume Define the new volume of the sound
  114014. * @param time Define time for gradual change to new volume
  114015. */
  114016. setVolume(newVolume: number, time?: number): void;
  114017. /**
  114018. * Set the sound play back rate
  114019. * @param newPlaybackRate Define the playback rate the sound should be played at
  114020. */
  114021. setPlaybackRate(newPlaybackRate: number): void;
  114022. /**
  114023. * Gets the volume of the sound.
  114024. * @returns the volume of the sound
  114025. */
  114026. getVolume(): number;
  114027. /**
  114028. * Attach the sound to a dedicated mesh
  114029. * @param transformNode The transform node to connect the sound with
  114030. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  114031. */
  114032. attachToMesh(transformNode: TransformNode): void;
  114033. /**
  114034. * Detach the sound from the previously attached mesh
  114035. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  114036. */
  114037. detachFromMesh(): void;
  114038. private _onRegisterAfterWorldMatrixUpdate;
  114039. /**
  114040. * Clone the current sound in the scene.
  114041. * @returns the new sound clone
  114042. */
  114043. clone(): Nullable<Sound>;
  114044. /**
  114045. * Gets the current underlying audio buffer containing the data
  114046. * @returns the audio buffer
  114047. */
  114048. getAudioBuffer(): Nullable<AudioBuffer>;
  114049. /**
  114050. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  114051. * @returns the source node
  114052. */
  114053. getSoundSource(): Nullable<AudioBufferSourceNode>;
  114054. /**
  114055. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  114056. * @returns the gain node
  114057. */
  114058. getSoundGain(): Nullable<GainNode>;
  114059. /**
  114060. * Serializes the Sound in a JSON representation
  114061. * @returns the JSON representation of the sound
  114062. */
  114063. serialize(): any;
  114064. /**
  114065. * Parse a JSON representation of a sound to innstantiate in a given scene
  114066. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  114067. * @param scene Define the scene the new parsed sound should be created in
  114068. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  114069. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  114070. * @returns the newly parsed sound
  114071. */
  114072. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  114073. }
  114074. }
  114075. declare module BABYLON {
  114076. /**
  114077. * This defines an action helpful to play a defined sound on a triggered action.
  114078. */
  114079. export class PlaySoundAction extends Action {
  114080. private _sound;
  114081. /**
  114082. * Instantiate the action
  114083. * @param triggerOptions defines the trigger options
  114084. * @param sound defines the sound to play
  114085. * @param condition defines the trigger related conditions
  114086. */
  114087. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  114088. /** @hidden */
  114089. _prepare(): void;
  114090. /**
  114091. * Execute the action and play the sound.
  114092. */
  114093. execute(): void;
  114094. /**
  114095. * Serializes the actions and its related information.
  114096. * @param parent defines the object to serialize in
  114097. * @returns the serialized object
  114098. */
  114099. serialize(parent: any): any;
  114100. }
  114101. /**
  114102. * This defines an action helpful to stop a defined sound on a triggered action.
  114103. */
  114104. export class StopSoundAction extends Action {
  114105. private _sound;
  114106. /**
  114107. * Instantiate the action
  114108. * @param triggerOptions defines the trigger options
  114109. * @param sound defines the sound to stop
  114110. * @param condition defines the trigger related conditions
  114111. */
  114112. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  114113. /** @hidden */
  114114. _prepare(): void;
  114115. /**
  114116. * Execute the action and stop the sound.
  114117. */
  114118. execute(): void;
  114119. /**
  114120. * Serializes the actions and its related information.
  114121. * @param parent defines the object to serialize in
  114122. * @returns the serialized object
  114123. */
  114124. serialize(parent: any): any;
  114125. }
  114126. }
  114127. declare module BABYLON {
  114128. /**
  114129. * This defines an action responsible to change the value of a property
  114130. * by interpolating between its current value and the newly set one once triggered.
  114131. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  114132. */
  114133. export class InterpolateValueAction extends Action {
  114134. /**
  114135. * Defines the path of the property where the value should be interpolated
  114136. */
  114137. propertyPath: string;
  114138. /**
  114139. * Defines the target value at the end of the interpolation.
  114140. */
  114141. value: any;
  114142. /**
  114143. * Defines the time it will take for the property to interpolate to the value.
  114144. */
  114145. duration: number;
  114146. /**
  114147. * Defines if the other scene animations should be stopped when the action has been triggered
  114148. */
  114149. stopOtherAnimations?: boolean;
  114150. /**
  114151. * Defines a callback raised once the interpolation animation has been done.
  114152. */
  114153. onInterpolationDone?: () => void;
  114154. /**
  114155. * Observable triggered once the interpolation animation has been done.
  114156. */
  114157. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  114158. private _target;
  114159. private _effectiveTarget;
  114160. private _property;
  114161. /**
  114162. * Instantiate the action
  114163. * @param triggerOptions defines the trigger options
  114164. * @param target defines the object containing the value to interpolate
  114165. * @param propertyPath defines the path to the property in the target object
  114166. * @param value defines the target value at the end of the interpolation
  114167. * @param duration deines the time it will take for the property to interpolate to the value.
  114168. * @param condition defines the trigger related conditions
  114169. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  114170. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  114171. */
  114172. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  114173. /** @hidden */
  114174. _prepare(): void;
  114175. /**
  114176. * Execute the action starts the value interpolation.
  114177. */
  114178. execute(): void;
  114179. /**
  114180. * Serializes the actions and its related information.
  114181. * @param parent defines the object to serialize in
  114182. * @returns the serialized object
  114183. */
  114184. serialize(parent: any): any;
  114185. }
  114186. }
  114187. declare module BABYLON {
  114188. /**
  114189. * Options allowed during the creation of a sound track.
  114190. */
  114191. export interface ISoundTrackOptions {
  114192. /**
  114193. * The volume the sound track should take during creation
  114194. */
  114195. volume?: number;
  114196. /**
  114197. * Define if the sound track is the main sound track of the scene
  114198. */
  114199. mainTrack?: boolean;
  114200. }
  114201. /**
  114202. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  114203. * It will be also used in a future release to apply effects on a specific track.
  114204. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  114205. */
  114206. export class SoundTrack {
  114207. /**
  114208. * The unique identifier of the sound track in the scene.
  114209. */
  114210. id: number;
  114211. /**
  114212. * The list of sounds included in the sound track.
  114213. */
  114214. soundCollection: Array<Sound>;
  114215. private _outputAudioNode;
  114216. private _scene;
  114217. private _connectedAnalyser;
  114218. private _options;
  114219. private _isInitialized;
  114220. /**
  114221. * Creates a new sound track.
  114222. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  114223. * @param scene Define the scene the sound track belongs to
  114224. * @param options
  114225. */
  114226. constructor(scene: Scene, options?: ISoundTrackOptions);
  114227. private _initializeSoundTrackAudioGraph;
  114228. /**
  114229. * Release the sound track and its associated resources
  114230. */
  114231. dispose(): void;
  114232. /**
  114233. * Adds a sound to this sound track
  114234. * @param sound define the cound to add
  114235. * @ignoreNaming
  114236. */
  114237. AddSound(sound: Sound): void;
  114238. /**
  114239. * Removes a sound to this sound track
  114240. * @param sound define the cound to remove
  114241. * @ignoreNaming
  114242. */
  114243. RemoveSound(sound: Sound): void;
  114244. /**
  114245. * Set a global volume for the full sound track.
  114246. * @param newVolume Define the new volume of the sound track
  114247. */
  114248. setVolume(newVolume: number): void;
  114249. /**
  114250. * Switch the panning model to HRTF:
  114251. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  114252. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  114253. */
  114254. switchPanningModelToHRTF(): void;
  114255. /**
  114256. * Switch the panning model to Equal Power:
  114257. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  114258. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  114259. */
  114260. switchPanningModelToEqualPower(): void;
  114261. /**
  114262. * Connect the sound track to an audio analyser allowing some amazing
  114263. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  114264. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  114265. * @param analyser The analyser to connect to the engine
  114266. */
  114267. connectToAnalyser(analyser: Analyser): void;
  114268. }
  114269. }
  114270. declare module BABYLON {
  114271. interface AbstractScene {
  114272. /**
  114273. * The list of sounds used in the scene.
  114274. */
  114275. sounds: Nullable<Array<Sound>>;
  114276. }
  114277. interface Scene {
  114278. /**
  114279. * @hidden
  114280. * Backing field
  114281. */
  114282. _mainSoundTrack: SoundTrack;
  114283. /**
  114284. * The main sound track played by the scene.
  114285. * It cotains your primary collection of sounds.
  114286. */
  114287. mainSoundTrack: SoundTrack;
  114288. /**
  114289. * The list of sound tracks added to the scene
  114290. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  114291. */
  114292. soundTracks: Nullable<Array<SoundTrack>>;
  114293. /**
  114294. * Gets a sound using a given name
  114295. * @param name defines the name to search for
  114296. * @return the found sound or null if not found at all.
  114297. */
  114298. getSoundByName(name: string): Nullable<Sound>;
  114299. /**
  114300. * Gets or sets if audio support is enabled
  114301. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  114302. */
  114303. audioEnabled: boolean;
  114304. /**
  114305. * Gets or sets if audio will be output to headphones
  114306. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  114307. */
  114308. headphone: boolean;
  114309. /**
  114310. * Gets or sets custom audio listener position provider
  114311. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  114312. */
  114313. audioListenerPositionProvider: Nullable<() => Vector3>;
  114314. /**
  114315. * Gets or sets a refresh rate when using 3D audio positioning
  114316. */
  114317. audioPositioningRefreshRate: number;
  114318. }
  114319. /**
  114320. * Defines the sound scene component responsible to manage any sounds
  114321. * in a given scene.
  114322. */
  114323. export class AudioSceneComponent implements ISceneSerializableComponent {
  114324. /**
  114325. * The component name helpfull to identify the component in the list of scene components.
  114326. */
  114327. readonly name: string;
  114328. /**
  114329. * The scene the component belongs to.
  114330. */
  114331. scene: Scene;
  114332. private _audioEnabled;
  114333. /**
  114334. * Gets whether audio is enabled or not.
  114335. * Please use related enable/disable method to switch state.
  114336. */
  114337. get audioEnabled(): boolean;
  114338. private _headphone;
  114339. /**
  114340. * Gets whether audio is outputing to headphone or not.
  114341. * Please use the according Switch methods to change output.
  114342. */
  114343. get headphone(): boolean;
  114344. /**
  114345. * Gets or sets a refresh rate when using 3D audio positioning
  114346. */
  114347. audioPositioningRefreshRate: number;
  114348. private _audioListenerPositionProvider;
  114349. /**
  114350. * Gets the current audio listener position provider
  114351. */
  114352. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  114353. /**
  114354. * Sets a custom listener position for all sounds in the scene
  114355. * By default, this is the position of the first active camera
  114356. */
  114357. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  114358. /**
  114359. * Creates a new instance of the component for the given scene
  114360. * @param scene Defines the scene to register the component in
  114361. */
  114362. constructor(scene: Scene);
  114363. /**
  114364. * Registers the component in a given scene
  114365. */
  114366. register(): void;
  114367. /**
  114368. * Rebuilds the elements related to this component in case of
  114369. * context lost for instance.
  114370. */
  114371. rebuild(): void;
  114372. /**
  114373. * Serializes the component data to the specified json object
  114374. * @param serializationObject The object to serialize to
  114375. */
  114376. serialize(serializationObject: any): void;
  114377. /**
  114378. * Adds all the elements from the container to the scene
  114379. * @param container the container holding the elements
  114380. */
  114381. addFromContainer(container: AbstractScene): void;
  114382. /**
  114383. * Removes all the elements in the container from the scene
  114384. * @param container contains the elements to remove
  114385. * @param dispose if the removed element should be disposed (default: false)
  114386. */
  114387. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  114388. /**
  114389. * Disposes the component and the associated ressources.
  114390. */
  114391. dispose(): void;
  114392. /**
  114393. * Disables audio in the associated scene.
  114394. */
  114395. disableAudio(): void;
  114396. /**
  114397. * Enables audio in the associated scene.
  114398. */
  114399. enableAudio(): void;
  114400. /**
  114401. * Switch audio to headphone output.
  114402. */
  114403. switchAudioModeForHeadphones(): void;
  114404. /**
  114405. * Switch audio to normal speakers.
  114406. */
  114407. switchAudioModeForNormalSpeakers(): void;
  114408. private _cachedCameraDirection;
  114409. private _cachedCameraPosition;
  114410. private _lastCheck;
  114411. private _afterRender;
  114412. }
  114413. }
  114414. declare module BABYLON {
  114415. /**
  114416. * Wraps one or more Sound objects and selects one with random weight for playback.
  114417. */
  114418. export class WeightedSound {
  114419. /** When true a Sound will be selected and played when the current playing Sound completes. */
  114420. loop: boolean;
  114421. private _coneInnerAngle;
  114422. private _coneOuterAngle;
  114423. private _volume;
  114424. /** A Sound is currently playing. */
  114425. isPlaying: boolean;
  114426. /** A Sound is currently paused. */
  114427. isPaused: boolean;
  114428. private _sounds;
  114429. private _weights;
  114430. private _currentIndex?;
  114431. /**
  114432. * Creates a new WeightedSound from the list of sounds given.
  114433. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  114434. * @param sounds Array of Sounds that will be selected from.
  114435. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  114436. */
  114437. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  114438. /**
  114439. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  114440. */
  114441. get directionalConeInnerAngle(): number;
  114442. /**
  114443. * The size of cone in degress for a directional sound in which there will be no attenuation.
  114444. */
  114445. set directionalConeInnerAngle(value: number);
  114446. /**
  114447. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  114448. * Listener angles between innerAngle and outerAngle will falloff linearly.
  114449. */
  114450. get directionalConeOuterAngle(): number;
  114451. /**
  114452. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  114453. * Listener angles between innerAngle and outerAngle will falloff linearly.
  114454. */
  114455. set directionalConeOuterAngle(value: number);
  114456. /**
  114457. * Playback volume.
  114458. */
  114459. get volume(): number;
  114460. /**
  114461. * Playback volume.
  114462. */
  114463. set volume(value: number);
  114464. private _onended;
  114465. /**
  114466. * Suspend playback
  114467. */
  114468. pause(): void;
  114469. /**
  114470. * Stop playback
  114471. */
  114472. stop(): void;
  114473. /**
  114474. * Start playback.
  114475. * @param startOffset Position the clip head at a specific time in seconds.
  114476. */
  114477. play(startOffset?: number): void;
  114478. }
  114479. }
  114480. declare module BABYLON {
  114481. /**
  114482. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  114483. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  114484. */
  114485. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  114486. /**
  114487. * Gets the name of the behavior.
  114488. */
  114489. get name(): string;
  114490. /**
  114491. * The easing function used by animations
  114492. */
  114493. static EasingFunction: BackEase;
  114494. /**
  114495. * The easing mode used by animations
  114496. */
  114497. static EasingMode: number;
  114498. /**
  114499. * The duration of the animation, in milliseconds
  114500. */
  114501. transitionDuration: number;
  114502. /**
  114503. * Length of the distance animated by the transition when lower radius is reached
  114504. */
  114505. lowerRadiusTransitionRange: number;
  114506. /**
  114507. * Length of the distance animated by the transition when upper radius is reached
  114508. */
  114509. upperRadiusTransitionRange: number;
  114510. private _autoTransitionRange;
  114511. /**
  114512. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  114513. */
  114514. get autoTransitionRange(): boolean;
  114515. /**
  114516. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  114517. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  114518. */
  114519. set autoTransitionRange(value: boolean);
  114520. private _attachedCamera;
  114521. private _onAfterCheckInputsObserver;
  114522. private _onMeshTargetChangedObserver;
  114523. /**
  114524. * Initializes the behavior.
  114525. */
  114526. init(): void;
  114527. /**
  114528. * Attaches the behavior to its arc rotate camera.
  114529. * @param camera Defines the camera to attach the behavior to
  114530. */
  114531. attach(camera: ArcRotateCamera): void;
  114532. /**
  114533. * Detaches the behavior from its current arc rotate camera.
  114534. */
  114535. detach(): void;
  114536. private _radiusIsAnimating;
  114537. private _radiusBounceTransition;
  114538. private _animatables;
  114539. private _cachedWheelPrecision;
  114540. /**
  114541. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  114542. * @param radiusLimit The limit to check against.
  114543. * @return Bool to indicate if at limit.
  114544. */
  114545. private _isRadiusAtLimit;
  114546. /**
  114547. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  114548. * @param radiusDelta The delta by which to animate to. Can be negative.
  114549. */
  114550. private _applyBoundRadiusAnimation;
  114551. /**
  114552. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  114553. */
  114554. protected _clearAnimationLocks(): void;
  114555. /**
  114556. * Stops and removes all animations that have been applied to the camera
  114557. */
  114558. stopAllAnimations(): void;
  114559. }
  114560. }
  114561. declare module BABYLON {
  114562. /**
  114563. * 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.
  114564. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  114565. */
  114566. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  114567. /**
  114568. * Gets the name of the behavior.
  114569. */
  114570. get name(): string;
  114571. private _mode;
  114572. private _radiusScale;
  114573. private _positionScale;
  114574. private _defaultElevation;
  114575. private _elevationReturnTime;
  114576. private _elevationReturnWaitTime;
  114577. private _zoomStopsAnimation;
  114578. private _framingTime;
  114579. /**
  114580. * The easing function used by animations
  114581. */
  114582. static EasingFunction: ExponentialEase;
  114583. /**
  114584. * The easing mode used by animations
  114585. */
  114586. static EasingMode: number;
  114587. /**
  114588. * Sets the current mode used by the behavior
  114589. */
  114590. set mode(mode: number);
  114591. /**
  114592. * Gets current mode used by the behavior.
  114593. */
  114594. get mode(): number;
  114595. /**
  114596. * Sets the scale applied to the radius (1 by default)
  114597. */
  114598. set radiusScale(radius: number);
  114599. /**
  114600. * Gets the scale applied to the radius
  114601. */
  114602. get radiusScale(): number;
  114603. /**
  114604. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  114605. */
  114606. set positionScale(scale: number);
  114607. /**
  114608. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  114609. */
  114610. get positionScale(): number;
  114611. /**
  114612. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  114613. * behaviour is triggered, in radians.
  114614. */
  114615. set defaultElevation(elevation: number);
  114616. /**
  114617. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  114618. * behaviour is triggered, in radians.
  114619. */
  114620. get defaultElevation(): number;
  114621. /**
  114622. * Sets the time (in milliseconds) taken to return to the default beta position.
  114623. * Negative value indicates camera should not return to default.
  114624. */
  114625. set elevationReturnTime(speed: number);
  114626. /**
  114627. * Gets the time (in milliseconds) taken to return to the default beta position.
  114628. * Negative value indicates camera should not return to default.
  114629. */
  114630. get elevationReturnTime(): number;
  114631. /**
  114632. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  114633. */
  114634. set elevationReturnWaitTime(time: number);
  114635. /**
  114636. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  114637. */
  114638. get elevationReturnWaitTime(): number;
  114639. /**
  114640. * Sets the flag that indicates if user zooming should stop animation.
  114641. */
  114642. set zoomStopsAnimation(flag: boolean);
  114643. /**
  114644. * Gets the flag that indicates if user zooming should stop animation.
  114645. */
  114646. get zoomStopsAnimation(): boolean;
  114647. /**
  114648. * Sets the transition time when framing the mesh, in milliseconds
  114649. */
  114650. set framingTime(time: number);
  114651. /**
  114652. * Gets the transition time when framing the mesh, in milliseconds
  114653. */
  114654. get framingTime(): number;
  114655. /**
  114656. * Define if the behavior should automatically change the configured
  114657. * camera limits and sensibilities.
  114658. */
  114659. autoCorrectCameraLimitsAndSensibility: boolean;
  114660. private _onPrePointerObservableObserver;
  114661. private _onAfterCheckInputsObserver;
  114662. private _onMeshTargetChangedObserver;
  114663. private _attachedCamera;
  114664. private _isPointerDown;
  114665. private _lastInteractionTime;
  114666. /**
  114667. * Initializes the behavior.
  114668. */
  114669. init(): void;
  114670. /**
  114671. * Attaches the behavior to its arc rotate camera.
  114672. * @param camera Defines the camera to attach the behavior to
  114673. */
  114674. attach(camera: ArcRotateCamera): void;
  114675. /**
  114676. * Detaches the behavior from its current arc rotate camera.
  114677. */
  114678. detach(): void;
  114679. private _animatables;
  114680. private _betaIsAnimating;
  114681. private _betaTransition;
  114682. private _radiusTransition;
  114683. private _vectorTransition;
  114684. /**
  114685. * Targets the given mesh and updates zoom level accordingly.
  114686. * @param mesh The mesh to target.
  114687. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  114688. * @param onAnimationEnd Callback triggered at the end of the framing animation
  114689. */
  114690. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  114691. /**
  114692. * Targets the given mesh with its children and updates zoom level accordingly.
  114693. * @param mesh The mesh to target.
  114694. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  114695. * @param onAnimationEnd Callback triggered at the end of the framing animation
  114696. */
  114697. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  114698. /**
  114699. * Targets the given meshes with their children and updates zoom level accordingly.
  114700. * @param meshes The mesh to target.
  114701. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  114702. * @param onAnimationEnd Callback triggered at the end of the framing animation
  114703. */
  114704. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  114705. /**
  114706. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  114707. * @param minimumWorld Determines the smaller position of the bounding box extend
  114708. * @param maximumWorld Determines the bigger position of the bounding box extend
  114709. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  114710. * @param onAnimationEnd Callback triggered at the end of the framing animation
  114711. */
  114712. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  114713. /**
  114714. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  114715. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  114716. * frustum width.
  114717. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  114718. * to fully enclose the mesh in the viewing frustum.
  114719. */
  114720. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  114721. /**
  114722. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  114723. * is automatically returned to its default position (expected to be above ground plane).
  114724. */
  114725. private _maintainCameraAboveGround;
  114726. /**
  114727. * Returns the frustum slope based on the canvas ratio and camera FOV
  114728. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  114729. */
  114730. private _getFrustumSlope;
  114731. /**
  114732. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  114733. */
  114734. private _clearAnimationLocks;
  114735. /**
  114736. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  114737. */
  114738. private _applyUserInteraction;
  114739. /**
  114740. * Stops and removes all animations that have been applied to the camera
  114741. */
  114742. stopAllAnimations(): void;
  114743. /**
  114744. * Gets a value indicating if the user is moving the camera
  114745. */
  114746. get isUserIsMoving(): boolean;
  114747. /**
  114748. * The camera can move all the way towards the mesh.
  114749. */
  114750. static IgnoreBoundsSizeMode: number;
  114751. /**
  114752. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  114753. */
  114754. static FitFrustumSidesMode: number;
  114755. }
  114756. }
  114757. declare module BABYLON {
  114758. /**
  114759. * Base class for Camera Pointer Inputs.
  114760. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  114761. * for example usage.
  114762. */
  114763. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  114764. /**
  114765. * Defines the camera the input is attached to.
  114766. */
  114767. abstract camera: Camera;
  114768. /**
  114769. * Whether keyboard modifier keys are pressed at time of last mouse event.
  114770. */
  114771. protected _altKey: boolean;
  114772. protected _ctrlKey: boolean;
  114773. protected _metaKey: boolean;
  114774. protected _shiftKey: boolean;
  114775. /**
  114776. * Which mouse buttons were pressed at time of last mouse event.
  114777. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  114778. */
  114779. protected _buttonsPressed: number;
  114780. /**
  114781. * Defines the buttons associated with the input to handle camera move.
  114782. */
  114783. buttons: number[];
  114784. /**
  114785. * Attach the input controls to a specific dom element to get the input from.
  114786. * @param element Defines the element the controls should be listened from
  114787. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  114788. */
  114789. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  114790. /**
  114791. * Detach the current controls from the specified dom element.
  114792. * @param element Defines the element to stop listening the inputs from
  114793. */
  114794. detachControl(element: Nullable<HTMLElement>): void;
  114795. /**
  114796. * Gets the class name of the current input.
  114797. * @returns the class name
  114798. */
  114799. getClassName(): string;
  114800. /**
  114801. * Get the friendly name associated with the input class.
  114802. * @returns the input friendly name
  114803. */
  114804. getSimpleName(): string;
  114805. /**
  114806. * Called on pointer POINTERDOUBLETAP event.
  114807. * Override this method to provide functionality on POINTERDOUBLETAP event.
  114808. */
  114809. protected onDoubleTap(type: string): void;
  114810. /**
  114811. * Called on pointer POINTERMOVE event if only a single touch is active.
  114812. * Override this method to provide functionality.
  114813. */
  114814. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  114815. /**
  114816. * Called on pointer POINTERMOVE event if multiple touches are active.
  114817. * Override this method to provide functionality.
  114818. */
  114819. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  114820. /**
  114821. * Called on JS contextmenu event.
  114822. * Override this method to provide functionality.
  114823. */
  114824. protected onContextMenu(evt: PointerEvent): void;
  114825. /**
  114826. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  114827. * press.
  114828. * Override this method to provide functionality.
  114829. */
  114830. protected onButtonDown(evt: PointerEvent): void;
  114831. /**
  114832. * Called each time a new POINTERUP event occurs. Ie, for each button
  114833. * release.
  114834. * Override this method to provide functionality.
  114835. */
  114836. protected onButtonUp(evt: PointerEvent): void;
  114837. /**
  114838. * Called when window becomes inactive.
  114839. * Override this method to provide functionality.
  114840. */
  114841. protected onLostFocus(): void;
  114842. private _pointerInput;
  114843. private _observer;
  114844. private _onLostFocus;
  114845. private pointA;
  114846. private pointB;
  114847. }
  114848. }
  114849. declare module BABYLON {
  114850. /**
  114851. * Manage the pointers inputs to control an arc rotate camera.
  114852. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  114853. */
  114854. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  114855. /**
  114856. * Defines the camera the input is attached to.
  114857. */
  114858. camera: ArcRotateCamera;
  114859. /**
  114860. * Gets the class name of the current input.
  114861. * @returns the class name
  114862. */
  114863. getClassName(): string;
  114864. /**
  114865. * Defines the buttons associated with the input to handle camera move.
  114866. */
  114867. buttons: number[];
  114868. /**
  114869. * Defines the pointer angular sensibility along the X axis or how fast is
  114870. * the camera rotating.
  114871. */
  114872. angularSensibilityX: number;
  114873. /**
  114874. * Defines the pointer angular sensibility along the Y axis or how fast is
  114875. * the camera rotating.
  114876. */
  114877. angularSensibilityY: number;
  114878. /**
  114879. * Defines the pointer pinch precision or how fast is the camera zooming.
  114880. */
  114881. pinchPrecision: number;
  114882. /**
  114883. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  114884. * from 0.
  114885. * It defines the percentage of current camera.radius to use as delta when
  114886. * pinch zoom is used.
  114887. */
  114888. pinchDeltaPercentage: number;
  114889. /**
  114890. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  114891. * that any object in the plane at the camera's target point will scale
  114892. * perfectly with finger motion.
  114893. * Overrides pinchDeltaPercentage and pinchPrecision.
  114894. */
  114895. useNaturalPinchZoom: boolean;
  114896. /**
  114897. * Defines the pointer panning sensibility or how fast is the camera moving.
  114898. */
  114899. panningSensibility: number;
  114900. /**
  114901. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  114902. */
  114903. multiTouchPanning: boolean;
  114904. /**
  114905. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  114906. * zoom (pinch) through multitouch.
  114907. */
  114908. multiTouchPanAndZoom: boolean;
  114909. /**
  114910. * Revers pinch action direction.
  114911. */
  114912. pinchInwards: boolean;
  114913. private _isPanClick;
  114914. private _twoFingerActivityCount;
  114915. private _isPinching;
  114916. /**
  114917. * Called on pointer POINTERMOVE event if only a single touch is active.
  114918. */
  114919. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  114920. /**
  114921. * Called on pointer POINTERDOUBLETAP event.
  114922. */
  114923. protected onDoubleTap(type: string): void;
  114924. /**
  114925. * Called on pointer POINTERMOVE event if multiple touches are active.
  114926. */
  114927. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  114928. /**
  114929. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  114930. * press.
  114931. */
  114932. protected onButtonDown(evt: PointerEvent): void;
  114933. /**
  114934. * Called each time a new POINTERUP event occurs. Ie, for each button
  114935. * release.
  114936. */
  114937. protected onButtonUp(evt: PointerEvent): void;
  114938. /**
  114939. * Called when window becomes inactive.
  114940. */
  114941. protected onLostFocus(): void;
  114942. }
  114943. }
  114944. declare module BABYLON {
  114945. /**
  114946. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  114947. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  114948. */
  114949. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  114950. /**
  114951. * Defines the camera the input is attached to.
  114952. */
  114953. camera: ArcRotateCamera;
  114954. /**
  114955. * Defines the list of key codes associated with the up action (increase alpha)
  114956. */
  114957. keysUp: number[];
  114958. /**
  114959. * Defines the list of key codes associated with the down action (decrease alpha)
  114960. */
  114961. keysDown: number[];
  114962. /**
  114963. * Defines the list of key codes associated with the left action (increase beta)
  114964. */
  114965. keysLeft: number[];
  114966. /**
  114967. * Defines the list of key codes associated with the right action (decrease beta)
  114968. */
  114969. keysRight: number[];
  114970. /**
  114971. * Defines the list of key codes associated with the reset action.
  114972. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  114973. */
  114974. keysReset: number[];
  114975. /**
  114976. * Defines the panning sensibility of the inputs.
  114977. * (How fast is the camera panning)
  114978. */
  114979. panningSensibility: number;
  114980. /**
  114981. * Defines the zooming sensibility of the inputs.
  114982. * (How fast is the camera zooming)
  114983. */
  114984. zoomingSensibility: number;
  114985. /**
  114986. * Defines whether maintaining the alt key down switch the movement mode from
  114987. * orientation to zoom.
  114988. */
  114989. useAltToZoom: boolean;
  114990. /**
  114991. * Rotation speed of the camera
  114992. */
  114993. angularSpeed: number;
  114994. private _keys;
  114995. private _ctrlPressed;
  114996. private _altPressed;
  114997. private _onCanvasBlurObserver;
  114998. private _onKeyboardObserver;
  114999. private _engine;
  115000. private _scene;
  115001. /**
  115002. * Attach the input controls to a specific dom element to get the input from.
  115003. * @param element Defines the element the controls should be listened from
  115004. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  115005. */
  115006. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  115007. /**
  115008. * Detach the current controls from the specified dom element.
  115009. * @param element Defines the element to stop listening the inputs from
  115010. */
  115011. detachControl(element: Nullable<HTMLElement>): void;
  115012. /**
  115013. * Update the current camera state depending on the inputs that have been used this frame.
  115014. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  115015. */
  115016. checkInputs(): void;
  115017. /**
  115018. * Gets the class name of the current intput.
  115019. * @returns the class name
  115020. */
  115021. getClassName(): string;
  115022. /**
  115023. * Get the friendly name associated with the input class.
  115024. * @returns the input friendly name
  115025. */
  115026. getSimpleName(): string;
  115027. }
  115028. }
  115029. declare module BABYLON {
  115030. /**
  115031. * Manage the mouse wheel inputs to control an arc rotate camera.
  115032. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  115033. */
  115034. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  115035. /**
  115036. * Defines the camera the input is attached to.
  115037. */
  115038. camera: ArcRotateCamera;
  115039. /**
  115040. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  115041. */
  115042. wheelPrecision: number;
  115043. /**
  115044. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  115045. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  115046. */
  115047. wheelDeltaPercentage: number;
  115048. private _wheel;
  115049. private _observer;
  115050. private computeDeltaFromMouseWheelLegacyEvent;
  115051. /**
  115052. * Attach the input controls to a specific dom element to get the input from.
  115053. * @param element Defines the element the controls should be listened from
  115054. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  115055. */
  115056. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  115057. /**
  115058. * Detach the current controls from the specified dom element.
  115059. * @param element Defines the element to stop listening the inputs from
  115060. */
  115061. detachControl(element: Nullable<HTMLElement>): void;
  115062. /**
  115063. * Gets the class name of the current intput.
  115064. * @returns the class name
  115065. */
  115066. getClassName(): string;
  115067. /**
  115068. * Get the friendly name associated with the input class.
  115069. * @returns the input friendly name
  115070. */
  115071. getSimpleName(): string;
  115072. }
  115073. }
  115074. declare module BABYLON {
  115075. /**
  115076. * Default Inputs manager for the ArcRotateCamera.
  115077. * It groups all the default supported inputs for ease of use.
  115078. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  115079. */
  115080. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  115081. /**
  115082. * Instantiates a new ArcRotateCameraInputsManager.
  115083. * @param camera Defines the camera the inputs belong to
  115084. */
  115085. constructor(camera: ArcRotateCamera);
  115086. /**
  115087. * Add mouse wheel input support to the input manager.
  115088. * @returns the current input manager
  115089. */
  115090. addMouseWheel(): ArcRotateCameraInputsManager;
  115091. /**
  115092. * Add pointers input support to the input manager.
  115093. * @returns the current input manager
  115094. */
  115095. addPointers(): ArcRotateCameraInputsManager;
  115096. /**
  115097. * Add keyboard input support to the input manager.
  115098. * @returns the current input manager
  115099. */
  115100. addKeyboard(): ArcRotateCameraInputsManager;
  115101. }
  115102. }
  115103. declare module BABYLON {
  115104. /**
  115105. * This represents an orbital type of camera.
  115106. *
  115107. * 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.
  115108. * 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.
  115109. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  115110. */
  115111. export class ArcRotateCamera extends TargetCamera {
  115112. /**
  115113. * Defines the rotation angle of the camera along the longitudinal axis.
  115114. */
  115115. alpha: number;
  115116. /**
  115117. * Defines the rotation angle of the camera along the latitudinal axis.
  115118. */
  115119. beta: number;
  115120. /**
  115121. * Defines the radius of the camera from it s target point.
  115122. */
  115123. radius: number;
  115124. protected _target: Vector3;
  115125. protected _targetHost: Nullable<AbstractMesh>;
  115126. /**
  115127. * Defines the target point of the camera.
  115128. * The camera looks towards it form the radius distance.
  115129. */
  115130. get target(): Vector3;
  115131. set target(value: Vector3);
  115132. /**
  115133. * Define the current local position of the camera in the scene
  115134. */
  115135. get position(): Vector3;
  115136. set position(newPosition: Vector3);
  115137. protected _upVector: Vector3;
  115138. protected _upToYMatrix: Matrix;
  115139. protected _YToUpMatrix: Matrix;
  115140. /**
  115141. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  115142. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  115143. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  115144. */
  115145. set upVector(vec: Vector3);
  115146. get upVector(): Vector3;
  115147. /**
  115148. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  115149. */
  115150. setMatUp(): void;
  115151. /**
  115152. * Current inertia value on the longitudinal axis.
  115153. * The bigger this number the longer it will take for the camera to stop.
  115154. */
  115155. inertialAlphaOffset: number;
  115156. /**
  115157. * Current inertia value on the latitudinal axis.
  115158. * The bigger this number the longer it will take for the camera to stop.
  115159. */
  115160. inertialBetaOffset: number;
  115161. /**
  115162. * Current inertia value on the radius axis.
  115163. * The bigger this number the longer it will take for the camera to stop.
  115164. */
  115165. inertialRadiusOffset: number;
  115166. /**
  115167. * Minimum allowed angle on the longitudinal axis.
  115168. * This can help limiting how the Camera is able to move in the scene.
  115169. */
  115170. lowerAlphaLimit: Nullable<number>;
  115171. /**
  115172. * Maximum allowed angle on the longitudinal axis.
  115173. * This can help limiting how the Camera is able to move in the scene.
  115174. */
  115175. upperAlphaLimit: Nullable<number>;
  115176. /**
  115177. * Minimum allowed angle on the latitudinal axis.
  115178. * This can help limiting how the Camera is able to move in the scene.
  115179. */
  115180. lowerBetaLimit: number;
  115181. /**
  115182. * Maximum allowed angle on the latitudinal axis.
  115183. * This can help limiting how the Camera is able to move in the scene.
  115184. */
  115185. upperBetaLimit: number;
  115186. /**
  115187. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  115188. * This can help limiting how the Camera is able to move in the scene.
  115189. */
  115190. lowerRadiusLimit: Nullable<number>;
  115191. /**
  115192. * Maximum allowed distance of the camera to the target (The camera can not get further).
  115193. * This can help limiting how the Camera is able to move in the scene.
  115194. */
  115195. upperRadiusLimit: Nullable<number>;
  115196. /**
  115197. * Defines the current inertia value used during panning of the camera along the X axis.
  115198. */
  115199. inertialPanningX: number;
  115200. /**
  115201. * Defines the current inertia value used during panning of the camera along the Y axis.
  115202. */
  115203. inertialPanningY: number;
  115204. /**
  115205. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  115206. * Basically if your fingers moves away from more than this distance you will be considered
  115207. * in pinch mode.
  115208. */
  115209. pinchToPanMaxDistance: number;
  115210. /**
  115211. * Defines the maximum distance the camera can pan.
  115212. * This could help keeping the cammera always in your scene.
  115213. */
  115214. panningDistanceLimit: Nullable<number>;
  115215. /**
  115216. * Defines the target of the camera before paning.
  115217. */
  115218. panningOriginTarget: Vector3;
  115219. /**
  115220. * Defines the value of the inertia used during panning.
  115221. * 0 would mean stop inertia and one would mean no decelleration at all.
  115222. */
  115223. panningInertia: number;
  115224. /**
  115225. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  115226. */
  115227. get angularSensibilityX(): number;
  115228. set angularSensibilityX(value: number);
  115229. /**
  115230. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  115231. */
  115232. get angularSensibilityY(): number;
  115233. set angularSensibilityY(value: number);
  115234. /**
  115235. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  115236. */
  115237. get pinchPrecision(): number;
  115238. set pinchPrecision(value: number);
  115239. /**
  115240. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  115241. * It will be used instead of pinchDeltaPrecision if different from 0.
  115242. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  115243. */
  115244. get pinchDeltaPercentage(): number;
  115245. set pinchDeltaPercentage(value: number);
  115246. /**
  115247. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  115248. * and pinch delta percentage.
  115249. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  115250. * that any object in the plane at the camera's target point will scale
  115251. * perfectly with finger motion.
  115252. */
  115253. get useNaturalPinchZoom(): boolean;
  115254. set useNaturalPinchZoom(value: boolean);
  115255. /**
  115256. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  115257. */
  115258. get panningSensibility(): number;
  115259. set panningSensibility(value: number);
  115260. /**
  115261. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  115262. */
  115263. get keysUp(): number[];
  115264. set keysUp(value: number[]);
  115265. /**
  115266. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  115267. */
  115268. get keysDown(): number[];
  115269. set keysDown(value: number[]);
  115270. /**
  115271. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  115272. */
  115273. get keysLeft(): number[];
  115274. set keysLeft(value: number[]);
  115275. /**
  115276. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  115277. */
  115278. get keysRight(): number[];
  115279. set keysRight(value: number[]);
  115280. /**
  115281. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  115282. */
  115283. get wheelPrecision(): number;
  115284. set wheelPrecision(value: number);
  115285. /**
  115286. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  115287. * It will be used instead of pinchDeltaPrecision if different from 0.
  115288. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  115289. */
  115290. get wheelDeltaPercentage(): number;
  115291. set wheelDeltaPercentage(value: number);
  115292. /**
  115293. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  115294. */
  115295. zoomOnFactor: number;
  115296. /**
  115297. * Defines a screen offset for the camera position.
  115298. */
  115299. targetScreenOffset: Vector2;
  115300. /**
  115301. * Allows the camera to be completely reversed.
  115302. * If false the camera can not arrive upside down.
  115303. */
  115304. allowUpsideDown: boolean;
  115305. /**
  115306. * Define if double tap/click is used to restore the previously saved state of the camera.
  115307. */
  115308. useInputToRestoreState: boolean;
  115309. /** @hidden */
  115310. _viewMatrix: Matrix;
  115311. /** @hidden */
  115312. _useCtrlForPanning: boolean;
  115313. /** @hidden */
  115314. _panningMouseButton: number;
  115315. /**
  115316. * Defines the input associated to the camera.
  115317. */
  115318. inputs: ArcRotateCameraInputsManager;
  115319. /** @hidden */
  115320. _reset: () => void;
  115321. /**
  115322. * Defines the allowed panning axis.
  115323. */
  115324. panningAxis: Vector3;
  115325. protected _localDirection: Vector3;
  115326. protected _transformedDirection: Vector3;
  115327. private _bouncingBehavior;
  115328. /**
  115329. * Gets the bouncing behavior of the camera if it has been enabled.
  115330. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  115331. */
  115332. get bouncingBehavior(): Nullable<BouncingBehavior>;
  115333. /**
  115334. * Defines if the bouncing behavior of the camera is enabled on the camera.
  115335. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  115336. */
  115337. get useBouncingBehavior(): boolean;
  115338. set useBouncingBehavior(value: boolean);
  115339. private _framingBehavior;
  115340. /**
  115341. * Gets the framing behavior of the camera if it has been enabled.
  115342. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  115343. */
  115344. get framingBehavior(): Nullable<FramingBehavior>;
  115345. /**
  115346. * Defines if the framing behavior of the camera is enabled on the camera.
  115347. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  115348. */
  115349. get useFramingBehavior(): boolean;
  115350. set useFramingBehavior(value: boolean);
  115351. private _autoRotationBehavior;
  115352. /**
  115353. * Gets the auto rotation behavior of the camera if it has been enabled.
  115354. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  115355. */
  115356. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  115357. /**
  115358. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  115359. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  115360. */
  115361. get useAutoRotationBehavior(): boolean;
  115362. set useAutoRotationBehavior(value: boolean);
  115363. /**
  115364. * Observable triggered when the mesh target has been changed on the camera.
  115365. */
  115366. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  115367. /**
  115368. * Event raised when the camera is colliding with a mesh.
  115369. */
  115370. onCollide: (collidedMesh: AbstractMesh) => void;
  115371. /**
  115372. * Defines whether the camera should check collision with the objects oh the scene.
  115373. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  115374. */
  115375. checkCollisions: boolean;
  115376. /**
  115377. * Defines the collision radius of the camera.
  115378. * This simulates a sphere around the camera.
  115379. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  115380. */
  115381. collisionRadius: Vector3;
  115382. protected _collider: Collider;
  115383. protected _previousPosition: Vector3;
  115384. protected _collisionVelocity: Vector3;
  115385. protected _newPosition: Vector3;
  115386. protected _previousAlpha: number;
  115387. protected _previousBeta: number;
  115388. protected _previousRadius: number;
  115389. protected _collisionTriggered: boolean;
  115390. protected _targetBoundingCenter: Nullable<Vector3>;
  115391. private _computationVector;
  115392. /**
  115393. * Instantiates a new ArcRotateCamera in a given scene
  115394. * @param name Defines the name of the camera
  115395. * @param alpha Defines the camera rotation along the logitudinal axis
  115396. * @param beta Defines the camera rotation along the latitudinal axis
  115397. * @param radius Defines the camera distance from its target
  115398. * @param target Defines the camera target
  115399. * @param scene Defines the scene the camera belongs to
  115400. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  115401. */
  115402. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  115403. /** @hidden */
  115404. _initCache(): void;
  115405. /** @hidden */
  115406. _updateCache(ignoreParentClass?: boolean): void;
  115407. protected _getTargetPosition(): Vector3;
  115408. private _storedAlpha;
  115409. private _storedBeta;
  115410. private _storedRadius;
  115411. private _storedTarget;
  115412. private _storedTargetScreenOffset;
  115413. /**
  115414. * Stores the current state of the camera (alpha, beta, radius and target)
  115415. * @returns the camera itself
  115416. */
  115417. storeState(): Camera;
  115418. /**
  115419. * @hidden
  115420. * Restored camera state. You must call storeState() first
  115421. */
  115422. _restoreStateValues(): boolean;
  115423. /** @hidden */
  115424. _isSynchronizedViewMatrix(): boolean;
  115425. /**
  115426. * Attached controls to the current camera.
  115427. * @param element Defines the element the controls should be listened from
  115428. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  115429. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  115430. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  115431. */
  115432. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  115433. /**
  115434. * Detach the current controls from the camera.
  115435. * The camera will stop reacting to inputs.
  115436. * @param element Defines the element to stop listening the inputs from
  115437. */
  115438. detachControl(element: HTMLElement): void;
  115439. /** @hidden */
  115440. _checkInputs(): void;
  115441. protected _checkLimits(): void;
  115442. /**
  115443. * Rebuilds angles (alpha, beta) and radius from the give position and target
  115444. */
  115445. rebuildAnglesAndRadius(): void;
  115446. /**
  115447. * Use a position to define the current camera related information like alpha, beta and radius
  115448. * @param position Defines the position to set the camera at
  115449. */
  115450. setPosition(position: Vector3): void;
  115451. /**
  115452. * Defines the target the camera should look at.
  115453. * This will automatically adapt alpha beta and radius to fit within the new target.
  115454. * @param target Defines the new target as a Vector or a mesh
  115455. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  115456. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  115457. */
  115458. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  115459. /** @hidden */
  115460. _getViewMatrix(): Matrix;
  115461. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  115462. /**
  115463. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  115464. * @param meshes Defines the mesh to zoom on
  115465. * @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)
  115466. */
  115467. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  115468. /**
  115469. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  115470. * The target will be changed but the radius
  115471. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  115472. * @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)
  115473. */
  115474. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  115475. min: Vector3;
  115476. max: Vector3;
  115477. distance: number;
  115478. }, doNotUpdateMaxZ?: boolean): void;
  115479. /**
  115480. * @override
  115481. * Override Camera.createRigCamera
  115482. */
  115483. createRigCamera(name: string, cameraIndex: number): Camera;
  115484. /**
  115485. * @hidden
  115486. * @override
  115487. * Override Camera._updateRigCameras
  115488. */
  115489. _updateRigCameras(): void;
  115490. /**
  115491. * Destroy the camera and release the current resources hold by it.
  115492. */
  115493. dispose(): void;
  115494. /**
  115495. * Gets the current object class name.
  115496. * @return the class name
  115497. */
  115498. getClassName(): string;
  115499. }
  115500. }
  115501. declare module BABYLON {
  115502. /**
  115503. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  115504. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  115505. */
  115506. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  115507. /**
  115508. * Gets the name of the behavior.
  115509. */
  115510. get name(): string;
  115511. private _zoomStopsAnimation;
  115512. private _idleRotationSpeed;
  115513. private _idleRotationWaitTime;
  115514. private _idleRotationSpinupTime;
  115515. /**
  115516. * Sets the flag that indicates if user zooming should stop animation.
  115517. */
  115518. set zoomStopsAnimation(flag: boolean);
  115519. /**
  115520. * Gets the flag that indicates if user zooming should stop animation.
  115521. */
  115522. get zoomStopsAnimation(): boolean;
  115523. /**
  115524. * Sets the default speed at which the camera rotates around the model.
  115525. */
  115526. set idleRotationSpeed(speed: number);
  115527. /**
  115528. * Gets the default speed at which the camera rotates around the model.
  115529. */
  115530. get idleRotationSpeed(): number;
  115531. /**
  115532. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  115533. */
  115534. set idleRotationWaitTime(time: number);
  115535. /**
  115536. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  115537. */
  115538. get idleRotationWaitTime(): number;
  115539. /**
  115540. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  115541. */
  115542. set idleRotationSpinupTime(time: number);
  115543. /**
  115544. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  115545. */
  115546. get idleRotationSpinupTime(): number;
  115547. /**
  115548. * Gets a value indicating if the camera is currently rotating because of this behavior
  115549. */
  115550. get rotationInProgress(): boolean;
  115551. private _onPrePointerObservableObserver;
  115552. private _onAfterCheckInputsObserver;
  115553. private _attachedCamera;
  115554. private _isPointerDown;
  115555. private _lastFrameTime;
  115556. private _lastInteractionTime;
  115557. private _cameraRotationSpeed;
  115558. /**
  115559. * Initializes the behavior.
  115560. */
  115561. init(): void;
  115562. /**
  115563. * Attaches the behavior to its arc rotate camera.
  115564. * @param camera Defines the camera to attach the behavior to
  115565. */
  115566. attach(camera: ArcRotateCamera): void;
  115567. /**
  115568. * Detaches the behavior from its current arc rotate camera.
  115569. */
  115570. detach(): void;
  115571. /**
  115572. * Returns true if user is scrolling.
  115573. * @return true if user is scrolling.
  115574. */
  115575. private _userIsZooming;
  115576. private _lastFrameRadius;
  115577. private _shouldAnimationStopForInteraction;
  115578. /**
  115579. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  115580. */
  115581. private _applyUserInteraction;
  115582. private _userIsMoving;
  115583. }
  115584. }
  115585. declare module BABYLON {
  115586. /**
  115587. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  115588. */
  115589. export class AttachToBoxBehavior implements Behavior<Mesh> {
  115590. private ui;
  115591. /**
  115592. * The name of the behavior
  115593. */
  115594. name: string;
  115595. /**
  115596. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  115597. */
  115598. distanceAwayFromFace: number;
  115599. /**
  115600. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  115601. */
  115602. distanceAwayFromBottomOfFace: number;
  115603. private _faceVectors;
  115604. private _target;
  115605. private _scene;
  115606. private _onRenderObserver;
  115607. private _tmpMatrix;
  115608. private _tmpVector;
  115609. /**
  115610. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  115611. * @param ui The transform node that should be attched to the mesh
  115612. */
  115613. constructor(ui: TransformNode);
  115614. /**
  115615. * Initializes the behavior
  115616. */
  115617. init(): void;
  115618. private _closestFace;
  115619. private _zeroVector;
  115620. private _lookAtTmpMatrix;
  115621. private _lookAtToRef;
  115622. /**
  115623. * Attaches the AttachToBoxBehavior to the passed in mesh
  115624. * @param target The mesh that the specified node will be attached to
  115625. */
  115626. attach(target: Mesh): void;
  115627. /**
  115628. * Detaches the behavior from the mesh
  115629. */
  115630. detach(): void;
  115631. }
  115632. }
  115633. declare module BABYLON {
  115634. /**
  115635. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  115636. */
  115637. export class FadeInOutBehavior implements Behavior<Mesh> {
  115638. /**
  115639. * Time in milliseconds to delay before fading in (Default: 0)
  115640. */
  115641. delay: number;
  115642. /**
  115643. * Time in milliseconds for the mesh to fade in (Default: 300)
  115644. */
  115645. fadeInTime: number;
  115646. private _millisecondsPerFrame;
  115647. private _hovered;
  115648. private _hoverValue;
  115649. private _ownerNode;
  115650. /**
  115651. * Instatiates the FadeInOutBehavior
  115652. */
  115653. constructor();
  115654. /**
  115655. * The name of the behavior
  115656. */
  115657. get name(): string;
  115658. /**
  115659. * Initializes the behavior
  115660. */
  115661. init(): void;
  115662. /**
  115663. * Attaches the fade behavior on the passed in mesh
  115664. * @param ownerNode The mesh that will be faded in/out once attached
  115665. */
  115666. attach(ownerNode: Mesh): void;
  115667. /**
  115668. * Detaches the behavior from the mesh
  115669. */
  115670. detach(): void;
  115671. /**
  115672. * Triggers the mesh to begin fading in or out
  115673. * @param value if the object should fade in or out (true to fade in)
  115674. */
  115675. fadeIn(value: boolean): void;
  115676. private _update;
  115677. private _setAllVisibility;
  115678. }
  115679. }
  115680. declare module BABYLON {
  115681. /**
  115682. * Class containing a set of static utilities functions for managing Pivots
  115683. * @hidden
  115684. */
  115685. export class PivotTools {
  115686. private static _PivotCached;
  115687. private static _OldPivotPoint;
  115688. private static _PivotTranslation;
  115689. private static _PivotTmpVector;
  115690. /** @hidden */
  115691. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  115692. /** @hidden */
  115693. static _RestorePivotPoint(mesh: AbstractMesh): void;
  115694. }
  115695. }
  115696. declare module BABYLON {
  115697. /**
  115698. * Class containing static functions to help procedurally build meshes
  115699. */
  115700. export class PlaneBuilder {
  115701. /**
  115702. * Creates a plane mesh
  115703. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  115704. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  115705. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  115706. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  115707. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115708. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  115709. * @param name defines the name of the mesh
  115710. * @param options defines the options used to create the mesh
  115711. * @param scene defines the hosting scene
  115712. * @returns the plane mesh
  115713. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  115714. */
  115715. static CreatePlane(name: string, options: {
  115716. size?: number;
  115717. width?: number;
  115718. height?: number;
  115719. sideOrientation?: number;
  115720. frontUVs?: Vector4;
  115721. backUVs?: Vector4;
  115722. updatable?: boolean;
  115723. sourcePlane?: Plane;
  115724. }, scene?: Nullable<Scene>): Mesh;
  115725. }
  115726. }
  115727. declare module BABYLON {
  115728. /**
  115729. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  115730. */
  115731. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  115732. private static _AnyMouseID;
  115733. /**
  115734. * Abstract mesh the behavior is set on
  115735. */
  115736. attachedNode: AbstractMesh;
  115737. private _dragPlane;
  115738. private _scene;
  115739. private _pointerObserver;
  115740. private _beforeRenderObserver;
  115741. private static _planeScene;
  115742. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  115743. /**
  115744. * 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)
  115745. */
  115746. maxDragAngle: number;
  115747. /**
  115748. * @hidden
  115749. */
  115750. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  115751. /**
  115752. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  115753. */
  115754. currentDraggingPointerID: number;
  115755. /**
  115756. * The last position where the pointer hit the drag plane in world space
  115757. */
  115758. lastDragPosition: Vector3;
  115759. /**
  115760. * If the behavior is currently in a dragging state
  115761. */
  115762. dragging: boolean;
  115763. /**
  115764. * 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)
  115765. */
  115766. dragDeltaRatio: number;
  115767. /**
  115768. * If the drag plane orientation should be updated during the dragging (Default: true)
  115769. */
  115770. updateDragPlane: boolean;
  115771. private _debugMode;
  115772. private _moving;
  115773. /**
  115774. * Fires each time the attached mesh is dragged with the pointer
  115775. * * delta between last drag position and current drag position in world space
  115776. * * dragDistance along the drag axis
  115777. * * dragPlaneNormal normal of the current drag plane used during the drag
  115778. * * dragPlanePoint in world space where the drag intersects the drag plane
  115779. */
  115780. onDragObservable: Observable<{
  115781. delta: Vector3;
  115782. dragPlanePoint: Vector3;
  115783. dragPlaneNormal: Vector3;
  115784. dragDistance: number;
  115785. pointerId: number;
  115786. }>;
  115787. /**
  115788. * Fires each time a drag begins (eg. mouse down on mesh)
  115789. */
  115790. onDragStartObservable: Observable<{
  115791. dragPlanePoint: Vector3;
  115792. pointerId: number;
  115793. }>;
  115794. /**
  115795. * Fires each time a drag ends (eg. mouse release after drag)
  115796. */
  115797. onDragEndObservable: Observable<{
  115798. dragPlanePoint: Vector3;
  115799. pointerId: number;
  115800. }>;
  115801. /**
  115802. * If the attached mesh should be moved when dragged
  115803. */
  115804. moveAttached: boolean;
  115805. /**
  115806. * If the drag behavior will react to drag events (Default: true)
  115807. */
  115808. enabled: boolean;
  115809. /**
  115810. * If pointer events should start and release the drag (Default: true)
  115811. */
  115812. startAndReleaseDragOnPointerEvents: boolean;
  115813. /**
  115814. * If camera controls should be detached during the drag
  115815. */
  115816. detachCameraControls: boolean;
  115817. /**
  115818. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  115819. */
  115820. useObjectOrientationForDragging: boolean;
  115821. private _options;
  115822. /**
  115823. * Gets the options used by the behavior
  115824. */
  115825. get options(): {
  115826. dragAxis?: Vector3;
  115827. dragPlaneNormal?: Vector3;
  115828. };
  115829. /**
  115830. * Sets the options used by the behavior
  115831. */
  115832. set options(options: {
  115833. dragAxis?: Vector3;
  115834. dragPlaneNormal?: Vector3;
  115835. });
  115836. /**
  115837. * Creates a pointer drag behavior that can be attached to a mesh
  115838. * @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)
  115839. */
  115840. constructor(options?: {
  115841. dragAxis?: Vector3;
  115842. dragPlaneNormal?: Vector3;
  115843. });
  115844. /**
  115845. * Predicate to determine if it is valid to move the object to a new position when it is moved
  115846. */
  115847. validateDrag: (targetPosition: Vector3) => boolean;
  115848. /**
  115849. * The name of the behavior
  115850. */
  115851. get name(): string;
  115852. /**
  115853. * Initializes the behavior
  115854. */
  115855. init(): void;
  115856. private _tmpVector;
  115857. private _alternatePickedPoint;
  115858. private _worldDragAxis;
  115859. private _targetPosition;
  115860. private _attachedElement;
  115861. /**
  115862. * Attaches the drag behavior the passed in mesh
  115863. * @param ownerNode The mesh that will be dragged around once attached
  115864. * @param predicate Predicate to use for pick filtering
  115865. */
  115866. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  115867. /**
  115868. * Force relase the drag action by code.
  115869. */
  115870. releaseDrag(): void;
  115871. private _startDragRay;
  115872. private _lastPointerRay;
  115873. /**
  115874. * Simulates the start of a pointer drag event on the behavior
  115875. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  115876. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  115877. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  115878. */
  115879. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  115880. private _startDrag;
  115881. private _dragDelta;
  115882. private _moveDrag;
  115883. private _pickWithRayOnDragPlane;
  115884. private _pointA;
  115885. private _pointB;
  115886. private _pointC;
  115887. private _lineA;
  115888. private _lineB;
  115889. private _localAxis;
  115890. private _lookAt;
  115891. private _updateDragPlanePosition;
  115892. /**
  115893. * Detaches the behavior from the mesh
  115894. */
  115895. detach(): void;
  115896. }
  115897. }
  115898. declare module BABYLON {
  115899. /**
  115900. * A behavior that when attached to a mesh will allow the mesh to be scaled
  115901. */
  115902. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  115903. private _dragBehaviorA;
  115904. private _dragBehaviorB;
  115905. private _startDistance;
  115906. private _initialScale;
  115907. private _targetScale;
  115908. private _ownerNode;
  115909. private _sceneRenderObserver;
  115910. /**
  115911. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  115912. */
  115913. constructor();
  115914. /**
  115915. * The name of the behavior
  115916. */
  115917. get name(): string;
  115918. /**
  115919. * Initializes the behavior
  115920. */
  115921. init(): void;
  115922. private _getCurrentDistance;
  115923. /**
  115924. * Attaches the scale behavior the passed in mesh
  115925. * @param ownerNode The mesh that will be scaled around once attached
  115926. */
  115927. attach(ownerNode: Mesh): void;
  115928. /**
  115929. * Detaches the behavior from the mesh
  115930. */
  115931. detach(): void;
  115932. }
  115933. }
  115934. declare module BABYLON {
  115935. /**
  115936. * 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
  115937. */
  115938. export class SixDofDragBehavior implements Behavior<Mesh> {
  115939. private static _virtualScene;
  115940. private _ownerNode;
  115941. private _sceneRenderObserver;
  115942. private _scene;
  115943. private _targetPosition;
  115944. private _virtualOriginMesh;
  115945. private _virtualDragMesh;
  115946. private _pointerObserver;
  115947. private _moving;
  115948. private _startingOrientation;
  115949. private _attachedElement;
  115950. /**
  115951. * 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)
  115952. */
  115953. private zDragFactor;
  115954. /**
  115955. * If the object should rotate to face the drag origin
  115956. */
  115957. rotateDraggedObject: boolean;
  115958. /**
  115959. * If the behavior is currently in a dragging state
  115960. */
  115961. dragging: boolean;
  115962. /**
  115963. * 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)
  115964. */
  115965. dragDeltaRatio: number;
  115966. /**
  115967. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  115968. */
  115969. currentDraggingPointerID: number;
  115970. /**
  115971. * If camera controls should be detached during the drag
  115972. */
  115973. detachCameraControls: boolean;
  115974. /**
  115975. * Fires each time a drag starts
  115976. */
  115977. onDragStartObservable: Observable<{}>;
  115978. /**
  115979. * Fires each time a drag ends (eg. mouse release after drag)
  115980. */
  115981. onDragEndObservable: Observable<{}>;
  115982. /**
  115983. * 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
  115984. */
  115985. constructor();
  115986. /**
  115987. * The name of the behavior
  115988. */
  115989. get name(): string;
  115990. /**
  115991. * Initializes the behavior
  115992. */
  115993. init(): void;
  115994. /**
  115995. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  115996. */
  115997. private get _pointerCamera();
  115998. /**
  115999. * Attaches the scale behavior the passed in mesh
  116000. * @param ownerNode The mesh that will be scaled around once attached
  116001. */
  116002. attach(ownerNode: Mesh): void;
  116003. /**
  116004. * Detaches the behavior from the mesh
  116005. */
  116006. detach(): void;
  116007. }
  116008. }
  116009. declare module BABYLON {
  116010. /**
  116011. * Class used to apply inverse kinematics to bones
  116012. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  116013. */
  116014. export class BoneIKController {
  116015. private static _tmpVecs;
  116016. private static _tmpQuat;
  116017. private static _tmpMats;
  116018. /**
  116019. * Gets or sets the target mesh
  116020. */
  116021. targetMesh: AbstractMesh;
  116022. /** Gets or sets the mesh used as pole */
  116023. poleTargetMesh: AbstractMesh;
  116024. /**
  116025. * Gets or sets the bone used as pole
  116026. */
  116027. poleTargetBone: Nullable<Bone>;
  116028. /**
  116029. * Gets or sets the target position
  116030. */
  116031. targetPosition: Vector3;
  116032. /**
  116033. * Gets or sets the pole target position
  116034. */
  116035. poleTargetPosition: Vector3;
  116036. /**
  116037. * Gets or sets the pole target local offset
  116038. */
  116039. poleTargetLocalOffset: Vector3;
  116040. /**
  116041. * Gets or sets the pole angle
  116042. */
  116043. poleAngle: number;
  116044. /**
  116045. * Gets or sets the mesh associated with the controller
  116046. */
  116047. mesh: AbstractMesh;
  116048. /**
  116049. * 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)
  116050. */
  116051. slerpAmount: number;
  116052. private _bone1Quat;
  116053. private _bone1Mat;
  116054. private _bone2Ang;
  116055. private _bone1;
  116056. private _bone2;
  116057. private _bone1Length;
  116058. private _bone2Length;
  116059. private _maxAngle;
  116060. private _maxReach;
  116061. private _rightHandedSystem;
  116062. private _bendAxis;
  116063. private _slerping;
  116064. private _adjustRoll;
  116065. /**
  116066. * Gets or sets maximum allowed angle
  116067. */
  116068. get maxAngle(): number;
  116069. set maxAngle(value: number);
  116070. /**
  116071. * Creates a new BoneIKController
  116072. * @param mesh defines the mesh to control
  116073. * @param bone defines the bone to control
  116074. * @param options defines options to set up the controller
  116075. */
  116076. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  116077. targetMesh?: AbstractMesh;
  116078. poleTargetMesh?: AbstractMesh;
  116079. poleTargetBone?: Bone;
  116080. poleTargetLocalOffset?: Vector3;
  116081. poleAngle?: number;
  116082. bendAxis?: Vector3;
  116083. maxAngle?: number;
  116084. slerpAmount?: number;
  116085. });
  116086. private _setMaxAngle;
  116087. /**
  116088. * Force the controller to update the bones
  116089. */
  116090. update(): void;
  116091. }
  116092. }
  116093. declare module BABYLON {
  116094. /**
  116095. * Class used to make a bone look toward a point in space
  116096. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  116097. */
  116098. export class BoneLookController {
  116099. private static _tmpVecs;
  116100. private static _tmpQuat;
  116101. private static _tmpMats;
  116102. /**
  116103. * The target Vector3 that the bone will look at
  116104. */
  116105. target: Vector3;
  116106. /**
  116107. * The mesh that the bone is attached to
  116108. */
  116109. mesh: AbstractMesh;
  116110. /**
  116111. * The bone that will be looking to the target
  116112. */
  116113. bone: Bone;
  116114. /**
  116115. * The up axis of the coordinate system that is used when the bone is rotated
  116116. */
  116117. upAxis: Vector3;
  116118. /**
  116119. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  116120. */
  116121. upAxisSpace: Space;
  116122. /**
  116123. * Used to make an adjustment to the yaw of the bone
  116124. */
  116125. adjustYaw: number;
  116126. /**
  116127. * Used to make an adjustment to the pitch of the bone
  116128. */
  116129. adjustPitch: number;
  116130. /**
  116131. * Used to make an adjustment to the roll of the bone
  116132. */
  116133. adjustRoll: number;
  116134. /**
  116135. * 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)
  116136. */
  116137. slerpAmount: number;
  116138. private _minYaw;
  116139. private _maxYaw;
  116140. private _minPitch;
  116141. private _maxPitch;
  116142. private _minYawSin;
  116143. private _minYawCos;
  116144. private _maxYawSin;
  116145. private _maxYawCos;
  116146. private _midYawConstraint;
  116147. private _minPitchTan;
  116148. private _maxPitchTan;
  116149. private _boneQuat;
  116150. private _slerping;
  116151. private _transformYawPitch;
  116152. private _transformYawPitchInv;
  116153. private _firstFrameSkipped;
  116154. private _yawRange;
  116155. private _fowardAxis;
  116156. /**
  116157. * Gets or sets the minimum yaw angle that the bone can look to
  116158. */
  116159. get minYaw(): number;
  116160. set minYaw(value: number);
  116161. /**
  116162. * Gets or sets the maximum yaw angle that the bone can look to
  116163. */
  116164. get maxYaw(): number;
  116165. set maxYaw(value: number);
  116166. /**
  116167. * Gets or sets the minimum pitch angle that the bone can look to
  116168. */
  116169. get minPitch(): number;
  116170. set minPitch(value: number);
  116171. /**
  116172. * Gets or sets the maximum pitch angle that the bone can look to
  116173. */
  116174. get maxPitch(): number;
  116175. set maxPitch(value: number);
  116176. /**
  116177. * Create a BoneLookController
  116178. * @param mesh the mesh that the bone belongs to
  116179. * @param bone the bone that will be looking to the target
  116180. * @param target the target Vector3 to look at
  116181. * @param options optional settings:
  116182. * * maxYaw: the maximum angle the bone will yaw to
  116183. * * minYaw: the minimum angle the bone will yaw to
  116184. * * maxPitch: the maximum angle the bone will pitch to
  116185. * * minPitch: the minimum angle the bone will yaw to
  116186. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  116187. * * upAxis: the up axis of the coordinate system
  116188. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  116189. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  116190. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  116191. * * adjustYaw: used to make an adjustment to the yaw of the bone
  116192. * * adjustPitch: used to make an adjustment to the pitch of the bone
  116193. * * adjustRoll: used to make an adjustment to the roll of the bone
  116194. **/
  116195. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  116196. maxYaw?: number;
  116197. minYaw?: number;
  116198. maxPitch?: number;
  116199. minPitch?: number;
  116200. slerpAmount?: number;
  116201. upAxis?: Vector3;
  116202. upAxisSpace?: Space;
  116203. yawAxis?: Vector3;
  116204. pitchAxis?: Vector3;
  116205. adjustYaw?: number;
  116206. adjustPitch?: number;
  116207. adjustRoll?: number;
  116208. });
  116209. /**
  116210. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  116211. */
  116212. update(): void;
  116213. private _getAngleDiff;
  116214. private _getAngleBetween;
  116215. private _isAngleBetween;
  116216. }
  116217. }
  116218. declare module BABYLON {
  116219. /**
  116220. * Manage the gamepad inputs to control an arc rotate camera.
  116221. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  116222. */
  116223. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  116224. /**
  116225. * Defines the camera the input is attached to.
  116226. */
  116227. camera: ArcRotateCamera;
  116228. /**
  116229. * Defines the gamepad the input is gathering event from.
  116230. */
  116231. gamepad: Nullable<Gamepad>;
  116232. /**
  116233. * Defines the gamepad rotation sensiblity.
  116234. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  116235. */
  116236. gamepadRotationSensibility: number;
  116237. /**
  116238. * Defines the gamepad move sensiblity.
  116239. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  116240. */
  116241. gamepadMoveSensibility: number;
  116242. private _yAxisScale;
  116243. /**
  116244. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  116245. */
  116246. get invertYAxis(): boolean;
  116247. set invertYAxis(value: boolean);
  116248. private _onGamepadConnectedObserver;
  116249. private _onGamepadDisconnectedObserver;
  116250. /**
  116251. * Attach the input controls to a specific dom element to get the input from.
  116252. * @param element Defines the element the controls should be listened from
  116253. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  116254. */
  116255. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  116256. /**
  116257. * Detach the current controls from the specified dom element.
  116258. * @param element Defines the element to stop listening the inputs from
  116259. */
  116260. detachControl(element: Nullable<HTMLElement>): void;
  116261. /**
  116262. * Update the current camera state depending on the inputs that have been used this frame.
  116263. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  116264. */
  116265. checkInputs(): void;
  116266. /**
  116267. * Gets the class name of the current intput.
  116268. * @returns the class name
  116269. */
  116270. getClassName(): string;
  116271. /**
  116272. * Get the friendly name associated with the input class.
  116273. * @returns the input friendly name
  116274. */
  116275. getSimpleName(): string;
  116276. }
  116277. }
  116278. declare module BABYLON {
  116279. interface ArcRotateCameraInputsManager {
  116280. /**
  116281. * Add orientation input support to the input manager.
  116282. * @returns the current input manager
  116283. */
  116284. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  116285. }
  116286. /**
  116287. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  116288. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  116289. */
  116290. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  116291. /**
  116292. * Defines the camera the input is attached to.
  116293. */
  116294. camera: ArcRotateCamera;
  116295. /**
  116296. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  116297. */
  116298. alphaCorrection: number;
  116299. /**
  116300. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  116301. */
  116302. gammaCorrection: number;
  116303. private _alpha;
  116304. private _gamma;
  116305. private _dirty;
  116306. private _deviceOrientationHandler;
  116307. /**
  116308. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  116309. */
  116310. constructor();
  116311. /**
  116312. * Attach the input controls to a specific dom element to get the input from.
  116313. * @param element Defines the element the controls should be listened from
  116314. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  116315. */
  116316. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  116317. /** @hidden */
  116318. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  116319. /**
  116320. * Update the current camera state depending on the inputs that have been used this frame.
  116321. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  116322. */
  116323. checkInputs(): void;
  116324. /**
  116325. * Detach the current controls from the specified dom element.
  116326. * @param element Defines the element to stop listening the inputs from
  116327. */
  116328. detachControl(element: Nullable<HTMLElement>): void;
  116329. /**
  116330. * Gets the class name of the current intput.
  116331. * @returns the class name
  116332. */
  116333. getClassName(): string;
  116334. /**
  116335. * Get the friendly name associated with the input class.
  116336. * @returns the input friendly name
  116337. */
  116338. getSimpleName(): string;
  116339. }
  116340. }
  116341. declare module BABYLON {
  116342. /**
  116343. * Listen to mouse events to control the camera.
  116344. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  116345. */
  116346. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  116347. /**
  116348. * Defines the camera the input is attached to.
  116349. */
  116350. camera: FlyCamera;
  116351. /**
  116352. * Defines if touch is enabled. (Default is true.)
  116353. */
  116354. touchEnabled: boolean;
  116355. /**
  116356. * Defines the buttons associated with the input to handle camera rotation.
  116357. */
  116358. buttons: number[];
  116359. /**
  116360. * Assign buttons for Yaw control.
  116361. */
  116362. buttonsYaw: number[];
  116363. /**
  116364. * Assign buttons for Pitch control.
  116365. */
  116366. buttonsPitch: number[];
  116367. /**
  116368. * Assign buttons for Roll control.
  116369. */
  116370. buttonsRoll: number[];
  116371. /**
  116372. * Detect if any button is being pressed while mouse is moved.
  116373. * -1 = Mouse locked.
  116374. * 0 = Left button.
  116375. * 1 = Middle Button.
  116376. * 2 = Right Button.
  116377. */
  116378. activeButton: number;
  116379. /**
  116380. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  116381. * Higher values reduce its sensitivity.
  116382. */
  116383. angularSensibility: number;
  116384. private _mousemoveCallback;
  116385. private _observer;
  116386. private _rollObserver;
  116387. private previousPosition;
  116388. private noPreventDefault;
  116389. private element;
  116390. /**
  116391. * Listen to mouse events to control the camera.
  116392. * @param touchEnabled Define if touch is enabled. (Default is true.)
  116393. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  116394. */
  116395. constructor(touchEnabled?: boolean);
  116396. /**
  116397. * Attach the mouse control to the HTML DOM element.
  116398. * @param element Defines the element that listens to the input events.
  116399. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  116400. */
  116401. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  116402. /**
  116403. * Detach the current controls from the specified dom element.
  116404. * @param element Defines the element to stop listening the inputs from
  116405. */
  116406. detachControl(element: Nullable<HTMLElement>): void;
  116407. /**
  116408. * Gets the class name of the current input.
  116409. * @returns the class name.
  116410. */
  116411. getClassName(): string;
  116412. /**
  116413. * Get the friendly name associated with the input class.
  116414. * @returns the input's friendly name.
  116415. */
  116416. getSimpleName(): string;
  116417. private _pointerInput;
  116418. private _onMouseMove;
  116419. /**
  116420. * Rotate camera by mouse offset.
  116421. */
  116422. private rotateCamera;
  116423. }
  116424. }
  116425. declare module BABYLON {
  116426. /**
  116427. * Default Inputs manager for the FlyCamera.
  116428. * It groups all the default supported inputs for ease of use.
  116429. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  116430. */
  116431. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  116432. /**
  116433. * Instantiates a new FlyCameraInputsManager.
  116434. * @param camera Defines the camera the inputs belong to.
  116435. */
  116436. constructor(camera: FlyCamera);
  116437. /**
  116438. * Add keyboard input support to the input manager.
  116439. * @returns the new FlyCameraKeyboardMoveInput().
  116440. */
  116441. addKeyboard(): FlyCameraInputsManager;
  116442. /**
  116443. * Add mouse input support to the input manager.
  116444. * @param touchEnabled Enable touch screen support.
  116445. * @returns the new FlyCameraMouseInput().
  116446. */
  116447. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  116448. }
  116449. }
  116450. declare module BABYLON {
  116451. /**
  116452. * This is a flying camera, designed for 3D movement and rotation in all directions,
  116453. * such as in a 3D Space Shooter or a Flight Simulator.
  116454. */
  116455. export class FlyCamera extends TargetCamera {
  116456. /**
  116457. * Define the collision ellipsoid of the camera.
  116458. * This is helpful for simulating a camera body, like a player's body.
  116459. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  116460. */
  116461. ellipsoid: Vector3;
  116462. /**
  116463. * Define an offset for the position of the ellipsoid around the camera.
  116464. * This can be helpful if the camera is attached away from the player's body center,
  116465. * such as at its head.
  116466. */
  116467. ellipsoidOffset: Vector3;
  116468. /**
  116469. * Enable or disable collisions of the camera with the rest of the scene objects.
  116470. */
  116471. checkCollisions: boolean;
  116472. /**
  116473. * Enable or disable gravity on the camera.
  116474. */
  116475. applyGravity: boolean;
  116476. /**
  116477. * Define the current direction the camera is moving to.
  116478. */
  116479. cameraDirection: Vector3;
  116480. /**
  116481. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  116482. * This overrides and empties cameraRotation.
  116483. */
  116484. rotationQuaternion: Quaternion;
  116485. /**
  116486. * Track Roll to maintain the wanted Rolling when looking around.
  116487. */
  116488. _trackRoll: number;
  116489. /**
  116490. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  116491. */
  116492. rollCorrect: number;
  116493. /**
  116494. * Mimic a banked turn, Rolling the camera when Yawing.
  116495. * It's recommended to use rollCorrect = 10 for faster banking correction.
  116496. */
  116497. bankedTurn: boolean;
  116498. /**
  116499. * Limit in radians for how much Roll banking will add. (Default: 90°)
  116500. */
  116501. bankedTurnLimit: number;
  116502. /**
  116503. * Value of 0 disables the banked Roll.
  116504. * Value of 1 is equal to the Yaw angle in radians.
  116505. */
  116506. bankedTurnMultiplier: number;
  116507. /**
  116508. * The inputs manager loads all the input sources, such as keyboard and mouse.
  116509. */
  116510. inputs: FlyCameraInputsManager;
  116511. /**
  116512. * Gets the input sensibility for mouse input.
  116513. * Higher values reduce sensitivity.
  116514. */
  116515. get angularSensibility(): number;
  116516. /**
  116517. * Sets the input sensibility for a mouse input.
  116518. * Higher values reduce sensitivity.
  116519. */
  116520. set angularSensibility(value: number);
  116521. /**
  116522. * Get the keys for camera movement forward.
  116523. */
  116524. get keysForward(): number[];
  116525. /**
  116526. * Set the keys for camera movement forward.
  116527. */
  116528. set keysForward(value: number[]);
  116529. /**
  116530. * Get the keys for camera movement backward.
  116531. */
  116532. get keysBackward(): number[];
  116533. set keysBackward(value: number[]);
  116534. /**
  116535. * Get the keys for camera movement up.
  116536. */
  116537. get keysUp(): number[];
  116538. /**
  116539. * Set the keys for camera movement up.
  116540. */
  116541. set keysUp(value: number[]);
  116542. /**
  116543. * Get the keys for camera movement down.
  116544. */
  116545. get keysDown(): number[];
  116546. /**
  116547. * Set the keys for camera movement down.
  116548. */
  116549. set keysDown(value: number[]);
  116550. /**
  116551. * Get the keys for camera movement left.
  116552. */
  116553. get keysLeft(): number[];
  116554. /**
  116555. * Set the keys for camera movement left.
  116556. */
  116557. set keysLeft(value: number[]);
  116558. /**
  116559. * Set the keys for camera movement right.
  116560. */
  116561. get keysRight(): number[];
  116562. /**
  116563. * Set the keys for camera movement right.
  116564. */
  116565. set keysRight(value: number[]);
  116566. /**
  116567. * Event raised when the camera collides with a mesh in the scene.
  116568. */
  116569. onCollide: (collidedMesh: AbstractMesh) => void;
  116570. private _collider;
  116571. private _needMoveForGravity;
  116572. private _oldPosition;
  116573. private _diffPosition;
  116574. private _newPosition;
  116575. /** @hidden */
  116576. _localDirection: Vector3;
  116577. /** @hidden */
  116578. _transformedDirection: Vector3;
  116579. /**
  116580. * Instantiates a FlyCamera.
  116581. * This is a flying camera, designed for 3D movement and rotation in all directions,
  116582. * such as in a 3D Space Shooter or a Flight Simulator.
  116583. * @param name Define the name of the camera in the scene.
  116584. * @param position Define the starting position of the camera in the scene.
  116585. * @param scene Define the scene the camera belongs to.
  116586. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  116587. */
  116588. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  116589. /**
  116590. * Attach a control to the HTML DOM element.
  116591. * @param element Defines the element that listens to the input events.
  116592. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  116593. */
  116594. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  116595. /**
  116596. * Detach a control from the HTML DOM element.
  116597. * The camera will stop reacting to that input.
  116598. * @param element Defines the element that listens to the input events.
  116599. */
  116600. detachControl(element: HTMLElement): void;
  116601. private _collisionMask;
  116602. /**
  116603. * Get the mask that the camera ignores in collision events.
  116604. */
  116605. get collisionMask(): number;
  116606. /**
  116607. * Set the mask that the camera ignores in collision events.
  116608. */
  116609. set collisionMask(mask: number);
  116610. /** @hidden */
  116611. _collideWithWorld(displacement: Vector3): void;
  116612. /** @hidden */
  116613. private _onCollisionPositionChange;
  116614. /** @hidden */
  116615. _checkInputs(): void;
  116616. /** @hidden */
  116617. _decideIfNeedsToMove(): boolean;
  116618. /** @hidden */
  116619. _updatePosition(): void;
  116620. /**
  116621. * Restore the Roll to its target value at the rate specified.
  116622. * @param rate - Higher means slower restoring.
  116623. * @hidden
  116624. */
  116625. restoreRoll(rate: number): void;
  116626. /**
  116627. * Destroy the camera and release the current resources held by it.
  116628. */
  116629. dispose(): void;
  116630. /**
  116631. * Get the current object class name.
  116632. * @returns the class name.
  116633. */
  116634. getClassName(): string;
  116635. }
  116636. }
  116637. declare module BABYLON {
  116638. /**
  116639. * Listen to keyboard events to control the camera.
  116640. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  116641. */
  116642. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  116643. /**
  116644. * Defines the camera the input is attached to.
  116645. */
  116646. camera: FlyCamera;
  116647. /**
  116648. * The list of keyboard keys used to control the forward move of the camera.
  116649. */
  116650. keysForward: number[];
  116651. /**
  116652. * The list of keyboard keys used to control the backward move of the camera.
  116653. */
  116654. keysBackward: number[];
  116655. /**
  116656. * The list of keyboard keys used to control the forward move of the camera.
  116657. */
  116658. keysUp: number[];
  116659. /**
  116660. * The list of keyboard keys used to control the backward move of the camera.
  116661. */
  116662. keysDown: number[];
  116663. /**
  116664. * The list of keyboard keys used to control the right strafe move of the camera.
  116665. */
  116666. keysRight: number[];
  116667. /**
  116668. * The list of keyboard keys used to control the left strafe move of the camera.
  116669. */
  116670. keysLeft: number[];
  116671. private _keys;
  116672. private _onCanvasBlurObserver;
  116673. private _onKeyboardObserver;
  116674. private _engine;
  116675. private _scene;
  116676. /**
  116677. * Attach the input controls to a specific dom element to get the input from.
  116678. * @param element Defines the element the controls should be listened from
  116679. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  116680. */
  116681. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  116682. /**
  116683. * Detach the current controls from the specified dom element.
  116684. * @param element Defines the element to stop listening the inputs from
  116685. */
  116686. detachControl(element: Nullable<HTMLElement>): void;
  116687. /**
  116688. * Gets the class name of the current intput.
  116689. * @returns the class name
  116690. */
  116691. getClassName(): string;
  116692. /** @hidden */
  116693. _onLostFocus(e: FocusEvent): void;
  116694. /**
  116695. * Get the friendly name associated with the input class.
  116696. * @returns the input friendly name
  116697. */
  116698. getSimpleName(): string;
  116699. /**
  116700. * Update the current camera state depending on the inputs that have been used this frame.
  116701. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  116702. */
  116703. checkInputs(): void;
  116704. }
  116705. }
  116706. declare module BABYLON {
  116707. /**
  116708. * Manage the mouse wheel inputs to control a follow camera.
  116709. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  116710. */
  116711. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  116712. /**
  116713. * Defines the camera the input is attached to.
  116714. */
  116715. camera: FollowCamera;
  116716. /**
  116717. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  116718. */
  116719. axisControlRadius: boolean;
  116720. /**
  116721. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  116722. */
  116723. axisControlHeight: boolean;
  116724. /**
  116725. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  116726. */
  116727. axisControlRotation: boolean;
  116728. /**
  116729. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  116730. * relation to mouseWheel events.
  116731. */
  116732. wheelPrecision: number;
  116733. /**
  116734. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  116735. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  116736. */
  116737. wheelDeltaPercentage: number;
  116738. private _wheel;
  116739. private _observer;
  116740. /**
  116741. * Attach the input controls to a specific dom element to get the input from.
  116742. * @param element Defines the element the controls should be listened from
  116743. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  116744. */
  116745. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  116746. /**
  116747. * Detach the current controls from the specified dom element.
  116748. * @param element Defines the element to stop listening the inputs from
  116749. */
  116750. detachControl(element: Nullable<HTMLElement>): void;
  116751. /**
  116752. * Gets the class name of the current intput.
  116753. * @returns the class name
  116754. */
  116755. getClassName(): string;
  116756. /**
  116757. * Get the friendly name associated with the input class.
  116758. * @returns the input friendly name
  116759. */
  116760. getSimpleName(): string;
  116761. }
  116762. }
  116763. declare module BABYLON {
  116764. /**
  116765. * Manage the pointers inputs to control an follow camera.
  116766. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  116767. */
  116768. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  116769. /**
  116770. * Defines the camera the input is attached to.
  116771. */
  116772. camera: FollowCamera;
  116773. /**
  116774. * Gets the class name of the current input.
  116775. * @returns the class name
  116776. */
  116777. getClassName(): string;
  116778. /**
  116779. * Defines the pointer angular sensibility along the X axis or how fast is
  116780. * the camera rotating.
  116781. * A negative number will reverse the axis direction.
  116782. */
  116783. angularSensibilityX: number;
  116784. /**
  116785. * Defines the pointer angular sensibility along the Y axis or how fast is
  116786. * the camera rotating.
  116787. * A negative number will reverse the axis direction.
  116788. */
  116789. angularSensibilityY: number;
  116790. /**
  116791. * Defines the pointer pinch precision or how fast is the camera zooming.
  116792. * A negative number will reverse the axis direction.
  116793. */
  116794. pinchPrecision: number;
  116795. /**
  116796. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  116797. * from 0.
  116798. * It defines the percentage of current camera.radius to use as delta when
  116799. * pinch zoom is used.
  116800. */
  116801. pinchDeltaPercentage: number;
  116802. /**
  116803. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  116804. */
  116805. axisXControlRadius: boolean;
  116806. /**
  116807. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  116808. */
  116809. axisXControlHeight: boolean;
  116810. /**
  116811. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  116812. */
  116813. axisXControlRotation: boolean;
  116814. /**
  116815. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  116816. */
  116817. axisYControlRadius: boolean;
  116818. /**
  116819. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  116820. */
  116821. axisYControlHeight: boolean;
  116822. /**
  116823. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  116824. */
  116825. axisYControlRotation: boolean;
  116826. /**
  116827. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  116828. */
  116829. axisPinchControlRadius: boolean;
  116830. /**
  116831. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  116832. */
  116833. axisPinchControlHeight: boolean;
  116834. /**
  116835. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  116836. */
  116837. axisPinchControlRotation: boolean;
  116838. /**
  116839. * Log error messages if basic misconfiguration has occurred.
  116840. */
  116841. warningEnable: boolean;
  116842. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  116843. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  116844. private _warningCounter;
  116845. private _warning;
  116846. }
  116847. }
  116848. declare module BABYLON {
  116849. /**
  116850. * Default Inputs manager for the FollowCamera.
  116851. * It groups all the default supported inputs for ease of use.
  116852. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  116853. */
  116854. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  116855. /**
  116856. * Instantiates a new FollowCameraInputsManager.
  116857. * @param camera Defines the camera the inputs belong to
  116858. */
  116859. constructor(camera: FollowCamera);
  116860. /**
  116861. * Add keyboard input support to the input manager.
  116862. * @returns the current input manager
  116863. */
  116864. addKeyboard(): FollowCameraInputsManager;
  116865. /**
  116866. * Add mouse wheel input support to the input manager.
  116867. * @returns the current input manager
  116868. */
  116869. addMouseWheel(): FollowCameraInputsManager;
  116870. /**
  116871. * Add pointers input support to the input manager.
  116872. * @returns the current input manager
  116873. */
  116874. addPointers(): FollowCameraInputsManager;
  116875. /**
  116876. * Add orientation input support to the input manager.
  116877. * @returns the current input manager
  116878. */
  116879. addVRDeviceOrientation(): FollowCameraInputsManager;
  116880. }
  116881. }
  116882. declare module BABYLON {
  116883. /**
  116884. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  116885. * an arc rotate version arcFollowCamera are available.
  116886. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  116887. */
  116888. export class FollowCamera extends TargetCamera {
  116889. /**
  116890. * Distance the follow camera should follow an object at
  116891. */
  116892. radius: number;
  116893. /**
  116894. * Minimum allowed distance of the camera to the axis of rotation
  116895. * (The camera can not get closer).
  116896. * This can help limiting how the Camera is able to move in the scene.
  116897. */
  116898. lowerRadiusLimit: Nullable<number>;
  116899. /**
  116900. * Maximum allowed distance of the camera to the axis of rotation
  116901. * (The camera can not get further).
  116902. * This can help limiting how the Camera is able to move in the scene.
  116903. */
  116904. upperRadiusLimit: Nullable<number>;
  116905. /**
  116906. * Define a rotation offset between the camera and the object it follows
  116907. */
  116908. rotationOffset: number;
  116909. /**
  116910. * Minimum allowed angle to camera position relative to target object.
  116911. * This can help limiting how the Camera is able to move in the scene.
  116912. */
  116913. lowerRotationOffsetLimit: Nullable<number>;
  116914. /**
  116915. * Maximum allowed angle to camera position relative to target object.
  116916. * This can help limiting how the Camera is able to move in the scene.
  116917. */
  116918. upperRotationOffsetLimit: Nullable<number>;
  116919. /**
  116920. * Define a height offset between the camera and the object it follows.
  116921. * It can help following an object from the top (like a car chaing a plane)
  116922. */
  116923. heightOffset: number;
  116924. /**
  116925. * Minimum allowed height of camera position relative to target object.
  116926. * This can help limiting how the Camera is able to move in the scene.
  116927. */
  116928. lowerHeightOffsetLimit: Nullable<number>;
  116929. /**
  116930. * Maximum allowed height of camera position relative to target object.
  116931. * This can help limiting how the Camera is able to move in the scene.
  116932. */
  116933. upperHeightOffsetLimit: Nullable<number>;
  116934. /**
  116935. * Define how fast the camera can accelerate to follow it s target.
  116936. */
  116937. cameraAcceleration: number;
  116938. /**
  116939. * Define the speed limit of the camera following an object.
  116940. */
  116941. maxCameraSpeed: number;
  116942. /**
  116943. * Define the target of the camera.
  116944. */
  116945. lockedTarget: Nullable<AbstractMesh>;
  116946. /**
  116947. * Defines the input associated with the camera.
  116948. */
  116949. inputs: FollowCameraInputsManager;
  116950. /**
  116951. * Instantiates the follow camera.
  116952. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  116953. * @param name Define the name of the camera in the scene
  116954. * @param position Define the position of the camera
  116955. * @param scene Define the scene the camera belong to
  116956. * @param lockedTarget Define the target of the camera
  116957. */
  116958. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  116959. private _follow;
  116960. /**
  116961. * Attached controls to the current camera.
  116962. * @param element Defines the element the controls should be listened from
  116963. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  116964. */
  116965. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  116966. /**
  116967. * Detach the current controls from the camera.
  116968. * The camera will stop reacting to inputs.
  116969. * @param element Defines the element to stop listening the inputs from
  116970. */
  116971. detachControl(element: HTMLElement): void;
  116972. /** @hidden */
  116973. _checkInputs(): void;
  116974. private _checkLimits;
  116975. /**
  116976. * Gets the camera class name.
  116977. * @returns the class name
  116978. */
  116979. getClassName(): string;
  116980. }
  116981. /**
  116982. * Arc Rotate version of the follow camera.
  116983. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  116984. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  116985. */
  116986. export class ArcFollowCamera extends TargetCamera {
  116987. /** The longitudinal angle of the camera */
  116988. alpha: number;
  116989. /** The latitudinal angle of the camera */
  116990. beta: number;
  116991. /** The radius of the camera from its target */
  116992. radius: number;
  116993. /** Define the camera target (the messh it should follow) */
  116994. target: Nullable<AbstractMesh>;
  116995. private _cartesianCoordinates;
  116996. /**
  116997. * Instantiates a new ArcFollowCamera
  116998. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  116999. * @param name Define the name of the camera
  117000. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  117001. * @param beta Define the rotation angle of the camera around the elevation axis
  117002. * @param radius Define the radius of the camera from its target point
  117003. * @param target Define the target of the camera
  117004. * @param scene Define the scene the camera belongs to
  117005. */
  117006. constructor(name: string,
  117007. /** The longitudinal angle of the camera */
  117008. alpha: number,
  117009. /** The latitudinal angle of the camera */
  117010. beta: number,
  117011. /** The radius of the camera from its target */
  117012. radius: number,
  117013. /** Define the camera target (the messh it should follow) */
  117014. target: Nullable<AbstractMesh>, scene: Scene);
  117015. private _follow;
  117016. /** @hidden */
  117017. _checkInputs(): void;
  117018. /**
  117019. * Returns the class name of the object.
  117020. * It is mostly used internally for serialization purposes.
  117021. */
  117022. getClassName(): string;
  117023. }
  117024. }
  117025. declare module BABYLON {
  117026. /**
  117027. * Manage the keyboard inputs to control the movement of a follow camera.
  117028. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  117029. */
  117030. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  117031. /**
  117032. * Defines the camera the input is attached to.
  117033. */
  117034. camera: FollowCamera;
  117035. /**
  117036. * Defines the list of key codes associated with the up action (increase heightOffset)
  117037. */
  117038. keysHeightOffsetIncr: number[];
  117039. /**
  117040. * Defines the list of key codes associated with the down action (decrease heightOffset)
  117041. */
  117042. keysHeightOffsetDecr: number[];
  117043. /**
  117044. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  117045. */
  117046. keysHeightOffsetModifierAlt: boolean;
  117047. /**
  117048. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  117049. */
  117050. keysHeightOffsetModifierCtrl: boolean;
  117051. /**
  117052. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  117053. */
  117054. keysHeightOffsetModifierShift: boolean;
  117055. /**
  117056. * Defines the list of key codes associated with the left action (increase rotationOffset)
  117057. */
  117058. keysRotationOffsetIncr: number[];
  117059. /**
  117060. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  117061. */
  117062. keysRotationOffsetDecr: number[];
  117063. /**
  117064. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  117065. */
  117066. keysRotationOffsetModifierAlt: boolean;
  117067. /**
  117068. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  117069. */
  117070. keysRotationOffsetModifierCtrl: boolean;
  117071. /**
  117072. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  117073. */
  117074. keysRotationOffsetModifierShift: boolean;
  117075. /**
  117076. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  117077. */
  117078. keysRadiusIncr: number[];
  117079. /**
  117080. * Defines the list of key codes associated with the zoom-out action (increase radius)
  117081. */
  117082. keysRadiusDecr: number[];
  117083. /**
  117084. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  117085. */
  117086. keysRadiusModifierAlt: boolean;
  117087. /**
  117088. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  117089. */
  117090. keysRadiusModifierCtrl: boolean;
  117091. /**
  117092. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  117093. */
  117094. keysRadiusModifierShift: boolean;
  117095. /**
  117096. * Defines the rate of change of heightOffset.
  117097. */
  117098. heightSensibility: number;
  117099. /**
  117100. * Defines the rate of change of rotationOffset.
  117101. */
  117102. rotationSensibility: number;
  117103. /**
  117104. * Defines the rate of change of radius.
  117105. */
  117106. radiusSensibility: number;
  117107. private _keys;
  117108. private _ctrlPressed;
  117109. private _altPressed;
  117110. private _shiftPressed;
  117111. private _onCanvasBlurObserver;
  117112. private _onKeyboardObserver;
  117113. private _engine;
  117114. private _scene;
  117115. /**
  117116. * Attach the input controls to a specific dom element to get the input from.
  117117. * @param element Defines the element the controls should be listened from
  117118. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  117119. */
  117120. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  117121. /**
  117122. * Detach the current controls from the specified dom element.
  117123. * @param element Defines the element to stop listening the inputs from
  117124. */
  117125. detachControl(element: Nullable<HTMLElement>): void;
  117126. /**
  117127. * Update the current camera state depending on the inputs that have been used this frame.
  117128. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  117129. */
  117130. checkInputs(): void;
  117131. /**
  117132. * Gets the class name of the current input.
  117133. * @returns the class name
  117134. */
  117135. getClassName(): string;
  117136. /**
  117137. * Get the friendly name associated with the input class.
  117138. * @returns the input friendly name
  117139. */
  117140. getSimpleName(): string;
  117141. /**
  117142. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  117143. * allow modification of the heightOffset value.
  117144. */
  117145. private _modifierHeightOffset;
  117146. /**
  117147. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  117148. * allow modification of the rotationOffset value.
  117149. */
  117150. private _modifierRotationOffset;
  117151. /**
  117152. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  117153. * allow modification of the radius value.
  117154. */
  117155. private _modifierRadius;
  117156. }
  117157. }
  117158. declare module BABYLON {
  117159. interface FreeCameraInputsManager {
  117160. /**
  117161. * @hidden
  117162. */
  117163. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  117164. /**
  117165. * Add orientation input support to the input manager.
  117166. * @returns the current input manager
  117167. */
  117168. addDeviceOrientation(): FreeCameraInputsManager;
  117169. }
  117170. /**
  117171. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  117172. * Screen rotation is taken into account.
  117173. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  117174. */
  117175. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  117176. private _camera;
  117177. private _screenOrientationAngle;
  117178. private _constantTranform;
  117179. private _screenQuaternion;
  117180. private _alpha;
  117181. private _beta;
  117182. private _gamma;
  117183. /**
  117184. * Can be used to detect if a device orientation sensor is available on a device
  117185. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  117186. * @returns a promise that will resolve on orientation change
  117187. */
  117188. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  117189. /**
  117190. * @hidden
  117191. */
  117192. _onDeviceOrientationChangedObservable: Observable<void>;
  117193. /**
  117194. * Instantiates a new input
  117195. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  117196. */
  117197. constructor();
  117198. /**
  117199. * Define the camera controlled by the input.
  117200. */
  117201. get camera(): FreeCamera;
  117202. set camera(camera: FreeCamera);
  117203. /**
  117204. * Attach the input controls to a specific dom element to get the input from.
  117205. * @param element Defines the element the controls should be listened from
  117206. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  117207. */
  117208. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  117209. private _orientationChanged;
  117210. private _deviceOrientation;
  117211. /**
  117212. * Detach the current controls from the specified dom element.
  117213. * @param element Defines the element to stop listening the inputs from
  117214. */
  117215. detachControl(element: Nullable<HTMLElement>): void;
  117216. /**
  117217. * Update the current camera state depending on the inputs that have been used this frame.
  117218. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  117219. */
  117220. checkInputs(): void;
  117221. /**
  117222. * Gets the class name of the current intput.
  117223. * @returns the class name
  117224. */
  117225. getClassName(): string;
  117226. /**
  117227. * Get the friendly name associated with the input class.
  117228. * @returns the input friendly name
  117229. */
  117230. getSimpleName(): string;
  117231. }
  117232. }
  117233. declare module BABYLON {
  117234. /**
  117235. * Manage the gamepad inputs to control a free camera.
  117236. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  117237. */
  117238. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  117239. /**
  117240. * Define the camera the input is attached to.
  117241. */
  117242. camera: FreeCamera;
  117243. /**
  117244. * Define the Gamepad controlling the input
  117245. */
  117246. gamepad: Nullable<Gamepad>;
  117247. /**
  117248. * Defines the gamepad rotation sensiblity.
  117249. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  117250. */
  117251. gamepadAngularSensibility: number;
  117252. /**
  117253. * Defines the gamepad move sensiblity.
  117254. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  117255. */
  117256. gamepadMoveSensibility: number;
  117257. private _yAxisScale;
  117258. /**
  117259. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  117260. */
  117261. get invertYAxis(): boolean;
  117262. set invertYAxis(value: boolean);
  117263. private _onGamepadConnectedObserver;
  117264. private _onGamepadDisconnectedObserver;
  117265. private _cameraTransform;
  117266. private _deltaTransform;
  117267. private _vector3;
  117268. private _vector2;
  117269. /**
  117270. * Attach the input controls to a specific dom element to get the input from.
  117271. * @param element Defines the element the controls should be listened from
  117272. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  117273. */
  117274. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  117275. /**
  117276. * Detach the current controls from the specified dom element.
  117277. * @param element Defines the element to stop listening the inputs from
  117278. */
  117279. detachControl(element: Nullable<HTMLElement>): void;
  117280. /**
  117281. * Update the current camera state depending on the inputs that have been used this frame.
  117282. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  117283. */
  117284. checkInputs(): void;
  117285. /**
  117286. * Gets the class name of the current intput.
  117287. * @returns the class name
  117288. */
  117289. getClassName(): string;
  117290. /**
  117291. * Get the friendly name associated with the input class.
  117292. * @returns the input friendly name
  117293. */
  117294. getSimpleName(): string;
  117295. }
  117296. }
  117297. declare module BABYLON {
  117298. /**
  117299. * Defines the potential axis of a Joystick
  117300. */
  117301. export enum JoystickAxis {
  117302. /** X axis */
  117303. X = 0,
  117304. /** Y axis */
  117305. Y = 1,
  117306. /** Z axis */
  117307. Z = 2
  117308. }
  117309. /**
  117310. * Class used to define virtual joystick (used in touch mode)
  117311. */
  117312. export class VirtualJoystick {
  117313. /**
  117314. * Gets or sets a boolean indicating that left and right values must be inverted
  117315. */
  117316. reverseLeftRight: boolean;
  117317. /**
  117318. * Gets or sets a boolean indicating that up and down values must be inverted
  117319. */
  117320. reverseUpDown: boolean;
  117321. /**
  117322. * Gets the offset value for the position (ie. the change of the position value)
  117323. */
  117324. deltaPosition: Vector3;
  117325. /**
  117326. * Gets a boolean indicating if the virtual joystick was pressed
  117327. */
  117328. pressed: boolean;
  117329. /**
  117330. * Canvas the virtual joystick will render onto, default z-index of this is 5
  117331. */
  117332. static Canvas: Nullable<HTMLCanvasElement>;
  117333. private static _globalJoystickIndex;
  117334. private static vjCanvasContext;
  117335. private static vjCanvasWidth;
  117336. private static vjCanvasHeight;
  117337. private static halfWidth;
  117338. private _action;
  117339. private _axisTargetedByLeftAndRight;
  117340. private _axisTargetedByUpAndDown;
  117341. private _joystickSensibility;
  117342. private _inversedSensibility;
  117343. private _joystickPointerID;
  117344. private _joystickColor;
  117345. private _joystickPointerPos;
  117346. private _joystickPreviousPointerPos;
  117347. private _joystickPointerStartPos;
  117348. private _deltaJoystickVector;
  117349. private _leftJoystick;
  117350. private _touches;
  117351. private _onPointerDownHandlerRef;
  117352. private _onPointerMoveHandlerRef;
  117353. private _onPointerUpHandlerRef;
  117354. private _onResize;
  117355. /**
  117356. * Creates a new virtual joystick
  117357. * @param leftJoystick defines that the joystick is for left hand (false by default)
  117358. */
  117359. constructor(leftJoystick?: boolean);
  117360. /**
  117361. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  117362. * @param newJoystickSensibility defines the new sensibility
  117363. */
  117364. setJoystickSensibility(newJoystickSensibility: number): void;
  117365. private _onPointerDown;
  117366. private _onPointerMove;
  117367. private _onPointerUp;
  117368. /**
  117369. * Change the color of the virtual joystick
  117370. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  117371. */
  117372. setJoystickColor(newColor: string): void;
  117373. /**
  117374. * Defines a callback to call when the joystick is touched
  117375. * @param action defines the callback
  117376. */
  117377. setActionOnTouch(action: () => any): void;
  117378. /**
  117379. * Defines which axis you'd like to control for left & right
  117380. * @param axis defines the axis to use
  117381. */
  117382. setAxisForLeftRight(axis: JoystickAxis): void;
  117383. /**
  117384. * Defines which axis you'd like to control for up & down
  117385. * @param axis defines the axis to use
  117386. */
  117387. setAxisForUpDown(axis: JoystickAxis): void;
  117388. private _drawVirtualJoystick;
  117389. /**
  117390. * Release internal HTML canvas
  117391. */
  117392. releaseCanvas(): void;
  117393. }
  117394. }
  117395. declare module BABYLON {
  117396. interface FreeCameraInputsManager {
  117397. /**
  117398. * Add virtual joystick input support to the input manager.
  117399. * @returns the current input manager
  117400. */
  117401. addVirtualJoystick(): FreeCameraInputsManager;
  117402. }
  117403. /**
  117404. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  117405. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  117406. */
  117407. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  117408. /**
  117409. * Defines the camera the input is attached to.
  117410. */
  117411. camera: FreeCamera;
  117412. private _leftjoystick;
  117413. private _rightjoystick;
  117414. /**
  117415. * Gets the left stick of the virtual joystick.
  117416. * @returns The virtual Joystick
  117417. */
  117418. getLeftJoystick(): VirtualJoystick;
  117419. /**
  117420. * Gets the right stick of the virtual joystick.
  117421. * @returns The virtual Joystick
  117422. */
  117423. getRightJoystick(): VirtualJoystick;
  117424. /**
  117425. * Update the current camera state depending on the inputs that have been used this frame.
  117426. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  117427. */
  117428. checkInputs(): void;
  117429. /**
  117430. * Attach the input controls to a specific dom element to get the input from.
  117431. * @param element Defines the element the controls should be listened from
  117432. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  117433. */
  117434. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  117435. /**
  117436. * Detach the current controls from the specified dom element.
  117437. * @param element Defines the element to stop listening the inputs from
  117438. */
  117439. detachControl(element: Nullable<HTMLElement>): void;
  117440. /**
  117441. * Gets the class name of the current intput.
  117442. * @returns the class name
  117443. */
  117444. getClassName(): string;
  117445. /**
  117446. * Get the friendly name associated with the input class.
  117447. * @returns the input friendly name
  117448. */
  117449. getSimpleName(): string;
  117450. }
  117451. }
  117452. declare module BABYLON {
  117453. /**
  117454. * This represents a FPS type of camera controlled by touch.
  117455. * This is like a universal camera minus the Gamepad controls.
  117456. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  117457. */
  117458. export class TouchCamera extends FreeCamera {
  117459. /**
  117460. * Defines the touch sensibility for rotation.
  117461. * The higher the faster.
  117462. */
  117463. get touchAngularSensibility(): number;
  117464. set touchAngularSensibility(value: number);
  117465. /**
  117466. * Defines the touch sensibility for move.
  117467. * The higher the faster.
  117468. */
  117469. get touchMoveSensibility(): number;
  117470. set touchMoveSensibility(value: number);
  117471. /**
  117472. * Instantiates a new touch camera.
  117473. * This represents a FPS type of camera controlled by touch.
  117474. * This is like a universal camera minus the Gamepad controls.
  117475. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  117476. * @param name Define the name of the camera in the scene
  117477. * @param position Define the start position of the camera in the scene
  117478. * @param scene Define the scene the camera belongs to
  117479. */
  117480. constructor(name: string, position: Vector3, scene: Scene);
  117481. /**
  117482. * Gets the current object class name.
  117483. * @return the class name
  117484. */
  117485. getClassName(): string;
  117486. /** @hidden */
  117487. _setupInputs(): void;
  117488. }
  117489. }
  117490. declare module BABYLON {
  117491. /**
  117492. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  117493. * being tilted forward or back and left or right.
  117494. */
  117495. export class DeviceOrientationCamera extends FreeCamera {
  117496. private _initialQuaternion;
  117497. private _quaternionCache;
  117498. private _tmpDragQuaternion;
  117499. private _disablePointerInputWhenUsingDeviceOrientation;
  117500. /**
  117501. * Creates a new device orientation camera
  117502. * @param name The name of the camera
  117503. * @param position The start position camera
  117504. * @param scene The scene the camera belongs to
  117505. */
  117506. constructor(name: string, position: Vector3, scene: Scene);
  117507. /**
  117508. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  117509. */
  117510. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  117511. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  117512. private _dragFactor;
  117513. /**
  117514. * Enabled turning on the y axis when the orientation sensor is active
  117515. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  117516. */
  117517. enableHorizontalDragging(dragFactor?: number): void;
  117518. /**
  117519. * Gets the current instance class name ("DeviceOrientationCamera").
  117520. * This helps avoiding instanceof at run time.
  117521. * @returns the class name
  117522. */
  117523. getClassName(): string;
  117524. /**
  117525. * @hidden
  117526. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  117527. */
  117528. _checkInputs(): void;
  117529. /**
  117530. * Reset the camera to its default orientation on the specified axis only.
  117531. * @param axis The axis to reset
  117532. */
  117533. resetToCurrentRotation(axis?: Axis): void;
  117534. }
  117535. }
  117536. declare module BABYLON {
  117537. /**
  117538. * Defines supported buttons for XBox360 compatible gamepads
  117539. */
  117540. export enum Xbox360Button {
  117541. /** A */
  117542. A = 0,
  117543. /** B */
  117544. B = 1,
  117545. /** X */
  117546. X = 2,
  117547. /** Y */
  117548. Y = 3,
  117549. /** Left button */
  117550. LB = 4,
  117551. /** Right button */
  117552. RB = 5,
  117553. /** Back */
  117554. Back = 8,
  117555. /** Start */
  117556. Start = 9,
  117557. /** Left stick */
  117558. LeftStick = 10,
  117559. /** Right stick */
  117560. RightStick = 11
  117561. }
  117562. /** Defines values for XBox360 DPad */
  117563. export enum Xbox360Dpad {
  117564. /** Up */
  117565. Up = 12,
  117566. /** Down */
  117567. Down = 13,
  117568. /** Left */
  117569. Left = 14,
  117570. /** Right */
  117571. Right = 15
  117572. }
  117573. /**
  117574. * Defines a XBox360 gamepad
  117575. */
  117576. export class Xbox360Pad extends Gamepad {
  117577. private _leftTrigger;
  117578. private _rightTrigger;
  117579. private _onlefttriggerchanged;
  117580. private _onrighttriggerchanged;
  117581. private _onbuttondown;
  117582. private _onbuttonup;
  117583. private _ondpaddown;
  117584. private _ondpadup;
  117585. /** Observable raised when a button is pressed */
  117586. onButtonDownObservable: Observable<Xbox360Button>;
  117587. /** Observable raised when a button is released */
  117588. onButtonUpObservable: Observable<Xbox360Button>;
  117589. /** Observable raised when a pad is pressed */
  117590. onPadDownObservable: Observable<Xbox360Dpad>;
  117591. /** Observable raised when a pad is released */
  117592. onPadUpObservable: Observable<Xbox360Dpad>;
  117593. private _buttonA;
  117594. private _buttonB;
  117595. private _buttonX;
  117596. private _buttonY;
  117597. private _buttonBack;
  117598. private _buttonStart;
  117599. private _buttonLB;
  117600. private _buttonRB;
  117601. private _buttonLeftStick;
  117602. private _buttonRightStick;
  117603. private _dPadUp;
  117604. private _dPadDown;
  117605. private _dPadLeft;
  117606. private _dPadRight;
  117607. private _isXboxOnePad;
  117608. /**
  117609. * Creates a new XBox360 gamepad object
  117610. * @param id defines the id of this gamepad
  117611. * @param index defines its index
  117612. * @param gamepad defines the internal HTML gamepad object
  117613. * @param xboxOne defines if it is a XBox One gamepad
  117614. */
  117615. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  117616. /**
  117617. * Defines the callback to call when left trigger is pressed
  117618. * @param callback defines the callback to use
  117619. */
  117620. onlefttriggerchanged(callback: (value: number) => void): void;
  117621. /**
  117622. * Defines the callback to call when right trigger is pressed
  117623. * @param callback defines the callback to use
  117624. */
  117625. onrighttriggerchanged(callback: (value: number) => void): void;
  117626. /**
  117627. * Gets the left trigger value
  117628. */
  117629. get leftTrigger(): number;
  117630. /**
  117631. * Sets the left trigger value
  117632. */
  117633. set leftTrigger(newValue: number);
  117634. /**
  117635. * Gets the right trigger value
  117636. */
  117637. get rightTrigger(): number;
  117638. /**
  117639. * Sets the right trigger value
  117640. */
  117641. set rightTrigger(newValue: number);
  117642. /**
  117643. * Defines the callback to call when a button is pressed
  117644. * @param callback defines the callback to use
  117645. */
  117646. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  117647. /**
  117648. * Defines the callback to call when a button is released
  117649. * @param callback defines the callback to use
  117650. */
  117651. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  117652. /**
  117653. * Defines the callback to call when a pad is pressed
  117654. * @param callback defines the callback to use
  117655. */
  117656. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  117657. /**
  117658. * Defines the callback to call when a pad is released
  117659. * @param callback defines the callback to use
  117660. */
  117661. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  117662. private _setButtonValue;
  117663. private _setDPadValue;
  117664. /**
  117665. * Gets the value of the `A` button
  117666. */
  117667. get buttonA(): number;
  117668. /**
  117669. * Sets the value of the `A` button
  117670. */
  117671. set buttonA(value: number);
  117672. /**
  117673. * Gets the value of the `B` button
  117674. */
  117675. get buttonB(): number;
  117676. /**
  117677. * Sets the value of the `B` button
  117678. */
  117679. set buttonB(value: number);
  117680. /**
  117681. * Gets the value of the `X` button
  117682. */
  117683. get buttonX(): number;
  117684. /**
  117685. * Sets the value of the `X` button
  117686. */
  117687. set buttonX(value: number);
  117688. /**
  117689. * Gets the value of the `Y` button
  117690. */
  117691. get buttonY(): number;
  117692. /**
  117693. * Sets the value of the `Y` button
  117694. */
  117695. set buttonY(value: number);
  117696. /**
  117697. * Gets the value of the `Start` button
  117698. */
  117699. get buttonStart(): number;
  117700. /**
  117701. * Sets the value of the `Start` button
  117702. */
  117703. set buttonStart(value: number);
  117704. /**
  117705. * Gets the value of the `Back` button
  117706. */
  117707. get buttonBack(): number;
  117708. /**
  117709. * Sets the value of the `Back` button
  117710. */
  117711. set buttonBack(value: number);
  117712. /**
  117713. * Gets the value of the `Left` button
  117714. */
  117715. get buttonLB(): number;
  117716. /**
  117717. * Sets the value of the `Left` button
  117718. */
  117719. set buttonLB(value: number);
  117720. /**
  117721. * Gets the value of the `Right` button
  117722. */
  117723. get buttonRB(): number;
  117724. /**
  117725. * Sets the value of the `Right` button
  117726. */
  117727. set buttonRB(value: number);
  117728. /**
  117729. * Gets the value of the Left joystick
  117730. */
  117731. get buttonLeftStick(): number;
  117732. /**
  117733. * Sets the value of the Left joystick
  117734. */
  117735. set buttonLeftStick(value: number);
  117736. /**
  117737. * Gets the value of the Right joystick
  117738. */
  117739. get buttonRightStick(): number;
  117740. /**
  117741. * Sets the value of the Right joystick
  117742. */
  117743. set buttonRightStick(value: number);
  117744. /**
  117745. * Gets the value of D-pad up
  117746. */
  117747. get dPadUp(): number;
  117748. /**
  117749. * Sets the value of D-pad up
  117750. */
  117751. set dPadUp(value: number);
  117752. /**
  117753. * Gets the value of D-pad down
  117754. */
  117755. get dPadDown(): number;
  117756. /**
  117757. * Sets the value of D-pad down
  117758. */
  117759. set dPadDown(value: number);
  117760. /**
  117761. * Gets the value of D-pad left
  117762. */
  117763. get dPadLeft(): number;
  117764. /**
  117765. * Sets the value of D-pad left
  117766. */
  117767. set dPadLeft(value: number);
  117768. /**
  117769. * Gets the value of D-pad right
  117770. */
  117771. get dPadRight(): number;
  117772. /**
  117773. * Sets the value of D-pad right
  117774. */
  117775. set dPadRight(value: number);
  117776. /**
  117777. * Force the gamepad to synchronize with device values
  117778. */
  117779. update(): void;
  117780. /**
  117781. * Disposes the gamepad
  117782. */
  117783. dispose(): void;
  117784. }
  117785. }
  117786. declare module BABYLON {
  117787. /**
  117788. * Defines supported buttons for DualShock compatible gamepads
  117789. */
  117790. export enum DualShockButton {
  117791. /** Cross */
  117792. Cross = 0,
  117793. /** Circle */
  117794. Circle = 1,
  117795. /** Square */
  117796. Square = 2,
  117797. /** Triangle */
  117798. Triangle = 3,
  117799. /** L1 */
  117800. L1 = 4,
  117801. /** R1 */
  117802. R1 = 5,
  117803. /** Share */
  117804. Share = 8,
  117805. /** Options */
  117806. Options = 9,
  117807. /** Left stick */
  117808. LeftStick = 10,
  117809. /** Right stick */
  117810. RightStick = 11
  117811. }
  117812. /** Defines values for DualShock DPad */
  117813. export enum DualShockDpad {
  117814. /** Up */
  117815. Up = 12,
  117816. /** Down */
  117817. Down = 13,
  117818. /** Left */
  117819. Left = 14,
  117820. /** Right */
  117821. Right = 15
  117822. }
  117823. /**
  117824. * Defines a DualShock gamepad
  117825. */
  117826. export class DualShockPad extends Gamepad {
  117827. private _leftTrigger;
  117828. private _rightTrigger;
  117829. private _onlefttriggerchanged;
  117830. private _onrighttriggerchanged;
  117831. private _onbuttondown;
  117832. private _onbuttonup;
  117833. private _ondpaddown;
  117834. private _ondpadup;
  117835. /** Observable raised when a button is pressed */
  117836. onButtonDownObservable: Observable<DualShockButton>;
  117837. /** Observable raised when a button is released */
  117838. onButtonUpObservable: Observable<DualShockButton>;
  117839. /** Observable raised when a pad is pressed */
  117840. onPadDownObservable: Observable<DualShockDpad>;
  117841. /** Observable raised when a pad is released */
  117842. onPadUpObservable: Observable<DualShockDpad>;
  117843. private _buttonCross;
  117844. private _buttonCircle;
  117845. private _buttonSquare;
  117846. private _buttonTriangle;
  117847. private _buttonShare;
  117848. private _buttonOptions;
  117849. private _buttonL1;
  117850. private _buttonR1;
  117851. private _buttonLeftStick;
  117852. private _buttonRightStick;
  117853. private _dPadUp;
  117854. private _dPadDown;
  117855. private _dPadLeft;
  117856. private _dPadRight;
  117857. /**
  117858. * Creates a new DualShock gamepad object
  117859. * @param id defines the id of this gamepad
  117860. * @param index defines its index
  117861. * @param gamepad defines the internal HTML gamepad object
  117862. */
  117863. constructor(id: string, index: number, gamepad: any);
  117864. /**
  117865. * Defines the callback to call when left trigger is pressed
  117866. * @param callback defines the callback to use
  117867. */
  117868. onlefttriggerchanged(callback: (value: number) => void): void;
  117869. /**
  117870. * Defines the callback to call when right trigger is pressed
  117871. * @param callback defines the callback to use
  117872. */
  117873. onrighttriggerchanged(callback: (value: number) => void): void;
  117874. /**
  117875. * Gets the left trigger value
  117876. */
  117877. get leftTrigger(): number;
  117878. /**
  117879. * Sets the left trigger value
  117880. */
  117881. set leftTrigger(newValue: number);
  117882. /**
  117883. * Gets the right trigger value
  117884. */
  117885. get rightTrigger(): number;
  117886. /**
  117887. * Sets the right trigger value
  117888. */
  117889. set rightTrigger(newValue: number);
  117890. /**
  117891. * Defines the callback to call when a button is pressed
  117892. * @param callback defines the callback to use
  117893. */
  117894. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  117895. /**
  117896. * Defines the callback to call when a button is released
  117897. * @param callback defines the callback to use
  117898. */
  117899. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  117900. /**
  117901. * Defines the callback to call when a pad is pressed
  117902. * @param callback defines the callback to use
  117903. */
  117904. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  117905. /**
  117906. * Defines the callback to call when a pad is released
  117907. * @param callback defines the callback to use
  117908. */
  117909. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  117910. private _setButtonValue;
  117911. private _setDPadValue;
  117912. /**
  117913. * Gets the value of the `Cross` button
  117914. */
  117915. get buttonCross(): number;
  117916. /**
  117917. * Sets the value of the `Cross` button
  117918. */
  117919. set buttonCross(value: number);
  117920. /**
  117921. * Gets the value of the `Circle` button
  117922. */
  117923. get buttonCircle(): number;
  117924. /**
  117925. * Sets the value of the `Circle` button
  117926. */
  117927. set buttonCircle(value: number);
  117928. /**
  117929. * Gets the value of the `Square` button
  117930. */
  117931. get buttonSquare(): number;
  117932. /**
  117933. * Sets the value of the `Square` button
  117934. */
  117935. set buttonSquare(value: number);
  117936. /**
  117937. * Gets the value of the `Triangle` button
  117938. */
  117939. get buttonTriangle(): number;
  117940. /**
  117941. * Sets the value of the `Triangle` button
  117942. */
  117943. set buttonTriangle(value: number);
  117944. /**
  117945. * Gets the value of the `Options` button
  117946. */
  117947. get buttonOptions(): number;
  117948. /**
  117949. * Sets the value of the `Options` button
  117950. */
  117951. set buttonOptions(value: number);
  117952. /**
  117953. * Gets the value of the `Share` button
  117954. */
  117955. get buttonShare(): number;
  117956. /**
  117957. * Sets the value of the `Share` button
  117958. */
  117959. set buttonShare(value: number);
  117960. /**
  117961. * Gets the value of the `L1` button
  117962. */
  117963. get buttonL1(): number;
  117964. /**
  117965. * Sets the value of the `L1` button
  117966. */
  117967. set buttonL1(value: number);
  117968. /**
  117969. * Gets the value of the `R1` button
  117970. */
  117971. get buttonR1(): number;
  117972. /**
  117973. * Sets the value of the `R1` button
  117974. */
  117975. set buttonR1(value: number);
  117976. /**
  117977. * Gets the value of the Left joystick
  117978. */
  117979. get buttonLeftStick(): number;
  117980. /**
  117981. * Sets the value of the Left joystick
  117982. */
  117983. set buttonLeftStick(value: number);
  117984. /**
  117985. * Gets the value of the Right joystick
  117986. */
  117987. get buttonRightStick(): number;
  117988. /**
  117989. * Sets the value of the Right joystick
  117990. */
  117991. set buttonRightStick(value: number);
  117992. /**
  117993. * Gets the value of D-pad up
  117994. */
  117995. get dPadUp(): number;
  117996. /**
  117997. * Sets the value of D-pad up
  117998. */
  117999. set dPadUp(value: number);
  118000. /**
  118001. * Gets the value of D-pad down
  118002. */
  118003. get dPadDown(): number;
  118004. /**
  118005. * Sets the value of D-pad down
  118006. */
  118007. set dPadDown(value: number);
  118008. /**
  118009. * Gets the value of D-pad left
  118010. */
  118011. get dPadLeft(): number;
  118012. /**
  118013. * Sets the value of D-pad left
  118014. */
  118015. set dPadLeft(value: number);
  118016. /**
  118017. * Gets the value of D-pad right
  118018. */
  118019. get dPadRight(): number;
  118020. /**
  118021. * Sets the value of D-pad right
  118022. */
  118023. set dPadRight(value: number);
  118024. /**
  118025. * Force the gamepad to synchronize with device values
  118026. */
  118027. update(): void;
  118028. /**
  118029. * Disposes the gamepad
  118030. */
  118031. dispose(): void;
  118032. }
  118033. }
  118034. declare module BABYLON {
  118035. /**
  118036. * Manager for handling gamepads
  118037. */
  118038. export class GamepadManager {
  118039. private _scene?;
  118040. private _babylonGamepads;
  118041. private _oneGamepadConnected;
  118042. /** @hidden */
  118043. _isMonitoring: boolean;
  118044. private _gamepadEventSupported;
  118045. private _gamepadSupport?;
  118046. /**
  118047. * observable to be triggered when the gamepad controller has been connected
  118048. */
  118049. onGamepadConnectedObservable: Observable<Gamepad>;
  118050. /**
  118051. * observable to be triggered when the gamepad controller has been disconnected
  118052. */
  118053. onGamepadDisconnectedObservable: Observable<Gamepad>;
  118054. private _onGamepadConnectedEvent;
  118055. private _onGamepadDisconnectedEvent;
  118056. /**
  118057. * Initializes the gamepad manager
  118058. * @param _scene BabylonJS scene
  118059. */
  118060. constructor(_scene?: Scene | undefined);
  118061. /**
  118062. * The gamepads in the game pad manager
  118063. */
  118064. get gamepads(): Gamepad[];
  118065. /**
  118066. * Get the gamepad controllers based on type
  118067. * @param type The type of gamepad controller
  118068. * @returns Nullable gamepad
  118069. */
  118070. getGamepadByType(type?: number): Nullable<Gamepad>;
  118071. /**
  118072. * Disposes the gamepad manager
  118073. */
  118074. dispose(): void;
  118075. private _addNewGamepad;
  118076. private _startMonitoringGamepads;
  118077. private _stopMonitoringGamepads;
  118078. /** @hidden */
  118079. _checkGamepadsStatus(): void;
  118080. private _updateGamepadObjects;
  118081. }
  118082. }
  118083. declare module BABYLON {
  118084. interface Scene {
  118085. /** @hidden */
  118086. _gamepadManager: Nullable<GamepadManager>;
  118087. /**
  118088. * Gets the gamepad manager associated with the scene
  118089. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  118090. */
  118091. gamepadManager: GamepadManager;
  118092. }
  118093. /**
  118094. * Interface representing a free camera inputs manager
  118095. */
  118096. interface FreeCameraInputsManager {
  118097. /**
  118098. * Adds gamepad input support to the FreeCameraInputsManager.
  118099. * @returns the FreeCameraInputsManager
  118100. */
  118101. addGamepad(): FreeCameraInputsManager;
  118102. }
  118103. /**
  118104. * Interface representing an arc rotate camera inputs manager
  118105. */
  118106. interface ArcRotateCameraInputsManager {
  118107. /**
  118108. * Adds gamepad input support to the ArcRotateCamera InputManager.
  118109. * @returns the camera inputs manager
  118110. */
  118111. addGamepad(): ArcRotateCameraInputsManager;
  118112. }
  118113. /**
  118114. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  118115. */
  118116. export class GamepadSystemSceneComponent implements ISceneComponent {
  118117. /**
  118118. * The component name helpfull to identify the component in the list of scene components.
  118119. */
  118120. readonly name: string;
  118121. /**
  118122. * The scene the component belongs to.
  118123. */
  118124. scene: Scene;
  118125. /**
  118126. * Creates a new instance of the component for the given scene
  118127. * @param scene Defines the scene to register the component in
  118128. */
  118129. constructor(scene: Scene);
  118130. /**
  118131. * Registers the component in a given scene
  118132. */
  118133. register(): void;
  118134. /**
  118135. * Rebuilds the elements related to this component in case of
  118136. * context lost for instance.
  118137. */
  118138. rebuild(): void;
  118139. /**
  118140. * Disposes the component and the associated ressources
  118141. */
  118142. dispose(): void;
  118143. private _beforeCameraUpdate;
  118144. }
  118145. }
  118146. declare module BABYLON {
  118147. /**
  118148. * 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,
  118149. * which still works and will still be found in many Playgrounds.
  118150. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  118151. */
  118152. export class UniversalCamera extends TouchCamera {
  118153. /**
  118154. * Defines the gamepad rotation sensiblity.
  118155. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  118156. */
  118157. get gamepadAngularSensibility(): number;
  118158. set gamepadAngularSensibility(value: number);
  118159. /**
  118160. * Defines the gamepad move sensiblity.
  118161. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  118162. */
  118163. get gamepadMoveSensibility(): number;
  118164. set gamepadMoveSensibility(value: number);
  118165. /**
  118166. * 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,
  118167. * which still works and will still be found in many Playgrounds.
  118168. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  118169. * @param name Define the name of the camera in the scene
  118170. * @param position Define the start position of the camera in the scene
  118171. * @param scene Define the scene the camera belongs to
  118172. */
  118173. constructor(name: string, position: Vector3, scene: Scene);
  118174. /**
  118175. * Gets the current object class name.
  118176. * @return the class name
  118177. */
  118178. getClassName(): string;
  118179. }
  118180. }
  118181. declare module BABYLON {
  118182. /**
  118183. * This represents a FPS type of camera. This is only here for back compat purpose.
  118184. * Please use the UniversalCamera instead as both are identical.
  118185. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  118186. */
  118187. export class GamepadCamera extends UniversalCamera {
  118188. /**
  118189. * Instantiates a new Gamepad Camera
  118190. * This represents a FPS type of camera. This is only here for back compat purpose.
  118191. * Please use the UniversalCamera instead as both are identical.
  118192. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  118193. * @param name Define the name of the camera in the scene
  118194. * @param position Define the start position of the camera in the scene
  118195. * @param scene Define the scene the camera belongs to
  118196. */
  118197. constructor(name: string, position: Vector3, scene: Scene);
  118198. /**
  118199. * Gets the current object class name.
  118200. * @return the class name
  118201. */
  118202. getClassName(): string;
  118203. }
  118204. }
  118205. declare module BABYLON {
  118206. /** @hidden */
  118207. export var passPixelShader: {
  118208. name: string;
  118209. shader: string;
  118210. };
  118211. }
  118212. declare module BABYLON {
  118213. /** @hidden */
  118214. export var passCubePixelShader: {
  118215. name: string;
  118216. shader: string;
  118217. };
  118218. }
  118219. declare module BABYLON {
  118220. /**
  118221. * PassPostProcess which produces an output the same as it's input
  118222. */
  118223. export class PassPostProcess extends PostProcess {
  118224. /**
  118225. * Creates the PassPostProcess
  118226. * @param name The name of the effect.
  118227. * @param options The required width/height ratio to downsize to before computing the render pass.
  118228. * @param camera The camera to apply the render pass to.
  118229. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  118230. * @param engine The engine which the post process will be applied. (default: current engine)
  118231. * @param reusable If the post process can be reused on the same frame. (default: false)
  118232. * @param textureType The type of texture to be used when performing the post processing.
  118233. * @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)
  118234. */
  118235. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  118236. }
  118237. /**
  118238. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  118239. */
  118240. export class PassCubePostProcess extends PostProcess {
  118241. private _face;
  118242. /**
  118243. * Gets or sets the cube face to display.
  118244. * * 0 is +X
  118245. * * 1 is -X
  118246. * * 2 is +Y
  118247. * * 3 is -Y
  118248. * * 4 is +Z
  118249. * * 5 is -Z
  118250. */
  118251. get face(): number;
  118252. set face(value: number);
  118253. /**
  118254. * Creates the PassCubePostProcess
  118255. * @param name The name of the effect.
  118256. * @param options The required width/height ratio to downsize to before computing the render pass.
  118257. * @param camera The camera to apply the render pass to.
  118258. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  118259. * @param engine The engine which the post process will be applied. (default: current engine)
  118260. * @param reusable If the post process can be reused on the same frame. (default: false)
  118261. * @param textureType The type of texture to be used when performing the post processing.
  118262. * @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)
  118263. */
  118264. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  118265. }
  118266. }
  118267. declare module BABYLON {
  118268. /** @hidden */
  118269. export var anaglyphPixelShader: {
  118270. name: string;
  118271. shader: string;
  118272. };
  118273. }
  118274. declare module BABYLON {
  118275. /**
  118276. * Postprocess used to generate anaglyphic rendering
  118277. */
  118278. export class AnaglyphPostProcess extends PostProcess {
  118279. private _passedProcess;
  118280. /**
  118281. * Creates a new AnaglyphPostProcess
  118282. * @param name defines postprocess name
  118283. * @param options defines creation options or target ratio scale
  118284. * @param rigCameras defines cameras using this postprocess
  118285. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  118286. * @param engine defines hosting engine
  118287. * @param reusable defines if the postprocess will be reused multiple times per frame
  118288. */
  118289. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  118290. }
  118291. }
  118292. declare module BABYLON {
  118293. /**
  118294. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  118295. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  118296. */
  118297. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  118298. /**
  118299. * Creates a new AnaglyphArcRotateCamera
  118300. * @param name defines camera name
  118301. * @param alpha defines alpha angle (in radians)
  118302. * @param beta defines beta angle (in radians)
  118303. * @param radius defines radius
  118304. * @param target defines camera target
  118305. * @param interaxialDistance defines distance between each color axis
  118306. * @param scene defines the hosting scene
  118307. */
  118308. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  118309. /**
  118310. * Gets camera class name
  118311. * @returns AnaglyphArcRotateCamera
  118312. */
  118313. getClassName(): string;
  118314. }
  118315. }
  118316. declare module BABYLON {
  118317. /**
  118318. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  118319. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  118320. */
  118321. export class AnaglyphFreeCamera extends FreeCamera {
  118322. /**
  118323. * Creates a new AnaglyphFreeCamera
  118324. * @param name defines camera name
  118325. * @param position defines initial position
  118326. * @param interaxialDistance defines distance between each color axis
  118327. * @param scene defines the hosting scene
  118328. */
  118329. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  118330. /**
  118331. * Gets camera class name
  118332. * @returns AnaglyphFreeCamera
  118333. */
  118334. getClassName(): string;
  118335. }
  118336. }
  118337. declare module BABYLON {
  118338. /**
  118339. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  118340. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  118341. */
  118342. export class AnaglyphGamepadCamera extends GamepadCamera {
  118343. /**
  118344. * Creates a new AnaglyphGamepadCamera
  118345. * @param name defines camera name
  118346. * @param position defines initial position
  118347. * @param interaxialDistance defines distance between each color axis
  118348. * @param scene defines the hosting scene
  118349. */
  118350. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  118351. /**
  118352. * Gets camera class name
  118353. * @returns AnaglyphGamepadCamera
  118354. */
  118355. getClassName(): string;
  118356. }
  118357. }
  118358. declare module BABYLON {
  118359. /**
  118360. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  118361. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  118362. */
  118363. export class AnaglyphUniversalCamera extends UniversalCamera {
  118364. /**
  118365. * Creates a new AnaglyphUniversalCamera
  118366. * @param name defines camera name
  118367. * @param position defines initial position
  118368. * @param interaxialDistance defines distance between each color axis
  118369. * @param scene defines the hosting scene
  118370. */
  118371. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  118372. /**
  118373. * Gets camera class name
  118374. * @returns AnaglyphUniversalCamera
  118375. */
  118376. getClassName(): string;
  118377. }
  118378. }
  118379. declare module BABYLON {
  118380. /**
  118381. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  118382. * @see http://doc.babylonjs.com/features/cameras
  118383. */
  118384. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  118385. /**
  118386. * Creates a new StereoscopicArcRotateCamera
  118387. * @param name defines camera name
  118388. * @param alpha defines alpha angle (in radians)
  118389. * @param beta defines beta angle (in radians)
  118390. * @param radius defines radius
  118391. * @param target defines camera target
  118392. * @param interaxialDistance defines distance between each color axis
  118393. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  118394. * @param scene defines the hosting scene
  118395. */
  118396. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  118397. /**
  118398. * Gets camera class name
  118399. * @returns StereoscopicArcRotateCamera
  118400. */
  118401. getClassName(): string;
  118402. }
  118403. }
  118404. declare module BABYLON {
  118405. /**
  118406. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  118407. * @see http://doc.babylonjs.com/features/cameras
  118408. */
  118409. export class StereoscopicFreeCamera extends FreeCamera {
  118410. /**
  118411. * Creates a new StereoscopicFreeCamera
  118412. * @param name defines camera name
  118413. * @param position defines initial position
  118414. * @param interaxialDistance defines distance between each color axis
  118415. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  118416. * @param scene defines the hosting scene
  118417. */
  118418. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  118419. /**
  118420. * Gets camera class name
  118421. * @returns StereoscopicFreeCamera
  118422. */
  118423. getClassName(): string;
  118424. }
  118425. }
  118426. declare module BABYLON {
  118427. /**
  118428. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  118429. * @see http://doc.babylonjs.com/features/cameras
  118430. */
  118431. export class StereoscopicGamepadCamera extends GamepadCamera {
  118432. /**
  118433. * Creates a new StereoscopicGamepadCamera
  118434. * @param name defines camera name
  118435. * @param position defines initial position
  118436. * @param interaxialDistance defines distance between each color axis
  118437. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  118438. * @param scene defines the hosting scene
  118439. */
  118440. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  118441. /**
  118442. * Gets camera class name
  118443. * @returns StereoscopicGamepadCamera
  118444. */
  118445. getClassName(): string;
  118446. }
  118447. }
  118448. declare module BABYLON {
  118449. /**
  118450. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  118451. * @see http://doc.babylonjs.com/features/cameras
  118452. */
  118453. export class StereoscopicUniversalCamera extends UniversalCamera {
  118454. /**
  118455. * Creates a new StereoscopicUniversalCamera
  118456. * @param name defines camera name
  118457. * @param position defines initial position
  118458. * @param interaxialDistance defines distance between each color axis
  118459. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  118460. * @param scene defines the hosting scene
  118461. */
  118462. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  118463. /**
  118464. * Gets camera class name
  118465. * @returns StereoscopicUniversalCamera
  118466. */
  118467. getClassName(): string;
  118468. }
  118469. }
  118470. declare module BABYLON {
  118471. /**
  118472. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  118473. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  118474. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  118475. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  118476. */
  118477. export class VirtualJoysticksCamera extends FreeCamera {
  118478. /**
  118479. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  118480. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  118481. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  118482. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  118483. * @param name Define the name of the camera in the scene
  118484. * @param position Define the start position of the camera in the scene
  118485. * @param scene Define the scene the camera belongs to
  118486. */
  118487. constructor(name: string, position: Vector3, scene: Scene);
  118488. /**
  118489. * Gets the current object class name.
  118490. * @return the class name
  118491. */
  118492. getClassName(): string;
  118493. }
  118494. }
  118495. declare module BABYLON {
  118496. /**
  118497. * This represents all the required metrics to create a VR camera.
  118498. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  118499. */
  118500. export class VRCameraMetrics {
  118501. /**
  118502. * Define the horizontal resolution off the screen.
  118503. */
  118504. hResolution: number;
  118505. /**
  118506. * Define the vertical resolution off the screen.
  118507. */
  118508. vResolution: number;
  118509. /**
  118510. * Define the horizontal screen size.
  118511. */
  118512. hScreenSize: number;
  118513. /**
  118514. * Define the vertical screen size.
  118515. */
  118516. vScreenSize: number;
  118517. /**
  118518. * Define the vertical screen center position.
  118519. */
  118520. vScreenCenter: number;
  118521. /**
  118522. * Define the distance of the eyes to the screen.
  118523. */
  118524. eyeToScreenDistance: number;
  118525. /**
  118526. * Define the distance between both lenses
  118527. */
  118528. lensSeparationDistance: number;
  118529. /**
  118530. * Define the distance between both viewer's eyes.
  118531. */
  118532. interpupillaryDistance: number;
  118533. /**
  118534. * Define the distortion factor of the VR postprocess.
  118535. * Please, touch with care.
  118536. */
  118537. distortionK: number[];
  118538. /**
  118539. * Define the chromatic aberration correction factors for the VR post process.
  118540. */
  118541. chromaAbCorrection: number[];
  118542. /**
  118543. * Define the scale factor of the post process.
  118544. * The smaller the better but the slower.
  118545. */
  118546. postProcessScaleFactor: number;
  118547. /**
  118548. * Define an offset for the lens center.
  118549. */
  118550. lensCenterOffset: number;
  118551. /**
  118552. * Define if the current vr camera should compensate the distortion of the lense or not.
  118553. */
  118554. compensateDistortion: boolean;
  118555. /**
  118556. * Defines if multiview should be enabled when rendering (Default: false)
  118557. */
  118558. multiviewEnabled: boolean;
  118559. /**
  118560. * Gets the rendering aspect ratio based on the provided resolutions.
  118561. */
  118562. get aspectRatio(): number;
  118563. /**
  118564. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  118565. */
  118566. get aspectRatioFov(): number;
  118567. /**
  118568. * @hidden
  118569. */
  118570. get leftHMatrix(): Matrix;
  118571. /**
  118572. * @hidden
  118573. */
  118574. get rightHMatrix(): Matrix;
  118575. /**
  118576. * @hidden
  118577. */
  118578. get leftPreViewMatrix(): Matrix;
  118579. /**
  118580. * @hidden
  118581. */
  118582. get rightPreViewMatrix(): Matrix;
  118583. /**
  118584. * Get the default VRMetrics based on the most generic setup.
  118585. * @returns the default vr metrics
  118586. */
  118587. static GetDefault(): VRCameraMetrics;
  118588. }
  118589. }
  118590. declare module BABYLON {
  118591. /** @hidden */
  118592. export var vrDistortionCorrectionPixelShader: {
  118593. name: string;
  118594. shader: string;
  118595. };
  118596. }
  118597. declare module BABYLON {
  118598. /**
  118599. * VRDistortionCorrectionPostProcess used for mobile VR
  118600. */
  118601. export class VRDistortionCorrectionPostProcess extends PostProcess {
  118602. private _isRightEye;
  118603. private _distortionFactors;
  118604. private _postProcessScaleFactor;
  118605. private _lensCenterOffset;
  118606. private _scaleIn;
  118607. private _scaleFactor;
  118608. private _lensCenter;
  118609. /**
  118610. * Initializes the VRDistortionCorrectionPostProcess
  118611. * @param name The name of the effect.
  118612. * @param camera The camera to apply the render pass to.
  118613. * @param isRightEye If this is for the right eye distortion
  118614. * @param vrMetrics All the required metrics for the VR camera
  118615. */
  118616. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  118617. }
  118618. }
  118619. declare module BABYLON {
  118620. /**
  118621. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  118622. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  118623. */
  118624. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  118625. /**
  118626. * Creates a new VRDeviceOrientationArcRotateCamera
  118627. * @param name defines camera name
  118628. * @param alpha defines the camera rotation along the logitudinal axis
  118629. * @param beta defines the camera rotation along the latitudinal axis
  118630. * @param radius defines the camera distance from its target
  118631. * @param target defines the camera target
  118632. * @param scene defines the scene the camera belongs to
  118633. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  118634. * @param vrCameraMetrics defines the vr metrics associated to the camera
  118635. */
  118636. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  118637. /**
  118638. * Gets camera class name
  118639. * @returns VRDeviceOrientationArcRotateCamera
  118640. */
  118641. getClassName(): string;
  118642. }
  118643. }
  118644. declare module BABYLON {
  118645. /**
  118646. * Camera used to simulate VR rendering (based on FreeCamera)
  118647. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  118648. */
  118649. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  118650. /**
  118651. * Creates a new VRDeviceOrientationFreeCamera
  118652. * @param name defines camera name
  118653. * @param position defines the start position of the camera
  118654. * @param scene defines the scene the camera belongs to
  118655. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  118656. * @param vrCameraMetrics defines the vr metrics associated to the camera
  118657. */
  118658. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  118659. /**
  118660. * Gets camera class name
  118661. * @returns VRDeviceOrientationFreeCamera
  118662. */
  118663. getClassName(): string;
  118664. }
  118665. }
  118666. declare module BABYLON {
  118667. /**
  118668. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  118669. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  118670. */
  118671. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  118672. /**
  118673. * Creates a new VRDeviceOrientationGamepadCamera
  118674. * @param name defines camera name
  118675. * @param position defines the start position of the camera
  118676. * @param scene defines the scene the camera belongs to
  118677. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  118678. * @param vrCameraMetrics defines the vr metrics associated to the camera
  118679. */
  118680. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  118681. /**
  118682. * Gets camera class name
  118683. * @returns VRDeviceOrientationGamepadCamera
  118684. */
  118685. getClassName(): string;
  118686. }
  118687. }
  118688. declare module BABYLON {
  118689. /** @hidden */
  118690. export var imageProcessingPixelShader: {
  118691. name: string;
  118692. shader: string;
  118693. };
  118694. }
  118695. declare module BABYLON {
  118696. /**
  118697. * ImageProcessingPostProcess
  118698. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  118699. */
  118700. export class ImageProcessingPostProcess extends PostProcess {
  118701. /**
  118702. * Default configuration related to image processing available in the PBR Material.
  118703. */
  118704. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  118705. /**
  118706. * Gets the image processing configuration used either in this material.
  118707. */
  118708. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  118709. /**
  118710. * Sets the Default image processing configuration used either in the this material.
  118711. *
  118712. * If sets to null, the scene one is in use.
  118713. */
  118714. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  118715. /**
  118716. * Keep track of the image processing observer to allow dispose and replace.
  118717. */
  118718. private _imageProcessingObserver;
  118719. /**
  118720. * Attaches a new image processing configuration to the PBR Material.
  118721. * @param configuration
  118722. */
  118723. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  118724. /**
  118725. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  118726. */
  118727. get colorCurves(): Nullable<ColorCurves>;
  118728. /**
  118729. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  118730. */
  118731. set colorCurves(value: Nullable<ColorCurves>);
  118732. /**
  118733. * Gets wether the color curves effect is enabled.
  118734. */
  118735. get colorCurvesEnabled(): boolean;
  118736. /**
  118737. * Sets wether the color curves effect is enabled.
  118738. */
  118739. set colorCurvesEnabled(value: boolean);
  118740. /**
  118741. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  118742. */
  118743. get colorGradingTexture(): Nullable<BaseTexture>;
  118744. /**
  118745. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  118746. */
  118747. set colorGradingTexture(value: Nullable<BaseTexture>);
  118748. /**
  118749. * Gets wether the color grading effect is enabled.
  118750. */
  118751. get colorGradingEnabled(): boolean;
  118752. /**
  118753. * Gets wether the color grading effect is enabled.
  118754. */
  118755. set colorGradingEnabled(value: boolean);
  118756. /**
  118757. * Gets exposure used in the effect.
  118758. */
  118759. get exposure(): number;
  118760. /**
  118761. * Sets exposure used in the effect.
  118762. */
  118763. set exposure(value: number);
  118764. /**
  118765. * Gets wether tonemapping is enabled or not.
  118766. */
  118767. get toneMappingEnabled(): boolean;
  118768. /**
  118769. * Sets wether tonemapping is enabled or not
  118770. */
  118771. set toneMappingEnabled(value: boolean);
  118772. /**
  118773. * Gets the type of tone mapping effect.
  118774. */
  118775. get toneMappingType(): number;
  118776. /**
  118777. * Sets the type of tone mapping effect.
  118778. */
  118779. set toneMappingType(value: number);
  118780. /**
  118781. * Gets contrast used in the effect.
  118782. */
  118783. get contrast(): number;
  118784. /**
  118785. * Sets contrast used in the effect.
  118786. */
  118787. set contrast(value: number);
  118788. /**
  118789. * Gets Vignette stretch size.
  118790. */
  118791. get vignetteStretch(): number;
  118792. /**
  118793. * Sets Vignette stretch size.
  118794. */
  118795. set vignetteStretch(value: number);
  118796. /**
  118797. * Gets Vignette centre X Offset.
  118798. */
  118799. get vignetteCentreX(): number;
  118800. /**
  118801. * Sets Vignette centre X Offset.
  118802. */
  118803. set vignetteCentreX(value: number);
  118804. /**
  118805. * Gets Vignette centre Y Offset.
  118806. */
  118807. get vignetteCentreY(): number;
  118808. /**
  118809. * Sets Vignette centre Y Offset.
  118810. */
  118811. set vignetteCentreY(value: number);
  118812. /**
  118813. * Gets Vignette weight or intensity of the vignette effect.
  118814. */
  118815. get vignetteWeight(): number;
  118816. /**
  118817. * Sets Vignette weight or intensity of the vignette effect.
  118818. */
  118819. set vignetteWeight(value: number);
  118820. /**
  118821. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  118822. * if vignetteEnabled is set to true.
  118823. */
  118824. get vignetteColor(): Color4;
  118825. /**
  118826. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  118827. * if vignetteEnabled is set to true.
  118828. */
  118829. set vignetteColor(value: Color4);
  118830. /**
  118831. * Gets Camera field of view used by the Vignette effect.
  118832. */
  118833. get vignetteCameraFov(): number;
  118834. /**
  118835. * Sets Camera field of view used by the Vignette effect.
  118836. */
  118837. set vignetteCameraFov(value: number);
  118838. /**
  118839. * Gets the vignette blend mode allowing different kind of effect.
  118840. */
  118841. get vignetteBlendMode(): number;
  118842. /**
  118843. * Sets the vignette blend mode allowing different kind of effect.
  118844. */
  118845. set vignetteBlendMode(value: number);
  118846. /**
  118847. * Gets wether the vignette effect is enabled.
  118848. */
  118849. get vignetteEnabled(): boolean;
  118850. /**
  118851. * Sets wether the vignette effect is enabled.
  118852. */
  118853. set vignetteEnabled(value: boolean);
  118854. private _fromLinearSpace;
  118855. /**
  118856. * Gets wether the input of the processing is in Gamma or Linear Space.
  118857. */
  118858. get fromLinearSpace(): boolean;
  118859. /**
  118860. * Sets wether the input of the processing is in Gamma or Linear Space.
  118861. */
  118862. set fromLinearSpace(value: boolean);
  118863. /**
  118864. * Defines cache preventing GC.
  118865. */
  118866. private _defines;
  118867. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  118868. /**
  118869. * "ImageProcessingPostProcess"
  118870. * @returns "ImageProcessingPostProcess"
  118871. */
  118872. getClassName(): string;
  118873. protected _updateParameters(): void;
  118874. dispose(camera?: Camera): void;
  118875. }
  118876. }
  118877. declare module BABYLON {
  118878. /**
  118879. * Class containing static functions to help procedurally build meshes
  118880. */
  118881. export class GroundBuilder {
  118882. /**
  118883. * Creates a ground mesh
  118884. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  118885. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  118886. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  118887. * @param name defines the name of the mesh
  118888. * @param options defines the options used to create the mesh
  118889. * @param scene defines the hosting scene
  118890. * @returns the ground mesh
  118891. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  118892. */
  118893. static CreateGround(name: string, options: {
  118894. width?: number;
  118895. height?: number;
  118896. subdivisions?: number;
  118897. subdivisionsX?: number;
  118898. subdivisionsY?: number;
  118899. updatable?: boolean;
  118900. }, scene: any): Mesh;
  118901. /**
  118902. * Creates a tiled ground mesh
  118903. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  118904. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  118905. * * 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
  118906. * * 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
  118907. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  118908. * @param name defines the name of the mesh
  118909. * @param options defines the options used to create the mesh
  118910. * @param scene defines the hosting scene
  118911. * @returns the tiled ground mesh
  118912. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  118913. */
  118914. static CreateTiledGround(name: string, options: {
  118915. xmin: number;
  118916. zmin: number;
  118917. xmax: number;
  118918. zmax: number;
  118919. subdivisions?: {
  118920. w: number;
  118921. h: number;
  118922. };
  118923. precision?: {
  118924. w: number;
  118925. h: number;
  118926. };
  118927. updatable?: boolean;
  118928. }, scene?: Nullable<Scene>): Mesh;
  118929. /**
  118930. * Creates a ground mesh from a height map
  118931. * * The parameter `url` sets the URL of the height map image resource.
  118932. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  118933. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  118934. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  118935. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  118936. * * 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.
  118937. * * 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).
  118938. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  118939. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  118940. * @param name defines the name of the mesh
  118941. * @param url defines the url to the height map
  118942. * @param options defines the options used to create the mesh
  118943. * @param scene defines the hosting scene
  118944. * @returns the ground mesh
  118945. * @see https://doc.babylonjs.com/babylon101/height_map
  118946. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  118947. */
  118948. static CreateGroundFromHeightMap(name: string, url: string, options: {
  118949. width?: number;
  118950. height?: number;
  118951. subdivisions?: number;
  118952. minHeight?: number;
  118953. maxHeight?: number;
  118954. colorFilter?: Color3;
  118955. alphaFilter?: number;
  118956. updatable?: boolean;
  118957. onReady?: (mesh: GroundMesh) => void;
  118958. }, scene?: Nullable<Scene>): GroundMesh;
  118959. }
  118960. }
  118961. declare module BABYLON {
  118962. /**
  118963. * Class containing static functions to help procedurally build meshes
  118964. */
  118965. export class TorusBuilder {
  118966. /**
  118967. * Creates a torus mesh
  118968. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  118969. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  118970. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  118971. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  118972. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  118973. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  118974. * @param name defines the name of the mesh
  118975. * @param options defines the options used to create the mesh
  118976. * @param scene defines the hosting scene
  118977. * @returns the torus mesh
  118978. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  118979. */
  118980. static CreateTorus(name: string, options: {
  118981. diameter?: number;
  118982. thickness?: number;
  118983. tessellation?: number;
  118984. updatable?: boolean;
  118985. sideOrientation?: number;
  118986. frontUVs?: Vector4;
  118987. backUVs?: Vector4;
  118988. }, scene: any): Mesh;
  118989. }
  118990. }
  118991. declare module BABYLON {
  118992. /**
  118993. * Class containing static functions to help procedurally build meshes
  118994. */
  118995. export class CylinderBuilder {
  118996. /**
  118997. * Creates a cylinder or a cone mesh
  118998. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  118999. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  119000. * * 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.
  119001. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  119002. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  119003. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  119004. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  119005. * * 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).
  119006. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  119007. * * 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).
  119008. * * 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
  119009. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  119010. * * 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
  119011. * * 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.
  119012. * * If `enclose` is false, a ring surface is one element.
  119013. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  119014. * * 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
  119015. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  119016. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  119017. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  119018. * @param name defines the name of the mesh
  119019. * @param options defines the options used to create the mesh
  119020. * @param scene defines the hosting scene
  119021. * @returns the cylinder mesh
  119022. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  119023. */
  119024. static CreateCylinder(name: string, options: {
  119025. height?: number;
  119026. diameterTop?: number;
  119027. diameterBottom?: number;
  119028. diameter?: number;
  119029. tessellation?: number;
  119030. subdivisions?: number;
  119031. arc?: number;
  119032. faceColors?: Color4[];
  119033. faceUV?: Vector4[];
  119034. updatable?: boolean;
  119035. hasRings?: boolean;
  119036. enclose?: boolean;
  119037. cap?: number;
  119038. sideOrientation?: number;
  119039. frontUVs?: Vector4;
  119040. backUVs?: Vector4;
  119041. }, scene: any): Mesh;
  119042. }
  119043. }
  119044. declare module BABYLON {
  119045. /**
  119046. * States of the webXR experience
  119047. */
  119048. export enum WebXRState {
  119049. /**
  119050. * Transitioning to being in XR mode
  119051. */
  119052. ENTERING_XR = 0,
  119053. /**
  119054. * Transitioning to non XR mode
  119055. */
  119056. EXITING_XR = 1,
  119057. /**
  119058. * In XR mode and presenting
  119059. */
  119060. IN_XR = 2,
  119061. /**
  119062. * Not entered XR mode
  119063. */
  119064. NOT_IN_XR = 3
  119065. }
  119066. /**
  119067. * Abstraction of the XR render target
  119068. */
  119069. export interface WebXRRenderTarget extends IDisposable {
  119070. /**
  119071. * xrpresent context of the canvas which can be used to display/mirror xr content
  119072. */
  119073. canvasContext: WebGLRenderingContext;
  119074. /**
  119075. * xr layer for the canvas
  119076. */
  119077. xrLayer: Nullable<XRWebGLLayer>;
  119078. /**
  119079. * Initializes the xr layer for the session
  119080. * @param xrSession xr session
  119081. * @returns a promise that will resolve once the XR Layer has been created
  119082. */
  119083. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  119084. }
  119085. }
  119086. declare module BABYLON {
  119087. /**
  119088. * COnfiguration object for WebXR output canvas
  119089. */
  119090. export class WebXRManagedOutputCanvasOptions {
  119091. /**
  119092. * An optional canvas in case you wish to create it yourself and provide it here.
  119093. * If not provided, a new canvas will be created
  119094. */
  119095. canvasElement?: HTMLCanvasElement;
  119096. /**
  119097. * Options for this XR Layer output
  119098. */
  119099. canvasOptions?: XRWebGLLayerOptions;
  119100. /**
  119101. * CSS styling for a newly created canvas (if not provided)
  119102. */
  119103. newCanvasCssStyle?: string;
  119104. /**
  119105. * Get the default values of the configuration object
  119106. * @returns default values of this configuration object
  119107. */
  119108. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  119109. }
  119110. /**
  119111. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  119112. */
  119113. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  119114. private _options;
  119115. private _canvas;
  119116. private _engine;
  119117. /**
  119118. * Rendering context of the canvas which can be used to display/mirror xr content
  119119. */
  119120. canvasContext: WebGLRenderingContext;
  119121. /**
  119122. * xr layer for the canvas
  119123. */
  119124. xrLayer: Nullable<XRWebGLLayer>;
  119125. /**
  119126. * Initializes the canvas to be added/removed upon entering/exiting xr
  119127. * @param _xrSessionManager The XR Session manager
  119128. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  119129. */
  119130. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  119131. /**
  119132. * Disposes of the object
  119133. */
  119134. dispose(): void;
  119135. /**
  119136. * Initializes the xr layer for the session
  119137. * @param xrSession xr session
  119138. * @returns a promise that will resolve once the XR Layer has been created
  119139. */
  119140. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  119141. private _addCanvas;
  119142. private _removeCanvas;
  119143. private _setManagedOutputCanvas;
  119144. }
  119145. }
  119146. declare module BABYLON {
  119147. /**
  119148. * Manages an XRSession to work with Babylon's engine
  119149. * @see https://doc.babylonjs.com/how_to/webxr
  119150. */
  119151. export class WebXRSessionManager implements IDisposable {
  119152. /** The scene which the session should be created for */
  119153. scene: Scene;
  119154. private _referenceSpace;
  119155. private _rttProvider;
  119156. private _sessionEnded;
  119157. private _xrNavigator;
  119158. private baseLayer;
  119159. /**
  119160. * The base reference space from which the session started. good if you want to reset your
  119161. * reference space
  119162. */
  119163. baseReferenceSpace: XRReferenceSpace;
  119164. /**
  119165. * Current XR frame
  119166. */
  119167. currentFrame: Nullable<XRFrame>;
  119168. /** WebXR timestamp updated every frame */
  119169. currentTimestamp: number;
  119170. /**
  119171. * Used just in case of a failure to initialize an immersive session.
  119172. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  119173. */
  119174. defaultHeightCompensation: number;
  119175. /**
  119176. * Fires every time a new xrFrame arrives which can be used to update the camera
  119177. */
  119178. onXRFrameObservable: Observable<XRFrame>;
  119179. /**
  119180. * Fires when the reference space changed
  119181. */
  119182. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  119183. /**
  119184. * Fires when the xr session is ended either by the device or manually done
  119185. */
  119186. onXRSessionEnded: Observable<any>;
  119187. /**
  119188. * Fires when the xr session is ended either by the device or manually done
  119189. */
  119190. onXRSessionInit: Observable<XRSession>;
  119191. /**
  119192. * Underlying xr session
  119193. */
  119194. session: XRSession;
  119195. /**
  119196. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  119197. * or get the offset the player is currently at.
  119198. */
  119199. viewerReferenceSpace: XRReferenceSpace;
  119200. /**
  119201. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  119202. * @param scene The scene which the session should be created for
  119203. */
  119204. constructor(
  119205. /** The scene which the session should be created for */
  119206. scene: Scene);
  119207. /**
  119208. * The current reference space used in this session. This reference space can constantly change!
  119209. * It is mainly used to offset the camera's position.
  119210. */
  119211. get referenceSpace(): XRReferenceSpace;
  119212. /**
  119213. * Set a new reference space and triggers the observable
  119214. */
  119215. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  119216. /**
  119217. * Disposes of the session manager
  119218. */
  119219. dispose(): void;
  119220. /**
  119221. * Stops the xrSession and restores the render loop
  119222. * @returns Promise which resolves after it exits XR
  119223. */
  119224. exitXRAsync(): Promise<void>;
  119225. /**
  119226. * Gets the correct render target texture to be rendered this frame for this eye
  119227. * @param eye the eye for which to get the render target
  119228. * @returns the render target for the specified eye
  119229. */
  119230. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  119231. /**
  119232. * Creates a WebXRRenderTarget object for the XR session
  119233. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  119234. * @param options optional options to provide when creating a new render target
  119235. * @returns a WebXR render target to which the session can render
  119236. */
  119237. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  119238. /**
  119239. * Initializes the manager
  119240. * After initialization enterXR can be called to start an XR session
  119241. * @returns Promise which resolves after it is initialized
  119242. */
  119243. initializeAsync(): Promise<void>;
  119244. /**
  119245. * Initializes an xr session
  119246. * @param xrSessionMode mode to initialize
  119247. * @param xrSessionInit defines optional and required values to pass to the session builder
  119248. * @returns a promise which will resolve once the session has been initialized
  119249. */
  119250. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  119251. /**
  119252. * Checks if a session would be supported for the creation options specified
  119253. * @param sessionMode session mode to check if supported eg. immersive-vr
  119254. * @returns A Promise that resolves to true if supported and false if not
  119255. */
  119256. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  119257. /**
  119258. * Resets the reference space to the one started the session
  119259. */
  119260. resetReferenceSpace(): void;
  119261. /**
  119262. * Starts rendering to the xr layer
  119263. */
  119264. runXRRenderLoop(): void;
  119265. /**
  119266. * Sets the reference space on the xr session
  119267. * @param referenceSpaceType space to set
  119268. * @returns a promise that will resolve once the reference space has been set
  119269. */
  119270. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  119271. /**
  119272. * Updates the render state of the session
  119273. * @param state state to set
  119274. * @returns a promise that resolves once the render state has been updated
  119275. */
  119276. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  119277. /**
  119278. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  119279. * @param sessionMode defines the session to test
  119280. * @returns a promise with boolean as final value
  119281. */
  119282. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  119283. private _createRenderTargetTexture;
  119284. }
  119285. }
  119286. declare module BABYLON {
  119287. /**
  119288. * WebXR Camera which holds the views for the xrSession
  119289. * @see https://doc.babylonjs.com/how_to/webxr_camera
  119290. */
  119291. export class WebXRCamera extends FreeCamera {
  119292. private _xrSessionManager;
  119293. private _firstFrame;
  119294. private _referenceQuaternion;
  119295. private _referencedPosition;
  119296. private _xrInvPositionCache;
  119297. private _xrInvQuaternionCache;
  119298. /**
  119299. * Should position compensation execute on first frame.
  119300. * This is used when copying the position from a native (non XR) camera
  119301. */
  119302. compensateOnFirstFrame: boolean;
  119303. /**
  119304. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  119305. * @param name the name of the camera
  119306. * @param scene the scene to add the camera to
  119307. * @param _xrSessionManager a constructed xr session manager
  119308. */
  119309. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  119310. /**
  119311. * Return the user's height, unrelated to the current ground.
  119312. * This will be the y position of this camera, when ground level is 0.
  119313. */
  119314. get realWorldHeight(): number;
  119315. /** @hidden */
  119316. _updateForDualEyeDebugging(): void;
  119317. /**
  119318. * Sets this camera's transformation based on a non-vr camera
  119319. * @param otherCamera the non-vr camera to copy the transformation from
  119320. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  119321. */
  119322. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  119323. /**
  119324. * Gets the current instance class name ("WebXRCamera").
  119325. * @returns the class name
  119326. */
  119327. getClassName(): string;
  119328. private _updateFromXRSession;
  119329. private _updateNumberOfRigCameras;
  119330. private _updateReferenceSpace;
  119331. private _updateReferenceSpaceOffset;
  119332. }
  119333. }
  119334. declare module BABYLON {
  119335. /**
  119336. * Defining the interface required for a (webxr) feature
  119337. */
  119338. export interface IWebXRFeature extends IDisposable {
  119339. /**
  119340. * Is this feature attached
  119341. */
  119342. attached: boolean;
  119343. /**
  119344. * Should auto-attach be disabled?
  119345. */
  119346. disableAutoAttach: boolean;
  119347. /**
  119348. * Attach the feature to the session
  119349. * Will usually be called by the features manager
  119350. *
  119351. * @param force should attachment be forced (even when already attached)
  119352. * @returns true if successful.
  119353. */
  119354. attach(force?: boolean): boolean;
  119355. /**
  119356. * Detach the feature from the session
  119357. * Will usually be called by the features manager
  119358. *
  119359. * @returns true if successful.
  119360. */
  119361. detach(): boolean;
  119362. }
  119363. /**
  119364. * A list of the currently available features without referencing them
  119365. */
  119366. export class WebXRFeatureName {
  119367. /**
  119368. * The name of the anchor system feature
  119369. */
  119370. static ANCHOR_SYSTEM: string;
  119371. /**
  119372. * The name of the background remover feature
  119373. */
  119374. static BACKGROUND_REMOVER: string;
  119375. /**
  119376. * The name of the hit test feature
  119377. */
  119378. static HIT_TEST: string;
  119379. /**
  119380. * physics impostors for xr controllers feature
  119381. */
  119382. static PHYSICS_CONTROLLERS: string;
  119383. /**
  119384. * The name of the plane detection feature
  119385. */
  119386. static PLANE_DETECTION: string;
  119387. /**
  119388. * The name of the pointer selection feature
  119389. */
  119390. static POINTER_SELECTION: string;
  119391. /**
  119392. * The name of the teleportation feature
  119393. */
  119394. static TELEPORTATION: string;
  119395. }
  119396. /**
  119397. * Defining the constructor of a feature. Used to register the modules.
  119398. */
  119399. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => (() => IWebXRFeature);
  119400. /**
  119401. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  119402. * It is mainly used in AR sessions.
  119403. *
  119404. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  119405. */
  119406. export class WebXRFeaturesManager implements IDisposable {
  119407. private _xrSessionManager;
  119408. private static readonly _AvailableFeatures;
  119409. private _features;
  119410. /**
  119411. * constructs a new features manages.
  119412. *
  119413. * @param _xrSessionManager an instance of WebXRSessionManager
  119414. */
  119415. constructor(_xrSessionManager: WebXRSessionManager);
  119416. /**
  119417. * Used to register a module. After calling this function a developer can use this feature in the scene.
  119418. * Mainly used internally.
  119419. *
  119420. * @param featureName the name of the feature to register
  119421. * @param constructorFunction the function used to construct the module
  119422. * @param version the (babylon) version of the module
  119423. * @param stable is that a stable version of this module
  119424. */
  119425. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  119426. /**
  119427. * Returns a constructor of a specific feature.
  119428. *
  119429. * @param featureName the name of the feature to construct
  119430. * @param version the version of the feature to load
  119431. * @param xrSessionManager the xrSessionManager. Used to construct the module
  119432. * @param options optional options provided to the module.
  119433. * @returns a function that, when called, will return a new instance of this feature
  119434. */
  119435. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): (() => IWebXRFeature);
  119436. /**
  119437. * Can be used to return the list of features currently registered
  119438. *
  119439. * @returns an Array of available features
  119440. */
  119441. static GetAvailableFeatures(): string[];
  119442. /**
  119443. * Gets the versions available for a specific feature
  119444. * @param featureName the name of the feature
  119445. * @returns an array with the available versions
  119446. */
  119447. static GetAvailableVersions(featureName: string): string[];
  119448. /**
  119449. * Return the latest unstable version of this feature
  119450. * @param featureName the name of the feature to search
  119451. * @returns the version number. if not found will return -1
  119452. */
  119453. static GetLatestVersionOfFeature(featureName: string): number;
  119454. /**
  119455. * Return the latest stable version of this feature
  119456. * @param featureName the name of the feature to search
  119457. * @returns the version number. if not found will return -1
  119458. */
  119459. static GetStableVersionOfFeature(featureName: string): number;
  119460. /**
  119461. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  119462. * Can be used during a session to start a feature
  119463. * @param featureName the name of feature to attach
  119464. */
  119465. attachFeature(featureName: string): void;
  119466. /**
  119467. * Can be used inside a session or when the session ends to detach a specific feature
  119468. * @param featureName the name of the feature to detach
  119469. */
  119470. detachFeature(featureName: string): void;
  119471. /**
  119472. * Used to disable an already-enabled feature
  119473. * The feature will be disposed and will be recreated once enabled.
  119474. * @param featureName the feature to disable
  119475. * @returns true if disable was successful
  119476. */
  119477. disableFeature(featureName: string | {
  119478. Name: string;
  119479. }): boolean;
  119480. /**
  119481. * dispose this features manager
  119482. */
  119483. dispose(): void;
  119484. /**
  119485. * 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.
  119486. * 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.
  119487. *
  119488. * @param featureName the name of the feature to load or the class of the feature
  119489. * @param version optional version to load. if not provided the latest version will be enabled
  119490. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  119491. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  119492. * @returns a new constructed feature or throws an error if feature not found.
  119493. */
  119494. enableFeature(featureName: string | {
  119495. Name: string;
  119496. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean): IWebXRFeature;
  119497. /**
  119498. * get the implementation of an enabled feature.
  119499. * @param featureName the name of the feature to load
  119500. * @returns the feature class, if found
  119501. */
  119502. getEnabledFeature(featureName: string): IWebXRFeature;
  119503. /**
  119504. * Get the list of enabled features
  119505. * @returns an array of enabled features
  119506. */
  119507. getEnabledFeatures(): string[];
  119508. }
  119509. }
  119510. declare module BABYLON {
  119511. /**
  119512. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  119513. * @see https://doc.babylonjs.com/how_to/webxr
  119514. */
  119515. export class WebXRExperienceHelper implements IDisposable {
  119516. private scene;
  119517. private _nonVRCamera;
  119518. private _originalSceneAutoClear;
  119519. private _supported;
  119520. /**
  119521. * Camera used to render xr content
  119522. */
  119523. camera: WebXRCamera;
  119524. /** A features manager for this xr session */
  119525. featuresManager: WebXRFeaturesManager;
  119526. /**
  119527. * Observers registered here will be triggered after the camera's initial transformation is set
  119528. * This can be used to set a different ground level or an extra rotation.
  119529. *
  119530. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  119531. * to the position set after this observable is done executing.
  119532. */
  119533. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  119534. /**
  119535. * Fires when the state of the experience helper has changed
  119536. */
  119537. onStateChangedObservable: Observable<WebXRState>;
  119538. /** Session manager used to keep track of xr session */
  119539. sessionManager: WebXRSessionManager;
  119540. /**
  119541. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  119542. */
  119543. state: WebXRState;
  119544. /**
  119545. * Creates a WebXRExperienceHelper
  119546. * @param scene The scene the helper should be created in
  119547. */
  119548. private constructor();
  119549. /**
  119550. * Creates the experience helper
  119551. * @param scene the scene to attach the experience helper to
  119552. * @returns a promise for the experience helper
  119553. */
  119554. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  119555. /**
  119556. * Disposes of the experience helper
  119557. */
  119558. dispose(): void;
  119559. /**
  119560. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  119561. * @param sessionMode options for the XR session
  119562. * @param referenceSpaceType frame of reference of the XR session
  119563. * @param renderTarget the output canvas that will be used to enter XR mode
  119564. * @param sessionCreationOptions optional XRSessionInit object to init the session with
  119565. * @returns promise that resolves after xr mode has entered
  119566. */
  119567. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget, sessionCreationOptions?: XRSessionInit): Promise<WebXRSessionManager>;
  119568. /**
  119569. * Exits XR mode and returns the scene to its original state
  119570. * @returns promise that resolves after xr mode has exited
  119571. */
  119572. exitXRAsync(): Promise<void>;
  119573. private _nonXRToXRCamera;
  119574. private _setState;
  119575. }
  119576. }
  119577. declare module BABYLON {
  119578. /**
  119579. * X-Y values for axes in WebXR
  119580. */
  119581. export interface IWebXRMotionControllerAxesValue {
  119582. /**
  119583. * The value of the x axis
  119584. */
  119585. x: number;
  119586. /**
  119587. * The value of the y-axis
  119588. */
  119589. y: number;
  119590. }
  119591. /**
  119592. * changed / previous values for the values of this component
  119593. */
  119594. export interface IWebXRMotionControllerComponentChangesValues<T> {
  119595. /**
  119596. * current (this frame) value
  119597. */
  119598. current: T;
  119599. /**
  119600. * previous (last change) value
  119601. */
  119602. previous: T;
  119603. }
  119604. /**
  119605. * Represents changes in the component between current frame and last values recorded
  119606. */
  119607. export interface IWebXRMotionControllerComponentChanges {
  119608. /**
  119609. * will be populated with previous and current values if axes changed
  119610. */
  119611. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  119612. /**
  119613. * will be populated with previous and current values if pressed changed
  119614. */
  119615. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  119616. /**
  119617. * will be populated with previous and current values if touched changed
  119618. */
  119619. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  119620. /**
  119621. * will be populated with previous and current values if value changed
  119622. */
  119623. value?: IWebXRMotionControllerComponentChangesValues<number>;
  119624. }
  119625. /**
  119626. * This class represents a single component (for example button or thumbstick) of a motion controller
  119627. */
  119628. export class WebXRControllerComponent implements IDisposable {
  119629. /**
  119630. * the id of this component
  119631. */
  119632. id: string;
  119633. /**
  119634. * the type of the component
  119635. */
  119636. type: MotionControllerComponentType;
  119637. private _buttonIndex;
  119638. private _axesIndices;
  119639. private _axes;
  119640. private _changes;
  119641. private _currentValue;
  119642. private _hasChanges;
  119643. private _pressed;
  119644. private _touched;
  119645. /**
  119646. * button component type
  119647. */
  119648. static BUTTON_TYPE: MotionControllerComponentType;
  119649. /**
  119650. * squeeze component type
  119651. */
  119652. static SQUEEZE_TYPE: MotionControllerComponentType;
  119653. /**
  119654. * Thumbstick component type
  119655. */
  119656. static THUMBSTICK_TYPE: MotionControllerComponentType;
  119657. /**
  119658. * Touchpad component type
  119659. */
  119660. static TOUCHPAD_TYPE: MotionControllerComponentType;
  119661. /**
  119662. * trigger component type
  119663. */
  119664. static TRIGGER_TYPE: MotionControllerComponentType;
  119665. /**
  119666. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  119667. * the axes data changes
  119668. */
  119669. onAxisValueChangedObservable: Observable<{
  119670. x: number;
  119671. y: number;
  119672. }>;
  119673. /**
  119674. * Observers registered here will be triggered when the state of a button changes
  119675. * State change is either pressed / touched / value
  119676. */
  119677. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  119678. /**
  119679. * Creates a new component for a motion controller.
  119680. * It is created by the motion controller itself
  119681. *
  119682. * @param id the id of this component
  119683. * @param type the type of the component
  119684. * @param _buttonIndex index in the buttons array of the gamepad
  119685. * @param _axesIndices indices of the values in the axes array of the gamepad
  119686. */
  119687. constructor(
  119688. /**
  119689. * the id of this component
  119690. */
  119691. id: string,
  119692. /**
  119693. * the type of the component
  119694. */
  119695. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  119696. /**
  119697. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  119698. */
  119699. get axes(): IWebXRMotionControllerAxesValue;
  119700. /**
  119701. * Get the changes. Elements will be populated only if they changed with their previous and current value
  119702. */
  119703. get changes(): IWebXRMotionControllerComponentChanges;
  119704. /**
  119705. * Return whether or not the component changed the last frame
  119706. */
  119707. get hasChanges(): boolean;
  119708. /**
  119709. * is the button currently pressed
  119710. */
  119711. get pressed(): boolean;
  119712. /**
  119713. * is the button currently touched
  119714. */
  119715. get touched(): boolean;
  119716. /**
  119717. * Get the current value of this component
  119718. */
  119719. get value(): number;
  119720. /**
  119721. * Dispose this component
  119722. */
  119723. dispose(): void;
  119724. /**
  119725. * Are there axes correlating to this component
  119726. * @return true is axes data is available
  119727. */
  119728. isAxes(): boolean;
  119729. /**
  119730. * Is this component a button (hence - pressable)
  119731. * @returns true if can be pressed
  119732. */
  119733. isButton(): boolean;
  119734. /**
  119735. * update this component using the gamepad object it is in. Called on every frame
  119736. * @param nativeController the native gamepad controller object
  119737. */
  119738. update(nativeController: IMinimalMotionControllerObject): void;
  119739. }
  119740. }
  119741. declare module BABYLON {
  119742. /**
  119743. * Class used to represent data loading progression
  119744. */
  119745. export class SceneLoaderProgressEvent {
  119746. /** defines if data length to load can be evaluated */
  119747. readonly lengthComputable: boolean;
  119748. /** defines the loaded data length */
  119749. readonly loaded: number;
  119750. /** defines the data length to load */
  119751. readonly total: number;
  119752. /**
  119753. * Create a new progress event
  119754. * @param lengthComputable defines if data length to load can be evaluated
  119755. * @param loaded defines the loaded data length
  119756. * @param total defines the data length to load
  119757. */
  119758. constructor(
  119759. /** defines if data length to load can be evaluated */
  119760. lengthComputable: boolean,
  119761. /** defines the loaded data length */
  119762. loaded: number,
  119763. /** defines the data length to load */
  119764. total: number);
  119765. /**
  119766. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  119767. * @param event defines the source event
  119768. * @returns a new SceneLoaderProgressEvent
  119769. */
  119770. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  119771. }
  119772. /**
  119773. * Interface used by SceneLoader plugins to define supported file extensions
  119774. */
  119775. export interface ISceneLoaderPluginExtensions {
  119776. /**
  119777. * Defines the list of supported extensions
  119778. */
  119779. [extension: string]: {
  119780. isBinary: boolean;
  119781. };
  119782. }
  119783. /**
  119784. * Interface used by SceneLoader plugin factory
  119785. */
  119786. export interface ISceneLoaderPluginFactory {
  119787. /**
  119788. * Defines the name of the factory
  119789. */
  119790. name: string;
  119791. /**
  119792. * Function called to create a new plugin
  119793. * @return the new plugin
  119794. */
  119795. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  119796. /**
  119797. * The callback that returns true if the data can be directly loaded.
  119798. * @param data string containing the file data
  119799. * @returns if the data can be loaded directly
  119800. */
  119801. canDirectLoad?(data: string): boolean;
  119802. }
  119803. /**
  119804. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  119805. */
  119806. export interface ISceneLoaderPluginBase {
  119807. /**
  119808. * The friendly name of this plugin.
  119809. */
  119810. name: string;
  119811. /**
  119812. * The file extensions supported by this plugin.
  119813. */
  119814. extensions: string | ISceneLoaderPluginExtensions;
  119815. /**
  119816. * The callback called when loading from a url.
  119817. * @param scene scene loading this url
  119818. * @param url url to load
  119819. * @param onSuccess callback called when the file successfully loads
  119820. * @param onProgress callback called while file is loading (if the server supports this mode)
  119821. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  119822. * @param onError callback called when the file fails to load
  119823. * @returns a file request object
  119824. */
  119825. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  119826. /**
  119827. * The callback called when loading from a file object.
  119828. * @param scene scene loading this file
  119829. * @param file defines the file to load
  119830. * @param onSuccess defines the callback to call when data is loaded
  119831. * @param onProgress defines the callback to call during loading process
  119832. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  119833. * @param onError defines the callback to call when an error occurs
  119834. * @returns a file request object
  119835. */
  119836. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  119837. /**
  119838. * The callback that returns true if the data can be directly loaded.
  119839. * @param data string containing the file data
  119840. * @returns if the data can be loaded directly
  119841. */
  119842. canDirectLoad?(data: string): boolean;
  119843. /**
  119844. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  119845. * @param scene scene loading this data
  119846. * @param data string containing the data
  119847. * @returns data to pass to the plugin
  119848. */
  119849. directLoad?(scene: Scene, data: string): any;
  119850. /**
  119851. * The callback that allows custom handling of the root url based on the response url.
  119852. * @param rootUrl the original root url
  119853. * @param responseURL the response url if available
  119854. * @returns the new root url
  119855. */
  119856. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  119857. }
  119858. /**
  119859. * Interface used to define a SceneLoader plugin
  119860. */
  119861. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  119862. /**
  119863. * Import meshes into a scene.
  119864. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  119865. * @param scene The scene to import into
  119866. * @param data The data to import
  119867. * @param rootUrl The root url for scene and resources
  119868. * @param meshes The meshes array to import into
  119869. * @param particleSystems The particle systems array to import into
  119870. * @param skeletons The skeletons array to import into
  119871. * @param onError The callback when import fails
  119872. * @returns True if successful or false otherwise
  119873. */
  119874. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  119875. /**
  119876. * Load into a scene.
  119877. * @param scene The scene to load into
  119878. * @param data The data to import
  119879. * @param rootUrl The root url for scene and resources
  119880. * @param onError The callback when import fails
  119881. * @returns True if successful or false otherwise
  119882. */
  119883. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  119884. /**
  119885. * Load into an asset container.
  119886. * @param scene The scene to load into
  119887. * @param data The data to import
  119888. * @param rootUrl The root url for scene and resources
  119889. * @param onError The callback when import fails
  119890. * @returns The loaded asset container
  119891. */
  119892. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  119893. }
  119894. /**
  119895. * Interface used to define an async SceneLoader plugin
  119896. */
  119897. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  119898. /**
  119899. * Import meshes into a scene.
  119900. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  119901. * @param scene The scene to import into
  119902. * @param data The data to import
  119903. * @param rootUrl The root url for scene and resources
  119904. * @param onProgress The callback when the load progresses
  119905. * @param fileName Defines the name of the file to load
  119906. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  119907. */
  119908. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  119909. meshes: AbstractMesh[];
  119910. particleSystems: IParticleSystem[];
  119911. skeletons: Skeleton[];
  119912. animationGroups: AnimationGroup[];
  119913. }>;
  119914. /**
  119915. * Load into a scene.
  119916. * @param scene The scene to load into
  119917. * @param data The data to import
  119918. * @param rootUrl The root url for scene and resources
  119919. * @param onProgress The callback when the load progresses
  119920. * @param fileName Defines the name of the file to load
  119921. * @returns Nothing
  119922. */
  119923. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  119924. /**
  119925. * Load into an asset container.
  119926. * @param scene The scene to load into
  119927. * @param data The data to import
  119928. * @param rootUrl The root url for scene and resources
  119929. * @param onProgress The callback when the load progresses
  119930. * @param fileName Defines the name of the file to load
  119931. * @returns The loaded asset container
  119932. */
  119933. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  119934. }
  119935. /**
  119936. * Mode that determines how to handle old animation groups before loading new ones.
  119937. */
  119938. export enum SceneLoaderAnimationGroupLoadingMode {
  119939. /**
  119940. * Reset all old animations to initial state then dispose them.
  119941. */
  119942. Clean = 0,
  119943. /**
  119944. * Stop all old animations.
  119945. */
  119946. Stop = 1,
  119947. /**
  119948. * Restart old animations from first frame.
  119949. */
  119950. Sync = 2,
  119951. /**
  119952. * Old animations remains untouched.
  119953. */
  119954. NoSync = 3
  119955. }
  119956. /**
  119957. * Class used to load scene from various file formats using registered plugins
  119958. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  119959. */
  119960. export class SceneLoader {
  119961. /**
  119962. * No logging while loading
  119963. */
  119964. static readonly NO_LOGGING: number;
  119965. /**
  119966. * Minimal logging while loading
  119967. */
  119968. static readonly MINIMAL_LOGGING: number;
  119969. /**
  119970. * Summary logging while loading
  119971. */
  119972. static readonly SUMMARY_LOGGING: number;
  119973. /**
  119974. * Detailled logging while loading
  119975. */
  119976. static readonly DETAILED_LOGGING: number;
  119977. /**
  119978. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  119979. */
  119980. static get ForceFullSceneLoadingForIncremental(): boolean;
  119981. static set ForceFullSceneLoadingForIncremental(value: boolean);
  119982. /**
  119983. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  119984. */
  119985. static get ShowLoadingScreen(): boolean;
  119986. static set ShowLoadingScreen(value: boolean);
  119987. /**
  119988. * Defines the current logging level (while loading the scene)
  119989. * @ignorenaming
  119990. */
  119991. static get loggingLevel(): number;
  119992. static set loggingLevel(value: number);
  119993. /**
  119994. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  119995. */
  119996. static get CleanBoneMatrixWeights(): boolean;
  119997. static set CleanBoneMatrixWeights(value: boolean);
  119998. /**
  119999. * Event raised when a plugin is used to load a scene
  120000. */
  120001. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  120002. private static _registeredPlugins;
  120003. private static _getDefaultPlugin;
  120004. private static _getPluginForExtension;
  120005. private static _getPluginForDirectLoad;
  120006. private static _getPluginForFilename;
  120007. private static _getDirectLoad;
  120008. private static _loadData;
  120009. private static _getFileInfo;
  120010. /**
  120011. * Gets a plugin that can load the given extension
  120012. * @param extension defines the extension to load
  120013. * @returns a plugin or null if none works
  120014. */
  120015. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  120016. /**
  120017. * Gets a boolean indicating that the given extension can be loaded
  120018. * @param extension defines the extension to load
  120019. * @returns true if the extension is supported
  120020. */
  120021. static IsPluginForExtensionAvailable(extension: string): boolean;
  120022. /**
  120023. * Adds a new plugin to the list of registered plugins
  120024. * @param plugin defines the plugin to add
  120025. */
  120026. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  120027. /**
  120028. * Import meshes into a scene
  120029. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  120030. * @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)
  120031. * @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)
  120032. * @param scene the instance of BABYLON.Scene to append to
  120033. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  120034. * @param onProgress a callback with a progress event for each file being loaded
  120035. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  120036. * @param pluginExtension the extension used to determine the plugin
  120037. * @returns The loaded plugin
  120038. */
  120039. 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>;
  120040. /**
  120041. * Import meshes into a scene
  120042. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  120043. * @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)
  120044. * @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)
  120045. * @param scene the instance of BABYLON.Scene to append to
  120046. * @param onProgress a callback with a progress event for each file being loaded
  120047. * @param pluginExtension the extension used to determine the plugin
  120048. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  120049. */
  120050. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  120051. meshes: AbstractMesh[];
  120052. particleSystems: IParticleSystem[];
  120053. skeletons: Skeleton[];
  120054. animationGroups: AnimationGroup[];
  120055. }>;
  120056. /**
  120057. * Load a scene
  120058. * @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)
  120059. * @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)
  120060. * @param engine is the instance of BABYLON.Engine to use to create the scene
  120061. * @param onSuccess a callback with the scene when import succeeds
  120062. * @param onProgress a callback with a progress event for each file being loaded
  120063. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  120064. * @param pluginExtension the extension used to determine the plugin
  120065. * @returns The loaded plugin
  120066. */
  120067. 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>;
  120068. /**
  120069. * Load a scene
  120070. * @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)
  120071. * @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)
  120072. * @param engine is the instance of BABYLON.Engine to use to create the scene
  120073. * @param onProgress a callback with a progress event for each file being loaded
  120074. * @param pluginExtension the extension used to determine the plugin
  120075. * @returns The loaded scene
  120076. */
  120077. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  120078. /**
  120079. * Append a scene
  120080. * @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)
  120081. * @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)
  120082. * @param scene is the instance of BABYLON.Scene to append to
  120083. * @param onSuccess a callback with the scene when import succeeds
  120084. * @param onProgress a callback with a progress event for each file being loaded
  120085. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  120086. * @param pluginExtension the extension used to determine the plugin
  120087. * @returns The loaded plugin
  120088. */
  120089. 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>;
  120090. /**
  120091. * Append a scene
  120092. * @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)
  120093. * @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)
  120094. * @param scene is the instance of BABYLON.Scene to append to
  120095. * @param onProgress a callback with a progress event for each file being loaded
  120096. * @param pluginExtension the extension used to determine the plugin
  120097. * @returns The given scene
  120098. */
  120099. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  120100. /**
  120101. * Load a scene into an asset container
  120102. * @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)
  120103. * @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)
  120104. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  120105. * @param onSuccess a callback with the scene when import succeeds
  120106. * @param onProgress a callback with a progress event for each file being loaded
  120107. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  120108. * @param pluginExtension the extension used to determine the plugin
  120109. * @returns The loaded plugin
  120110. */
  120111. 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>;
  120112. /**
  120113. * Load a scene into an asset container
  120114. * @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)
  120115. * @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)
  120116. * @param scene is the instance of Scene to append to
  120117. * @param onProgress a callback with a progress event for each file being loaded
  120118. * @param pluginExtension the extension used to determine the plugin
  120119. * @returns The loaded asset container
  120120. */
  120121. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  120122. /**
  120123. * Import animations from a file into a scene
  120124. * @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)
  120125. * @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)
  120126. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  120127. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  120128. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  120129. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  120130. * @param onSuccess a callback with the scene when import succeeds
  120131. * @param onProgress a callback with a progress event for each file being loaded
  120132. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  120133. */
  120134. 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;
  120135. /**
  120136. * Import animations from a file into a scene
  120137. * @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)
  120138. * @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)
  120139. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  120140. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  120141. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  120142. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  120143. * @param onSuccess a callback with the scene when import succeeds
  120144. * @param onProgress a callback with a progress event for each file being loaded
  120145. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  120146. * @returns the updated scene with imported animations
  120147. */
  120148. 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>;
  120149. }
  120150. }
  120151. declare module BABYLON {
  120152. /**
  120153. * Handedness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  120154. */
  120155. export type MotionControllerHandedness = "none" | "left" | "right";
  120156. /**
  120157. * The type of components available in motion controllers.
  120158. * This is not the name of the component.
  120159. */
  120160. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  120161. /**
  120162. * The state of a controller component
  120163. */
  120164. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  120165. /**
  120166. * The schema of motion controller layout.
  120167. * No object will be initialized using this interface
  120168. * This is used just to define the profile.
  120169. */
  120170. export interface IMotionControllerLayout {
  120171. /**
  120172. * Path to load the assets. Usually relative to the base path
  120173. */
  120174. assetPath: string;
  120175. /**
  120176. * Available components (unsorted)
  120177. */
  120178. components: {
  120179. /**
  120180. * A map of component Ids
  120181. */
  120182. [componentId: string]: {
  120183. /**
  120184. * The type of input the component outputs
  120185. */
  120186. type: MotionControllerComponentType;
  120187. /**
  120188. * The indices of this component in the gamepad object
  120189. */
  120190. gamepadIndices: {
  120191. /**
  120192. * Index of button
  120193. */
  120194. button?: number;
  120195. /**
  120196. * If available, index of x-axis
  120197. */
  120198. xAxis?: number;
  120199. /**
  120200. * If available, index of y-axis
  120201. */
  120202. yAxis?: number;
  120203. };
  120204. /**
  120205. * The mesh's root node name
  120206. */
  120207. rootNodeName: string;
  120208. /**
  120209. * Animation definitions for this model
  120210. */
  120211. visualResponses: {
  120212. [stateKey: string]: {
  120213. /**
  120214. * What property will be animated
  120215. */
  120216. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  120217. /**
  120218. * What states influence this visual response
  120219. */
  120220. states: MotionControllerComponentStateType[];
  120221. /**
  120222. * Type of animation - movement or visibility
  120223. */
  120224. valueNodeProperty: "transform" | "visibility";
  120225. /**
  120226. * Base node name to move. Its position will be calculated according to the min and max nodes
  120227. */
  120228. valueNodeName?: string;
  120229. /**
  120230. * Minimum movement node
  120231. */
  120232. minNodeName?: string;
  120233. /**
  120234. * Max movement node
  120235. */
  120236. maxNodeName?: string;
  120237. };
  120238. };
  120239. /**
  120240. * If touch enabled, what is the name of node to display user feedback
  120241. */
  120242. touchPointNodeName?: string;
  120243. };
  120244. };
  120245. /**
  120246. * Is it xr standard mapping or not
  120247. */
  120248. gamepadMapping: "" | "xr-standard";
  120249. /**
  120250. * Base root node of this entire model
  120251. */
  120252. rootNodeName: string;
  120253. /**
  120254. * Defines the main button component id
  120255. */
  120256. selectComponentId: string;
  120257. }
  120258. /**
  120259. * A definition for the layout map in the input profile
  120260. */
  120261. export interface IMotionControllerLayoutMap {
  120262. /**
  120263. * Layouts with handedness type as a key
  120264. */
  120265. [handedness: string]: IMotionControllerLayout;
  120266. }
  120267. /**
  120268. * The XR Input profile schema
  120269. * Profiles can be found here:
  120270. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  120271. */
  120272. export interface IMotionControllerProfile {
  120273. /**
  120274. * fallback profiles for this profileId
  120275. */
  120276. fallbackProfileIds: string[];
  120277. /**
  120278. * The layout map, with handedness as key
  120279. */
  120280. layouts: IMotionControllerLayoutMap;
  120281. /**
  120282. * The id of this profile
  120283. * correlates to the profile(s) in the xrInput.profiles array
  120284. */
  120285. profileId: string;
  120286. }
  120287. /**
  120288. * A helper-interface for the 3 meshes needed for controller button animation
  120289. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  120290. */
  120291. export interface IMotionControllerButtonMeshMap {
  120292. /**
  120293. * the mesh that defines the pressed value mesh position.
  120294. * This is used to find the max-position of this button
  120295. */
  120296. pressedMesh: AbstractMesh;
  120297. /**
  120298. * the mesh that defines the unpressed value mesh position.
  120299. * This is used to find the min (or initial) position of this button
  120300. */
  120301. unpressedMesh: AbstractMesh;
  120302. /**
  120303. * The mesh that will be changed when value changes
  120304. */
  120305. valueMesh: AbstractMesh;
  120306. }
  120307. /**
  120308. * A helper-interface for the 3 meshes needed for controller axis animation.
  120309. * This will be expanded when touchpad animations are fully supported
  120310. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  120311. */
  120312. export interface IMotionControllerMeshMap {
  120313. /**
  120314. * the mesh that defines the maximum value mesh position.
  120315. */
  120316. maxMesh?: AbstractMesh;
  120317. /**
  120318. * the mesh that defines the minimum value mesh position.
  120319. */
  120320. minMesh?: AbstractMesh;
  120321. /**
  120322. * The mesh that will be changed when axis value changes
  120323. */
  120324. valueMesh: AbstractMesh;
  120325. }
  120326. /**
  120327. * The elements needed for change-detection of the gamepad objects in motion controllers
  120328. */
  120329. export interface IMinimalMotionControllerObject {
  120330. /**
  120331. * Available axes of this controller
  120332. */
  120333. axes: number[];
  120334. /**
  120335. * An array of available buttons
  120336. */
  120337. buttons: Array<{
  120338. /**
  120339. * Value of the button/trigger
  120340. */
  120341. value: number;
  120342. /**
  120343. * If the button/trigger is currently touched
  120344. */
  120345. touched: boolean;
  120346. /**
  120347. * If the button/trigger is currently pressed
  120348. */
  120349. pressed: boolean;
  120350. }>;
  120351. /**
  120352. * EXPERIMENTAL haptic support.
  120353. */
  120354. hapticActuators?: Array<{
  120355. pulse: (value: number, duration: number) => Promise<boolean>;
  120356. }>;
  120357. }
  120358. /**
  120359. * An Abstract Motion controller
  120360. * This class receives an xrInput and a profile layout and uses those to initialize the components
  120361. * Each component has an observable to check for changes in value and state
  120362. */
  120363. export abstract class WebXRAbstractMotionController implements IDisposable {
  120364. protected scene: Scene;
  120365. protected layout: IMotionControllerLayout;
  120366. /**
  120367. * The gamepad object correlating to this controller
  120368. */
  120369. gamepadObject: IMinimalMotionControllerObject;
  120370. /**
  120371. * handedness (left/right/none) of this controller
  120372. */
  120373. handedness: MotionControllerHandedness;
  120374. private _initComponent;
  120375. private _modelReady;
  120376. /**
  120377. * A map of components (WebXRControllerComponent) in this motion controller
  120378. * Components have a ComponentType and can also have both button and axis definitions
  120379. */
  120380. readonly components: {
  120381. [id: string]: WebXRControllerComponent;
  120382. };
  120383. /**
  120384. * Disable the model's animation. Can be set at any time.
  120385. */
  120386. disableAnimation: boolean;
  120387. /**
  120388. * Observers registered here will be triggered when the model of this controller is done loading
  120389. */
  120390. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  120391. /**
  120392. * The profile id of this motion controller
  120393. */
  120394. abstract profileId: string;
  120395. /**
  120396. * The root mesh of the model. It is null if the model was not yet initialized
  120397. */
  120398. rootMesh: Nullable<AbstractMesh>;
  120399. /**
  120400. * constructs a new abstract motion controller
  120401. * @param scene the scene to which the model of the controller will be added
  120402. * @param layout The profile layout to load
  120403. * @param gamepadObject The gamepad object correlating to this controller
  120404. * @param handedness handedness (left/right/none) of this controller
  120405. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  120406. */
  120407. constructor(scene: Scene, layout: IMotionControllerLayout,
  120408. /**
  120409. * The gamepad object correlating to this controller
  120410. */
  120411. gamepadObject: IMinimalMotionControllerObject,
  120412. /**
  120413. * handedness (left/right/none) of this controller
  120414. */
  120415. handedness: MotionControllerHandedness, _doNotLoadControllerMesh?: boolean);
  120416. /**
  120417. * Dispose this controller, the model mesh and all its components
  120418. */
  120419. dispose(): void;
  120420. /**
  120421. * Returns all components of specific type
  120422. * @param type the type to search for
  120423. * @return an array of components with this type
  120424. */
  120425. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  120426. /**
  120427. * get a component based an its component id as defined in layout.components
  120428. * @param id the id of the component
  120429. * @returns the component correlates to the id or undefined if not found
  120430. */
  120431. getComponent(id: string): WebXRControllerComponent;
  120432. /**
  120433. * Get the list of components available in this motion controller
  120434. * @returns an array of strings correlating to available components
  120435. */
  120436. getComponentIds(): string[];
  120437. /**
  120438. * Get the first component of specific type
  120439. * @param type type of component to find
  120440. * @return a controller component or null if not found
  120441. */
  120442. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  120443. /**
  120444. * Get the main (Select) component of this controller as defined in the layout
  120445. * @returns the main component of this controller
  120446. */
  120447. getMainComponent(): WebXRControllerComponent;
  120448. /**
  120449. * Loads the model correlating to this controller
  120450. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  120451. * @returns A promise fulfilled with the result of the model loading
  120452. */
  120453. loadModel(): Promise<boolean>;
  120454. /**
  120455. * Update this model using the current XRFrame
  120456. * @param xrFrame the current xr frame to use and update the model
  120457. */
  120458. updateFromXRFrame(xrFrame: XRFrame): void;
  120459. /**
  120460. * Backwards compatibility due to a deeply-integrated typo
  120461. */
  120462. get handness(): XREye;
  120463. /**
  120464. * Pulse (vibrate) this controller
  120465. * If the controller does not support pulses, this function will fail silently and return Promise<false> directly after called
  120466. * Consecutive calls to this function will cancel the last pulse call
  120467. *
  120468. * @param value the strength of the pulse in 0.0...1.0 range
  120469. * @param duration Duration of the pulse in milliseconds
  120470. * @param hapticActuatorIndex optional index of actuator (will usually be 0)
  120471. * @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
  120472. */
  120473. pulse(value: number, duration: number, hapticActuatorIndex?: number): Promise<boolean>;
  120474. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh;
  120475. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh;
  120476. /**
  120477. * Moves the axis on the controller mesh based on its current state
  120478. * @param axis the index of the axis
  120479. * @param axisValue the value of the axis which determines the meshes new position
  120480. * @hidden
  120481. */
  120482. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  120483. /**
  120484. * Update the model itself with the current frame data
  120485. * @param xrFrame the frame to use for updating the model mesh
  120486. */
  120487. protected updateModel(xrFrame: XRFrame): void;
  120488. /**
  120489. * Get the filename and path for this controller's model
  120490. * @returns a map of filename and path
  120491. */
  120492. protected abstract _getFilenameAndPath(): {
  120493. filename: string;
  120494. path: string;
  120495. };
  120496. /**
  120497. * This function is called before the mesh is loaded. It checks for loading constraints.
  120498. * For example, this function can check if the GLB loader is available
  120499. * If this function returns false, the generic controller will be loaded instead
  120500. * @returns Is the client ready to load the mesh
  120501. */
  120502. protected abstract _getModelLoadingConstraints(): boolean;
  120503. /**
  120504. * This function will be called after the model was successfully loaded and can be used
  120505. * for mesh transformations before it is available for the user
  120506. * @param meshes the loaded meshes
  120507. */
  120508. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  120509. /**
  120510. * Set the root mesh for this controller. Important for the WebXR controller class
  120511. * @param meshes the loaded meshes
  120512. */
  120513. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  120514. /**
  120515. * A function executed each frame that updates the mesh (if needed)
  120516. * @param xrFrame the current xrFrame
  120517. */
  120518. protected abstract _updateModel(xrFrame: XRFrame): void;
  120519. private _getGenericFilenameAndPath;
  120520. private _getGenericParentMesh;
  120521. }
  120522. }
  120523. declare module BABYLON {
  120524. /**
  120525. * A generic trigger-only motion controller for WebXR
  120526. */
  120527. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  120528. /**
  120529. * Static version of the profile id of this controller
  120530. */
  120531. static ProfileId: string;
  120532. profileId: string;
  120533. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  120534. protected _getFilenameAndPath(): {
  120535. filename: string;
  120536. path: string;
  120537. };
  120538. protected _getModelLoadingConstraints(): boolean;
  120539. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  120540. protected _setRootMesh(meshes: AbstractMesh[]): void;
  120541. protected _updateModel(): void;
  120542. }
  120543. }
  120544. declare module BABYLON {
  120545. /**
  120546. * Class containing static functions to help procedurally build meshes
  120547. */
  120548. export class SphereBuilder {
  120549. /**
  120550. * Creates a sphere mesh
  120551. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  120552. * * 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`)
  120553. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  120554. * * 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
  120555. * * 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)
  120556. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  120557. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  120558. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  120559. * @param name defines the name of the mesh
  120560. * @param options defines the options used to create the mesh
  120561. * @param scene defines the hosting scene
  120562. * @returns the sphere mesh
  120563. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  120564. */
  120565. static CreateSphere(name: string, options: {
  120566. segments?: number;
  120567. diameter?: number;
  120568. diameterX?: number;
  120569. diameterY?: number;
  120570. diameterZ?: number;
  120571. arc?: number;
  120572. slice?: number;
  120573. sideOrientation?: number;
  120574. frontUVs?: Vector4;
  120575. backUVs?: Vector4;
  120576. updatable?: boolean;
  120577. }, scene?: Nullable<Scene>): Mesh;
  120578. }
  120579. }
  120580. declare module BABYLON {
  120581. /**
  120582. * A profiled motion controller has its profile loaded from an online repository.
  120583. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  120584. */
  120585. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  120586. private _repositoryUrl;
  120587. private _buttonMeshMapping;
  120588. private _touchDots;
  120589. /**
  120590. * The profile ID of this controller. Will be populated when the controller initializes.
  120591. */
  120592. profileId: string;
  120593. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  120594. dispose(): void;
  120595. protected _getFilenameAndPath(): {
  120596. filename: string;
  120597. path: string;
  120598. };
  120599. protected _getModelLoadingConstraints(): boolean;
  120600. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  120601. protected _setRootMesh(meshes: AbstractMesh[]): void;
  120602. protected _updateModel(_xrFrame: XRFrame): void;
  120603. }
  120604. }
  120605. declare module BABYLON {
  120606. /**
  120607. * A construction function type to create a new controller based on an xrInput object
  120608. */
  120609. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  120610. /**
  120611. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  120612. *
  120613. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  120614. * it should be replaced with auto-loaded controllers.
  120615. *
  120616. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  120617. */
  120618. export class WebXRMotionControllerManager {
  120619. private static _AvailableControllers;
  120620. private static _Fallbacks;
  120621. private static _ProfileLoadingPromises;
  120622. private static _ProfilesList;
  120623. /**
  120624. * The base URL of the online controller repository. Can be changed at any time.
  120625. */
  120626. static BaseRepositoryUrl: string;
  120627. /**
  120628. * Which repository gets priority - local or online
  120629. */
  120630. static PrioritizeOnlineRepository: boolean;
  120631. /**
  120632. * Use the online repository, or use only locally-defined controllers
  120633. */
  120634. static UseOnlineRepository: boolean;
  120635. /**
  120636. * Clear the cache used for profile loading and reload when requested again
  120637. */
  120638. static ClearProfilesCache(): void;
  120639. /**
  120640. * Register the default fallbacks.
  120641. * This function is called automatically when this file is imported.
  120642. */
  120643. static DefaultFallbacks(): void;
  120644. /**
  120645. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  120646. * @param profileId the profile to which a fallback needs to be found
  120647. * @return an array with corresponding fallback profiles
  120648. */
  120649. static FindFallbackWithProfileId(profileId: string): string[];
  120650. /**
  120651. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  120652. * The order of search:
  120653. *
  120654. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  120655. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  120656. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  120657. * 4) return the generic trigger controller if none were found
  120658. *
  120659. * @param xrInput the xrInput to which a new controller is initialized
  120660. * @param scene the scene to which the model will be added
  120661. * @param forceProfile force a certain profile for this controller
  120662. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  120663. */
  120664. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  120665. /**
  120666. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  120667. *
  120668. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  120669. *
  120670. * @param type the profile type to register
  120671. * @param constructFunction the function to be called when loading this profile
  120672. */
  120673. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  120674. /**
  120675. * Register a fallback to a specific profile.
  120676. * @param profileId the profileId that will receive the fallbacks
  120677. * @param fallbacks A list of fallback profiles
  120678. */
  120679. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  120680. /**
  120681. * Will update the list of profiles available in the repository
  120682. * @return a promise that resolves to a map of profiles available online
  120683. */
  120684. static UpdateProfilesList(): Promise<{
  120685. [profile: string]: string;
  120686. }>;
  120687. private static _LoadProfileFromRepository;
  120688. private static _LoadProfilesFromAvailableControllers;
  120689. }
  120690. }
  120691. declare module BABYLON {
  120692. /**
  120693. * Configuration options for the WebXR controller creation
  120694. */
  120695. export interface IWebXRControllerOptions {
  120696. /**
  120697. * Should the controller mesh be animated when a user interacts with it
  120698. * The pressed buttons / thumbstick and touchpad animations will be disabled
  120699. */
  120700. disableMotionControllerAnimation?: boolean;
  120701. /**
  120702. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  120703. */
  120704. doNotLoadControllerMesh?: boolean;
  120705. /**
  120706. * Force a specific controller type for this controller.
  120707. * This can be used when creating your own profile or when testing different controllers
  120708. */
  120709. forceControllerProfile?: string;
  120710. /**
  120711. * Defines a rendering group ID for meshes that will be loaded.
  120712. * This is for the default controllers only.
  120713. */
  120714. renderingGroupId?: number;
  120715. }
  120716. /**
  120717. * Represents an XR controller
  120718. */
  120719. export class WebXRInputSource {
  120720. private _scene;
  120721. /** The underlying input source for the controller */
  120722. inputSource: XRInputSource;
  120723. private _options;
  120724. private _tmpQuaternion;
  120725. private _tmpVector;
  120726. private _uniqueId;
  120727. /**
  120728. * 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
  120729. */
  120730. grip?: AbstractMesh;
  120731. /**
  120732. * If available, this is the gamepad object related to this controller.
  120733. * Using this object it is possible to get click events and trackpad changes of the
  120734. * webxr controller that is currently being used.
  120735. */
  120736. motionController?: WebXRAbstractMotionController;
  120737. /**
  120738. * Event that fires when the controller is removed/disposed.
  120739. * The object provided as event data is this controller, after associated assets were disposed.
  120740. * uniqueId is still available.
  120741. */
  120742. onDisposeObservable: Observable<WebXRInputSource>;
  120743. /**
  120744. * Will be triggered when the mesh associated with the motion controller is done loading.
  120745. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  120746. * A shortened version of controller -> motion controller -> on mesh loaded.
  120747. */
  120748. onMeshLoadedObservable: Observable<AbstractMesh>;
  120749. /**
  120750. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  120751. */
  120752. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  120753. /**
  120754. * Pointer which can be used to select objects or attach a visible laser to
  120755. */
  120756. pointer: AbstractMesh;
  120757. /**
  120758. * Creates the controller
  120759. * @see https://doc.babylonjs.com/how_to/webxr
  120760. * @param _scene the scene which the controller should be associated to
  120761. * @param inputSource the underlying input source for the controller
  120762. * @param _options options for this controller creation
  120763. */
  120764. constructor(_scene: Scene,
  120765. /** The underlying input source for the controller */
  120766. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  120767. /**
  120768. * Get this controllers unique id
  120769. */
  120770. get uniqueId(): string;
  120771. /**
  120772. * Disposes of the object
  120773. */
  120774. dispose(): void;
  120775. /**
  120776. * Gets a world space ray coming from the pointer or grip
  120777. * @param result the resulting ray
  120778. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  120779. */
  120780. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  120781. /**
  120782. * Updates the controller pose based on the given XRFrame
  120783. * @param xrFrame xr frame to update the pose with
  120784. * @param referenceSpace reference space to use
  120785. */
  120786. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  120787. }
  120788. }
  120789. declare module BABYLON {
  120790. /**
  120791. * The schema for initialization options of the XR Input class
  120792. */
  120793. export interface IWebXRInputOptions {
  120794. /**
  120795. * If set to true no model will be automatically loaded
  120796. */
  120797. doNotLoadControllerMeshes?: boolean;
  120798. /**
  120799. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  120800. * If not found, the xr input profile data will be used.
  120801. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  120802. */
  120803. forceInputProfile?: string;
  120804. /**
  120805. * Do not send a request to the controller repository to load the profile.
  120806. *
  120807. * Instead, use the controllers available in babylon itself.
  120808. */
  120809. disableOnlineControllerRepository?: boolean;
  120810. /**
  120811. * A custom URL for the controllers repository
  120812. */
  120813. customControllersRepositoryURL?: string;
  120814. /**
  120815. * Should the controller model's components not move according to the user input
  120816. */
  120817. disableControllerAnimation?: boolean;
  120818. /**
  120819. * Optional options to pass to the controller. Will be overridden by the Input options where applicable
  120820. */
  120821. controllerOptions?: IWebXRControllerOptions;
  120822. }
  120823. /**
  120824. * XR input used to track XR inputs such as controllers/rays
  120825. */
  120826. export class WebXRInput implements IDisposable {
  120827. /**
  120828. * the xr session manager for this session
  120829. */
  120830. xrSessionManager: WebXRSessionManager;
  120831. /**
  120832. * the WebXR camera for this session. Mainly used for teleportation
  120833. */
  120834. xrCamera: WebXRCamera;
  120835. private readonly options;
  120836. /**
  120837. * XR controllers being tracked
  120838. */
  120839. controllers: Array<WebXRInputSource>;
  120840. private _frameObserver;
  120841. private _sessionEndedObserver;
  120842. private _sessionInitObserver;
  120843. /**
  120844. * Event when a controller has been connected/added
  120845. */
  120846. onControllerAddedObservable: Observable<WebXRInputSource>;
  120847. /**
  120848. * Event when a controller has been removed/disconnected
  120849. */
  120850. onControllerRemovedObservable: Observable<WebXRInputSource>;
  120851. /**
  120852. * Initializes the WebXRInput
  120853. * @param xrSessionManager the xr session manager for this session
  120854. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  120855. * @param options = initialization options for this xr input
  120856. */
  120857. constructor(
  120858. /**
  120859. * the xr session manager for this session
  120860. */
  120861. xrSessionManager: WebXRSessionManager,
  120862. /**
  120863. * the WebXR camera for this session. Mainly used for teleportation
  120864. */
  120865. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  120866. private _onInputSourcesChange;
  120867. private _addAndRemoveControllers;
  120868. /**
  120869. * Disposes of the object
  120870. */
  120871. dispose(): void;
  120872. }
  120873. }
  120874. declare module BABYLON {
  120875. /**
  120876. * This is the base class for all WebXR features.
  120877. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  120878. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  120879. */
  120880. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  120881. protected _xrSessionManager: WebXRSessionManager;
  120882. private _attached;
  120883. private _removeOnDetach;
  120884. /**
  120885. * Should auto-attach be disabled?
  120886. */
  120887. disableAutoAttach: boolean;
  120888. /**
  120889. * Construct a new (abstract) WebXR feature
  120890. * @param _xrSessionManager the xr session manager for this feature
  120891. */
  120892. constructor(_xrSessionManager: WebXRSessionManager);
  120893. /**
  120894. * Is this feature attached
  120895. */
  120896. get attached(): boolean;
  120897. /**
  120898. * attach this feature
  120899. *
  120900. * @param force should attachment be forced (even when already attached)
  120901. * @returns true if successful, false is failed or already attached
  120902. */
  120903. attach(force?: boolean): boolean;
  120904. /**
  120905. * detach this feature.
  120906. *
  120907. * @returns true if successful, false if failed or already detached
  120908. */
  120909. detach(): boolean;
  120910. /**
  120911. * Dispose this feature and all of the resources attached
  120912. */
  120913. dispose(): void;
  120914. /**
  120915. * This is used to register callbacks that will automatically be removed when detach is called.
  120916. * @param observable the observable to which the observer will be attached
  120917. * @param callback the callback to register
  120918. */
  120919. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  120920. /**
  120921. * Code in this function will be executed on each xrFrame received from the browser.
  120922. * This function will not execute after the feature is detached.
  120923. * @param _xrFrame the current frame
  120924. */
  120925. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  120926. }
  120927. }
  120928. declare module BABYLON {
  120929. /**
  120930. * Renders a layer on top of an existing scene
  120931. */
  120932. export class UtilityLayerRenderer implements IDisposable {
  120933. /** the original scene that will be rendered on top of */
  120934. originalScene: Scene;
  120935. private _pointerCaptures;
  120936. private _lastPointerEvents;
  120937. private static _DefaultUtilityLayer;
  120938. private static _DefaultKeepDepthUtilityLayer;
  120939. private _sharedGizmoLight;
  120940. private _renderCamera;
  120941. /**
  120942. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  120943. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  120944. * @returns the camera that is used when rendering the utility layer
  120945. */
  120946. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  120947. /**
  120948. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  120949. * @param cam the camera that should be used when rendering the utility layer
  120950. */
  120951. setRenderCamera(cam: Nullable<Camera>): void;
  120952. /**
  120953. * @hidden
  120954. * Light which used by gizmos to get light shading
  120955. */
  120956. _getSharedGizmoLight(): HemisphericLight;
  120957. /**
  120958. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  120959. */
  120960. pickUtilitySceneFirst: boolean;
  120961. /**
  120962. * 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)
  120963. */
  120964. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  120965. /**
  120966. * 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)
  120967. */
  120968. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  120969. /**
  120970. * The scene that is rendered on top of the original scene
  120971. */
  120972. utilityLayerScene: Scene;
  120973. /**
  120974. * If the utility layer should automatically be rendered on top of existing scene
  120975. */
  120976. shouldRender: boolean;
  120977. /**
  120978. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  120979. */
  120980. onlyCheckPointerDownEvents: boolean;
  120981. /**
  120982. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  120983. */
  120984. processAllEvents: boolean;
  120985. /**
  120986. * Observable raised when the pointer move from the utility layer scene to the main scene
  120987. */
  120988. onPointerOutObservable: Observable<number>;
  120989. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  120990. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  120991. private _afterRenderObserver;
  120992. private _sceneDisposeObserver;
  120993. private _originalPointerObserver;
  120994. /**
  120995. * Instantiates a UtilityLayerRenderer
  120996. * @param originalScene the original scene that will be rendered on top of
  120997. * @param handleEvents boolean indicating if the utility layer should handle events
  120998. */
  120999. constructor(
  121000. /** the original scene that will be rendered on top of */
  121001. originalScene: Scene, handleEvents?: boolean);
  121002. private _notifyObservers;
  121003. /**
  121004. * Renders the utility layers scene on top of the original scene
  121005. */
  121006. render(): void;
  121007. /**
  121008. * Disposes of the renderer
  121009. */
  121010. dispose(): void;
  121011. private _updateCamera;
  121012. }
  121013. }
  121014. declare module BABYLON {
  121015. /**
  121016. * Options interface for the pointer selection module
  121017. */
  121018. export interface IWebXRControllerPointerSelectionOptions {
  121019. /**
  121020. * if provided, this scene will be used to render meshes.
  121021. */
  121022. customUtilityLayerScene?: Scene;
  121023. /**
  121024. * 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)
  121025. * If not disabled, the last picked point will be used to execute a pointer up event
  121026. * If disabled, pointer up event will be triggered right after the pointer down event.
  121027. * Used in screen and gaze target ray mode only
  121028. */
  121029. disablePointerUpOnTouchOut: boolean;
  121030. /**
  121031. * For gaze mode (time to select instead of press)
  121032. */
  121033. forceGazeMode: boolean;
  121034. /**
  121035. * 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
  121036. * to start a new countdown to the pointer down event.
  121037. * Defaults to 1.
  121038. */
  121039. gazeModePointerMovedFactor?: number;
  121040. /**
  121041. * Different button type to use instead of the main component
  121042. */
  121043. overrideButtonId?: string;
  121044. /**
  121045. * use this rendering group id for the meshes (optional)
  121046. */
  121047. renderingGroupId?: number;
  121048. /**
  121049. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  121050. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  121051. * 3000 means 3 seconds between pointing at something and selecting it
  121052. */
  121053. timeToSelect?: number;
  121054. /**
  121055. * Should meshes created here be added to a utility layer or the main scene
  121056. */
  121057. useUtilityLayer?: boolean;
  121058. /**
  121059. * the xr input to use with this pointer selection
  121060. */
  121061. xrInput: WebXRInput;
  121062. }
  121063. /**
  121064. * A module that will enable pointer selection for motion controllers of XR Input Sources
  121065. */
  121066. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  121067. private readonly _options;
  121068. private static _idCounter;
  121069. private _attachController;
  121070. private _controllers;
  121071. private _scene;
  121072. private _tmpVectorForPickCompare;
  121073. /**
  121074. * The module's name
  121075. */
  121076. static readonly Name: string;
  121077. /**
  121078. * The (Babylon) version of this module.
  121079. * This is an integer representing the implementation version.
  121080. * This number does not correspond to the WebXR specs version
  121081. */
  121082. static readonly Version: number;
  121083. /**
  121084. * Disable lighting on the laser pointer (so it will always be visible)
  121085. */
  121086. disablePointerLighting: boolean;
  121087. /**
  121088. * Disable lighting on the selection mesh (so it will always be visible)
  121089. */
  121090. disableSelectionMeshLighting: boolean;
  121091. /**
  121092. * Should the laser pointer be displayed
  121093. */
  121094. displayLaserPointer: boolean;
  121095. /**
  121096. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  121097. */
  121098. displaySelectionMesh: boolean;
  121099. /**
  121100. * This color will be set to the laser pointer when selection is triggered
  121101. */
  121102. laserPointerPickedColor: Color3;
  121103. /**
  121104. * Default color of the laser pointer
  121105. */
  121106. lasterPointerDefaultColor: Color3;
  121107. /**
  121108. * default color of the selection ring
  121109. */
  121110. selectionMeshDefaultColor: Color3;
  121111. /**
  121112. * This color will be applied to the selection ring when selection is triggered
  121113. */
  121114. selectionMeshPickedColor: Color3;
  121115. /**
  121116. * Optional filter to be used for ray selection. This predicate shares behavior with
  121117. * scene.pointerMovePredicate which takes priority if it is also assigned.
  121118. */
  121119. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  121120. /**
  121121. * constructs a new background remover module
  121122. * @param _xrSessionManager the session manager for this module
  121123. * @param _options read-only options to be used in this module
  121124. */
  121125. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  121126. /**
  121127. * attach this feature
  121128. * Will usually be called by the features manager
  121129. *
  121130. * @returns true if successful.
  121131. */
  121132. attach(): boolean;
  121133. /**
  121134. * detach this feature.
  121135. * Will usually be called by the features manager
  121136. *
  121137. * @returns true if successful.
  121138. */
  121139. detach(): boolean;
  121140. /**
  121141. * Will get the mesh under a specific pointer.
  121142. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  121143. * @param controllerId the controllerId to check
  121144. * @returns The mesh under pointer or null if no mesh is under the pointer
  121145. */
  121146. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  121147. /**
  121148. * Get the xr controller that correlates to the pointer id in the pointer event
  121149. *
  121150. * @param id the pointer id to search for
  121151. * @returns the controller that correlates to this id or null if not found
  121152. */
  121153. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  121154. protected _onXRFrame(_xrFrame: XRFrame): void;
  121155. private _attachGazeMode;
  121156. private _attachScreenRayMode;
  121157. private _attachTrackedPointerRayMode;
  121158. private _convertNormalToDirectionOfRay;
  121159. private _detachController;
  121160. private _generateNewMeshPair;
  121161. private _pickingMoved;
  121162. private _updatePointerDistance;
  121163. }
  121164. }
  121165. declare module BABYLON {
  121166. /**
  121167. * Button which can be used to enter a different mode of XR
  121168. */
  121169. export class WebXREnterExitUIButton {
  121170. /** button element */
  121171. element: HTMLElement;
  121172. /** XR initialization options for the button */
  121173. sessionMode: XRSessionMode;
  121174. /** Reference space type */
  121175. referenceSpaceType: XRReferenceSpaceType;
  121176. /**
  121177. * Creates a WebXREnterExitUIButton
  121178. * @param element button element
  121179. * @param sessionMode XR initialization session mode
  121180. * @param referenceSpaceType the type of reference space to be used
  121181. */
  121182. constructor(
  121183. /** button element */
  121184. element: HTMLElement,
  121185. /** XR initialization options for the button */
  121186. sessionMode: XRSessionMode,
  121187. /** Reference space type */
  121188. referenceSpaceType: XRReferenceSpaceType);
  121189. /**
  121190. * Extendable function which can be used to update the button's visuals when the state changes
  121191. * @param activeButton the current active button in the UI
  121192. */
  121193. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  121194. }
  121195. /**
  121196. * Options to create the webXR UI
  121197. */
  121198. export class WebXREnterExitUIOptions {
  121199. /**
  121200. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  121201. */
  121202. customButtons?: Array<WebXREnterExitUIButton>;
  121203. /**
  121204. * A reference space type to use when creating the default button.
  121205. * Default is local-floor
  121206. */
  121207. referenceSpaceType?: XRReferenceSpaceType;
  121208. /**
  121209. * Context to enter xr with
  121210. */
  121211. renderTarget?: Nullable<WebXRRenderTarget>;
  121212. /**
  121213. * A session mode to use when creating the default button.
  121214. * Default is immersive-vr
  121215. */
  121216. sessionMode?: XRSessionMode;
  121217. /**
  121218. * A list of optional features to init the session with
  121219. */
  121220. optionalFeatures?: string[];
  121221. }
  121222. /**
  121223. * UI to allow the user to enter/exit XR mode
  121224. */
  121225. export class WebXREnterExitUI implements IDisposable {
  121226. private scene;
  121227. /** version of the options passed to this UI */
  121228. options: WebXREnterExitUIOptions;
  121229. private _activeButton;
  121230. private _buttons;
  121231. private _overlay;
  121232. /**
  121233. * Fired every time the active button is changed.
  121234. *
  121235. * When xr is entered via a button that launches xr that button will be the callback parameter
  121236. *
  121237. * When exiting xr the callback parameter will be null)
  121238. */
  121239. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  121240. /**
  121241. *
  121242. * @param scene babylon scene object to use
  121243. * @param options (read-only) version of the options passed to this UI
  121244. */
  121245. private constructor();
  121246. /**
  121247. * Creates UI to allow the user to enter/exit XR mode
  121248. * @param scene the scene to add the ui to
  121249. * @param helper the xr experience helper to enter/exit xr with
  121250. * @param options options to configure the UI
  121251. * @returns the created ui
  121252. */
  121253. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  121254. /**
  121255. * Disposes of the XR UI component
  121256. */
  121257. dispose(): void;
  121258. private _updateButtons;
  121259. }
  121260. }
  121261. declare module BABYLON {
  121262. /**
  121263. * Class containing static functions to help procedurally build meshes
  121264. */
  121265. export class LinesBuilder {
  121266. /**
  121267. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  121268. * * 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
  121269. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  121270. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  121271. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  121272. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  121273. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  121274. * * 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
  121275. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  121276. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121277. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  121278. * @param name defines the name of the new line system
  121279. * @param options defines the options used to create the line system
  121280. * @param scene defines the hosting scene
  121281. * @returns a new line system mesh
  121282. */
  121283. static CreateLineSystem(name: string, options: {
  121284. lines: Vector3[][];
  121285. updatable?: boolean;
  121286. instance?: Nullable<LinesMesh>;
  121287. colors?: Nullable<Color4[][]>;
  121288. useVertexAlpha?: boolean;
  121289. }, scene: Nullable<Scene>): LinesMesh;
  121290. /**
  121291. * Creates a line mesh
  121292. * 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
  121293. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  121294. * * The parameter `points` is an array successive Vector3
  121295. * * 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
  121296. * * The optional parameter `colors` is an array of successive Color4, one per line point
  121297. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  121298. * * When updating an instance, remember that only point positions can change, not the number of points
  121299. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121300. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  121301. * @param name defines the name of the new line system
  121302. * @param options defines the options used to create the line system
  121303. * @param scene defines the hosting scene
  121304. * @returns a new line mesh
  121305. */
  121306. static CreateLines(name: string, options: {
  121307. points: Vector3[];
  121308. updatable?: boolean;
  121309. instance?: Nullable<LinesMesh>;
  121310. colors?: Color4[];
  121311. useVertexAlpha?: boolean;
  121312. }, scene?: Nullable<Scene>): LinesMesh;
  121313. /**
  121314. * Creates a dashed line mesh
  121315. * * 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
  121316. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  121317. * * The parameter `points` is an array successive Vector3
  121318. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  121319. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  121320. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  121321. * * 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
  121322. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  121323. * * When updating an instance, remember that only point positions can change, not the number of points
  121324. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121325. * @param name defines the name of the mesh
  121326. * @param options defines the options used to create the mesh
  121327. * @param scene defines the hosting scene
  121328. * @returns the dashed line mesh
  121329. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  121330. */
  121331. static CreateDashedLines(name: string, options: {
  121332. points: Vector3[];
  121333. dashSize?: number;
  121334. gapSize?: number;
  121335. dashNb?: number;
  121336. updatable?: boolean;
  121337. instance?: LinesMesh;
  121338. useVertexAlpha?: boolean;
  121339. }, scene?: Nullable<Scene>): LinesMesh;
  121340. }
  121341. }
  121342. declare module BABYLON {
  121343. /**
  121344. * The options container for the teleportation module
  121345. */
  121346. export interface IWebXRTeleportationOptions {
  121347. /**
  121348. * if provided, this scene will be used to render meshes.
  121349. */
  121350. customUtilityLayerScene?: Scene;
  121351. /**
  121352. * Values to configure the default target mesh
  121353. */
  121354. defaultTargetMeshOptions?: {
  121355. /**
  121356. * Fill color of the teleportation area
  121357. */
  121358. teleportationFillColor?: string;
  121359. /**
  121360. * Border color for the teleportation area
  121361. */
  121362. teleportationBorderColor?: string;
  121363. /**
  121364. * Disable the mesh's animation sequence
  121365. */
  121366. disableAnimation?: boolean;
  121367. /**
  121368. * Disable lighting on the material or the ring and arrow
  121369. */
  121370. disableLighting?: boolean;
  121371. /**
  121372. * Override the default material of the torus and arrow
  121373. */
  121374. torusArrowMaterial?: Material;
  121375. };
  121376. /**
  121377. * A list of meshes to use as floor meshes.
  121378. * Meshes can be added and removed after initializing the feature using the
  121379. * addFloorMesh and removeFloorMesh functions
  121380. * If empty, rotation will still work
  121381. */
  121382. floorMeshes?: AbstractMesh[];
  121383. /**
  121384. * use this rendering group id for the meshes (optional)
  121385. */
  121386. renderingGroupId?: number;
  121387. /**
  121388. * Should teleportation move only to snap points
  121389. */
  121390. snapPointsOnly?: boolean;
  121391. /**
  121392. * An array of points to which the teleportation will snap to.
  121393. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  121394. */
  121395. snapPositions?: Vector3[];
  121396. /**
  121397. * How close should the teleportation ray be in order to snap to position.
  121398. * Default to 0.8 units (meters)
  121399. */
  121400. snapToPositionRadius?: number;
  121401. /**
  121402. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  121403. * If you want to support rotation, make sure your mesh has a direction indicator.
  121404. *
  121405. * When left untouched, the default mesh will be initialized.
  121406. */
  121407. teleportationTargetMesh?: AbstractMesh;
  121408. /**
  121409. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  121410. */
  121411. timeToTeleport?: number;
  121412. /**
  121413. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  121414. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  121415. */
  121416. useMainComponentOnly?: boolean;
  121417. /**
  121418. * Should meshes created here be added to a utility layer or the main scene
  121419. */
  121420. useUtilityLayer?: boolean;
  121421. /**
  121422. * Babylon XR Input class for controller
  121423. */
  121424. xrInput: WebXRInput;
  121425. }
  121426. /**
  121427. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  121428. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  121429. * the input of the attached controllers.
  121430. */
  121431. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  121432. private _options;
  121433. private _controllers;
  121434. private _currentTeleportationControllerId;
  121435. private _floorMeshes;
  121436. private _quadraticBezierCurve;
  121437. private _selectionFeature;
  121438. private _snapToPositions;
  121439. private _snappedToPoint;
  121440. private _teleportationRingMaterial?;
  121441. private _tmpRay;
  121442. private _tmpVector;
  121443. /**
  121444. * The module's name
  121445. */
  121446. static readonly Name: string;
  121447. /**
  121448. * The (Babylon) version of this module.
  121449. * This is an integer representing the implementation version.
  121450. * This number does not correspond to the webxr specs version
  121451. */
  121452. static readonly Version: number;
  121453. /**
  121454. * Is movement backwards enabled
  121455. */
  121456. backwardsMovementEnabled: boolean;
  121457. /**
  121458. * Distance to travel when moving backwards
  121459. */
  121460. backwardsTeleportationDistance: number;
  121461. /**
  121462. * The distance from the user to the inspection point in the direction of the controller
  121463. * A higher number will allow the user to move further
  121464. * defaults to 5 (meters, in xr units)
  121465. */
  121466. parabolicCheckRadius: number;
  121467. /**
  121468. * Should the module support parabolic ray on top of direct ray
  121469. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  121470. * Very helpful when moving between floors / different heights
  121471. */
  121472. parabolicRayEnabled: boolean;
  121473. /**
  121474. * How much rotation should be applied when rotating right and left
  121475. */
  121476. rotationAngle: number;
  121477. /**
  121478. * Is rotation enabled when moving forward?
  121479. * Disabling this feature will prevent the user from deciding the direction when teleporting
  121480. */
  121481. rotationEnabled: boolean;
  121482. /**
  121483. * constructs a new anchor system
  121484. * @param _xrSessionManager an instance of WebXRSessionManager
  121485. * @param _options configuration object for this feature
  121486. */
  121487. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  121488. /**
  121489. * Get the snapPointsOnly flag
  121490. */
  121491. get snapPointsOnly(): boolean;
  121492. /**
  121493. * Sets the snapPointsOnly flag
  121494. * @param snapToPoints should teleportation be exclusively to snap points
  121495. */
  121496. set snapPointsOnly(snapToPoints: boolean);
  121497. /**
  121498. * Add a new mesh to the floor meshes array
  121499. * @param mesh the mesh to use as floor mesh
  121500. */
  121501. addFloorMesh(mesh: AbstractMesh): void;
  121502. /**
  121503. * Add a new snap-to point to fix teleportation to this position
  121504. * @param newSnapPoint The new Snap-To point
  121505. */
  121506. addSnapPoint(newSnapPoint: Vector3): void;
  121507. attach(): boolean;
  121508. detach(): boolean;
  121509. dispose(): void;
  121510. /**
  121511. * Remove a mesh from the floor meshes array
  121512. * @param mesh the mesh to remove
  121513. */
  121514. removeFloorMesh(mesh: AbstractMesh): void;
  121515. /**
  121516. * Remove a mesh from the floor meshes array using its name
  121517. * @param name the mesh name to remove
  121518. */
  121519. removeFloorMeshByName(name: string): void;
  121520. /**
  121521. * 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
  121522. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  121523. * @returns was the point found and removed or not
  121524. */
  121525. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  121526. /**
  121527. * This function sets a selection feature that will be disabled when
  121528. * the forward ray is shown and will be reattached when hidden.
  121529. * This is used to remove the selection rays when moving.
  121530. * @param selectionFeature the feature to disable when forward movement is enabled
  121531. */
  121532. setSelectionFeature(selectionFeature: IWebXRFeature): void;
  121533. protected _onXRFrame(_xrFrame: XRFrame): void;
  121534. private _attachController;
  121535. private _createDefaultTargetMesh;
  121536. private _detachController;
  121537. private _findClosestSnapPointWithRadius;
  121538. private _setTargetMeshPosition;
  121539. private _setTargetMeshVisibility;
  121540. private _showParabolicPath;
  121541. private _teleportForward;
  121542. }
  121543. }
  121544. declare module BABYLON {
  121545. /**
  121546. * Options for the default xr helper
  121547. */
  121548. export class WebXRDefaultExperienceOptions {
  121549. /**
  121550. * Enable or disable default UI to enter XR
  121551. */
  121552. disableDefaultUI?: boolean;
  121553. /**
  121554. * Should teleportation not initialize. defaults to false.
  121555. */
  121556. disableTeleportation?: boolean;
  121557. /**
  121558. * Floor meshes that will be used for teleport
  121559. */
  121560. floorMeshes?: Array<AbstractMesh>;
  121561. /**
  121562. * If set to true, the first frame will not be used to reset position
  121563. * The first frame is mainly used when copying transformation from the old camera
  121564. * Mainly used in AR
  121565. */
  121566. ignoreNativeCameraTransformation?: boolean;
  121567. /**
  121568. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  121569. */
  121570. inputOptions?: IWebXRInputOptions;
  121571. /**
  121572. * optional configuration for the output canvas
  121573. */
  121574. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  121575. /**
  121576. * optional UI options. This can be used among other to change session mode and reference space type
  121577. */
  121578. uiOptions?: WebXREnterExitUIOptions;
  121579. /**
  121580. * When loading teleportation and pointer select, use stable versions instead of latest.
  121581. */
  121582. useStablePlugins?: boolean;
  121583. /**
  121584. * An optional rendering group id that will be set globally for teleportation, pointer selection and default controller meshes
  121585. */
  121586. renderingGroupId?: number;
  121587. /**
  121588. * A list of optional features to init the session with
  121589. * If set to true, all features we support will be added
  121590. */
  121591. optionalFeatures?: boolean | string[];
  121592. }
  121593. /**
  121594. * Default experience which provides a similar setup to the previous webVRExperience
  121595. */
  121596. export class WebXRDefaultExperience {
  121597. /**
  121598. * Base experience
  121599. */
  121600. baseExperience: WebXRExperienceHelper;
  121601. /**
  121602. * Enables ui for entering/exiting xr
  121603. */
  121604. enterExitUI: WebXREnterExitUI;
  121605. /**
  121606. * Input experience extension
  121607. */
  121608. input: WebXRInput;
  121609. /**
  121610. * Enables laser pointer and selection
  121611. */
  121612. pointerSelection: WebXRControllerPointerSelection;
  121613. /**
  121614. * Default target xr should render to
  121615. */
  121616. renderTarget: WebXRRenderTarget;
  121617. /**
  121618. * Enables teleportation
  121619. */
  121620. teleportation: WebXRMotionControllerTeleportation;
  121621. private constructor();
  121622. /**
  121623. * Creates the default xr experience
  121624. * @param scene scene
  121625. * @param options options for basic configuration
  121626. * @returns resulting WebXRDefaultExperience
  121627. */
  121628. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  121629. /**
  121630. * DIsposes of the experience helper
  121631. */
  121632. dispose(): void;
  121633. }
  121634. }
  121635. declare module BABYLON {
  121636. /**
  121637. * Options to modify the vr teleportation behavior.
  121638. */
  121639. export interface VRTeleportationOptions {
  121640. /**
  121641. * The name of the mesh which should be used as the teleportation floor. (default: null)
  121642. */
  121643. floorMeshName?: string;
  121644. /**
  121645. * A list of meshes to be used as the teleportation floor. (default: empty)
  121646. */
  121647. floorMeshes?: Mesh[];
  121648. /**
  121649. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  121650. */
  121651. teleportationMode?: number;
  121652. /**
  121653. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  121654. */
  121655. teleportationTime?: number;
  121656. /**
  121657. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  121658. */
  121659. teleportationSpeed?: number;
  121660. /**
  121661. * The easing function used in the animation or null for Linear. (default CircleEase)
  121662. */
  121663. easingFunction?: EasingFunction;
  121664. }
  121665. /**
  121666. * Options to modify the vr experience helper's behavior.
  121667. */
  121668. export interface VRExperienceHelperOptions extends WebVROptions {
  121669. /**
  121670. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  121671. */
  121672. createDeviceOrientationCamera?: boolean;
  121673. /**
  121674. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  121675. */
  121676. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  121677. /**
  121678. * Uses the main button on the controller to toggle the laser casted. (default: true)
  121679. */
  121680. laserToggle?: boolean;
  121681. /**
  121682. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  121683. */
  121684. floorMeshes?: Mesh[];
  121685. /**
  121686. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  121687. */
  121688. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  121689. /**
  121690. * Defines if WebXR should be used instead of WebVR (if available)
  121691. */
  121692. useXR?: boolean;
  121693. }
  121694. /**
  121695. * Event containing information after VR has been entered
  121696. */
  121697. export class OnAfterEnteringVRObservableEvent {
  121698. /**
  121699. * If entering vr was successful
  121700. */
  121701. success: boolean;
  121702. }
  121703. /**
  121704. * Helps to quickly add VR support to an existing scene.
  121705. * See http://doc.babylonjs.com/how_to/webvr_helper
  121706. */
  121707. export class VRExperienceHelper {
  121708. /** Options to modify the vr experience helper's behavior. */
  121709. webVROptions: VRExperienceHelperOptions;
  121710. private _scene;
  121711. private _position;
  121712. private _btnVR;
  121713. private _btnVRDisplayed;
  121714. private _webVRsupported;
  121715. private _webVRready;
  121716. private _webVRrequesting;
  121717. private _webVRpresenting;
  121718. private _hasEnteredVR;
  121719. private _fullscreenVRpresenting;
  121720. private _inputElement;
  121721. private _webVRCamera;
  121722. private _vrDeviceOrientationCamera;
  121723. private _deviceOrientationCamera;
  121724. private _existingCamera;
  121725. private _onKeyDown;
  121726. private _onVrDisplayPresentChange;
  121727. private _onVRDisplayChanged;
  121728. private _onVRRequestPresentStart;
  121729. private _onVRRequestPresentComplete;
  121730. /**
  121731. * 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)
  121732. */
  121733. enableGazeEvenWhenNoPointerLock: boolean;
  121734. /**
  121735. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  121736. */
  121737. exitVROnDoubleTap: boolean;
  121738. /**
  121739. * Observable raised right before entering VR.
  121740. */
  121741. onEnteringVRObservable: Observable<VRExperienceHelper>;
  121742. /**
  121743. * Observable raised when entering VR has completed.
  121744. */
  121745. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  121746. /**
  121747. * Observable raised when exiting VR.
  121748. */
  121749. onExitingVRObservable: Observable<VRExperienceHelper>;
  121750. /**
  121751. * Observable raised when controller mesh is loaded.
  121752. */
  121753. onControllerMeshLoadedObservable: Observable<WebVRController>;
  121754. /** Return this.onEnteringVRObservable
  121755. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  121756. */
  121757. get onEnteringVR(): Observable<VRExperienceHelper>;
  121758. /** Return this.onExitingVRObservable
  121759. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  121760. */
  121761. get onExitingVR(): Observable<VRExperienceHelper>;
  121762. /** Return this.onControllerMeshLoadedObservable
  121763. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  121764. */
  121765. get onControllerMeshLoaded(): Observable<WebVRController>;
  121766. private _rayLength;
  121767. private _useCustomVRButton;
  121768. private _teleportationRequested;
  121769. private _teleportActive;
  121770. private _floorMeshName;
  121771. private _floorMeshesCollection;
  121772. private _teleportationMode;
  121773. private _teleportationTime;
  121774. private _teleportationSpeed;
  121775. private _teleportationEasing;
  121776. private _rotationAllowed;
  121777. private _teleportBackwardsVector;
  121778. private _teleportationTarget;
  121779. private _isDefaultTeleportationTarget;
  121780. private _postProcessMove;
  121781. private _teleportationFillColor;
  121782. private _teleportationBorderColor;
  121783. private _rotationAngle;
  121784. private _haloCenter;
  121785. private _cameraGazer;
  121786. private _padSensibilityUp;
  121787. private _padSensibilityDown;
  121788. private _leftController;
  121789. private _rightController;
  121790. private _gazeColor;
  121791. private _laserColor;
  121792. private _pickedLaserColor;
  121793. private _pickedGazeColor;
  121794. /**
  121795. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  121796. */
  121797. onNewMeshSelected: Observable<AbstractMesh>;
  121798. /**
  121799. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  121800. * This observable will provide the mesh and the controller used to select the mesh
  121801. */
  121802. onMeshSelectedWithController: Observable<{
  121803. mesh: AbstractMesh;
  121804. controller: WebVRController;
  121805. }>;
  121806. /**
  121807. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  121808. */
  121809. onNewMeshPicked: Observable<PickingInfo>;
  121810. private _circleEase;
  121811. /**
  121812. * Observable raised before camera teleportation
  121813. */
  121814. onBeforeCameraTeleport: Observable<Vector3>;
  121815. /**
  121816. * Observable raised after camera teleportation
  121817. */
  121818. onAfterCameraTeleport: Observable<Vector3>;
  121819. /**
  121820. * Observable raised when current selected mesh gets unselected
  121821. */
  121822. onSelectedMeshUnselected: Observable<AbstractMesh>;
  121823. private _raySelectionPredicate;
  121824. /**
  121825. * To be optionaly changed by user to define custom ray selection
  121826. */
  121827. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  121828. /**
  121829. * To be optionaly changed by user to define custom selection logic (after ray selection)
  121830. */
  121831. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  121832. /**
  121833. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  121834. */
  121835. teleportationEnabled: boolean;
  121836. private _defaultHeight;
  121837. private _teleportationInitialized;
  121838. private _interactionsEnabled;
  121839. private _interactionsRequested;
  121840. private _displayGaze;
  121841. private _displayLaserPointer;
  121842. /**
  121843. * The mesh used to display where the user is going to teleport.
  121844. */
  121845. get teleportationTarget(): Mesh;
  121846. /**
  121847. * Sets the mesh to be used to display where the user is going to teleport.
  121848. */
  121849. set teleportationTarget(value: Mesh);
  121850. /**
  121851. * 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
  121852. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  121853. * See http://doc.babylonjs.com/resources/baking_transformations
  121854. */
  121855. get gazeTrackerMesh(): Mesh;
  121856. set gazeTrackerMesh(value: Mesh);
  121857. /**
  121858. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  121859. */
  121860. updateGazeTrackerScale: boolean;
  121861. /**
  121862. * If the gaze trackers color should be updated when selecting meshes
  121863. */
  121864. updateGazeTrackerColor: boolean;
  121865. /**
  121866. * If the controller laser color should be updated when selecting meshes
  121867. */
  121868. updateControllerLaserColor: boolean;
  121869. /**
  121870. * The gaze tracking mesh corresponding to the left controller
  121871. */
  121872. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  121873. /**
  121874. * The gaze tracking mesh corresponding to the right controller
  121875. */
  121876. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  121877. /**
  121878. * If the ray of the gaze should be displayed.
  121879. */
  121880. get displayGaze(): boolean;
  121881. /**
  121882. * Sets if the ray of the gaze should be displayed.
  121883. */
  121884. set displayGaze(value: boolean);
  121885. /**
  121886. * If the ray of the LaserPointer should be displayed.
  121887. */
  121888. get displayLaserPointer(): boolean;
  121889. /**
  121890. * Sets if the ray of the LaserPointer should be displayed.
  121891. */
  121892. set displayLaserPointer(value: boolean);
  121893. /**
  121894. * The deviceOrientationCamera used as the camera when not in VR.
  121895. */
  121896. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  121897. /**
  121898. * Based on the current WebVR support, returns the current VR camera used.
  121899. */
  121900. get currentVRCamera(): Nullable<Camera>;
  121901. /**
  121902. * The webVRCamera which is used when in VR.
  121903. */
  121904. get webVRCamera(): WebVRFreeCamera;
  121905. /**
  121906. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  121907. */
  121908. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  121909. /**
  121910. * The html button that is used to trigger entering into VR.
  121911. */
  121912. get vrButton(): Nullable<HTMLButtonElement>;
  121913. private get _teleportationRequestInitiated();
  121914. /**
  121915. * Defines whether or not Pointer lock should be requested when switching to
  121916. * full screen.
  121917. */
  121918. requestPointerLockOnFullScreen: boolean;
  121919. /**
  121920. * If asking to force XR, this will be populated with the default xr experience
  121921. */
  121922. xr: WebXRDefaultExperience;
  121923. /**
  121924. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  121925. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  121926. */
  121927. xrTestDone: boolean;
  121928. /**
  121929. * Instantiates a VRExperienceHelper.
  121930. * Helps to quickly add VR support to an existing scene.
  121931. * @param scene The scene the VRExperienceHelper belongs to.
  121932. * @param webVROptions Options to modify the vr experience helper's behavior.
  121933. */
  121934. constructor(scene: Scene,
  121935. /** Options to modify the vr experience helper's behavior. */
  121936. webVROptions?: VRExperienceHelperOptions);
  121937. private completeVRInit;
  121938. private _onDefaultMeshLoaded;
  121939. private _onResize;
  121940. private _onFullscreenChange;
  121941. /**
  121942. * Gets a value indicating if we are currently in VR mode.
  121943. */
  121944. get isInVRMode(): boolean;
  121945. private onVrDisplayPresentChange;
  121946. private onVRDisplayChanged;
  121947. private moveButtonToBottomRight;
  121948. private displayVRButton;
  121949. private updateButtonVisibility;
  121950. private _cachedAngularSensibility;
  121951. /**
  121952. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  121953. * Otherwise, will use the fullscreen API.
  121954. */
  121955. enterVR(): void;
  121956. /**
  121957. * Attempt to exit VR, or fullscreen.
  121958. */
  121959. exitVR(): void;
  121960. /**
  121961. * The position of the vr experience helper.
  121962. */
  121963. get position(): Vector3;
  121964. /**
  121965. * Sets the position of the vr experience helper.
  121966. */
  121967. set position(value: Vector3);
  121968. /**
  121969. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  121970. */
  121971. enableInteractions(): void;
  121972. private get _noControllerIsActive();
  121973. private beforeRender;
  121974. private _isTeleportationFloor;
  121975. /**
  121976. * Adds a floor mesh to be used for teleportation.
  121977. * @param floorMesh the mesh to be used for teleportation.
  121978. */
  121979. addFloorMesh(floorMesh: Mesh): void;
  121980. /**
  121981. * Removes a floor mesh from being used for teleportation.
  121982. * @param floorMesh the mesh to be removed.
  121983. */
  121984. removeFloorMesh(floorMesh: Mesh): void;
  121985. /**
  121986. * Enables interactions and teleportation using the VR controllers and gaze.
  121987. * @param vrTeleportationOptions options to modify teleportation behavior.
  121988. */
  121989. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  121990. private _onNewGamepadConnected;
  121991. private _tryEnableInteractionOnController;
  121992. private _onNewGamepadDisconnected;
  121993. private _enableInteractionOnController;
  121994. private _checkTeleportWithRay;
  121995. private _checkRotate;
  121996. private _checkTeleportBackwards;
  121997. private _enableTeleportationOnController;
  121998. private _createTeleportationCircles;
  121999. private _displayTeleportationTarget;
  122000. private _hideTeleportationTarget;
  122001. private _rotateCamera;
  122002. private _moveTeleportationSelectorTo;
  122003. private _workingVector;
  122004. private _workingQuaternion;
  122005. private _workingMatrix;
  122006. /**
  122007. * Time Constant Teleportation Mode
  122008. */
  122009. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  122010. /**
  122011. * Speed Constant Teleportation Mode
  122012. */
  122013. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  122014. /**
  122015. * Teleports the users feet to the desired location
  122016. * @param location The location where the user's feet should be placed
  122017. */
  122018. teleportCamera(location: Vector3): void;
  122019. private _convertNormalToDirectionOfRay;
  122020. private _castRayAndSelectObject;
  122021. private _notifySelectedMeshUnselected;
  122022. /**
  122023. * Permanently set new colors for the laser pointer
  122024. * @param color the new laser color
  122025. * @param pickedColor the new laser color when picked mesh detected
  122026. */
  122027. setLaserColor(color: Color3, pickedColor?: Color3): void;
  122028. /**
  122029. * Set lighting enabled / disabled on the laser pointer of both controllers
  122030. * @param enabled should the lighting be enabled on the laser pointer
  122031. */
  122032. setLaserLightingState(enabled?: boolean): void;
  122033. /**
  122034. * Permanently set new colors for the gaze pointer
  122035. * @param color the new gaze color
  122036. * @param pickedColor the new gaze color when picked mesh detected
  122037. */
  122038. setGazeColor(color: Color3, pickedColor?: Color3): void;
  122039. /**
  122040. * Sets the color of the laser ray from the vr controllers.
  122041. * @param color new color for the ray.
  122042. */
  122043. changeLaserColor(color: Color3): void;
  122044. /**
  122045. * Sets the color of the ray from the vr headsets gaze.
  122046. * @param color new color for the ray.
  122047. */
  122048. changeGazeColor(color: Color3): void;
  122049. /**
  122050. * Exits VR and disposes of the vr experience helper
  122051. */
  122052. dispose(): void;
  122053. /**
  122054. * Gets the name of the VRExperienceHelper class
  122055. * @returns "VRExperienceHelper"
  122056. */
  122057. getClassName(): string;
  122058. }
  122059. }
  122060. declare module BABYLON {
  122061. /**
  122062. * Contains an array of blocks representing the octree
  122063. */
  122064. export interface IOctreeContainer<T> {
  122065. /**
  122066. * Blocks within the octree
  122067. */
  122068. blocks: Array<OctreeBlock<T>>;
  122069. }
  122070. /**
  122071. * Class used to store a cell in an octree
  122072. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  122073. */
  122074. export class OctreeBlock<T> {
  122075. /**
  122076. * Gets the content of the current block
  122077. */
  122078. entries: T[];
  122079. /**
  122080. * Gets the list of block children
  122081. */
  122082. blocks: Array<OctreeBlock<T>>;
  122083. private _depth;
  122084. private _maxDepth;
  122085. private _capacity;
  122086. private _minPoint;
  122087. private _maxPoint;
  122088. private _boundingVectors;
  122089. private _creationFunc;
  122090. /**
  122091. * Creates a new block
  122092. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  122093. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  122094. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  122095. * @param depth defines the current depth of this block in the octree
  122096. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  122097. * @param creationFunc defines a callback to call when an element is added to the block
  122098. */
  122099. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  122100. /**
  122101. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  122102. */
  122103. get capacity(): number;
  122104. /**
  122105. * Gets the minimum vector (in world space) of the block's bounding box
  122106. */
  122107. get minPoint(): Vector3;
  122108. /**
  122109. * Gets the maximum vector (in world space) of the block's bounding box
  122110. */
  122111. get maxPoint(): Vector3;
  122112. /**
  122113. * Add a new element to this block
  122114. * @param entry defines the element to add
  122115. */
  122116. addEntry(entry: T): void;
  122117. /**
  122118. * Remove an element from this block
  122119. * @param entry defines the element to remove
  122120. */
  122121. removeEntry(entry: T): void;
  122122. /**
  122123. * Add an array of elements to this block
  122124. * @param entries defines the array of elements to add
  122125. */
  122126. addEntries(entries: T[]): void;
  122127. /**
  122128. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  122129. * @param frustumPlanes defines the frustum planes to test
  122130. * @param selection defines the array to store current content if selection is positive
  122131. * @param allowDuplicate defines if the selection array can contains duplicated entries
  122132. */
  122133. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  122134. /**
  122135. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  122136. * @param sphereCenter defines the bounding sphere center
  122137. * @param sphereRadius defines the bounding sphere radius
  122138. * @param selection defines the array to store current content if selection is positive
  122139. * @param allowDuplicate defines if the selection array can contains duplicated entries
  122140. */
  122141. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  122142. /**
  122143. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  122144. * @param ray defines the ray to test with
  122145. * @param selection defines the array to store current content if selection is positive
  122146. */
  122147. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  122148. /**
  122149. * Subdivide the content into child blocks (this block will then be empty)
  122150. */
  122151. createInnerBlocks(): void;
  122152. /**
  122153. * @hidden
  122154. */
  122155. 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;
  122156. }
  122157. }
  122158. declare module BABYLON {
  122159. /**
  122160. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  122161. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  122162. */
  122163. export class Octree<T> {
  122164. /** 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.) */
  122165. maxDepth: number;
  122166. /**
  122167. * Blocks within the octree containing objects
  122168. */
  122169. blocks: Array<OctreeBlock<T>>;
  122170. /**
  122171. * Content stored in the octree
  122172. */
  122173. dynamicContent: T[];
  122174. private _maxBlockCapacity;
  122175. private _selectionContent;
  122176. private _creationFunc;
  122177. /**
  122178. * Creates a octree
  122179. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  122180. * @param creationFunc function to be used to instatiate the octree
  122181. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  122182. * @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.)
  122183. */
  122184. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  122185. /** 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.) */
  122186. maxDepth?: number);
  122187. /**
  122188. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  122189. * @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);
  122190. * @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);
  122191. * @param entries meshes to be added to the octree blocks
  122192. */
  122193. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  122194. /**
  122195. * Adds a mesh to the octree
  122196. * @param entry Mesh to add to the octree
  122197. */
  122198. addMesh(entry: T): void;
  122199. /**
  122200. * Remove an element from the octree
  122201. * @param entry defines the element to remove
  122202. */
  122203. removeMesh(entry: T): void;
  122204. /**
  122205. * Selects an array of meshes within the frustum
  122206. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  122207. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  122208. * @returns array of meshes within the frustum
  122209. */
  122210. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  122211. /**
  122212. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  122213. * @param sphereCenter defines the bounding sphere center
  122214. * @param sphereRadius defines the bounding sphere radius
  122215. * @param allowDuplicate defines if the selection array can contains duplicated entries
  122216. * @returns an array of objects that intersect the sphere
  122217. */
  122218. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  122219. /**
  122220. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  122221. * @param ray defines the ray to test with
  122222. * @returns array of intersected objects
  122223. */
  122224. intersectsRay(ray: Ray): SmartArray<T>;
  122225. /**
  122226. * Adds a mesh into the octree block if it intersects the block
  122227. */
  122228. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  122229. /**
  122230. * Adds a submesh into the octree block if it intersects the block
  122231. */
  122232. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  122233. }
  122234. }
  122235. declare module BABYLON {
  122236. interface Scene {
  122237. /**
  122238. * @hidden
  122239. * Backing Filed
  122240. */
  122241. _selectionOctree: Octree<AbstractMesh>;
  122242. /**
  122243. * Gets the octree used to boost mesh selection (picking)
  122244. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  122245. */
  122246. selectionOctree: Octree<AbstractMesh>;
  122247. /**
  122248. * Creates or updates the octree used to boost selection (picking)
  122249. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  122250. * @param maxCapacity defines the maximum capacity per leaf
  122251. * @param maxDepth defines the maximum depth of the octree
  122252. * @returns an octree of AbstractMesh
  122253. */
  122254. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  122255. }
  122256. interface AbstractMesh {
  122257. /**
  122258. * @hidden
  122259. * Backing Field
  122260. */
  122261. _submeshesOctree: Octree<SubMesh>;
  122262. /**
  122263. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  122264. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  122265. * @param maxCapacity defines the maximum size of each block (64 by default)
  122266. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  122267. * @returns the new octree
  122268. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  122269. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  122270. */
  122271. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  122272. }
  122273. /**
  122274. * Defines the octree scene component responsible to manage any octrees
  122275. * in a given scene.
  122276. */
  122277. export class OctreeSceneComponent {
  122278. /**
  122279. * The component name help to identify the component in the list of scene components.
  122280. */
  122281. readonly name: string;
  122282. /**
  122283. * The scene the component belongs to.
  122284. */
  122285. scene: Scene;
  122286. /**
  122287. * Indicates if the meshes have been checked to make sure they are isEnabled()
  122288. */
  122289. readonly checksIsEnabled: boolean;
  122290. /**
  122291. * Creates a new instance of the component for the given scene
  122292. * @param scene Defines the scene to register the component in
  122293. */
  122294. constructor(scene: Scene);
  122295. /**
  122296. * Registers the component in a given scene
  122297. */
  122298. register(): void;
  122299. /**
  122300. * Return the list of active meshes
  122301. * @returns the list of active meshes
  122302. */
  122303. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  122304. /**
  122305. * Return the list of active sub meshes
  122306. * @param mesh The mesh to get the candidates sub meshes from
  122307. * @returns the list of active sub meshes
  122308. */
  122309. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  122310. private _tempRay;
  122311. /**
  122312. * Return the list of sub meshes intersecting with a given local ray
  122313. * @param mesh defines the mesh to find the submesh for
  122314. * @param localRay defines the ray in local space
  122315. * @returns the list of intersecting sub meshes
  122316. */
  122317. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  122318. /**
  122319. * Return the list of sub meshes colliding with a collider
  122320. * @param mesh defines the mesh to find the submesh for
  122321. * @param collider defines the collider to evaluate the collision against
  122322. * @returns the list of colliding sub meshes
  122323. */
  122324. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  122325. /**
  122326. * Rebuilds the elements related to this component in case of
  122327. * context lost for instance.
  122328. */
  122329. rebuild(): void;
  122330. /**
  122331. * Disposes the component and the associated ressources.
  122332. */
  122333. dispose(): void;
  122334. }
  122335. }
  122336. declare module BABYLON {
  122337. /**
  122338. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  122339. */
  122340. export class Gizmo implements IDisposable {
  122341. /** The utility layer the gizmo will be added to */
  122342. gizmoLayer: UtilityLayerRenderer;
  122343. /**
  122344. * The root mesh of the gizmo
  122345. */
  122346. _rootMesh: Mesh;
  122347. private _attachedMesh;
  122348. /**
  122349. * Ratio for the scale of the gizmo (Default: 1)
  122350. */
  122351. scaleRatio: number;
  122352. /**
  122353. * If a custom mesh has been set (Default: false)
  122354. */
  122355. protected _customMeshSet: boolean;
  122356. /**
  122357. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  122358. * * When set, interactions will be enabled
  122359. */
  122360. get attachedMesh(): Nullable<AbstractMesh>;
  122361. set attachedMesh(value: Nullable<AbstractMesh>);
  122362. /**
  122363. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  122364. * @param mesh The mesh to replace the default mesh of the gizmo
  122365. */
  122366. setCustomMesh(mesh: Mesh): void;
  122367. /**
  122368. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  122369. */
  122370. updateGizmoRotationToMatchAttachedMesh: boolean;
  122371. /**
  122372. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  122373. */
  122374. updateGizmoPositionToMatchAttachedMesh: boolean;
  122375. /**
  122376. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  122377. */
  122378. updateScale: boolean;
  122379. protected _interactionsEnabled: boolean;
  122380. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  122381. private _beforeRenderObserver;
  122382. private _tempVector;
  122383. /**
  122384. * Creates a gizmo
  122385. * @param gizmoLayer The utility layer the gizmo will be added to
  122386. */
  122387. constructor(
  122388. /** The utility layer the gizmo will be added to */
  122389. gizmoLayer?: UtilityLayerRenderer);
  122390. /**
  122391. * Updates the gizmo to match the attached mesh's position/rotation
  122392. */
  122393. protected _update(): void;
  122394. /**
  122395. * Disposes of the gizmo
  122396. */
  122397. dispose(): void;
  122398. }
  122399. }
  122400. declare module BABYLON {
  122401. /**
  122402. * Single plane drag gizmo
  122403. */
  122404. export class PlaneDragGizmo extends Gizmo {
  122405. /**
  122406. * Drag behavior responsible for the gizmos dragging interactions
  122407. */
  122408. dragBehavior: PointerDragBehavior;
  122409. private _pointerObserver;
  122410. /**
  122411. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  122412. */
  122413. snapDistance: number;
  122414. /**
  122415. * Event that fires each time the gizmo snaps to a new location.
  122416. * * snapDistance is the the change in distance
  122417. */
  122418. onSnapObservable: Observable<{
  122419. snapDistance: number;
  122420. }>;
  122421. private _plane;
  122422. private _coloredMaterial;
  122423. private _hoverMaterial;
  122424. private _isEnabled;
  122425. private _parent;
  122426. /** @hidden */
  122427. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  122428. /** @hidden */
  122429. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  122430. /**
  122431. * Creates a PlaneDragGizmo
  122432. * @param gizmoLayer The utility layer the gizmo will be added to
  122433. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  122434. * @param color The color of the gizmo
  122435. */
  122436. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  122437. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  122438. /**
  122439. * If the gizmo is enabled
  122440. */
  122441. set isEnabled(value: boolean);
  122442. get isEnabled(): boolean;
  122443. /**
  122444. * Disposes of the gizmo
  122445. */
  122446. dispose(): void;
  122447. }
  122448. }
  122449. declare module BABYLON {
  122450. /**
  122451. * Gizmo that enables dragging a mesh along 3 axis
  122452. */
  122453. export class PositionGizmo extends Gizmo {
  122454. /**
  122455. * Internal gizmo used for interactions on the x axis
  122456. */
  122457. xGizmo: AxisDragGizmo;
  122458. /**
  122459. * Internal gizmo used for interactions on the y axis
  122460. */
  122461. yGizmo: AxisDragGizmo;
  122462. /**
  122463. * Internal gizmo used for interactions on the z axis
  122464. */
  122465. zGizmo: AxisDragGizmo;
  122466. /**
  122467. * Internal gizmo used for interactions on the yz plane
  122468. */
  122469. xPlaneGizmo: PlaneDragGizmo;
  122470. /**
  122471. * Internal gizmo used for interactions on the xz plane
  122472. */
  122473. yPlaneGizmo: PlaneDragGizmo;
  122474. /**
  122475. * Internal gizmo used for interactions on the xy plane
  122476. */
  122477. zPlaneGizmo: PlaneDragGizmo;
  122478. /**
  122479. * private variables
  122480. */
  122481. private _meshAttached;
  122482. private _updateGizmoRotationToMatchAttachedMesh;
  122483. private _snapDistance;
  122484. private _scaleRatio;
  122485. /** Fires an event when any of it's sub gizmos are dragged */
  122486. onDragStartObservable: Observable<unknown>;
  122487. /** Fires an event when any of it's sub gizmos are released from dragging */
  122488. onDragEndObservable: Observable<unknown>;
  122489. /**
  122490. * If set to true, planar drag is enabled
  122491. */
  122492. private _planarGizmoEnabled;
  122493. get attachedMesh(): Nullable<AbstractMesh>;
  122494. set attachedMesh(mesh: Nullable<AbstractMesh>);
  122495. /**
  122496. * Creates a PositionGizmo
  122497. * @param gizmoLayer The utility layer the gizmo will be added to
  122498. */
  122499. constructor(gizmoLayer?: UtilityLayerRenderer);
  122500. /**
  122501. * If the planar drag gizmo is enabled
  122502. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  122503. */
  122504. set planarGizmoEnabled(value: boolean);
  122505. get planarGizmoEnabled(): boolean;
  122506. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  122507. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  122508. /**
  122509. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  122510. */
  122511. set snapDistance(value: number);
  122512. get snapDistance(): number;
  122513. /**
  122514. * Ratio for the scale of the gizmo (Default: 1)
  122515. */
  122516. set scaleRatio(value: number);
  122517. get scaleRatio(): number;
  122518. /**
  122519. * Disposes of the gizmo
  122520. */
  122521. dispose(): void;
  122522. /**
  122523. * CustomMeshes are not supported by this gizmo
  122524. * @param mesh The mesh to replace the default mesh of the gizmo
  122525. */
  122526. setCustomMesh(mesh: Mesh): void;
  122527. }
  122528. }
  122529. declare module BABYLON {
  122530. /**
  122531. * Single axis drag gizmo
  122532. */
  122533. export class AxisDragGizmo extends Gizmo {
  122534. /**
  122535. * Drag behavior responsible for the gizmos dragging interactions
  122536. */
  122537. dragBehavior: PointerDragBehavior;
  122538. private _pointerObserver;
  122539. /**
  122540. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  122541. */
  122542. snapDistance: number;
  122543. /**
  122544. * Event that fires each time the gizmo snaps to a new location.
  122545. * * snapDistance is the the change in distance
  122546. */
  122547. onSnapObservable: Observable<{
  122548. snapDistance: number;
  122549. }>;
  122550. private _isEnabled;
  122551. private _parent;
  122552. private _arrow;
  122553. private _coloredMaterial;
  122554. private _hoverMaterial;
  122555. /** @hidden */
  122556. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  122557. /** @hidden */
  122558. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  122559. /**
  122560. * Creates an AxisDragGizmo
  122561. * @param gizmoLayer The utility layer the gizmo will be added to
  122562. * @param dragAxis The axis which the gizmo will be able to drag on
  122563. * @param color The color of the gizmo
  122564. */
  122565. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  122566. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  122567. /**
  122568. * If the gizmo is enabled
  122569. */
  122570. set isEnabled(value: boolean);
  122571. get isEnabled(): boolean;
  122572. /**
  122573. * Disposes of the gizmo
  122574. */
  122575. dispose(): void;
  122576. }
  122577. }
  122578. declare module BABYLON.Debug {
  122579. /**
  122580. * The Axes viewer will show 3 axes in a specific point in space
  122581. */
  122582. export class AxesViewer {
  122583. private _xAxis;
  122584. private _yAxis;
  122585. private _zAxis;
  122586. private _scaleLinesFactor;
  122587. private _instanced;
  122588. /**
  122589. * Gets the hosting scene
  122590. */
  122591. scene: Scene;
  122592. /**
  122593. * Gets or sets a number used to scale line length
  122594. */
  122595. scaleLines: number;
  122596. /** Gets the node hierarchy used to render x-axis */
  122597. get xAxis(): TransformNode;
  122598. /** Gets the node hierarchy used to render y-axis */
  122599. get yAxis(): TransformNode;
  122600. /** Gets the node hierarchy used to render z-axis */
  122601. get zAxis(): TransformNode;
  122602. /**
  122603. * Creates a new AxesViewer
  122604. * @param scene defines the hosting scene
  122605. * @param scaleLines defines a number used to scale line length (1 by default)
  122606. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  122607. * @param xAxis defines the node hierarchy used to render the x-axis
  122608. * @param yAxis defines the node hierarchy used to render the y-axis
  122609. * @param zAxis defines the node hierarchy used to render the z-axis
  122610. */
  122611. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  122612. /**
  122613. * Force the viewer to update
  122614. * @param position defines the position of the viewer
  122615. * @param xaxis defines the x axis of the viewer
  122616. * @param yaxis defines the y axis of the viewer
  122617. * @param zaxis defines the z axis of the viewer
  122618. */
  122619. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  122620. /**
  122621. * Creates an instance of this axes viewer.
  122622. * @returns a new axes viewer with instanced meshes
  122623. */
  122624. createInstance(): AxesViewer;
  122625. /** Releases resources */
  122626. dispose(): void;
  122627. private static _SetRenderingGroupId;
  122628. }
  122629. }
  122630. declare module BABYLON.Debug {
  122631. /**
  122632. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  122633. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  122634. */
  122635. export class BoneAxesViewer extends AxesViewer {
  122636. /**
  122637. * Gets or sets the target mesh where to display the axes viewer
  122638. */
  122639. mesh: Nullable<Mesh>;
  122640. /**
  122641. * Gets or sets the target bone where to display the axes viewer
  122642. */
  122643. bone: Nullable<Bone>;
  122644. /** Gets current position */
  122645. pos: Vector3;
  122646. /** Gets direction of X axis */
  122647. xaxis: Vector3;
  122648. /** Gets direction of Y axis */
  122649. yaxis: Vector3;
  122650. /** Gets direction of Z axis */
  122651. zaxis: Vector3;
  122652. /**
  122653. * Creates a new BoneAxesViewer
  122654. * @param scene defines the hosting scene
  122655. * @param bone defines the target bone
  122656. * @param mesh defines the target mesh
  122657. * @param scaleLines defines a scaling factor for line length (1 by default)
  122658. */
  122659. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  122660. /**
  122661. * Force the viewer to update
  122662. */
  122663. update(): void;
  122664. /** Releases resources */
  122665. dispose(): void;
  122666. }
  122667. }
  122668. declare module BABYLON {
  122669. /**
  122670. * Interface used to define scene explorer extensibility option
  122671. */
  122672. export interface IExplorerExtensibilityOption {
  122673. /**
  122674. * Define the option label
  122675. */
  122676. label: string;
  122677. /**
  122678. * Defines the action to execute on click
  122679. */
  122680. action: (entity: any) => void;
  122681. }
  122682. /**
  122683. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  122684. */
  122685. export interface IExplorerExtensibilityGroup {
  122686. /**
  122687. * Defines a predicate to test if a given type mut be extended
  122688. */
  122689. predicate: (entity: any) => boolean;
  122690. /**
  122691. * Gets the list of options added to a type
  122692. */
  122693. entries: IExplorerExtensibilityOption[];
  122694. }
  122695. /**
  122696. * Interface used to define the options to use to create the Inspector
  122697. */
  122698. export interface IInspectorOptions {
  122699. /**
  122700. * Display in overlay mode (default: false)
  122701. */
  122702. overlay?: boolean;
  122703. /**
  122704. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  122705. */
  122706. globalRoot?: HTMLElement;
  122707. /**
  122708. * Display the Scene explorer
  122709. */
  122710. showExplorer?: boolean;
  122711. /**
  122712. * Display the property inspector
  122713. */
  122714. showInspector?: boolean;
  122715. /**
  122716. * Display in embed mode (both panes on the right)
  122717. */
  122718. embedMode?: boolean;
  122719. /**
  122720. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  122721. */
  122722. handleResize?: boolean;
  122723. /**
  122724. * Allow the panes to popup (default: true)
  122725. */
  122726. enablePopup?: boolean;
  122727. /**
  122728. * Allow the panes to be closed by users (default: true)
  122729. */
  122730. enableClose?: boolean;
  122731. /**
  122732. * Optional list of extensibility entries
  122733. */
  122734. explorerExtensibility?: IExplorerExtensibilityGroup[];
  122735. /**
  122736. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  122737. */
  122738. inspectorURL?: string;
  122739. /**
  122740. * Optional initial tab (default to DebugLayerTab.Properties)
  122741. */
  122742. initialTab?: DebugLayerTab;
  122743. }
  122744. interface Scene {
  122745. /**
  122746. * @hidden
  122747. * Backing field
  122748. */
  122749. _debugLayer: DebugLayer;
  122750. /**
  122751. * Gets the debug layer (aka Inspector) associated with the scene
  122752. * @see http://doc.babylonjs.com/features/playground_debuglayer
  122753. */
  122754. debugLayer: DebugLayer;
  122755. }
  122756. /**
  122757. * Enum of inspector action tab
  122758. */
  122759. export enum DebugLayerTab {
  122760. /**
  122761. * Properties tag (default)
  122762. */
  122763. Properties = 0,
  122764. /**
  122765. * Debug tab
  122766. */
  122767. Debug = 1,
  122768. /**
  122769. * Statistics tab
  122770. */
  122771. Statistics = 2,
  122772. /**
  122773. * Tools tab
  122774. */
  122775. Tools = 3,
  122776. /**
  122777. * Settings tab
  122778. */
  122779. Settings = 4
  122780. }
  122781. /**
  122782. * The debug layer (aka Inspector) is the go to tool in order to better understand
  122783. * what is happening in your scene
  122784. * @see http://doc.babylonjs.com/features/playground_debuglayer
  122785. */
  122786. export class DebugLayer {
  122787. /**
  122788. * Define the url to get the inspector script from.
  122789. * By default it uses the babylonjs CDN.
  122790. * @ignoreNaming
  122791. */
  122792. static InspectorURL: string;
  122793. private _scene;
  122794. private BJSINSPECTOR;
  122795. private _onPropertyChangedObservable?;
  122796. /**
  122797. * Observable triggered when a property is changed through the inspector.
  122798. */
  122799. get onPropertyChangedObservable(): any;
  122800. /**
  122801. * Instantiates a new debug layer.
  122802. * The debug layer (aka Inspector) is the go to tool in order to better understand
  122803. * what is happening in your scene
  122804. * @see http://doc.babylonjs.com/features/playground_debuglayer
  122805. * @param scene Defines the scene to inspect
  122806. */
  122807. constructor(scene: Scene);
  122808. /** Creates the inspector window. */
  122809. private _createInspector;
  122810. /**
  122811. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  122812. * @param entity defines the entity to select
  122813. * @param lineContainerTitle defines the specific block to highlight
  122814. */
  122815. select(entity: any, lineContainerTitle?: string): void;
  122816. /** Get the inspector from bundle or global */
  122817. private _getGlobalInspector;
  122818. /**
  122819. * Get if the inspector is visible or not.
  122820. * @returns true if visible otherwise, false
  122821. */
  122822. isVisible(): boolean;
  122823. /**
  122824. * Hide the inspector and close its window.
  122825. */
  122826. hide(): void;
  122827. /**
  122828. * Update the scene in the inspector
  122829. */
  122830. setAsActiveScene(): void;
  122831. /**
  122832. * Launch the debugLayer.
  122833. * @param config Define the configuration of the inspector
  122834. * @return a promise fulfilled when the debug layer is visible
  122835. */
  122836. show(config?: IInspectorOptions): Promise<DebugLayer>;
  122837. }
  122838. }
  122839. declare module BABYLON {
  122840. /**
  122841. * Class containing static functions to help procedurally build meshes
  122842. */
  122843. export class BoxBuilder {
  122844. /**
  122845. * Creates a box mesh
  122846. * * The parameter `size` sets the size (float) of each box side (default 1)
  122847. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  122848. * * 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)
  122849. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  122850. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  122851. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  122852. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  122853. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  122854. * @param name defines the name of the mesh
  122855. * @param options defines the options used to create the mesh
  122856. * @param scene defines the hosting scene
  122857. * @returns the box mesh
  122858. */
  122859. static CreateBox(name: string, options: {
  122860. size?: number;
  122861. width?: number;
  122862. height?: number;
  122863. depth?: number;
  122864. faceUV?: Vector4[];
  122865. faceColors?: Color4[];
  122866. sideOrientation?: number;
  122867. frontUVs?: Vector4;
  122868. backUVs?: Vector4;
  122869. wrap?: boolean;
  122870. topBaseAt?: number;
  122871. bottomBaseAt?: number;
  122872. updatable?: boolean;
  122873. }, scene?: Nullable<Scene>): Mesh;
  122874. }
  122875. }
  122876. declare module BABYLON.Debug {
  122877. /**
  122878. * Used to show the physics impostor around the specific mesh
  122879. */
  122880. export class PhysicsViewer {
  122881. /** @hidden */
  122882. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  122883. /** @hidden */
  122884. protected _meshes: Array<Nullable<AbstractMesh>>;
  122885. /** @hidden */
  122886. protected _scene: Nullable<Scene>;
  122887. /** @hidden */
  122888. protected _numMeshes: number;
  122889. /** @hidden */
  122890. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  122891. private _renderFunction;
  122892. private _utilityLayer;
  122893. private _debugBoxMesh;
  122894. private _debugSphereMesh;
  122895. private _debugCylinderMesh;
  122896. private _debugMaterial;
  122897. private _debugMeshMeshes;
  122898. /**
  122899. * Creates a new PhysicsViewer
  122900. * @param scene defines the hosting scene
  122901. */
  122902. constructor(scene: Scene);
  122903. /** @hidden */
  122904. protected _updateDebugMeshes(): void;
  122905. /**
  122906. * Renders a specified physic impostor
  122907. * @param impostor defines the impostor to render
  122908. * @param targetMesh defines the mesh represented by the impostor
  122909. * @returns the new debug mesh used to render the impostor
  122910. */
  122911. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  122912. /**
  122913. * Hides a specified physic impostor
  122914. * @param impostor defines the impostor to hide
  122915. */
  122916. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  122917. private _getDebugMaterial;
  122918. private _getDebugBoxMesh;
  122919. private _getDebugSphereMesh;
  122920. private _getDebugCylinderMesh;
  122921. private _getDebugMeshMesh;
  122922. private _getDebugMesh;
  122923. /** Releases all resources */
  122924. dispose(): void;
  122925. }
  122926. }
  122927. declare module BABYLON {
  122928. /**
  122929. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  122930. * in order to better appreciate the issue one might have.
  122931. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  122932. */
  122933. export class RayHelper {
  122934. /**
  122935. * Defines the ray we are currently tryin to visualize.
  122936. */
  122937. ray: Nullable<Ray>;
  122938. private _renderPoints;
  122939. private _renderLine;
  122940. private _renderFunction;
  122941. private _scene;
  122942. private _updateToMeshFunction;
  122943. private _attachedToMesh;
  122944. private _meshSpaceDirection;
  122945. private _meshSpaceOrigin;
  122946. /**
  122947. * Helper function to create a colored helper in a scene in one line.
  122948. * @param ray Defines the ray we are currently tryin to visualize
  122949. * @param scene Defines the scene the ray is used in
  122950. * @param color Defines the color we want to see the ray in
  122951. * @returns The newly created ray helper.
  122952. */
  122953. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  122954. /**
  122955. * Instantiate a new ray helper.
  122956. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  122957. * in order to better appreciate the issue one might have.
  122958. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  122959. * @param ray Defines the ray we are currently tryin to visualize
  122960. */
  122961. constructor(ray: Ray);
  122962. /**
  122963. * Shows the ray we are willing to debug.
  122964. * @param scene Defines the scene the ray needs to be rendered in
  122965. * @param color Defines the color the ray needs to be rendered in
  122966. */
  122967. show(scene: Scene, color?: Color3): void;
  122968. /**
  122969. * Hides the ray we are debugging.
  122970. */
  122971. hide(): void;
  122972. private _render;
  122973. /**
  122974. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  122975. * @param mesh Defines the mesh we want the helper attached to
  122976. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  122977. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  122978. * @param length Defines the length of the ray
  122979. */
  122980. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  122981. /**
  122982. * Detach the ray helper from the mesh it has previously been attached to.
  122983. */
  122984. detachFromMesh(): void;
  122985. private _updateToMesh;
  122986. /**
  122987. * Dispose the helper and release its associated resources.
  122988. */
  122989. dispose(): void;
  122990. }
  122991. }
  122992. declare module BABYLON.Debug {
  122993. /**
  122994. * Class used to render a debug view of a given skeleton
  122995. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  122996. */
  122997. export class SkeletonViewer {
  122998. /** defines the skeleton to render */
  122999. skeleton: Skeleton;
  123000. /** defines the mesh attached to the skeleton */
  123001. mesh: AbstractMesh;
  123002. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  123003. autoUpdateBonesMatrices: boolean;
  123004. /** defines the rendering group id to use with the viewer */
  123005. renderingGroupId: number;
  123006. /** Gets or sets the color used to render the skeleton */
  123007. color: Color3;
  123008. private _scene;
  123009. private _debugLines;
  123010. private _debugMesh;
  123011. private _isEnabled;
  123012. private _renderFunction;
  123013. private _utilityLayer;
  123014. /**
  123015. * Returns the mesh used to render the bones
  123016. */
  123017. get debugMesh(): Nullable<LinesMesh>;
  123018. /**
  123019. * Creates a new SkeletonViewer
  123020. * @param skeleton defines the skeleton to render
  123021. * @param mesh defines the mesh attached to the skeleton
  123022. * @param scene defines the hosting scene
  123023. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  123024. * @param renderingGroupId defines the rendering group id to use with the viewer
  123025. */
  123026. constructor(
  123027. /** defines the skeleton to render */
  123028. skeleton: Skeleton,
  123029. /** defines the mesh attached to the skeleton */
  123030. mesh: AbstractMesh, scene: Scene,
  123031. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  123032. autoUpdateBonesMatrices?: boolean,
  123033. /** defines the rendering group id to use with the viewer */
  123034. renderingGroupId?: number);
  123035. /** Gets or sets a boolean indicating if the viewer is enabled */
  123036. set isEnabled(value: boolean);
  123037. get isEnabled(): boolean;
  123038. private _getBonePosition;
  123039. private _getLinesForBonesWithLength;
  123040. private _getLinesForBonesNoLength;
  123041. /** Update the viewer to sync with current skeleton state */
  123042. update(): void;
  123043. /** Release associated resources */
  123044. dispose(): void;
  123045. }
  123046. }
  123047. declare module BABYLON {
  123048. /**
  123049. * This class will take all inputs from Keyboard, Pointer, and
  123050. * any Gamepads and provide a polling system that all devices
  123051. * will use. This class assumes that there will only be one
  123052. * pointer device and one keyboard.
  123053. */
  123054. export class DeviceInputSystem implements IDisposable {
  123055. /** POINTER_DEVICE */
  123056. static readonly POINTER_DEVICE: string;
  123057. /** KEYBOARD_DEVICE */
  123058. static readonly KEYBOARD_DEVICE: string;
  123059. /**
  123060. * Observable to be triggered when a device is connected
  123061. */
  123062. onDeviceConnectedObservable: Observable<string>;
  123063. /**
  123064. * Observable to be triggered when a device is disconnected
  123065. */
  123066. onDeviceDisconnectedObservable: Observable<string>;
  123067. private _inputs;
  123068. private _gamepads;
  123069. private _keyboardActive;
  123070. private _pointerActive;
  123071. private _elementToAttachTo;
  123072. private _keyboardDownEvent;
  123073. private _keyboardUpEvent;
  123074. private _pointerMoveEvent;
  123075. private _pointerDownEvent;
  123076. private _pointerUpEvent;
  123077. private _gamepadConnectedEvent;
  123078. private _gamepadDisconnectedEvent;
  123079. private static _MAX_KEYCODES;
  123080. private static _MAX_POINTER_INPUTS;
  123081. /**
  123082. * Default Constructor
  123083. * @param engine - engine to pull input element from
  123084. */
  123085. constructor(engine: Engine);
  123086. /**
  123087. * Checks for current device input value, given an id and input index
  123088. * @param deviceName Id of connected device
  123089. * @param inputIndex Index of device input
  123090. * @returns Current value of input
  123091. */
  123092. pollInput(deviceName: string, inputIndex: number): Nullable<number>;
  123093. /**
  123094. * Dispose of all the eventlisteners and clears the observables
  123095. */
  123096. dispose(): void;
  123097. /**
  123098. * Add device and inputs to device map
  123099. * @param deviceName Assigned name of device (may be SN)
  123100. * @param numberOfInputs Number of input entries to create for given device
  123101. */
  123102. private _registerDevice;
  123103. /**
  123104. * Given a specific device name, remove that device from the device map
  123105. * @param deviceName Name of device to be removed
  123106. */
  123107. private _unregisterDevice;
  123108. /**
  123109. * Handle all actions that come from keyboard interaction
  123110. */
  123111. private _handleKeyActions;
  123112. /**
  123113. * Handle all actions that come from pointer interaction
  123114. */
  123115. private _handlePointerActions;
  123116. /**
  123117. * Handle all actions that come from gamepad interaction
  123118. */
  123119. private _handleGamepadActions;
  123120. /**
  123121. * Update all non-event based devices with each frame
  123122. */
  123123. private _updateDevice;
  123124. }
  123125. }
  123126. declare module BABYLON {
  123127. /**
  123128. * Options to create the null engine
  123129. */
  123130. export class NullEngineOptions {
  123131. /**
  123132. * Render width (Default: 512)
  123133. */
  123134. renderWidth: number;
  123135. /**
  123136. * Render height (Default: 256)
  123137. */
  123138. renderHeight: number;
  123139. /**
  123140. * Texture size (Default: 512)
  123141. */
  123142. textureSize: number;
  123143. /**
  123144. * If delta time between frames should be constant
  123145. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  123146. */
  123147. deterministicLockstep: boolean;
  123148. /**
  123149. * Maximum about of steps between frames (Default: 4)
  123150. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  123151. */
  123152. lockstepMaxSteps: number;
  123153. }
  123154. /**
  123155. * The null engine class provides support for headless version of babylon.js.
  123156. * This can be used in server side scenario or for testing purposes
  123157. */
  123158. export class NullEngine extends Engine {
  123159. private _options;
  123160. /**
  123161. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  123162. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  123163. * @returns true if engine is in deterministic lock step mode
  123164. */
  123165. isDeterministicLockStep(): boolean;
  123166. /**
  123167. * Gets the max steps when engine is running in deterministic lock step
  123168. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  123169. * @returns the max steps
  123170. */
  123171. getLockstepMaxSteps(): number;
  123172. /**
  123173. * Gets the current hardware scaling level.
  123174. * By default the hardware scaling level is computed from the window device ratio.
  123175. * 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.
  123176. * @returns a number indicating the current hardware scaling level
  123177. */
  123178. getHardwareScalingLevel(): number;
  123179. constructor(options?: NullEngineOptions);
  123180. /**
  123181. * Creates a vertex buffer
  123182. * @param vertices the data for the vertex buffer
  123183. * @returns the new WebGL static buffer
  123184. */
  123185. createVertexBuffer(vertices: FloatArray): DataBuffer;
  123186. /**
  123187. * Creates a new index buffer
  123188. * @param indices defines the content of the index buffer
  123189. * @param updatable defines if the index buffer must be updatable
  123190. * @returns a new webGL buffer
  123191. */
  123192. createIndexBuffer(indices: IndicesArray): DataBuffer;
  123193. /**
  123194. * Clear the current render buffer or the current render target (if any is set up)
  123195. * @param color defines the color to use
  123196. * @param backBuffer defines if the back buffer must be cleared
  123197. * @param depth defines if the depth buffer must be cleared
  123198. * @param stencil defines if the stencil buffer must be cleared
  123199. */
  123200. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  123201. /**
  123202. * Gets the current render width
  123203. * @param useScreen defines if screen size must be used (or the current render target if any)
  123204. * @returns a number defining the current render width
  123205. */
  123206. getRenderWidth(useScreen?: boolean): number;
  123207. /**
  123208. * Gets the current render height
  123209. * @param useScreen defines if screen size must be used (or the current render target if any)
  123210. * @returns a number defining the current render height
  123211. */
  123212. getRenderHeight(useScreen?: boolean): number;
  123213. /**
  123214. * Set the WebGL's viewport
  123215. * @param viewport defines the viewport element to be used
  123216. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  123217. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  123218. */
  123219. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  123220. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  123221. /**
  123222. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  123223. * @param pipelineContext defines the pipeline context to use
  123224. * @param uniformsNames defines the list of uniform names
  123225. * @returns an array of webGL uniform locations
  123226. */
  123227. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  123228. /**
  123229. * Gets the lsit of active attributes for a given webGL program
  123230. * @param pipelineContext defines the pipeline context to use
  123231. * @param attributesNames defines the list of attribute names to get
  123232. * @returns an array of indices indicating the offset of each attribute
  123233. */
  123234. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  123235. /**
  123236. * Binds an effect to the webGL context
  123237. * @param effect defines the effect to bind
  123238. */
  123239. bindSamplers(effect: Effect): void;
  123240. /**
  123241. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  123242. * @param effect defines the effect to activate
  123243. */
  123244. enableEffect(effect: Effect): void;
  123245. /**
  123246. * Set various states to the webGL context
  123247. * @param culling defines backface culling state
  123248. * @param zOffset defines the value to apply to zOffset (0 by default)
  123249. * @param force defines if states must be applied even if cache is up to date
  123250. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  123251. */
  123252. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  123253. /**
  123254. * Set the value of an uniform to an array of int32
  123255. * @param uniform defines the webGL uniform location where to store the value
  123256. * @param array defines the array of int32 to store
  123257. */
  123258. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  123259. /**
  123260. * Set the value of an uniform to an array of int32 (stored as vec2)
  123261. * @param uniform defines the webGL uniform location where to store the value
  123262. * @param array defines the array of int32 to store
  123263. */
  123264. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  123265. /**
  123266. * Set the value of an uniform to an array of int32 (stored as vec3)
  123267. * @param uniform defines the webGL uniform location where to store the value
  123268. * @param array defines the array of int32 to store
  123269. */
  123270. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  123271. /**
  123272. * Set the value of an uniform to an array of int32 (stored as vec4)
  123273. * @param uniform defines the webGL uniform location where to store the value
  123274. * @param array defines the array of int32 to store
  123275. */
  123276. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  123277. /**
  123278. * Set the value of an uniform to an array of float32
  123279. * @param uniform defines the webGL uniform location where to store the value
  123280. * @param array defines the array of float32 to store
  123281. */
  123282. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  123283. /**
  123284. * Set the value of an uniform to an array of float32 (stored as vec2)
  123285. * @param uniform defines the webGL uniform location where to store the value
  123286. * @param array defines the array of float32 to store
  123287. */
  123288. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  123289. /**
  123290. * Set the value of an uniform to an array of float32 (stored as vec3)
  123291. * @param uniform defines the webGL uniform location where to store the value
  123292. * @param array defines the array of float32 to store
  123293. */
  123294. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  123295. /**
  123296. * Set the value of an uniform to an array of float32 (stored as vec4)
  123297. * @param uniform defines the webGL uniform location where to store the value
  123298. * @param array defines the array of float32 to store
  123299. */
  123300. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  123301. /**
  123302. * Set the value of an uniform to an array of number
  123303. * @param uniform defines the webGL uniform location where to store the value
  123304. * @param array defines the array of number to store
  123305. */
  123306. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  123307. /**
  123308. * Set the value of an uniform to an array of number (stored as vec2)
  123309. * @param uniform defines the webGL uniform location where to store the value
  123310. * @param array defines the array of number to store
  123311. */
  123312. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  123313. /**
  123314. * Set the value of an uniform to an array of number (stored as vec3)
  123315. * @param uniform defines the webGL uniform location where to store the value
  123316. * @param array defines the array of number to store
  123317. */
  123318. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  123319. /**
  123320. * Set the value of an uniform to an array of number (stored as vec4)
  123321. * @param uniform defines the webGL uniform location where to store the value
  123322. * @param array defines the array of number to store
  123323. */
  123324. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  123325. /**
  123326. * Set the value of an uniform to an array of float32 (stored as matrices)
  123327. * @param uniform defines the webGL uniform location where to store the value
  123328. * @param matrices defines the array of float32 to store
  123329. */
  123330. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  123331. /**
  123332. * Set the value of an uniform to a matrix (3x3)
  123333. * @param uniform defines the webGL uniform location where to store the value
  123334. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  123335. */
  123336. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  123337. /**
  123338. * Set the value of an uniform to a matrix (2x2)
  123339. * @param uniform defines the webGL uniform location where to store the value
  123340. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  123341. */
  123342. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  123343. /**
  123344. * Set the value of an uniform to a number (float)
  123345. * @param uniform defines the webGL uniform location where to store the value
  123346. * @param value defines the float number to store
  123347. */
  123348. setFloat(uniform: WebGLUniformLocation, value: number): void;
  123349. /**
  123350. * Set the value of an uniform to a vec2
  123351. * @param uniform defines the webGL uniform location where to store the value
  123352. * @param x defines the 1st component of the value
  123353. * @param y defines the 2nd component of the value
  123354. */
  123355. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  123356. /**
  123357. * Set the value of an uniform to a vec3
  123358. * @param uniform defines the webGL uniform location where to store the value
  123359. * @param x defines the 1st component of the value
  123360. * @param y defines the 2nd component of the value
  123361. * @param z defines the 3rd component of the value
  123362. */
  123363. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  123364. /**
  123365. * Set the value of an uniform to a boolean
  123366. * @param uniform defines the webGL uniform location where to store the value
  123367. * @param bool defines the boolean to store
  123368. */
  123369. setBool(uniform: WebGLUniformLocation, bool: number): void;
  123370. /**
  123371. * Set the value of an uniform to a vec4
  123372. * @param uniform defines the webGL uniform location where to store the value
  123373. * @param x defines the 1st component of the value
  123374. * @param y defines the 2nd component of the value
  123375. * @param z defines the 3rd component of the value
  123376. * @param w defines the 4th component of the value
  123377. */
  123378. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  123379. /**
  123380. * Sets the current alpha mode
  123381. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  123382. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  123383. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  123384. */
  123385. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  123386. /**
  123387. * Bind webGl buffers directly to the webGL context
  123388. * @param vertexBuffers defines the vertex buffer to bind
  123389. * @param indexBuffer defines the index buffer to bind
  123390. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  123391. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  123392. * @param effect defines the effect associated with the vertex buffer
  123393. */
  123394. bindBuffers(vertexBuffers: {
  123395. [key: string]: VertexBuffer;
  123396. }, indexBuffer: DataBuffer, effect: Effect): void;
  123397. /**
  123398. * Force the entire cache to be cleared
  123399. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  123400. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  123401. */
  123402. wipeCaches(bruteForce?: boolean): void;
  123403. /**
  123404. * Send a draw order
  123405. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  123406. * @param indexStart defines the starting index
  123407. * @param indexCount defines the number of index to draw
  123408. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  123409. */
  123410. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  123411. /**
  123412. * Draw a list of indexed primitives
  123413. * @param fillMode defines the primitive to use
  123414. * @param indexStart defines the starting index
  123415. * @param indexCount defines the number of index to draw
  123416. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  123417. */
  123418. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  123419. /**
  123420. * Draw a list of unindexed primitives
  123421. * @param fillMode defines the primitive to use
  123422. * @param verticesStart defines the index of first vertex to draw
  123423. * @param verticesCount defines the count of vertices to draw
  123424. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  123425. */
  123426. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  123427. /** @hidden */
  123428. _createTexture(): WebGLTexture;
  123429. /** @hidden */
  123430. _releaseTexture(texture: InternalTexture): void;
  123431. /**
  123432. * Usually called from Texture.ts.
  123433. * Passed information to create a WebGLTexture
  123434. * @param urlArg defines a value which contains one of the following:
  123435. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  123436. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  123437. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  123438. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  123439. * @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)
  123440. * @param scene needed for loading to the correct scene
  123441. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  123442. * @param onLoad optional callback to be called upon successful completion
  123443. * @param onError optional callback to be called upon failure
  123444. * @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
  123445. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  123446. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  123447. * @param forcedExtension defines the extension to use to pick the right loader
  123448. * @param mimeType defines an optional mime type
  123449. * @returns a InternalTexture for assignment back into BABYLON.Texture
  123450. */
  123451. 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;
  123452. /**
  123453. * Creates a new render target texture
  123454. * @param size defines the size of the texture
  123455. * @param options defines the options used to create the texture
  123456. * @returns a new render target texture stored in an InternalTexture
  123457. */
  123458. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  123459. /**
  123460. * Update the sampling mode of a given texture
  123461. * @param samplingMode defines the required sampling mode
  123462. * @param texture defines the texture to update
  123463. */
  123464. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  123465. /**
  123466. * Binds the frame buffer to the specified texture.
  123467. * @param texture The texture to render to or null for the default canvas
  123468. * @param faceIndex The face of the texture to render to in case of cube texture
  123469. * @param requiredWidth The width of the target to render to
  123470. * @param requiredHeight The height of the target to render to
  123471. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  123472. * @param lodLevel defines le lod level to bind to the frame buffer
  123473. */
  123474. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  123475. /**
  123476. * Unbind the current render target texture from the webGL context
  123477. * @param texture defines the render target texture to unbind
  123478. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  123479. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  123480. */
  123481. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  123482. /**
  123483. * Creates a dynamic vertex buffer
  123484. * @param vertices the data for the dynamic vertex buffer
  123485. * @returns the new WebGL dynamic buffer
  123486. */
  123487. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  123488. /**
  123489. * Update the content of a dynamic texture
  123490. * @param texture defines the texture to update
  123491. * @param canvas defines the canvas containing the source
  123492. * @param invertY defines if data must be stored with Y axis inverted
  123493. * @param premulAlpha defines if alpha is stored as premultiplied
  123494. * @param format defines the format of the data
  123495. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  123496. */
  123497. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  123498. /**
  123499. * Gets a boolean indicating if all created effects are ready
  123500. * @returns true if all effects are ready
  123501. */
  123502. areAllEffectsReady(): boolean;
  123503. /**
  123504. * @hidden
  123505. * Get the current error code of the webGL context
  123506. * @returns the error code
  123507. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  123508. */
  123509. getError(): number;
  123510. /** @hidden */
  123511. _getUnpackAlignement(): number;
  123512. /** @hidden */
  123513. _unpackFlipY(value: boolean): void;
  123514. /**
  123515. * Update a dynamic index buffer
  123516. * @param indexBuffer defines the target index buffer
  123517. * @param indices defines the data to update
  123518. * @param offset defines the offset in the target index buffer where update should start
  123519. */
  123520. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  123521. /**
  123522. * Updates a dynamic vertex buffer.
  123523. * @param vertexBuffer the vertex buffer to update
  123524. * @param vertices the data used to update the vertex buffer
  123525. * @param byteOffset the byte offset of the data (optional)
  123526. * @param byteLength the byte length of the data (optional)
  123527. */
  123528. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  123529. /** @hidden */
  123530. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  123531. /** @hidden */
  123532. _bindTexture(channel: number, texture: InternalTexture): void;
  123533. protected _deleteBuffer(buffer: WebGLBuffer): void;
  123534. /**
  123535. * 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
  123536. */
  123537. releaseEffects(): void;
  123538. displayLoadingUI(): void;
  123539. hideLoadingUI(): void;
  123540. /** @hidden */
  123541. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  123542. /** @hidden */
  123543. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  123544. /** @hidden */
  123545. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  123546. /** @hidden */
  123547. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  123548. }
  123549. }
  123550. declare module BABYLON {
  123551. /**
  123552. * @hidden
  123553. **/
  123554. export class _TimeToken {
  123555. _startTimeQuery: Nullable<WebGLQuery>;
  123556. _endTimeQuery: Nullable<WebGLQuery>;
  123557. _timeElapsedQuery: Nullable<WebGLQuery>;
  123558. _timeElapsedQueryEnded: boolean;
  123559. }
  123560. }
  123561. declare module BABYLON {
  123562. /** @hidden */
  123563. export class _OcclusionDataStorage {
  123564. /** @hidden */
  123565. occlusionInternalRetryCounter: number;
  123566. /** @hidden */
  123567. isOcclusionQueryInProgress: boolean;
  123568. /** @hidden */
  123569. isOccluded: boolean;
  123570. /** @hidden */
  123571. occlusionRetryCount: number;
  123572. /** @hidden */
  123573. occlusionType: number;
  123574. /** @hidden */
  123575. occlusionQueryAlgorithmType: number;
  123576. }
  123577. interface Engine {
  123578. /**
  123579. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  123580. * @return the new query
  123581. */
  123582. createQuery(): WebGLQuery;
  123583. /**
  123584. * Delete and release a webGL query
  123585. * @param query defines the query to delete
  123586. * @return the current engine
  123587. */
  123588. deleteQuery(query: WebGLQuery): Engine;
  123589. /**
  123590. * Check if a given query has resolved and got its value
  123591. * @param query defines the query to check
  123592. * @returns true if the query got its value
  123593. */
  123594. isQueryResultAvailable(query: WebGLQuery): boolean;
  123595. /**
  123596. * Gets the value of a given query
  123597. * @param query defines the query to check
  123598. * @returns the value of the query
  123599. */
  123600. getQueryResult(query: WebGLQuery): number;
  123601. /**
  123602. * Initiates an occlusion query
  123603. * @param algorithmType defines the algorithm to use
  123604. * @param query defines the query to use
  123605. * @returns the current engine
  123606. * @see http://doc.babylonjs.com/features/occlusionquery
  123607. */
  123608. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  123609. /**
  123610. * Ends an occlusion query
  123611. * @see http://doc.babylonjs.com/features/occlusionquery
  123612. * @param algorithmType defines the algorithm to use
  123613. * @returns the current engine
  123614. */
  123615. endOcclusionQuery(algorithmType: number): Engine;
  123616. /**
  123617. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  123618. * Please note that only one query can be issued at a time
  123619. * @returns a time token used to track the time span
  123620. */
  123621. startTimeQuery(): Nullable<_TimeToken>;
  123622. /**
  123623. * Ends a time query
  123624. * @param token defines the token used to measure the time span
  123625. * @returns the time spent (in ns)
  123626. */
  123627. endTimeQuery(token: _TimeToken): int;
  123628. /** @hidden */
  123629. _currentNonTimestampToken: Nullable<_TimeToken>;
  123630. /** @hidden */
  123631. _createTimeQuery(): WebGLQuery;
  123632. /** @hidden */
  123633. _deleteTimeQuery(query: WebGLQuery): void;
  123634. /** @hidden */
  123635. _getGlAlgorithmType(algorithmType: number): number;
  123636. /** @hidden */
  123637. _getTimeQueryResult(query: WebGLQuery): any;
  123638. /** @hidden */
  123639. _getTimeQueryAvailability(query: WebGLQuery): any;
  123640. }
  123641. interface AbstractMesh {
  123642. /**
  123643. * Backing filed
  123644. * @hidden
  123645. */
  123646. __occlusionDataStorage: _OcclusionDataStorage;
  123647. /**
  123648. * Access property
  123649. * @hidden
  123650. */
  123651. _occlusionDataStorage: _OcclusionDataStorage;
  123652. /**
  123653. * 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.
  123654. * The default value is -1 which means don't break the query and wait till the result
  123655. * @see http://doc.babylonjs.com/features/occlusionquery
  123656. */
  123657. occlusionRetryCount: number;
  123658. /**
  123659. * 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:
  123660. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  123661. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  123662. * * 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.
  123663. * @see http://doc.babylonjs.com/features/occlusionquery
  123664. */
  123665. occlusionType: number;
  123666. /**
  123667. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  123668. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  123669. * * 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.
  123670. * @see http://doc.babylonjs.com/features/occlusionquery
  123671. */
  123672. occlusionQueryAlgorithmType: number;
  123673. /**
  123674. * 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
  123675. * @see http://doc.babylonjs.com/features/occlusionquery
  123676. */
  123677. isOccluded: boolean;
  123678. /**
  123679. * Flag to check the progress status of the query
  123680. * @see http://doc.babylonjs.com/features/occlusionquery
  123681. */
  123682. isOcclusionQueryInProgress: boolean;
  123683. }
  123684. }
  123685. declare module BABYLON {
  123686. /** @hidden */
  123687. export var _forceTransformFeedbackToBundle: boolean;
  123688. interface Engine {
  123689. /**
  123690. * Creates a webGL transform feedback object
  123691. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  123692. * @returns the webGL transform feedback object
  123693. */
  123694. createTransformFeedback(): WebGLTransformFeedback;
  123695. /**
  123696. * Delete a webGL transform feedback object
  123697. * @param value defines the webGL transform feedback object to delete
  123698. */
  123699. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  123700. /**
  123701. * Bind a webGL transform feedback object to the webgl context
  123702. * @param value defines the webGL transform feedback object to bind
  123703. */
  123704. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  123705. /**
  123706. * Begins a transform feedback operation
  123707. * @param usePoints defines if points or triangles must be used
  123708. */
  123709. beginTransformFeedback(usePoints: boolean): void;
  123710. /**
  123711. * Ends a transform feedback operation
  123712. */
  123713. endTransformFeedback(): void;
  123714. /**
  123715. * Specify the varyings to use with transform feedback
  123716. * @param program defines the associated webGL program
  123717. * @param value defines the list of strings representing the varying names
  123718. */
  123719. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  123720. /**
  123721. * Bind a webGL buffer for a transform feedback operation
  123722. * @param value defines the webGL buffer to bind
  123723. */
  123724. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  123725. }
  123726. }
  123727. declare module BABYLON {
  123728. /**
  123729. * Creation options of the multi render target texture.
  123730. */
  123731. export interface IMultiRenderTargetOptions {
  123732. /**
  123733. * Define if the texture needs to create mip maps after render.
  123734. */
  123735. generateMipMaps?: boolean;
  123736. /**
  123737. * Define the types of all the draw buffers we want to create
  123738. */
  123739. types?: number[];
  123740. /**
  123741. * Define the sampling modes of all the draw buffers we want to create
  123742. */
  123743. samplingModes?: number[];
  123744. /**
  123745. * Define if a depth buffer is required
  123746. */
  123747. generateDepthBuffer?: boolean;
  123748. /**
  123749. * Define if a stencil buffer is required
  123750. */
  123751. generateStencilBuffer?: boolean;
  123752. /**
  123753. * Define if a depth texture is required instead of a depth buffer
  123754. */
  123755. generateDepthTexture?: boolean;
  123756. /**
  123757. * Define the number of desired draw buffers
  123758. */
  123759. textureCount?: number;
  123760. /**
  123761. * Define if aspect ratio should be adapted to the texture or stay the scene one
  123762. */
  123763. doNotChangeAspectRatio?: boolean;
  123764. /**
  123765. * Define the default type of the buffers we are creating
  123766. */
  123767. defaultType?: number;
  123768. }
  123769. /**
  123770. * A multi render target, like a render target provides the ability to render to a texture.
  123771. * Unlike the render target, it can render to several draw buffers in one draw.
  123772. * This is specially interesting in deferred rendering or for any effects requiring more than
  123773. * just one color from a single pass.
  123774. */
  123775. export class MultiRenderTarget extends RenderTargetTexture {
  123776. private _internalTextures;
  123777. private _textures;
  123778. private _multiRenderTargetOptions;
  123779. /**
  123780. * Get if draw buffers are currently supported by the used hardware and browser.
  123781. */
  123782. get isSupported(): boolean;
  123783. /**
  123784. * Get the list of textures generated by the multi render target.
  123785. */
  123786. get textures(): Texture[];
  123787. /**
  123788. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  123789. */
  123790. get depthTexture(): Texture;
  123791. /**
  123792. * Set the wrapping mode on U of all the textures we are rendering to.
  123793. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  123794. */
  123795. set wrapU(wrap: number);
  123796. /**
  123797. * Set the wrapping mode on V of all the textures we are rendering to.
  123798. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  123799. */
  123800. set wrapV(wrap: number);
  123801. /**
  123802. * Instantiate a new multi render target texture.
  123803. * A multi render target, like a render target provides the ability to render to a texture.
  123804. * Unlike the render target, it can render to several draw buffers in one draw.
  123805. * This is specially interesting in deferred rendering or for any effects requiring more than
  123806. * just one color from a single pass.
  123807. * @param name Define the name of the texture
  123808. * @param size Define the size of the buffers to render to
  123809. * @param count Define the number of target we are rendering into
  123810. * @param scene Define the scene the texture belongs to
  123811. * @param options Define the options used to create the multi render target
  123812. */
  123813. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  123814. /** @hidden */
  123815. _rebuild(): void;
  123816. private _createInternalTextures;
  123817. private _createTextures;
  123818. /**
  123819. * Define the number of samples used if MSAA is enabled.
  123820. */
  123821. get samples(): number;
  123822. set samples(value: number);
  123823. /**
  123824. * Resize all the textures in the multi render target.
  123825. * Be carrefull as it will recreate all the data in the new texture.
  123826. * @param size Define the new size
  123827. */
  123828. resize(size: any): void;
  123829. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  123830. /**
  123831. * Dispose the render targets and their associated resources
  123832. */
  123833. dispose(): void;
  123834. /**
  123835. * Release all the underlying texture used as draw buffers.
  123836. */
  123837. releaseInternalTextures(): void;
  123838. }
  123839. }
  123840. declare module BABYLON {
  123841. interface ThinEngine {
  123842. /**
  123843. * Unbind a list of render target textures from the webGL context
  123844. * This is used only when drawBuffer extension or webGL2 are active
  123845. * @param textures defines the render target textures to unbind
  123846. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  123847. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  123848. */
  123849. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  123850. /**
  123851. * Create a multi render target texture
  123852. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  123853. * @param size defines the size of the texture
  123854. * @param options defines the creation options
  123855. * @returns the cube texture as an InternalTexture
  123856. */
  123857. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  123858. /**
  123859. * Update the sample count for a given multiple render target texture
  123860. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  123861. * @param textures defines the textures to update
  123862. * @param samples defines the sample count to set
  123863. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  123864. */
  123865. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  123866. }
  123867. }
  123868. declare module BABYLON {
  123869. /**
  123870. * Class used to define an additional view for the engine
  123871. * @see https://doc.babylonjs.com/how_to/multi_canvases
  123872. */
  123873. export class EngineView {
  123874. /** Defines the canvas where to render the view */
  123875. target: HTMLCanvasElement;
  123876. /** Defines an optional camera used to render the view (will use active camera else) */
  123877. camera?: Camera;
  123878. }
  123879. interface Engine {
  123880. /**
  123881. * Gets or sets the HTML element to use for attaching events
  123882. */
  123883. inputElement: Nullable<HTMLElement>;
  123884. /**
  123885. * Gets the current engine view
  123886. * @see https://doc.babylonjs.com/how_to/multi_canvases
  123887. */
  123888. activeView: Nullable<EngineView>;
  123889. /** Gets or sets the list of views */
  123890. views: EngineView[];
  123891. /**
  123892. * Register a new child canvas
  123893. * @param canvas defines the canvas to register
  123894. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  123895. * @returns the associated view
  123896. */
  123897. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  123898. /**
  123899. * Remove a registered child canvas
  123900. * @param canvas defines the canvas to remove
  123901. * @returns the current engine
  123902. */
  123903. unRegisterView(canvas: HTMLCanvasElement): Engine;
  123904. }
  123905. }
  123906. declare module BABYLON {
  123907. interface Engine {
  123908. /** @hidden */
  123909. _excludedCompressedTextures: string[];
  123910. /** @hidden */
  123911. _textureFormatInUse: string;
  123912. /**
  123913. * Gets the list of texture formats supported
  123914. */
  123915. readonly texturesSupported: Array<string>;
  123916. /**
  123917. * Gets the texture format in use
  123918. */
  123919. readonly textureFormatInUse: Nullable<string>;
  123920. /**
  123921. * Set the compressed texture extensions or file names to skip.
  123922. *
  123923. * @param skippedFiles defines the list of those texture files you want to skip
  123924. * Example: [".dds", ".env", "myfile.png"]
  123925. */
  123926. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  123927. /**
  123928. * Set the compressed texture format to use, based on the formats you have, and the formats
  123929. * supported by the hardware / browser.
  123930. *
  123931. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  123932. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  123933. * to API arguments needed to compressed textures. This puts the burden on the container
  123934. * generator to house the arcane code for determining these for current & future formats.
  123935. *
  123936. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  123937. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  123938. *
  123939. * Note: The result of this call is not taken into account when a texture is base64.
  123940. *
  123941. * @param formatsAvailable defines the list of those format families you have created
  123942. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  123943. *
  123944. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  123945. * @returns The extension selected.
  123946. */
  123947. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  123948. }
  123949. }
  123950. declare module BABYLON {
  123951. /**
  123952. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  123953. */
  123954. export interface CubeMapInfo {
  123955. /**
  123956. * The pixel array for the front face.
  123957. * This is stored in format, left to right, up to down format.
  123958. */
  123959. front: Nullable<ArrayBufferView>;
  123960. /**
  123961. * The pixel array for the back face.
  123962. * This is stored in format, left to right, up to down format.
  123963. */
  123964. back: Nullable<ArrayBufferView>;
  123965. /**
  123966. * The pixel array for the left face.
  123967. * This is stored in format, left to right, up to down format.
  123968. */
  123969. left: Nullable<ArrayBufferView>;
  123970. /**
  123971. * The pixel array for the right face.
  123972. * This is stored in format, left to right, up to down format.
  123973. */
  123974. right: Nullable<ArrayBufferView>;
  123975. /**
  123976. * The pixel array for the up face.
  123977. * This is stored in format, left to right, up to down format.
  123978. */
  123979. up: Nullable<ArrayBufferView>;
  123980. /**
  123981. * The pixel array for the down face.
  123982. * This is stored in format, left to right, up to down format.
  123983. */
  123984. down: Nullable<ArrayBufferView>;
  123985. /**
  123986. * The size of the cubemap stored.
  123987. *
  123988. * Each faces will be size * size pixels.
  123989. */
  123990. size: number;
  123991. /**
  123992. * The format of the texture.
  123993. *
  123994. * RGBA, RGB.
  123995. */
  123996. format: number;
  123997. /**
  123998. * The type of the texture data.
  123999. *
  124000. * UNSIGNED_INT, FLOAT.
  124001. */
  124002. type: number;
  124003. /**
  124004. * Specifies whether the texture is in gamma space.
  124005. */
  124006. gammaSpace: boolean;
  124007. }
  124008. /**
  124009. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  124010. */
  124011. export class PanoramaToCubeMapTools {
  124012. private static FACE_LEFT;
  124013. private static FACE_RIGHT;
  124014. private static FACE_FRONT;
  124015. private static FACE_BACK;
  124016. private static FACE_DOWN;
  124017. private static FACE_UP;
  124018. /**
  124019. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  124020. *
  124021. * @param float32Array The source data.
  124022. * @param inputWidth The width of the input panorama.
  124023. * @param inputHeight The height of the input panorama.
  124024. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  124025. * @return The cubemap data
  124026. */
  124027. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  124028. private static CreateCubemapTexture;
  124029. private static CalcProjectionSpherical;
  124030. }
  124031. }
  124032. declare module BABYLON {
  124033. /**
  124034. * Helper class dealing with the extraction of spherical polynomial dataArray
  124035. * from a cube map.
  124036. */
  124037. export class CubeMapToSphericalPolynomialTools {
  124038. private static FileFaces;
  124039. /**
  124040. * Converts a texture to the according Spherical Polynomial data.
  124041. * This extracts the first 3 orders only as they are the only one used in the lighting.
  124042. *
  124043. * @param texture The texture to extract the information from.
  124044. * @return The Spherical Polynomial data.
  124045. */
  124046. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  124047. /**
  124048. * Converts a cubemap to the according Spherical Polynomial data.
  124049. * This extracts the first 3 orders only as they are the only one used in the lighting.
  124050. *
  124051. * @param cubeInfo The Cube map to extract the information from.
  124052. * @return The Spherical Polynomial data.
  124053. */
  124054. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  124055. }
  124056. }
  124057. declare module BABYLON {
  124058. interface BaseTexture {
  124059. /**
  124060. * Get the polynomial representation of the texture data.
  124061. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  124062. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  124063. */
  124064. sphericalPolynomial: Nullable<SphericalPolynomial>;
  124065. }
  124066. }
  124067. declare module BABYLON {
  124068. /** @hidden */
  124069. export var rgbdEncodePixelShader: {
  124070. name: string;
  124071. shader: string;
  124072. };
  124073. }
  124074. declare module BABYLON {
  124075. /** @hidden */
  124076. export var rgbdDecodePixelShader: {
  124077. name: string;
  124078. shader: string;
  124079. };
  124080. }
  124081. declare module BABYLON {
  124082. /**
  124083. * Raw texture data and descriptor sufficient for WebGL texture upload
  124084. */
  124085. export interface EnvironmentTextureInfo {
  124086. /**
  124087. * Version of the environment map
  124088. */
  124089. version: number;
  124090. /**
  124091. * Width of image
  124092. */
  124093. width: number;
  124094. /**
  124095. * Irradiance information stored in the file.
  124096. */
  124097. irradiance: any;
  124098. /**
  124099. * Specular information stored in the file.
  124100. */
  124101. specular: any;
  124102. }
  124103. /**
  124104. * Defines One Image in the file. It requires only the position in the file
  124105. * as well as the length.
  124106. */
  124107. interface BufferImageData {
  124108. /**
  124109. * Length of the image data.
  124110. */
  124111. length: number;
  124112. /**
  124113. * Position of the data from the null terminator delimiting the end of the JSON.
  124114. */
  124115. position: number;
  124116. }
  124117. /**
  124118. * Defines the specular data enclosed in the file.
  124119. * This corresponds to the version 1 of the data.
  124120. */
  124121. export interface EnvironmentTextureSpecularInfoV1 {
  124122. /**
  124123. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  124124. */
  124125. specularDataPosition?: number;
  124126. /**
  124127. * This contains all the images data needed to reconstruct the cubemap.
  124128. */
  124129. mipmaps: Array<BufferImageData>;
  124130. /**
  124131. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  124132. */
  124133. lodGenerationScale: number;
  124134. }
  124135. /**
  124136. * Sets of helpers addressing the serialization and deserialization of environment texture
  124137. * stored in a BabylonJS env file.
  124138. * Those files are usually stored as .env files.
  124139. */
  124140. export class EnvironmentTextureTools {
  124141. /**
  124142. * Magic number identifying the env file.
  124143. */
  124144. private static _MagicBytes;
  124145. /**
  124146. * Gets the environment info from an env file.
  124147. * @param data The array buffer containing the .env bytes.
  124148. * @returns the environment file info (the json header) if successfully parsed.
  124149. */
  124150. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  124151. /**
  124152. * Creates an environment texture from a loaded cube texture.
  124153. * @param texture defines the cube texture to convert in env file
  124154. * @return a promise containing the environment data if succesfull.
  124155. */
  124156. static CreateEnvTextureAsync(texture: BaseTexture): Promise<ArrayBuffer>;
  124157. /**
  124158. * Creates a JSON representation of the spherical data.
  124159. * @param texture defines the texture containing the polynomials
  124160. * @return the JSON representation of the spherical info
  124161. */
  124162. private static _CreateEnvTextureIrradiance;
  124163. /**
  124164. * Creates the ArrayBufferViews used for initializing environment texture image data.
  124165. * @param data the image data
  124166. * @param info parameters that determine what views will be created for accessing the underlying buffer
  124167. * @return the views described by info providing access to the underlying buffer
  124168. */
  124169. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  124170. /**
  124171. * Uploads the texture info contained in the env file to the GPU.
  124172. * @param texture defines the internal texture to upload to
  124173. * @param data defines the data to load
  124174. * @param info defines the texture info retrieved through the GetEnvInfo method
  124175. * @returns a promise
  124176. */
  124177. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  124178. private static _OnImageReadyAsync;
  124179. /**
  124180. * Uploads the levels of image data to the GPU.
  124181. * @param texture defines the internal texture to upload to
  124182. * @param imageData defines the array buffer views of image data [mipmap][face]
  124183. * @returns a promise
  124184. */
  124185. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  124186. /**
  124187. * Uploads spherical polynomials information to the texture.
  124188. * @param texture defines the texture we are trying to upload the information to
  124189. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  124190. */
  124191. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  124192. /** @hidden */
  124193. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  124194. }
  124195. }
  124196. declare module BABYLON {
  124197. /**
  124198. * Contains position and normal vectors for a vertex
  124199. */
  124200. export class PositionNormalVertex {
  124201. /** the position of the vertex (defaut: 0,0,0) */
  124202. position: Vector3;
  124203. /** the normal of the vertex (defaut: 0,1,0) */
  124204. normal: Vector3;
  124205. /**
  124206. * Creates a PositionNormalVertex
  124207. * @param position the position of the vertex (defaut: 0,0,0)
  124208. * @param normal the normal of the vertex (defaut: 0,1,0)
  124209. */
  124210. constructor(
  124211. /** the position of the vertex (defaut: 0,0,0) */
  124212. position?: Vector3,
  124213. /** the normal of the vertex (defaut: 0,1,0) */
  124214. normal?: Vector3);
  124215. /**
  124216. * Clones the PositionNormalVertex
  124217. * @returns the cloned PositionNormalVertex
  124218. */
  124219. clone(): PositionNormalVertex;
  124220. }
  124221. /**
  124222. * Contains position, normal and uv vectors for a vertex
  124223. */
  124224. export class PositionNormalTextureVertex {
  124225. /** the position of the vertex (defaut: 0,0,0) */
  124226. position: Vector3;
  124227. /** the normal of the vertex (defaut: 0,1,0) */
  124228. normal: Vector3;
  124229. /** the uv of the vertex (default: 0,0) */
  124230. uv: Vector2;
  124231. /**
  124232. * Creates a PositionNormalTextureVertex
  124233. * @param position the position of the vertex (defaut: 0,0,0)
  124234. * @param normal the normal of the vertex (defaut: 0,1,0)
  124235. * @param uv the uv of the vertex (default: 0,0)
  124236. */
  124237. constructor(
  124238. /** the position of the vertex (defaut: 0,0,0) */
  124239. position?: Vector3,
  124240. /** the normal of the vertex (defaut: 0,1,0) */
  124241. normal?: Vector3,
  124242. /** the uv of the vertex (default: 0,0) */
  124243. uv?: Vector2);
  124244. /**
  124245. * Clones the PositionNormalTextureVertex
  124246. * @returns the cloned PositionNormalTextureVertex
  124247. */
  124248. clone(): PositionNormalTextureVertex;
  124249. }
  124250. }
  124251. declare module BABYLON {
  124252. /** @hidden */
  124253. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  124254. private _genericAttributeLocation;
  124255. private _varyingLocationCount;
  124256. private _varyingLocationMap;
  124257. private _replacements;
  124258. private _textureCount;
  124259. private _uniforms;
  124260. lineProcessor(line: string): string;
  124261. attributeProcessor(attribute: string): string;
  124262. varyingProcessor(varying: string, isFragment: boolean): string;
  124263. uniformProcessor(uniform: string): string;
  124264. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  124265. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  124266. }
  124267. }
  124268. declare module BABYLON {
  124269. /**
  124270. * Container for accessors for natively-stored mesh data buffers.
  124271. */
  124272. class NativeDataBuffer extends DataBuffer {
  124273. /**
  124274. * Accessor value used to identify/retrieve a natively-stored index buffer.
  124275. */
  124276. nativeIndexBuffer?: any;
  124277. /**
  124278. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  124279. */
  124280. nativeVertexBuffer?: any;
  124281. }
  124282. /** @hidden */
  124283. class NativeTexture extends InternalTexture {
  124284. getInternalTexture(): InternalTexture;
  124285. getViewCount(): number;
  124286. }
  124287. /** @hidden */
  124288. export class NativeEngine extends Engine {
  124289. private readonly _native;
  124290. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  124291. private readonly INVALID_HANDLE;
  124292. getHardwareScalingLevel(): number;
  124293. constructor();
  124294. dispose(): void;
  124295. /**
  124296. * Can be used to override the current requestAnimationFrame requester.
  124297. * @hidden
  124298. */
  124299. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  124300. /**
  124301. * Override default engine behavior.
  124302. * @param color
  124303. * @param backBuffer
  124304. * @param depth
  124305. * @param stencil
  124306. */
  124307. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  124308. /**
  124309. * Gets host document
  124310. * @returns the host document object
  124311. */
  124312. getHostDocument(): Nullable<Document>;
  124313. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  124314. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  124315. createVertexBuffer(data: DataArray): NativeDataBuffer;
  124316. recordVertexArrayObject(vertexBuffers: {
  124317. [key: string]: VertexBuffer;
  124318. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  124319. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  124320. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  124321. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  124322. /**
  124323. * Draw a list of indexed primitives
  124324. * @param fillMode defines the primitive to use
  124325. * @param indexStart defines the starting index
  124326. * @param indexCount defines the number of index to draw
  124327. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  124328. */
  124329. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  124330. /**
  124331. * Draw a list of unindexed primitives
  124332. * @param fillMode defines the primitive to use
  124333. * @param verticesStart defines the index of first vertex to draw
  124334. * @param verticesCount defines the count of vertices to draw
  124335. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  124336. */
  124337. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  124338. createPipelineContext(): IPipelineContext;
  124339. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  124340. /** @hidden */
  124341. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  124342. /** @hidden */
  124343. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  124344. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  124345. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  124346. protected _setProgram(program: WebGLProgram): void;
  124347. _releaseEffect(effect: Effect): void;
  124348. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  124349. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  124350. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  124351. bindSamplers(effect: Effect): void;
  124352. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  124353. getRenderWidth(useScreen?: boolean): number;
  124354. getRenderHeight(useScreen?: boolean): number;
  124355. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  124356. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  124357. /**
  124358. * Set the z offset to apply to current rendering
  124359. * @param value defines the offset to apply
  124360. */
  124361. setZOffset(value: number): void;
  124362. /**
  124363. * Gets the current value of the zOffset
  124364. * @returns the current zOffset state
  124365. */
  124366. getZOffset(): number;
  124367. /**
  124368. * Enable or disable depth buffering
  124369. * @param enable defines the state to set
  124370. */
  124371. setDepthBuffer(enable: boolean): void;
  124372. /**
  124373. * Gets a boolean indicating if depth writing is enabled
  124374. * @returns the current depth writing state
  124375. */
  124376. getDepthWrite(): boolean;
  124377. /**
  124378. * Enable or disable depth writing
  124379. * @param enable defines the state to set
  124380. */
  124381. setDepthWrite(enable: boolean): void;
  124382. /**
  124383. * Enable or disable color writing
  124384. * @param enable defines the state to set
  124385. */
  124386. setColorWrite(enable: boolean): void;
  124387. /**
  124388. * Gets a boolean indicating if color writing is enabled
  124389. * @returns the current color writing state
  124390. */
  124391. getColorWrite(): boolean;
  124392. /**
  124393. * Sets alpha constants used by some alpha blending modes
  124394. * @param r defines the red component
  124395. * @param g defines the green component
  124396. * @param b defines the blue component
  124397. * @param a defines the alpha component
  124398. */
  124399. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  124400. /**
  124401. * Sets the current alpha mode
  124402. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  124403. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  124404. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  124405. */
  124406. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  124407. /**
  124408. * Gets the current alpha mode
  124409. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  124410. * @returns the current alpha mode
  124411. */
  124412. getAlphaMode(): number;
  124413. setInt(uniform: WebGLUniformLocation, int: number): void;
  124414. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  124415. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  124416. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  124417. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  124418. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  124419. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  124420. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  124421. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  124422. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  124423. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  124424. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  124425. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  124426. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  124427. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  124428. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  124429. setFloat(uniform: WebGLUniformLocation, value: number): void;
  124430. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  124431. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  124432. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  124433. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  124434. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  124435. wipeCaches(bruteForce?: boolean): void;
  124436. _createTexture(): WebGLTexture;
  124437. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  124438. /**
  124439. * Usually called from Texture.ts.
  124440. * Passed information to create a WebGLTexture
  124441. * @param url defines a value which contains one of the following:
  124442. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  124443. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  124444. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  124445. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  124446. * @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)
  124447. * @param scene needed for loading to the correct scene
  124448. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  124449. * @param onLoad optional callback to be called upon successful completion
  124450. * @param onError optional callback to be called upon failure
  124451. * @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
  124452. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  124453. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  124454. * @param forcedExtension defines the extension to use to pick the right loader
  124455. * @param mimeType defines an optional mime type
  124456. * @returns a InternalTexture for assignment back into BABYLON.Texture
  124457. */
  124458. 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;
  124459. /**
  124460. * Creates a cube texture
  124461. * @param rootUrl defines the url where the files to load is located
  124462. * @param scene defines the current scene
  124463. * @param files defines the list of files to load (1 per face)
  124464. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  124465. * @param onLoad defines an optional callback raised when the texture is loaded
  124466. * @param onError defines an optional callback raised if there is an issue to load the texture
  124467. * @param format defines the format of the data
  124468. * @param forcedExtension defines the extension to use to pick the right loader
  124469. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  124470. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  124471. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  124472. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  124473. * @returns the cube texture as an InternalTexture
  124474. */
  124475. 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;
  124476. private _getSamplingFilter;
  124477. private static _GetNativeTextureFormat;
  124478. createRenderTargetTexture(size: number | {
  124479. width: number;
  124480. height: number;
  124481. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  124482. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  124483. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  124484. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  124485. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  124486. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  124487. /**
  124488. * Updates a dynamic vertex buffer.
  124489. * @param vertexBuffer the vertex buffer to update
  124490. * @param data the data used to update the vertex buffer
  124491. * @param byteOffset the byte offset of the data (optional)
  124492. * @param byteLength the byte length of the data (optional)
  124493. */
  124494. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  124495. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  124496. private _updateAnisotropicLevel;
  124497. private _getAddressMode;
  124498. /** @hidden */
  124499. _bindTexture(channel: number, texture: InternalTexture): void;
  124500. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  124501. releaseEffects(): void;
  124502. /** @hidden */
  124503. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  124504. /** @hidden */
  124505. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  124506. /** @hidden */
  124507. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  124508. /** @hidden */
  124509. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  124510. }
  124511. }
  124512. declare module BABYLON {
  124513. /**
  124514. * Gather the list of clipboard event types as constants.
  124515. */
  124516. export class ClipboardEventTypes {
  124517. /**
  124518. * The clipboard event is fired when a copy command is active (pressed).
  124519. */
  124520. static readonly COPY: number;
  124521. /**
  124522. * The clipboard event is fired when a cut command is active (pressed).
  124523. */
  124524. static readonly CUT: number;
  124525. /**
  124526. * The clipboard event is fired when a paste command is active (pressed).
  124527. */
  124528. static readonly PASTE: number;
  124529. }
  124530. /**
  124531. * This class is used to store clipboard related info for the onClipboardObservable event.
  124532. */
  124533. export class ClipboardInfo {
  124534. /**
  124535. * Defines the type of event (BABYLON.ClipboardEventTypes)
  124536. */
  124537. type: number;
  124538. /**
  124539. * Defines the related dom event
  124540. */
  124541. event: ClipboardEvent;
  124542. /**
  124543. *Creates an instance of ClipboardInfo.
  124544. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  124545. * @param event Defines the related dom event
  124546. */
  124547. constructor(
  124548. /**
  124549. * Defines the type of event (BABYLON.ClipboardEventTypes)
  124550. */
  124551. type: number,
  124552. /**
  124553. * Defines the related dom event
  124554. */
  124555. event: ClipboardEvent);
  124556. /**
  124557. * Get the clipboard event's type from the keycode.
  124558. * @param keyCode Defines the keyCode for the current keyboard event.
  124559. * @return {number}
  124560. */
  124561. static GetTypeFromCharacter(keyCode: number): number;
  124562. }
  124563. }
  124564. declare module BABYLON {
  124565. /**
  124566. * Google Daydream controller
  124567. */
  124568. export class DaydreamController extends WebVRController {
  124569. /**
  124570. * Base Url for the controller model.
  124571. */
  124572. static MODEL_BASE_URL: string;
  124573. /**
  124574. * File name for the controller model.
  124575. */
  124576. static MODEL_FILENAME: string;
  124577. /**
  124578. * Gamepad Id prefix used to identify Daydream Controller.
  124579. */
  124580. static readonly GAMEPAD_ID_PREFIX: string;
  124581. /**
  124582. * Creates a new DaydreamController from a gamepad
  124583. * @param vrGamepad the gamepad that the controller should be created from
  124584. */
  124585. constructor(vrGamepad: any);
  124586. /**
  124587. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  124588. * @param scene scene in which to add meshes
  124589. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  124590. */
  124591. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  124592. /**
  124593. * Called once for each button that changed state since the last frame
  124594. * @param buttonIdx Which button index changed
  124595. * @param state New state of the button
  124596. * @param changes Which properties on the state changed since last frame
  124597. */
  124598. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  124599. }
  124600. }
  124601. declare module BABYLON {
  124602. /**
  124603. * Gear VR Controller
  124604. */
  124605. export class GearVRController extends WebVRController {
  124606. /**
  124607. * Base Url for the controller model.
  124608. */
  124609. static MODEL_BASE_URL: string;
  124610. /**
  124611. * File name for the controller model.
  124612. */
  124613. static MODEL_FILENAME: string;
  124614. /**
  124615. * Gamepad Id prefix used to identify this controller.
  124616. */
  124617. static readonly GAMEPAD_ID_PREFIX: string;
  124618. private readonly _buttonIndexToObservableNameMap;
  124619. /**
  124620. * Creates a new GearVRController from a gamepad
  124621. * @param vrGamepad the gamepad that the controller should be created from
  124622. */
  124623. constructor(vrGamepad: any);
  124624. /**
  124625. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  124626. * @param scene scene in which to add meshes
  124627. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  124628. */
  124629. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  124630. /**
  124631. * Called once for each button that changed state since the last frame
  124632. * @param buttonIdx Which button index changed
  124633. * @param state New state of the button
  124634. * @param changes Which properties on the state changed since last frame
  124635. */
  124636. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  124637. }
  124638. }
  124639. declare module BABYLON {
  124640. /**
  124641. * Generic Controller
  124642. */
  124643. export class GenericController extends WebVRController {
  124644. /**
  124645. * Base Url for the controller model.
  124646. */
  124647. static readonly MODEL_BASE_URL: string;
  124648. /**
  124649. * File name for the controller model.
  124650. */
  124651. static readonly MODEL_FILENAME: string;
  124652. /**
  124653. * Creates a new GenericController from a gamepad
  124654. * @param vrGamepad the gamepad that the controller should be created from
  124655. */
  124656. constructor(vrGamepad: any);
  124657. /**
  124658. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  124659. * @param scene scene in which to add meshes
  124660. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  124661. */
  124662. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  124663. /**
  124664. * Called once for each button that changed state since the last frame
  124665. * @param buttonIdx Which button index changed
  124666. * @param state New state of the button
  124667. * @param changes Which properties on the state changed since last frame
  124668. */
  124669. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  124670. }
  124671. }
  124672. declare module BABYLON {
  124673. /**
  124674. * Oculus Touch Controller
  124675. */
  124676. export class OculusTouchController extends WebVRController {
  124677. /**
  124678. * Base Url for the controller model.
  124679. */
  124680. static MODEL_BASE_URL: string;
  124681. /**
  124682. * File name for the left controller model.
  124683. */
  124684. static MODEL_LEFT_FILENAME: string;
  124685. /**
  124686. * File name for the right controller model.
  124687. */
  124688. static MODEL_RIGHT_FILENAME: string;
  124689. /**
  124690. * Base Url for the Quest controller model.
  124691. */
  124692. static QUEST_MODEL_BASE_URL: string;
  124693. /**
  124694. * @hidden
  124695. * If the controllers are running on a device that needs the updated Quest controller models
  124696. */
  124697. static _IsQuest: boolean;
  124698. /**
  124699. * Fired when the secondary trigger on this controller is modified
  124700. */
  124701. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  124702. /**
  124703. * Fired when the thumb rest on this controller is modified
  124704. */
  124705. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  124706. /**
  124707. * Creates a new OculusTouchController from a gamepad
  124708. * @param vrGamepad the gamepad that the controller should be created from
  124709. */
  124710. constructor(vrGamepad: any);
  124711. /**
  124712. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  124713. * @param scene scene in which to add meshes
  124714. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  124715. */
  124716. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  124717. /**
  124718. * Fired when the A button on this controller is modified
  124719. */
  124720. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  124721. /**
  124722. * Fired when the B button on this controller is modified
  124723. */
  124724. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  124725. /**
  124726. * Fired when the X button on this controller is modified
  124727. */
  124728. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  124729. /**
  124730. * Fired when the Y button on this controller is modified
  124731. */
  124732. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  124733. /**
  124734. * Called once for each button that changed state since the last frame
  124735. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  124736. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  124737. * 2) secondary trigger (same)
  124738. * 3) A (right) X (left), touch, pressed = value
  124739. * 4) B / Y
  124740. * 5) thumb rest
  124741. * @param buttonIdx Which button index changed
  124742. * @param state New state of the button
  124743. * @param changes Which properties on the state changed since last frame
  124744. */
  124745. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  124746. }
  124747. }
  124748. declare module BABYLON {
  124749. /**
  124750. * Vive Controller
  124751. */
  124752. export class ViveController extends WebVRController {
  124753. /**
  124754. * Base Url for the controller model.
  124755. */
  124756. static MODEL_BASE_URL: string;
  124757. /**
  124758. * File name for the controller model.
  124759. */
  124760. static MODEL_FILENAME: string;
  124761. /**
  124762. * Creates a new ViveController from a gamepad
  124763. * @param vrGamepad the gamepad that the controller should be created from
  124764. */
  124765. constructor(vrGamepad: any);
  124766. /**
  124767. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  124768. * @param scene scene in which to add meshes
  124769. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  124770. */
  124771. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  124772. /**
  124773. * Fired when the left button on this controller is modified
  124774. */
  124775. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  124776. /**
  124777. * Fired when the right button on this controller is modified
  124778. */
  124779. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  124780. /**
  124781. * Fired when the menu button on this controller is modified
  124782. */
  124783. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  124784. /**
  124785. * Called once for each button that changed state since the last frame
  124786. * Vive mapping:
  124787. * 0: touchpad
  124788. * 1: trigger
  124789. * 2: left AND right buttons
  124790. * 3: menu button
  124791. * @param buttonIdx Which button index changed
  124792. * @param state New state of the button
  124793. * @param changes Which properties on the state changed since last frame
  124794. */
  124795. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  124796. }
  124797. }
  124798. declare module BABYLON {
  124799. /**
  124800. * Defines the WindowsMotionController object that the state of the windows motion controller
  124801. */
  124802. export class WindowsMotionController extends WebVRController {
  124803. /**
  124804. * The base url used to load the left and right controller models
  124805. */
  124806. static MODEL_BASE_URL: string;
  124807. /**
  124808. * The name of the left controller model file
  124809. */
  124810. static MODEL_LEFT_FILENAME: string;
  124811. /**
  124812. * The name of the right controller model file
  124813. */
  124814. static MODEL_RIGHT_FILENAME: string;
  124815. /**
  124816. * The controller name prefix for this controller type
  124817. */
  124818. static readonly GAMEPAD_ID_PREFIX: string;
  124819. /**
  124820. * The controller id pattern for this controller type
  124821. */
  124822. private static readonly GAMEPAD_ID_PATTERN;
  124823. private _loadedMeshInfo;
  124824. protected readonly _mapping: {
  124825. buttons: string[];
  124826. buttonMeshNames: {
  124827. trigger: string;
  124828. menu: string;
  124829. grip: string;
  124830. thumbstick: string;
  124831. trackpad: string;
  124832. };
  124833. buttonObservableNames: {
  124834. trigger: string;
  124835. menu: string;
  124836. grip: string;
  124837. thumbstick: string;
  124838. trackpad: string;
  124839. };
  124840. axisMeshNames: string[];
  124841. pointingPoseMeshName: string;
  124842. };
  124843. /**
  124844. * Fired when the trackpad on this controller is clicked
  124845. */
  124846. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  124847. /**
  124848. * Fired when the trackpad on this controller is modified
  124849. */
  124850. onTrackpadValuesChangedObservable: Observable<StickValues>;
  124851. /**
  124852. * The current x and y values of this controller's trackpad
  124853. */
  124854. trackpad: StickValues;
  124855. /**
  124856. * Creates a new WindowsMotionController from a gamepad
  124857. * @param vrGamepad the gamepad that the controller should be created from
  124858. */
  124859. constructor(vrGamepad: any);
  124860. /**
  124861. * Fired when the trigger on this controller is modified
  124862. */
  124863. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  124864. /**
  124865. * Fired when the menu button on this controller is modified
  124866. */
  124867. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  124868. /**
  124869. * Fired when the grip button on this controller is modified
  124870. */
  124871. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  124872. /**
  124873. * Fired when the thumbstick button on this controller is modified
  124874. */
  124875. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  124876. /**
  124877. * Fired when the touchpad button on this controller is modified
  124878. */
  124879. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  124880. /**
  124881. * Fired when the touchpad values on this controller are modified
  124882. */
  124883. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  124884. protected _updateTrackpad(): void;
  124885. /**
  124886. * Called once per frame by the engine.
  124887. */
  124888. update(): void;
  124889. /**
  124890. * Called once for each button that changed state since the last frame
  124891. * @param buttonIdx Which button index changed
  124892. * @param state New state of the button
  124893. * @param changes Which properties on the state changed since last frame
  124894. */
  124895. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  124896. /**
  124897. * Moves the buttons on the controller mesh based on their current state
  124898. * @param buttonName the name of the button to move
  124899. * @param buttonValue the value of the button which determines the buttons new position
  124900. */
  124901. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  124902. /**
  124903. * Moves the axis on the controller mesh based on its current state
  124904. * @param axis the index of the axis
  124905. * @param axisValue the value of the axis which determines the meshes new position
  124906. * @hidden
  124907. */
  124908. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  124909. /**
  124910. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  124911. * @param scene scene in which to add meshes
  124912. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  124913. */
  124914. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  124915. /**
  124916. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  124917. * can be transformed by button presses and axes values, based on this._mapping.
  124918. *
  124919. * @param scene scene in which the meshes exist
  124920. * @param meshes list of meshes that make up the controller model to process
  124921. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  124922. */
  124923. private processModel;
  124924. private createMeshInfo;
  124925. /**
  124926. * Gets the ray of the controller in the direction the controller is pointing
  124927. * @param length the length the resulting ray should be
  124928. * @returns a ray in the direction the controller is pointing
  124929. */
  124930. getForwardRay(length?: number): Ray;
  124931. /**
  124932. * Disposes of the controller
  124933. */
  124934. dispose(): void;
  124935. }
  124936. /**
  124937. * This class represents a new windows motion controller in XR.
  124938. */
  124939. export class XRWindowsMotionController extends WindowsMotionController {
  124940. /**
  124941. * Changing the original WIndowsMotionController mapping to fir the new mapping
  124942. */
  124943. protected readonly _mapping: {
  124944. buttons: string[];
  124945. buttonMeshNames: {
  124946. trigger: string;
  124947. menu: string;
  124948. grip: string;
  124949. thumbstick: string;
  124950. trackpad: string;
  124951. };
  124952. buttonObservableNames: {
  124953. trigger: string;
  124954. menu: string;
  124955. grip: string;
  124956. thumbstick: string;
  124957. trackpad: string;
  124958. };
  124959. axisMeshNames: string[];
  124960. pointingPoseMeshName: string;
  124961. };
  124962. /**
  124963. * Construct a new XR-Based windows motion controller
  124964. *
  124965. * @param gamepadInfo the gamepad object from the browser
  124966. */
  124967. constructor(gamepadInfo: any);
  124968. /**
  124969. * holds the thumbstick values (X,Y)
  124970. */
  124971. thumbstickValues: StickValues;
  124972. /**
  124973. * Fired when the thumbstick on this controller is clicked
  124974. */
  124975. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  124976. /**
  124977. * Fired when the thumbstick on this controller is modified
  124978. */
  124979. onThumbstickValuesChangedObservable: Observable<StickValues>;
  124980. /**
  124981. * Fired when the touchpad button on this controller is modified
  124982. */
  124983. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  124984. /**
  124985. * Fired when the touchpad values on this controller are modified
  124986. */
  124987. onTrackpadValuesChangedObservable: Observable<StickValues>;
  124988. /**
  124989. * Fired when the thumbstick button on this controller is modified
  124990. * here to prevent breaking changes
  124991. */
  124992. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  124993. /**
  124994. * updating the thumbstick(!) and not the trackpad.
  124995. * This is named this way due to the difference between WebVR and XR and to avoid
  124996. * changing the parent class.
  124997. */
  124998. protected _updateTrackpad(): void;
  124999. /**
  125000. * Disposes the class with joy
  125001. */
  125002. dispose(): void;
  125003. }
  125004. }
  125005. declare module BABYLON {
  125006. /**
  125007. * Class containing static functions to help procedurally build meshes
  125008. */
  125009. export class PolyhedronBuilder {
  125010. /**
  125011. * Creates a polyhedron mesh
  125012. * * 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
  125013. * * The parameter `size` (positive float, default 1) sets the polygon size
  125014. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  125015. * * 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`
  125016. * * 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
  125017. * * 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)`)
  125018. * * 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
  125019. * * 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
  125020. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  125021. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  125022. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  125023. * @param name defines the name of the mesh
  125024. * @param options defines the options used to create the mesh
  125025. * @param scene defines the hosting scene
  125026. * @returns the polyhedron mesh
  125027. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  125028. */
  125029. static CreatePolyhedron(name: string, options: {
  125030. type?: number;
  125031. size?: number;
  125032. sizeX?: number;
  125033. sizeY?: number;
  125034. sizeZ?: number;
  125035. custom?: any;
  125036. faceUV?: Vector4[];
  125037. faceColors?: Color4[];
  125038. flat?: boolean;
  125039. updatable?: boolean;
  125040. sideOrientation?: number;
  125041. frontUVs?: Vector4;
  125042. backUVs?: Vector4;
  125043. }, scene?: Nullable<Scene>): Mesh;
  125044. }
  125045. }
  125046. declare module BABYLON {
  125047. /**
  125048. * Gizmo that enables scaling a mesh along 3 axis
  125049. */
  125050. export class ScaleGizmo extends Gizmo {
  125051. /**
  125052. * Internal gizmo used for interactions on the x axis
  125053. */
  125054. xGizmo: AxisScaleGizmo;
  125055. /**
  125056. * Internal gizmo used for interactions on the y axis
  125057. */
  125058. yGizmo: AxisScaleGizmo;
  125059. /**
  125060. * Internal gizmo used for interactions on the z axis
  125061. */
  125062. zGizmo: AxisScaleGizmo;
  125063. /**
  125064. * Internal gizmo used to scale all axis equally
  125065. */
  125066. uniformScaleGizmo: AxisScaleGizmo;
  125067. private _meshAttached;
  125068. private _updateGizmoRotationToMatchAttachedMesh;
  125069. private _snapDistance;
  125070. private _scaleRatio;
  125071. private _uniformScalingMesh;
  125072. private _octahedron;
  125073. private _sensitivity;
  125074. /** Fires an event when any of it's sub gizmos are dragged */
  125075. onDragStartObservable: Observable<unknown>;
  125076. /** Fires an event when any of it's sub gizmos are released from dragging */
  125077. onDragEndObservable: Observable<unknown>;
  125078. get attachedMesh(): Nullable<AbstractMesh>;
  125079. set attachedMesh(mesh: Nullable<AbstractMesh>);
  125080. /**
  125081. * Creates a ScaleGizmo
  125082. * @param gizmoLayer The utility layer the gizmo will be added to
  125083. */
  125084. constructor(gizmoLayer?: UtilityLayerRenderer);
  125085. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  125086. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  125087. /**
  125088. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  125089. */
  125090. set snapDistance(value: number);
  125091. get snapDistance(): number;
  125092. /**
  125093. * Ratio for the scale of the gizmo (Default: 1)
  125094. */
  125095. set scaleRatio(value: number);
  125096. get scaleRatio(): number;
  125097. /**
  125098. * Sensitivity factor for dragging (Default: 1)
  125099. */
  125100. set sensitivity(value: number);
  125101. get sensitivity(): number;
  125102. /**
  125103. * Disposes of the gizmo
  125104. */
  125105. dispose(): void;
  125106. }
  125107. }
  125108. declare module BABYLON {
  125109. /**
  125110. * Single axis scale gizmo
  125111. */
  125112. export class AxisScaleGizmo extends Gizmo {
  125113. /**
  125114. * Drag behavior responsible for the gizmos dragging interactions
  125115. */
  125116. dragBehavior: PointerDragBehavior;
  125117. private _pointerObserver;
  125118. /**
  125119. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  125120. */
  125121. snapDistance: number;
  125122. /**
  125123. * Event that fires each time the gizmo snaps to a new location.
  125124. * * snapDistance is the the change in distance
  125125. */
  125126. onSnapObservable: Observable<{
  125127. snapDistance: number;
  125128. }>;
  125129. /**
  125130. * If the scaling operation should be done on all axis (default: false)
  125131. */
  125132. uniformScaling: boolean;
  125133. /**
  125134. * Custom sensitivity value for the drag strength
  125135. */
  125136. sensitivity: number;
  125137. private _isEnabled;
  125138. private _parent;
  125139. private _arrow;
  125140. private _coloredMaterial;
  125141. private _hoverMaterial;
  125142. /**
  125143. * Creates an AxisScaleGizmo
  125144. * @param gizmoLayer The utility layer the gizmo will be added to
  125145. * @param dragAxis The axis which the gizmo will be able to scale on
  125146. * @param color The color of the gizmo
  125147. */
  125148. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  125149. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  125150. /**
  125151. * If the gizmo is enabled
  125152. */
  125153. set isEnabled(value: boolean);
  125154. get isEnabled(): boolean;
  125155. /**
  125156. * Disposes of the gizmo
  125157. */
  125158. dispose(): void;
  125159. /**
  125160. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  125161. * @param mesh The mesh to replace the default mesh of the gizmo
  125162. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  125163. */
  125164. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  125165. }
  125166. }
  125167. declare module BABYLON {
  125168. /**
  125169. * Bounding box gizmo
  125170. */
  125171. export class BoundingBoxGizmo extends Gizmo {
  125172. private _lineBoundingBox;
  125173. private _rotateSpheresParent;
  125174. private _scaleBoxesParent;
  125175. private _boundingDimensions;
  125176. private _renderObserver;
  125177. private _pointerObserver;
  125178. private _scaleDragSpeed;
  125179. private _tmpQuaternion;
  125180. private _tmpVector;
  125181. private _tmpRotationMatrix;
  125182. /**
  125183. * 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)
  125184. */
  125185. ignoreChildren: boolean;
  125186. /**
  125187. * 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)
  125188. */
  125189. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  125190. /**
  125191. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  125192. */
  125193. rotationSphereSize: number;
  125194. /**
  125195. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  125196. */
  125197. scaleBoxSize: number;
  125198. /**
  125199. * 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)
  125200. */
  125201. fixedDragMeshScreenSize: boolean;
  125202. /**
  125203. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  125204. */
  125205. fixedDragMeshScreenSizeDistanceFactor: number;
  125206. /**
  125207. * Fired when a rotation sphere or scale box is dragged
  125208. */
  125209. onDragStartObservable: Observable<{}>;
  125210. /**
  125211. * Fired when a scale box is dragged
  125212. */
  125213. onScaleBoxDragObservable: Observable<{}>;
  125214. /**
  125215. * Fired when a scale box drag is ended
  125216. */
  125217. onScaleBoxDragEndObservable: Observable<{}>;
  125218. /**
  125219. * Fired when a rotation sphere is dragged
  125220. */
  125221. onRotationSphereDragObservable: Observable<{}>;
  125222. /**
  125223. * Fired when a rotation sphere drag is ended
  125224. */
  125225. onRotationSphereDragEndObservable: Observable<{}>;
  125226. /**
  125227. * 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)
  125228. */
  125229. scalePivot: Nullable<Vector3>;
  125230. /**
  125231. * Mesh used as a pivot to rotate the attached mesh
  125232. */
  125233. private _anchorMesh;
  125234. private _existingMeshScale;
  125235. private _dragMesh;
  125236. private pointerDragBehavior;
  125237. private coloredMaterial;
  125238. private hoverColoredMaterial;
  125239. /**
  125240. * Sets the color of the bounding box gizmo
  125241. * @param color the color to set
  125242. */
  125243. setColor(color: Color3): void;
  125244. /**
  125245. * Creates an BoundingBoxGizmo
  125246. * @param gizmoLayer The utility layer the gizmo will be added to
  125247. * @param color The color of the gizmo
  125248. */
  125249. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  125250. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  125251. private _selectNode;
  125252. /**
  125253. * Updates the bounding box information for the Gizmo
  125254. */
  125255. updateBoundingBox(): void;
  125256. private _updateRotationSpheres;
  125257. private _updateScaleBoxes;
  125258. /**
  125259. * Enables rotation on the specified axis and disables rotation on the others
  125260. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  125261. */
  125262. setEnabledRotationAxis(axis: string): void;
  125263. /**
  125264. * Enables/disables scaling
  125265. * @param enable if scaling should be enabled
  125266. * @param homogeneousScaling defines if scaling should only be homogeneous
  125267. */
  125268. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  125269. private _updateDummy;
  125270. /**
  125271. * Enables a pointer drag behavior on the bounding box of the gizmo
  125272. */
  125273. enableDragBehavior(): void;
  125274. /**
  125275. * Disposes of the gizmo
  125276. */
  125277. dispose(): void;
  125278. /**
  125279. * 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)
  125280. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  125281. * @returns the bounding box mesh with the passed in mesh as a child
  125282. */
  125283. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  125284. /**
  125285. * CustomMeshes are not supported by this gizmo
  125286. * @param mesh The mesh to replace the default mesh of the gizmo
  125287. */
  125288. setCustomMesh(mesh: Mesh): void;
  125289. }
  125290. }
  125291. declare module BABYLON {
  125292. /**
  125293. * Single plane rotation gizmo
  125294. */
  125295. export class PlaneRotationGizmo extends Gizmo {
  125296. /**
  125297. * Drag behavior responsible for the gizmos dragging interactions
  125298. */
  125299. dragBehavior: PointerDragBehavior;
  125300. private _pointerObserver;
  125301. /**
  125302. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  125303. */
  125304. snapDistance: number;
  125305. /**
  125306. * Event that fires each time the gizmo snaps to a new location.
  125307. * * snapDistance is the the change in distance
  125308. */
  125309. onSnapObservable: Observable<{
  125310. snapDistance: number;
  125311. }>;
  125312. private _isEnabled;
  125313. private _parent;
  125314. /**
  125315. * Creates a PlaneRotationGizmo
  125316. * @param gizmoLayer The utility layer the gizmo will be added to
  125317. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  125318. * @param color The color of the gizmo
  125319. * @param tessellation Amount of tessellation to be used when creating rotation circles
  125320. * @param useEulerRotation Use and update Euler angle instead of quaternion
  125321. */
  125322. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  125323. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  125324. /**
  125325. * If the gizmo is enabled
  125326. */
  125327. set isEnabled(value: boolean);
  125328. get isEnabled(): boolean;
  125329. /**
  125330. * Disposes of the gizmo
  125331. */
  125332. dispose(): void;
  125333. }
  125334. }
  125335. declare module BABYLON {
  125336. /**
  125337. * Gizmo that enables rotating a mesh along 3 axis
  125338. */
  125339. export class RotationGizmo extends Gizmo {
  125340. /**
  125341. * Internal gizmo used for interactions on the x axis
  125342. */
  125343. xGizmo: PlaneRotationGizmo;
  125344. /**
  125345. * Internal gizmo used for interactions on the y axis
  125346. */
  125347. yGizmo: PlaneRotationGizmo;
  125348. /**
  125349. * Internal gizmo used for interactions on the z axis
  125350. */
  125351. zGizmo: PlaneRotationGizmo;
  125352. /** Fires an event when any of it's sub gizmos are dragged */
  125353. onDragStartObservable: Observable<unknown>;
  125354. /** Fires an event when any of it's sub gizmos are released from dragging */
  125355. onDragEndObservable: Observable<unknown>;
  125356. private _meshAttached;
  125357. get attachedMesh(): Nullable<AbstractMesh>;
  125358. set attachedMesh(mesh: Nullable<AbstractMesh>);
  125359. /**
  125360. * Creates a RotationGizmo
  125361. * @param gizmoLayer The utility layer the gizmo will be added to
  125362. * @param tessellation Amount of tessellation to be used when creating rotation circles
  125363. * @param useEulerRotation Use and update Euler angle instead of quaternion
  125364. */
  125365. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  125366. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  125367. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  125368. /**
  125369. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  125370. */
  125371. set snapDistance(value: number);
  125372. get snapDistance(): number;
  125373. /**
  125374. * Ratio for the scale of the gizmo (Default: 1)
  125375. */
  125376. set scaleRatio(value: number);
  125377. get scaleRatio(): number;
  125378. /**
  125379. * Disposes of the gizmo
  125380. */
  125381. dispose(): void;
  125382. /**
  125383. * CustomMeshes are not supported by this gizmo
  125384. * @param mesh The mesh to replace the default mesh of the gizmo
  125385. */
  125386. setCustomMesh(mesh: Mesh): void;
  125387. }
  125388. }
  125389. declare module BABYLON {
  125390. /**
  125391. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  125392. */
  125393. export class GizmoManager implements IDisposable {
  125394. private scene;
  125395. /**
  125396. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  125397. */
  125398. gizmos: {
  125399. positionGizmo: Nullable<PositionGizmo>;
  125400. rotationGizmo: Nullable<RotationGizmo>;
  125401. scaleGizmo: Nullable<ScaleGizmo>;
  125402. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  125403. };
  125404. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  125405. clearGizmoOnEmptyPointerEvent: boolean;
  125406. /** Fires an event when the manager is attached to a mesh */
  125407. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  125408. private _gizmosEnabled;
  125409. private _pointerObserver;
  125410. private _attachedMesh;
  125411. private _boundingBoxColor;
  125412. private _defaultUtilityLayer;
  125413. private _defaultKeepDepthUtilityLayer;
  125414. /**
  125415. * When bounding box gizmo is enabled, this can be used to track drag/end events
  125416. */
  125417. boundingBoxDragBehavior: SixDofDragBehavior;
  125418. /**
  125419. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  125420. */
  125421. attachableMeshes: Nullable<Array<AbstractMesh>>;
  125422. /**
  125423. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  125424. */
  125425. usePointerToAttachGizmos: boolean;
  125426. /**
  125427. * Utility layer that the bounding box gizmo belongs to
  125428. */
  125429. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  125430. /**
  125431. * Utility layer that all gizmos besides bounding box belong to
  125432. */
  125433. get utilityLayer(): UtilityLayerRenderer;
  125434. /**
  125435. * Instatiates a gizmo manager
  125436. * @param scene the scene to overlay the gizmos on top of
  125437. */
  125438. constructor(scene: Scene);
  125439. /**
  125440. * Attaches a set of gizmos to the specified mesh
  125441. * @param mesh The mesh the gizmo's should be attached to
  125442. */
  125443. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  125444. /**
  125445. * If the position gizmo is enabled
  125446. */
  125447. set positionGizmoEnabled(value: boolean);
  125448. get positionGizmoEnabled(): boolean;
  125449. /**
  125450. * If the rotation gizmo is enabled
  125451. */
  125452. set rotationGizmoEnabled(value: boolean);
  125453. get rotationGizmoEnabled(): boolean;
  125454. /**
  125455. * If the scale gizmo is enabled
  125456. */
  125457. set scaleGizmoEnabled(value: boolean);
  125458. get scaleGizmoEnabled(): boolean;
  125459. /**
  125460. * If the boundingBox gizmo is enabled
  125461. */
  125462. set boundingBoxGizmoEnabled(value: boolean);
  125463. get boundingBoxGizmoEnabled(): boolean;
  125464. /**
  125465. * Disposes of the gizmo manager
  125466. */
  125467. dispose(): void;
  125468. }
  125469. }
  125470. declare module BABYLON {
  125471. /**
  125472. * A directional light is defined by a direction (what a surprise!).
  125473. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  125474. * 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.
  125475. * Documentation: https://doc.babylonjs.com/babylon101/lights
  125476. */
  125477. export class DirectionalLight extends ShadowLight {
  125478. private _shadowFrustumSize;
  125479. /**
  125480. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  125481. */
  125482. get shadowFrustumSize(): number;
  125483. /**
  125484. * Specifies a fix frustum size for the shadow generation.
  125485. */
  125486. set shadowFrustumSize(value: number);
  125487. private _shadowOrthoScale;
  125488. /**
  125489. * Gets the shadow projection scale against the optimal computed one.
  125490. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  125491. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  125492. */
  125493. get shadowOrthoScale(): number;
  125494. /**
  125495. * Sets the shadow projection scale against the optimal computed one.
  125496. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  125497. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  125498. */
  125499. set shadowOrthoScale(value: number);
  125500. /**
  125501. * Automatically compute the projection matrix to best fit (including all the casters)
  125502. * on each frame.
  125503. */
  125504. autoUpdateExtends: boolean;
  125505. /**
  125506. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  125507. * on each frame. autoUpdateExtends must be set to true for this to work
  125508. */
  125509. autoCalcShadowZBounds: boolean;
  125510. private _orthoLeft;
  125511. private _orthoRight;
  125512. private _orthoTop;
  125513. private _orthoBottom;
  125514. /**
  125515. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  125516. * The directional light is emitted from everywhere in the given direction.
  125517. * It can cast shadows.
  125518. * Documentation : https://doc.babylonjs.com/babylon101/lights
  125519. * @param name The friendly name of the light
  125520. * @param direction The direction of the light
  125521. * @param scene The scene the light belongs to
  125522. */
  125523. constructor(name: string, direction: Vector3, scene: Scene);
  125524. /**
  125525. * Returns the string "DirectionalLight".
  125526. * @return The class name
  125527. */
  125528. getClassName(): string;
  125529. /**
  125530. * Returns the integer 1.
  125531. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  125532. */
  125533. getTypeID(): number;
  125534. /**
  125535. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  125536. * Returns the DirectionalLight Shadow projection matrix.
  125537. */
  125538. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  125539. /**
  125540. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  125541. * Returns the DirectionalLight Shadow projection matrix.
  125542. */
  125543. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  125544. /**
  125545. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  125546. * Returns the DirectionalLight Shadow projection matrix.
  125547. */
  125548. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  125549. protected _buildUniformLayout(): void;
  125550. /**
  125551. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  125552. * @param effect The effect to update
  125553. * @param lightIndex The index of the light in the effect to update
  125554. * @returns The directional light
  125555. */
  125556. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  125557. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  125558. /**
  125559. * Gets the minZ used for shadow according to both the scene and the light.
  125560. *
  125561. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  125562. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  125563. * @param activeCamera The camera we are returning the min for
  125564. * @returns the depth min z
  125565. */
  125566. getDepthMinZ(activeCamera: Camera): number;
  125567. /**
  125568. * Gets the maxZ used for shadow according to both the scene and the light.
  125569. *
  125570. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  125571. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  125572. * @param activeCamera The camera we are returning the max for
  125573. * @returns the depth max z
  125574. */
  125575. getDepthMaxZ(activeCamera: Camera): number;
  125576. /**
  125577. * Prepares the list of defines specific to the light type.
  125578. * @param defines the list of defines
  125579. * @param lightIndex defines the index of the light for the effect
  125580. */
  125581. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  125582. }
  125583. }
  125584. declare module BABYLON {
  125585. /**
  125586. * Class containing static functions to help procedurally build meshes
  125587. */
  125588. export class HemisphereBuilder {
  125589. /**
  125590. * Creates a hemisphere mesh
  125591. * @param name defines the name of the mesh
  125592. * @param options defines the options used to create the mesh
  125593. * @param scene defines the hosting scene
  125594. * @returns the hemisphere mesh
  125595. */
  125596. static CreateHemisphere(name: string, options: {
  125597. segments?: number;
  125598. diameter?: number;
  125599. sideOrientation?: number;
  125600. }, scene: any): Mesh;
  125601. }
  125602. }
  125603. declare module BABYLON {
  125604. /**
  125605. * A spot light is defined by a position, a direction, an angle, and an exponent.
  125606. * These values define a cone of light starting from the position, emitting toward the direction.
  125607. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  125608. * and the exponent defines the speed of the decay of the light with distance (reach).
  125609. * Documentation: https://doc.babylonjs.com/babylon101/lights
  125610. */
  125611. export class SpotLight extends ShadowLight {
  125612. private _angle;
  125613. private _innerAngle;
  125614. private _cosHalfAngle;
  125615. private _lightAngleScale;
  125616. private _lightAngleOffset;
  125617. /**
  125618. * Gets the cone angle of the spot light in Radians.
  125619. */
  125620. get angle(): number;
  125621. /**
  125622. * Sets the cone angle of the spot light in Radians.
  125623. */
  125624. set angle(value: number);
  125625. /**
  125626. * Only used in gltf falloff mode, this defines the angle where
  125627. * the directional falloff will start before cutting at angle which could be seen
  125628. * as outer angle.
  125629. */
  125630. get innerAngle(): number;
  125631. /**
  125632. * Only used in gltf falloff mode, this defines the angle where
  125633. * the directional falloff will start before cutting at angle which could be seen
  125634. * as outer angle.
  125635. */
  125636. set innerAngle(value: number);
  125637. private _shadowAngleScale;
  125638. /**
  125639. * Allows scaling the angle of the light for shadow generation only.
  125640. */
  125641. get shadowAngleScale(): number;
  125642. /**
  125643. * Allows scaling the angle of the light for shadow generation only.
  125644. */
  125645. set shadowAngleScale(value: number);
  125646. /**
  125647. * The light decay speed with the distance from the emission spot.
  125648. */
  125649. exponent: number;
  125650. private _projectionTextureMatrix;
  125651. /**
  125652. * Allows reading the projecton texture
  125653. */
  125654. get projectionTextureMatrix(): Matrix;
  125655. protected _projectionTextureLightNear: number;
  125656. /**
  125657. * Gets the near clip of the Spotlight for texture projection.
  125658. */
  125659. get projectionTextureLightNear(): number;
  125660. /**
  125661. * Sets the near clip of the Spotlight for texture projection.
  125662. */
  125663. set projectionTextureLightNear(value: number);
  125664. protected _projectionTextureLightFar: number;
  125665. /**
  125666. * Gets the far clip of the Spotlight for texture projection.
  125667. */
  125668. get projectionTextureLightFar(): number;
  125669. /**
  125670. * Sets the far clip of the Spotlight for texture projection.
  125671. */
  125672. set projectionTextureLightFar(value: number);
  125673. protected _projectionTextureUpDirection: Vector3;
  125674. /**
  125675. * Gets the Up vector of the Spotlight for texture projection.
  125676. */
  125677. get projectionTextureUpDirection(): Vector3;
  125678. /**
  125679. * Sets the Up vector of the Spotlight for texture projection.
  125680. */
  125681. set projectionTextureUpDirection(value: Vector3);
  125682. private _projectionTexture;
  125683. /**
  125684. * Gets the projection texture of the light.
  125685. */
  125686. get projectionTexture(): Nullable<BaseTexture>;
  125687. /**
  125688. * Sets the projection texture of the light.
  125689. */
  125690. set projectionTexture(value: Nullable<BaseTexture>);
  125691. private _projectionTextureViewLightDirty;
  125692. private _projectionTextureProjectionLightDirty;
  125693. private _projectionTextureDirty;
  125694. private _projectionTextureViewTargetVector;
  125695. private _projectionTextureViewLightMatrix;
  125696. private _projectionTextureProjectionLightMatrix;
  125697. private _projectionTextureScalingMatrix;
  125698. /**
  125699. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  125700. * It can cast shadows.
  125701. * Documentation : https://doc.babylonjs.com/babylon101/lights
  125702. * @param name The light friendly name
  125703. * @param position The position of the spot light in the scene
  125704. * @param direction The direction of the light in the scene
  125705. * @param angle The cone angle of the light in Radians
  125706. * @param exponent The light decay speed with the distance from the emission spot
  125707. * @param scene The scene the lights belongs to
  125708. */
  125709. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  125710. /**
  125711. * Returns the string "SpotLight".
  125712. * @returns the class name
  125713. */
  125714. getClassName(): string;
  125715. /**
  125716. * Returns the integer 2.
  125717. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  125718. */
  125719. getTypeID(): number;
  125720. /**
  125721. * Overrides the direction setter to recompute the projection texture view light Matrix.
  125722. */
  125723. protected _setDirection(value: Vector3): void;
  125724. /**
  125725. * Overrides the position setter to recompute the projection texture view light Matrix.
  125726. */
  125727. protected _setPosition(value: Vector3): void;
  125728. /**
  125729. * 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.
  125730. * Returns the SpotLight.
  125731. */
  125732. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  125733. protected _computeProjectionTextureViewLightMatrix(): void;
  125734. protected _computeProjectionTextureProjectionLightMatrix(): void;
  125735. /**
  125736. * Main function for light texture projection matrix computing.
  125737. */
  125738. protected _computeProjectionTextureMatrix(): void;
  125739. protected _buildUniformLayout(): void;
  125740. private _computeAngleValues;
  125741. /**
  125742. * Sets the passed Effect "effect" with the Light textures.
  125743. * @param effect The effect to update
  125744. * @param lightIndex The index of the light in the effect to update
  125745. * @returns The light
  125746. */
  125747. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  125748. /**
  125749. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  125750. * @param effect The effect to update
  125751. * @param lightIndex The index of the light in the effect to update
  125752. * @returns The spot light
  125753. */
  125754. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  125755. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  125756. /**
  125757. * Disposes the light and the associated resources.
  125758. */
  125759. dispose(): void;
  125760. /**
  125761. * Prepares the list of defines specific to the light type.
  125762. * @param defines the list of defines
  125763. * @param lightIndex defines the index of the light for the effect
  125764. */
  125765. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  125766. }
  125767. }
  125768. declare module BABYLON {
  125769. /**
  125770. * Gizmo that enables viewing a light
  125771. */
  125772. export class LightGizmo extends Gizmo {
  125773. private _lightMesh;
  125774. private _material;
  125775. private _cachedPosition;
  125776. private _cachedForward;
  125777. private _attachedMeshParent;
  125778. /**
  125779. * Creates a LightGizmo
  125780. * @param gizmoLayer The utility layer the gizmo will be added to
  125781. */
  125782. constructor(gizmoLayer?: UtilityLayerRenderer);
  125783. private _light;
  125784. /**
  125785. * The light that the gizmo is attached to
  125786. */
  125787. set light(light: Nullable<Light>);
  125788. get light(): Nullable<Light>;
  125789. /**
  125790. * Gets the material used to render the light gizmo
  125791. */
  125792. get material(): StandardMaterial;
  125793. /**
  125794. * @hidden
  125795. * Updates the gizmo to match the attached mesh's position/rotation
  125796. */
  125797. protected _update(): void;
  125798. private static _Scale;
  125799. /**
  125800. * Creates the lines for a light mesh
  125801. */
  125802. private static _CreateLightLines;
  125803. /**
  125804. * Disposes of the light gizmo
  125805. */
  125806. dispose(): void;
  125807. private static _CreateHemisphericLightMesh;
  125808. private static _CreatePointLightMesh;
  125809. private static _CreateSpotLightMesh;
  125810. private static _CreateDirectionalLightMesh;
  125811. }
  125812. }
  125813. declare module BABYLON {
  125814. /** @hidden */
  125815. export var backgroundFragmentDeclaration: {
  125816. name: string;
  125817. shader: string;
  125818. };
  125819. }
  125820. declare module BABYLON {
  125821. /** @hidden */
  125822. export var backgroundUboDeclaration: {
  125823. name: string;
  125824. shader: string;
  125825. };
  125826. }
  125827. declare module BABYLON {
  125828. /** @hidden */
  125829. export var backgroundPixelShader: {
  125830. name: string;
  125831. shader: string;
  125832. };
  125833. }
  125834. declare module BABYLON {
  125835. /** @hidden */
  125836. export var backgroundVertexDeclaration: {
  125837. name: string;
  125838. shader: string;
  125839. };
  125840. }
  125841. declare module BABYLON {
  125842. /** @hidden */
  125843. export var backgroundVertexShader: {
  125844. name: string;
  125845. shader: string;
  125846. };
  125847. }
  125848. declare module BABYLON {
  125849. /**
  125850. * Background material used to create an efficient environement around your scene.
  125851. */
  125852. export class BackgroundMaterial extends PushMaterial {
  125853. /**
  125854. * Standard reflectance value at parallel view angle.
  125855. */
  125856. static StandardReflectance0: number;
  125857. /**
  125858. * Standard reflectance value at grazing angle.
  125859. */
  125860. static StandardReflectance90: number;
  125861. protected _primaryColor: Color3;
  125862. /**
  125863. * Key light Color (multiply against the environement texture)
  125864. */
  125865. primaryColor: Color3;
  125866. protected __perceptualColor: Nullable<Color3>;
  125867. /**
  125868. * Experimental Internal Use Only.
  125869. *
  125870. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  125871. * This acts as a helper to set the primary color to a more "human friendly" value.
  125872. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  125873. * output color as close as possible from the chosen value.
  125874. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  125875. * part of lighting setup.)
  125876. */
  125877. get _perceptualColor(): Nullable<Color3>;
  125878. set _perceptualColor(value: Nullable<Color3>);
  125879. protected _primaryColorShadowLevel: float;
  125880. /**
  125881. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  125882. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  125883. */
  125884. get primaryColorShadowLevel(): float;
  125885. set primaryColorShadowLevel(value: float);
  125886. protected _primaryColorHighlightLevel: float;
  125887. /**
  125888. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  125889. * The primary color is used at the level chosen to define what the white area would look.
  125890. */
  125891. get primaryColorHighlightLevel(): float;
  125892. set primaryColorHighlightLevel(value: float);
  125893. protected _reflectionTexture: Nullable<BaseTexture>;
  125894. /**
  125895. * Reflection Texture used in the material.
  125896. * Should be author in a specific way for the best result (refer to the documentation).
  125897. */
  125898. reflectionTexture: Nullable<BaseTexture>;
  125899. protected _reflectionBlur: float;
  125900. /**
  125901. * Reflection Texture level of blur.
  125902. *
  125903. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  125904. * texture twice.
  125905. */
  125906. reflectionBlur: float;
  125907. protected _diffuseTexture: Nullable<BaseTexture>;
  125908. /**
  125909. * Diffuse Texture used in the material.
  125910. * Should be author in a specific way for the best result (refer to the documentation).
  125911. */
  125912. diffuseTexture: Nullable<BaseTexture>;
  125913. protected _shadowLights: Nullable<IShadowLight[]>;
  125914. /**
  125915. * Specify the list of lights casting shadow on the material.
  125916. * All scene shadow lights will be included if null.
  125917. */
  125918. shadowLights: Nullable<IShadowLight[]>;
  125919. protected _shadowLevel: float;
  125920. /**
  125921. * Helps adjusting the shadow to a softer level if required.
  125922. * 0 means black shadows and 1 means no shadows.
  125923. */
  125924. shadowLevel: float;
  125925. protected _sceneCenter: Vector3;
  125926. /**
  125927. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  125928. * It is usually zero but might be interesting to modify according to your setup.
  125929. */
  125930. sceneCenter: Vector3;
  125931. protected _opacityFresnel: boolean;
  125932. /**
  125933. * This helps specifying that the material is falling off to the sky box at grazing angle.
  125934. * This helps ensuring a nice transition when the camera goes under the ground.
  125935. */
  125936. opacityFresnel: boolean;
  125937. protected _reflectionFresnel: boolean;
  125938. /**
  125939. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  125940. * This helps adding a mirror texture on the ground.
  125941. */
  125942. reflectionFresnel: boolean;
  125943. protected _reflectionFalloffDistance: number;
  125944. /**
  125945. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  125946. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  125947. */
  125948. reflectionFalloffDistance: number;
  125949. protected _reflectionAmount: number;
  125950. /**
  125951. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  125952. */
  125953. reflectionAmount: number;
  125954. protected _reflectionReflectance0: number;
  125955. /**
  125956. * This specifies the weight of the reflection at grazing angle.
  125957. */
  125958. reflectionReflectance0: number;
  125959. protected _reflectionReflectance90: number;
  125960. /**
  125961. * This specifies the weight of the reflection at a perpendicular point of view.
  125962. */
  125963. reflectionReflectance90: number;
  125964. /**
  125965. * Sets the reflection reflectance fresnel values according to the default standard
  125966. * empirically know to work well :-)
  125967. */
  125968. set reflectionStandardFresnelWeight(value: number);
  125969. protected _useRGBColor: boolean;
  125970. /**
  125971. * Helps to directly use the maps channels instead of their level.
  125972. */
  125973. useRGBColor: boolean;
  125974. protected _enableNoise: boolean;
  125975. /**
  125976. * This helps reducing the banding effect that could occur on the background.
  125977. */
  125978. enableNoise: boolean;
  125979. /**
  125980. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  125981. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  125982. * Recommended to be keep at 1.0 except for special cases.
  125983. */
  125984. get fovMultiplier(): number;
  125985. set fovMultiplier(value: number);
  125986. private _fovMultiplier;
  125987. /**
  125988. * Enable the FOV adjustment feature controlled by fovMultiplier.
  125989. */
  125990. useEquirectangularFOV: boolean;
  125991. private _maxSimultaneousLights;
  125992. /**
  125993. * Number of Simultaneous lights allowed on the material.
  125994. */
  125995. maxSimultaneousLights: int;
  125996. /**
  125997. * Default configuration related to image processing available in the Background Material.
  125998. */
  125999. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  126000. /**
  126001. * Keep track of the image processing observer to allow dispose and replace.
  126002. */
  126003. private _imageProcessingObserver;
  126004. /**
  126005. * Attaches a new image processing configuration to the PBR Material.
  126006. * @param configuration (if null the scene configuration will be use)
  126007. */
  126008. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  126009. /**
  126010. * Gets the image processing configuration used either in this material.
  126011. */
  126012. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  126013. /**
  126014. * Sets the Default image processing configuration used either in the this material.
  126015. *
  126016. * If sets to null, the scene one is in use.
  126017. */
  126018. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  126019. /**
  126020. * Gets wether the color curves effect is enabled.
  126021. */
  126022. get cameraColorCurvesEnabled(): boolean;
  126023. /**
  126024. * Sets wether the color curves effect is enabled.
  126025. */
  126026. set cameraColorCurvesEnabled(value: boolean);
  126027. /**
  126028. * Gets wether the color grading effect is enabled.
  126029. */
  126030. get cameraColorGradingEnabled(): boolean;
  126031. /**
  126032. * Gets wether the color grading effect is enabled.
  126033. */
  126034. set cameraColorGradingEnabled(value: boolean);
  126035. /**
  126036. * Gets wether tonemapping is enabled or not.
  126037. */
  126038. get cameraToneMappingEnabled(): boolean;
  126039. /**
  126040. * Sets wether tonemapping is enabled or not
  126041. */
  126042. set cameraToneMappingEnabled(value: boolean);
  126043. /**
  126044. * The camera exposure used on this material.
  126045. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  126046. * This corresponds to a photographic exposure.
  126047. */
  126048. get cameraExposure(): float;
  126049. /**
  126050. * The camera exposure used on this material.
  126051. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  126052. * This corresponds to a photographic exposure.
  126053. */
  126054. set cameraExposure(value: float);
  126055. /**
  126056. * Gets The camera contrast used on this material.
  126057. */
  126058. get cameraContrast(): float;
  126059. /**
  126060. * Sets The camera contrast used on this material.
  126061. */
  126062. set cameraContrast(value: float);
  126063. /**
  126064. * Gets the Color Grading 2D Lookup Texture.
  126065. */
  126066. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  126067. /**
  126068. * Sets the Color Grading 2D Lookup Texture.
  126069. */
  126070. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  126071. /**
  126072. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  126073. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  126074. * 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;
  126075. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  126076. */
  126077. get cameraColorCurves(): Nullable<ColorCurves>;
  126078. /**
  126079. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  126080. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  126081. * 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;
  126082. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  126083. */
  126084. set cameraColorCurves(value: Nullable<ColorCurves>);
  126085. /**
  126086. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  126087. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  126088. */
  126089. switchToBGR: boolean;
  126090. private _renderTargets;
  126091. private _reflectionControls;
  126092. private _white;
  126093. private _primaryShadowColor;
  126094. private _primaryHighlightColor;
  126095. /**
  126096. * Instantiates a Background Material in the given scene
  126097. * @param name The friendly name of the material
  126098. * @param scene The scene to add the material to
  126099. */
  126100. constructor(name: string, scene: Scene);
  126101. /**
  126102. * Gets a boolean indicating that current material needs to register RTT
  126103. */
  126104. get hasRenderTargetTextures(): boolean;
  126105. /**
  126106. * The entire material has been created in order to prevent overdraw.
  126107. * @returns false
  126108. */
  126109. needAlphaTesting(): boolean;
  126110. /**
  126111. * The entire material has been created in order to prevent overdraw.
  126112. * @returns true if blending is enable
  126113. */
  126114. needAlphaBlending(): boolean;
  126115. /**
  126116. * Checks wether the material is ready to be rendered for a given mesh.
  126117. * @param mesh The mesh to render
  126118. * @param subMesh The submesh to check against
  126119. * @param useInstances Specify wether or not the material is used with instances
  126120. * @returns true if all the dependencies are ready (Textures, Effects...)
  126121. */
  126122. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  126123. /**
  126124. * Compute the primary color according to the chosen perceptual color.
  126125. */
  126126. private _computePrimaryColorFromPerceptualColor;
  126127. /**
  126128. * Compute the highlights and shadow colors according to their chosen levels.
  126129. */
  126130. private _computePrimaryColors;
  126131. /**
  126132. * Build the uniform buffer used in the material.
  126133. */
  126134. buildUniformLayout(): void;
  126135. /**
  126136. * Unbind the material.
  126137. */
  126138. unbind(): void;
  126139. /**
  126140. * Bind only the world matrix to the material.
  126141. * @param world The world matrix to bind.
  126142. */
  126143. bindOnlyWorldMatrix(world: Matrix): void;
  126144. /**
  126145. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  126146. * @param world The world matrix to bind.
  126147. * @param subMesh The submesh to bind for.
  126148. */
  126149. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  126150. /**
  126151. * Checks to see if a texture is used in the material.
  126152. * @param texture - Base texture to use.
  126153. * @returns - Boolean specifying if a texture is used in the material.
  126154. */
  126155. hasTexture(texture: BaseTexture): boolean;
  126156. /**
  126157. * Dispose the material.
  126158. * @param forceDisposeEffect Force disposal of the associated effect.
  126159. * @param forceDisposeTextures Force disposal of the associated textures.
  126160. */
  126161. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  126162. /**
  126163. * Clones the material.
  126164. * @param name The cloned name.
  126165. * @returns The cloned material.
  126166. */
  126167. clone(name: string): BackgroundMaterial;
  126168. /**
  126169. * Serializes the current material to its JSON representation.
  126170. * @returns The JSON representation.
  126171. */
  126172. serialize(): any;
  126173. /**
  126174. * Gets the class name of the material
  126175. * @returns "BackgroundMaterial"
  126176. */
  126177. getClassName(): string;
  126178. /**
  126179. * Parse a JSON input to create back a background material.
  126180. * @param source The JSON data to parse
  126181. * @param scene The scene to create the parsed material in
  126182. * @param rootUrl The root url of the assets the material depends upon
  126183. * @returns the instantiated BackgroundMaterial.
  126184. */
  126185. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  126186. }
  126187. }
  126188. declare module BABYLON {
  126189. /**
  126190. * Represents the different options available during the creation of
  126191. * a Environment helper.
  126192. *
  126193. * This can control the default ground, skybox and image processing setup of your scene.
  126194. */
  126195. export interface IEnvironmentHelperOptions {
  126196. /**
  126197. * Specifies whether or not to create a ground.
  126198. * True by default.
  126199. */
  126200. createGround: boolean;
  126201. /**
  126202. * Specifies the ground size.
  126203. * 15 by default.
  126204. */
  126205. groundSize: number;
  126206. /**
  126207. * The texture used on the ground for the main color.
  126208. * Comes from the BabylonJS CDN by default.
  126209. *
  126210. * Remarks: Can be either a texture or a url.
  126211. */
  126212. groundTexture: string | BaseTexture;
  126213. /**
  126214. * The color mixed in the ground texture by default.
  126215. * BabylonJS clearColor by default.
  126216. */
  126217. groundColor: Color3;
  126218. /**
  126219. * Specifies the ground opacity.
  126220. * 1 by default.
  126221. */
  126222. groundOpacity: number;
  126223. /**
  126224. * Enables the ground to receive shadows.
  126225. * True by default.
  126226. */
  126227. enableGroundShadow: boolean;
  126228. /**
  126229. * Helps preventing the shadow to be fully black on the ground.
  126230. * 0.5 by default.
  126231. */
  126232. groundShadowLevel: number;
  126233. /**
  126234. * Creates a mirror texture attach to the ground.
  126235. * false by default.
  126236. */
  126237. enableGroundMirror: boolean;
  126238. /**
  126239. * Specifies the ground mirror size ratio.
  126240. * 0.3 by default as the default kernel is 64.
  126241. */
  126242. groundMirrorSizeRatio: number;
  126243. /**
  126244. * Specifies the ground mirror blur kernel size.
  126245. * 64 by default.
  126246. */
  126247. groundMirrorBlurKernel: number;
  126248. /**
  126249. * Specifies the ground mirror visibility amount.
  126250. * 1 by default
  126251. */
  126252. groundMirrorAmount: number;
  126253. /**
  126254. * Specifies the ground mirror reflectance weight.
  126255. * This uses the standard weight of the background material to setup the fresnel effect
  126256. * of the mirror.
  126257. * 1 by default.
  126258. */
  126259. groundMirrorFresnelWeight: number;
  126260. /**
  126261. * Specifies the ground mirror Falloff distance.
  126262. * This can helps reducing the size of the reflection.
  126263. * 0 by Default.
  126264. */
  126265. groundMirrorFallOffDistance: number;
  126266. /**
  126267. * Specifies the ground mirror texture type.
  126268. * Unsigned Int by Default.
  126269. */
  126270. groundMirrorTextureType: number;
  126271. /**
  126272. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  126273. * the shown objects.
  126274. */
  126275. groundYBias: number;
  126276. /**
  126277. * Specifies whether or not to create a skybox.
  126278. * True by default.
  126279. */
  126280. createSkybox: boolean;
  126281. /**
  126282. * Specifies the skybox size.
  126283. * 20 by default.
  126284. */
  126285. skyboxSize: number;
  126286. /**
  126287. * The texture used on the skybox for the main color.
  126288. * Comes from the BabylonJS CDN by default.
  126289. *
  126290. * Remarks: Can be either a texture or a url.
  126291. */
  126292. skyboxTexture: string | BaseTexture;
  126293. /**
  126294. * The color mixed in the skybox texture by default.
  126295. * BabylonJS clearColor by default.
  126296. */
  126297. skyboxColor: Color3;
  126298. /**
  126299. * The background rotation around the Y axis of the scene.
  126300. * This helps aligning the key lights of your scene with the background.
  126301. * 0 by default.
  126302. */
  126303. backgroundYRotation: number;
  126304. /**
  126305. * Compute automatically the size of the elements to best fit with the scene.
  126306. */
  126307. sizeAuto: boolean;
  126308. /**
  126309. * Default position of the rootMesh if autoSize is not true.
  126310. */
  126311. rootPosition: Vector3;
  126312. /**
  126313. * Sets up the image processing in the scene.
  126314. * true by default.
  126315. */
  126316. setupImageProcessing: boolean;
  126317. /**
  126318. * The texture used as your environment texture in the scene.
  126319. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  126320. *
  126321. * Remarks: Can be either a texture or a url.
  126322. */
  126323. environmentTexture: string | BaseTexture;
  126324. /**
  126325. * The value of the exposure to apply to the scene.
  126326. * 0.6 by default if setupImageProcessing is true.
  126327. */
  126328. cameraExposure: number;
  126329. /**
  126330. * The value of the contrast to apply to the scene.
  126331. * 1.6 by default if setupImageProcessing is true.
  126332. */
  126333. cameraContrast: number;
  126334. /**
  126335. * Specifies whether or not tonemapping should be enabled in the scene.
  126336. * true by default if setupImageProcessing is true.
  126337. */
  126338. toneMappingEnabled: boolean;
  126339. }
  126340. /**
  126341. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  126342. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  126343. * It also helps with the default setup of your imageProcessing configuration.
  126344. */
  126345. export class EnvironmentHelper {
  126346. /**
  126347. * Default ground texture URL.
  126348. */
  126349. private static _groundTextureCDNUrl;
  126350. /**
  126351. * Default skybox texture URL.
  126352. */
  126353. private static _skyboxTextureCDNUrl;
  126354. /**
  126355. * Default environment texture URL.
  126356. */
  126357. private static _environmentTextureCDNUrl;
  126358. /**
  126359. * Creates the default options for the helper.
  126360. */
  126361. private static _getDefaultOptions;
  126362. private _rootMesh;
  126363. /**
  126364. * Gets the root mesh created by the helper.
  126365. */
  126366. get rootMesh(): Mesh;
  126367. private _skybox;
  126368. /**
  126369. * Gets the skybox created by the helper.
  126370. */
  126371. get skybox(): Nullable<Mesh>;
  126372. private _skyboxTexture;
  126373. /**
  126374. * Gets the skybox texture created by the helper.
  126375. */
  126376. get skyboxTexture(): Nullable<BaseTexture>;
  126377. private _skyboxMaterial;
  126378. /**
  126379. * Gets the skybox material created by the helper.
  126380. */
  126381. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  126382. private _ground;
  126383. /**
  126384. * Gets the ground mesh created by the helper.
  126385. */
  126386. get ground(): Nullable<Mesh>;
  126387. private _groundTexture;
  126388. /**
  126389. * Gets the ground texture created by the helper.
  126390. */
  126391. get groundTexture(): Nullable<BaseTexture>;
  126392. private _groundMirror;
  126393. /**
  126394. * Gets the ground mirror created by the helper.
  126395. */
  126396. get groundMirror(): Nullable<MirrorTexture>;
  126397. /**
  126398. * Gets the ground mirror render list to helps pushing the meshes
  126399. * you wish in the ground reflection.
  126400. */
  126401. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  126402. private _groundMaterial;
  126403. /**
  126404. * Gets the ground material created by the helper.
  126405. */
  126406. get groundMaterial(): Nullable<BackgroundMaterial>;
  126407. /**
  126408. * Stores the creation options.
  126409. */
  126410. private readonly _scene;
  126411. private _options;
  126412. /**
  126413. * This observable will be notified with any error during the creation of the environment,
  126414. * mainly texture creation errors.
  126415. */
  126416. onErrorObservable: Observable<{
  126417. message?: string;
  126418. exception?: any;
  126419. }>;
  126420. /**
  126421. * constructor
  126422. * @param options Defines the options we want to customize the helper
  126423. * @param scene The scene to add the material to
  126424. */
  126425. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  126426. /**
  126427. * Updates the background according to the new options
  126428. * @param options
  126429. */
  126430. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  126431. /**
  126432. * Sets the primary color of all the available elements.
  126433. * @param color the main color to affect to the ground and the background
  126434. */
  126435. setMainColor(color: Color3): void;
  126436. /**
  126437. * Setup the image processing according to the specified options.
  126438. */
  126439. private _setupImageProcessing;
  126440. /**
  126441. * Setup the environment texture according to the specified options.
  126442. */
  126443. private _setupEnvironmentTexture;
  126444. /**
  126445. * Setup the background according to the specified options.
  126446. */
  126447. private _setupBackground;
  126448. /**
  126449. * Get the scene sizes according to the setup.
  126450. */
  126451. private _getSceneSize;
  126452. /**
  126453. * Setup the ground according to the specified options.
  126454. */
  126455. private _setupGround;
  126456. /**
  126457. * Setup the ground material according to the specified options.
  126458. */
  126459. private _setupGroundMaterial;
  126460. /**
  126461. * Setup the ground diffuse texture according to the specified options.
  126462. */
  126463. private _setupGroundDiffuseTexture;
  126464. /**
  126465. * Setup the ground mirror texture according to the specified options.
  126466. */
  126467. private _setupGroundMirrorTexture;
  126468. /**
  126469. * Setup the ground to receive the mirror texture.
  126470. */
  126471. private _setupMirrorInGroundMaterial;
  126472. /**
  126473. * Setup the skybox according to the specified options.
  126474. */
  126475. private _setupSkybox;
  126476. /**
  126477. * Setup the skybox material according to the specified options.
  126478. */
  126479. private _setupSkyboxMaterial;
  126480. /**
  126481. * Setup the skybox reflection texture according to the specified options.
  126482. */
  126483. private _setupSkyboxReflectionTexture;
  126484. private _errorHandler;
  126485. /**
  126486. * Dispose all the elements created by the Helper.
  126487. */
  126488. dispose(): void;
  126489. }
  126490. }
  126491. declare module BABYLON {
  126492. /**
  126493. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  126494. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  126495. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  126496. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  126497. */
  126498. export class PhotoDome extends TransformNode {
  126499. /**
  126500. * Define the image as a Monoscopic panoramic 360 image.
  126501. */
  126502. static readonly MODE_MONOSCOPIC: number;
  126503. /**
  126504. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  126505. */
  126506. static readonly MODE_TOPBOTTOM: number;
  126507. /**
  126508. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  126509. */
  126510. static readonly MODE_SIDEBYSIDE: number;
  126511. private _useDirectMapping;
  126512. /**
  126513. * The texture being displayed on the sphere
  126514. */
  126515. protected _photoTexture: Texture;
  126516. /**
  126517. * Gets or sets the texture being displayed on the sphere
  126518. */
  126519. get photoTexture(): Texture;
  126520. set photoTexture(value: Texture);
  126521. /**
  126522. * Observable raised when an error occured while loading the 360 image
  126523. */
  126524. onLoadErrorObservable: Observable<string>;
  126525. /**
  126526. * The skybox material
  126527. */
  126528. protected _material: BackgroundMaterial;
  126529. /**
  126530. * The surface used for the skybox
  126531. */
  126532. protected _mesh: Mesh;
  126533. /**
  126534. * Gets the mesh used for the skybox.
  126535. */
  126536. get mesh(): Mesh;
  126537. /**
  126538. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  126539. * Also see the options.resolution property.
  126540. */
  126541. get fovMultiplier(): number;
  126542. set fovMultiplier(value: number);
  126543. private _imageMode;
  126544. /**
  126545. * Gets or set the current video mode for the video. It can be:
  126546. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  126547. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  126548. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  126549. */
  126550. get imageMode(): number;
  126551. set imageMode(value: number);
  126552. /**
  126553. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  126554. * @param name Element's name, child elements will append suffixes for their own names.
  126555. * @param urlsOfPhoto defines the url of the photo to display
  126556. * @param options defines an object containing optional or exposed sub element properties
  126557. * @param onError defines a callback called when an error occured while loading the texture
  126558. */
  126559. constructor(name: string, urlOfPhoto: string, options: {
  126560. resolution?: number;
  126561. size?: number;
  126562. useDirectMapping?: boolean;
  126563. faceForward?: boolean;
  126564. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  126565. private _onBeforeCameraRenderObserver;
  126566. private _changeImageMode;
  126567. /**
  126568. * Releases resources associated with this node.
  126569. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  126570. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  126571. */
  126572. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  126573. }
  126574. }
  126575. declare module BABYLON {
  126576. /**
  126577. * Class used to host RGBD texture specific utilities
  126578. */
  126579. export class RGBDTextureTools {
  126580. /**
  126581. * Expand the RGBD Texture from RGBD to Half Float if possible.
  126582. * @param texture the texture to expand.
  126583. */
  126584. static ExpandRGBDTexture(texture: Texture): void;
  126585. }
  126586. }
  126587. declare module BABYLON {
  126588. /**
  126589. * Class used to host texture specific utilities
  126590. */
  126591. export class BRDFTextureTools {
  126592. /**
  126593. * Prevents texture cache collision
  126594. */
  126595. private static _instanceNumber;
  126596. /**
  126597. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  126598. * @param scene defines the hosting scene
  126599. * @returns the environment BRDF texture
  126600. */
  126601. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  126602. private static _environmentBRDFBase64Texture;
  126603. }
  126604. }
  126605. declare module BABYLON {
  126606. /**
  126607. * @hidden
  126608. */
  126609. export interface IMaterialClearCoatDefines {
  126610. CLEARCOAT: boolean;
  126611. CLEARCOAT_DEFAULTIOR: boolean;
  126612. CLEARCOAT_TEXTURE: boolean;
  126613. CLEARCOAT_TEXTUREDIRECTUV: number;
  126614. CLEARCOAT_BUMP: boolean;
  126615. CLEARCOAT_BUMPDIRECTUV: number;
  126616. CLEARCOAT_TINT: boolean;
  126617. CLEARCOAT_TINT_TEXTURE: boolean;
  126618. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  126619. /** @hidden */
  126620. _areTexturesDirty: boolean;
  126621. }
  126622. /**
  126623. * Define the code related to the clear coat parameters of the pbr material.
  126624. */
  126625. export class PBRClearCoatConfiguration {
  126626. /**
  126627. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  126628. * The default fits with a polyurethane material.
  126629. */
  126630. private static readonly _DefaultIndexOfRefraction;
  126631. private _isEnabled;
  126632. /**
  126633. * Defines if the clear coat is enabled in the material.
  126634. */
  126635. isEnabled: boolean;
  126636. /**
  126637. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  126638. */
  126639. intensity: number;
  126640. /**
  126641. * Defines the clear coat layer roughness.
  126642. */
  126643. roughness: number;
  126644. private _indexOfRefraction;
  126645. /**
  126646. * Defines the index of refraction of the clear coat.
  126647. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  126648. * The default fits with a polyurethane material.
  126649. * Changing the default value is more performance intensive.
  126650. */
  126651. indexOfRefraction: number;
  126652. private _texture;
  126653. /**
  126654. * Stores the clear coat values in a texture.
  126655. */
  126656. texture: Nullable<BaseTexture>;
  126657. private _bumpTexture;
  126658. /**
  126659. * Define the clear coat specific bump texture.
  126660. */
  126661. bumpTexture: Nullable<BaseTexture>;
  126662. private _isTintEnabled;
  126663. /**
  126664. * Defines if the clear coat tint is enabled in the material.
  126665. */
  126666. isTintEnabled: boolean;
  126667. /**
  126668. * Defines the clear coat tint of the material.
  126669. * This is only use if tint is enabled
  126670. */
  126671. tintColor: Color3;
  126672. /**
  126673. * Defines the distance at which the tint color should be found in the
  126674. * clear coat media.
  126675. * This is only use if tint is enabled
  126676. */
  126677. tintColorAtDistance: number;
  126678. /**
  126679. * Defines the clear coat layer thickness.
  126680. * This is only use if tint is enabled
  126681. */
  126682. tintThickness: number;
  126683. private _tintTexture;
  126684. /**
  126685. * Stores the clear tint values in a texture.
  126686. * rgb is tint
  126687. * a is a thickness factor
  126688. */
  126689. tintTexture: Nullable<BaseTexture>;
  126690. /** @hidden */
  126691. private _internalMarkAllSubMeshesAsTexturesDirty;
  126692. /** @hidden */
  126693. _markAllSubMeshesAsTexturesDirty(): void;
  126694. /**
  126695. * Instantiate a new istance of clear coat configuration.
  126696. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  126697. */
  126698. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  126699. /**
  126700. * Gets wehter the submesh is ready to be used or not.
  126701. * @param defines the list of "defines" to update.
  126702. * @param scene defines the scene the material belongs to.
  126703. * @param engine defines the engine the material belongs to.
  126704. * @param disableBumpMap defines wether the material disables bump or not.
  126705. * @returns - boolean indicating that the submesh is ready or not.
  126706. */
  126707. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  126708. /**
  126709. * Checks to see if a texture is used in the material.
  126710. * @param defines the list of "defines" to update.
  126711. * @param scene defines the scene to the material belongs to.
  126712. */
  126713. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  126714. /**
  126715. * Binds the material data.
  126716. * @param uniformBuffer defines the Uniform buffer to fill in.
  126717. * @param scene defines the scene the material belongs to.
  126718. * @param engine defines the engine the material belongs to.
  126719. * @param disableBumpMap defines wether the material disables bump or not.
  126720. * @param isFrozen defines wether the material is frozen or not.
  126721. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  126722. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  126723. */
  126724. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  126725. /**
  126726. * Checks to see if a texture is used in the material.
  126727. * @param texture - Base texture to use.
  126728. * @returns - Boolean specifying if a texture is used in the material.
  126729. */
  126730. hasTexture(texture: BaseTexture): boolean;
  126731. /**
  126732. * Returns an array of the actively used textures.
  126733. * @param activeTextures Array of BaseTextures
  126734. */
  126735. getActiveTextures(activeTextures: BaseTexture[]): void;
  126736. /**
  126737. * Returns the animatable textures.
  126738. * @param animatables Array of animatable textures.
  126739. */
  126740. getAnimatables(animatables: IAnimatable[]): void;
  126741. /**
  126742. * Disposes the resources of the material.
  126743. * @param forceDisposeTextures - Forces the disposal of all textures.
  126744. */
  126745. dispose(forceDisposeTextures?: boolean): void;
  126746. /**
  126747. * Get the current class name of the texture useful for serialization or dynamic coding.
  126748. * @returns "PBRClearCoatConfiguration"
  126749. */
  126750. getClassName(): string;
  126751. /**
  126752. * Add fallbacks to the effect fallbacks list.
  126753. * @param defines defines the Base texture to use.
  126754. * @param fallbacks defines the current fallback list.
  126755. * @param currentRank defines the current fallback rank.
  126756. * @returns the new fallback rank.
  126757. */
  126758. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  126759. /**
  126760. * Add the required uniforms to the current list.
  126761. * @param uniforms defines the current uniform list.
  126762. */
  126763. static AddUniforms(uniforms: string[]): void;
  126764. /**
  126765. * Add the required samplers to the current list.
  126766. * @param samplers defines the current sampler list.
  126767. */
  126768. static AddSamplers(samplers: string[]): void;
  126769. /**
  126770. * Add the required uniforms to the current buffer.
  126771. * @param uniformBuffer defines the current uniform buffer.
  126772. */
  126773. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  126774. /**
  126775. * Makes a duplicate of the current configuration into another one.
  126776. * @param clearCoatConfiguration define the config where to copy the info
  126777. */
  126778. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  126779. /**
  126780. * Serializes this clear coat configuration.
  126781. * @returns - An object with the serialized config.
  126782. */
  126783. serialize(): any;
  126784. /**
  126785. * Parses a anisotropy Configuration from a serialized object.
  126786. * @param source - Serialized object.
  126787. * @param scene Defines the scene we are parsing for
  126788. * @param rootUrl Defines the rootUrl to load from
  126789. */
  126790. parse(source: any, scene: Scene, rootUrl: string): void;
  126791. }
  126792. }
  126793. declare module BABYLON {
  126794. /**
  126795. * @hidden
  126796. */
  126797. export interface IMaterialAnisotropicDefines {
  126798. ANISOTROPIC: boolean;
  126799. ANISOTROPIC_TEXTURE: boolean;
  126800. ANISOTROPIC_TEXTUREDIRECTUV: number;
  126801. MAINUV1: boolean;
  126802. _areTexturesDirty: boolean;
  126803. _needUVs: boolean;
  126804. }
  126805. /**
  126806. * Define the code related to the anisotropic parameters of the pbr material.
  126807. */
  126808. export class PBRAnisotropicConfiguration {
  126809. private _isEnabled;
  126810. /**
  126811. * Defines if the anisotropy is enabled in the material.
  126812. */
  126813. isEnabled: boolean;
  126814. /**
  126815. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  126816. */
  126817. intensity: number;
  126818. /**
  126819. * Defines if the effect is along the tangents, bitangents or in between.
  126820. * By default, the effect is "strectching" the highlights along the tangents.
  126821. */
  126822. direction: Vector2;
  126823. private _texture;
  126824. /**
  126825. * Stores the anisotropy values in a texture.
  126826. * rg is direction (like normal from -1 to 1)
  126827. * b is a intensity
  126828. */
  126829. texture: Nullable<BaseTexture>;
  126830. /** @hidden */
  126831. private _internalMarkAllSubMeshesAsTexturesDirty;
  126832. /** @hidden */
  126833. _markAllSubMeshesAsTexturesDirty(): void;
  126834. /**
  126835. * Instantiate a new istance of anisotropy configuration.
  126836. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  126837. */
  126838. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  126839. /**
  126840. * Specifies that the submesh is ready to be used.
  126841. * @param defines the list of "defines" to update.
  126842. * @param scene defines the scene the material belongs to.
  126843. * @returns - boolean indicating that the submesh is ready or not.
  126844. */
  126845. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  126846. /**
  126847. * Checks to see if a texture is used in the material.
  126848. * @param defines the list of "defines" to update.
  126849. * @param mesh the mesh we are preparing the defines for.
  126850. * @param scene defines the scene the material belongs to.
  126851. */
  126852. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  126853. /**
  126854. * Binds the material data.
  126855. * @param uniformBuffer defines the Uniform buffer to fill in.
  126856. * @param scene defines the scene the material belongs to.
  126857. * @param isFrozen defines wether the material is frozen or not.
  126858. */
  126859. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  126860. /**
  126861. * Checks to see if a texture is used in the material.
  126862. * @param texture - Base texture to use.
  126863. * @returns - Boolean specifying if a texture is used in the material.
  126864. */
  126865. hasTexture(texture: BaseTexture): boolean;
  126866. /**
  126867. * Returns an array of the actively used textures.
  126868. * @param activeTextures Array of BaseTextures
  126869. */
  126870. getActiveTextures(activeTextures: BaseTexture[]): void;
  126871. /**
  126872. * Returns the animatable textures.
  126873. * @param animatables Array of animatable textures.
  126874. */
  126875. getAnimatables(animatables: IAnimatable[]): void;
  126876. /**
  126877. * Disposes the resources of the material.
  126878. * @param forceDisposeTextures - Forces the disposal of all textures.
  126879. */
  126880. dispose(forceDisposeTextures?: boolean): void;
  126881. /**
  126882. * Get the current class name of the texture useful for serialization or dynamic coding.
  126883. * @returns "PBRAnisotropicConfiguration"
  126884. */
  126885. getClassName(): string;
  126886. /**
  126887. * Add fallbacks to the effect fallbacks list.
  126888. * @param defines defines the Base texture to use.
  126889. * @param fallbacks defines the current fallback list.
  126890. * @param currentRank defines the current fallback rank.
  126891. * @returns the new fallback rank.
  126892. */
  126893. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  126894. /**
  126895. * Add the required uniforms to the current list.
  126896. * @param uniforms defines the current uniform list.
  126897. */
  126898. static AddUniforms(uniforms: string[]): void;
  126899. /**
  126900. * Add the required uniforms to the current buffer.
  126901. * @param uniformBuffer defines the current uniform buffer.
  126902. */
  126903. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  126904. /**
  126905. * Add the required samplers to the current list.
  126906. * @param samplers defines the current sampler list.
  126907. */
  126908. static AddSamplers(samplers: string[]): void;
  126909. /**
  126910. * Makes a duplicate of the current configuration into another one.
  126911. * @param anisotropicConfiguration define the config where to copy the info
  126912. */
  126913. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  126914. /**
  126915. * Serializes this anisotropy configuration.
  126916. * @returns - An object with the serialized config.
  126917. */
  126918. serialize(): any;
  126919. /**
  126920. * Parses a anisotropy Configuration from a serialized object.
  126921. * @param source - Serialized object.
  126922. * @param scene Defines the scene we are parsing for
  126923. * @param rootUrl Defines the rootUrl to load from
  126924. */
  126925. parse(source: any, scene: Scene, rootUrl: string): void;
  126926. }
  126927. }
  126928. declare module BABYLON {
  126929. /**
  126930. * @hidden
  126931. */
  126932. export interface IMaterialBRDFDefines {
  126933. BRDF_V_HEIGHT_CORRELATED: boolean;
  126934. MS_BRDF_ENERGY_CONSERVATION: boolean;
  126935. SPHERICAL_HARMONICS: boolean;
  126936. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  126937. /** @hidden */
  126938. _areMiscDirty: boolean;
  126939. }
  126940. /**
  126941. * Define the code related to the BRDF parameters of the pbr material.
  126942. */
  126943. export class PBRBRDFConfiguration {
  126944. /**
  126945. * Default value used for the energy conservation.
  126946. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  126947. */
  126948. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  126949. /**
  126950. * Default value used for the Smith Visibility Height Correlated mode.
  126951. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  126952. */
  126953. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  126954. /**
  126955. * Default value used for the IBL diffuse part.
  126956. * This can help switching back to the polynomials mode globally which is a tiny bit
  126957. * less GPU intensive at the drawback of a lower quality.
  126958. */
  126959. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  126960. /**
  126961. * Default value used for activating energy conservation for the specular workflow.
  126962. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  126963. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  126964. */
  126965. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  126966. private _useEnergyConservation;
  126967. /**
  126968. * Defines if the material uses energy conservation.
  126969. */
  126970. useEnergyConservation: boolean;
  126971. private _useSmithVisibilityHeightCorrelated;
  126972. /**
  126973. * LEGACY Mode set to false
  126974. * Defines if the material uses height smith correlated visibility term.
  126975. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  126976. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  126977. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  126978. * Not relying on height correlated will also disable energy conservation.
  126979. */
  126980. useSmithVisibilityHeightCorrelated: boolean;
  126981. private _useSphericalHarmonics;
  126982. /**
  126983. * LEGACY Mode set to false
  126984. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  126985. * diffuse part of the IBL.
  126986. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  126987. * to the ground truth.
  126988. */
  126989. useSphericalHarmonics: boolean;
  126990. private _useSpecularGlossinessInputEnergyConservation;
  126991. /**
  126992. * Defines if the material uses energy conservation, when the specular workflow is active.
  126993. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  126994. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  126995. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  126996. */
  126997. useSpecularGlossinessInputEnergyConservation: boolean;
  126998. /** @hidden */
  126999. private _internalMarkAllSubMeshesAsMiscDirty;
  127000. /** @hidden */
  127001. _markAllSubMeshesAsMiscDirty(): void;
  127002. /**
  127003. * Instantiate a new istance of clear coat configuration.
  127004. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  127005. */
  127006. constructor(markAllSubMeshesAsMiscDirty: () => void);
  127007. /**
  127008. * Checks to see if a texture is used in the material.
  127009. * @param defines the list of "defines" to update.
  127010. */
  127011. prepareDefines(defines: IMaterialBRDFDefines): void;
  127012. /**
  127013. * Get the current class name of the texture useful for serialization or dynamic coding.
  127014. * @returns "PBRClearCoatConfiguration"
  127015. */
  127016. getClassName(): string;
  127017. /**
  127018. * Makes a duplicate of the current configuration into another one.
  127019. * @param brdfConfiguration define the config where to copy the info
  127020. */
  127021. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  127022. /**
  127023. * Serializes this BRDF configuration.
  127024. * @returns - An object with the serialized config.
  127025. */
  127026. serialize(): any;
  127027. /**
  127028. * Parses a anisotropy Configuration from a serialized object.
  127029. * @param source - Serialized object.
  127030. * @param scene Defines the scene we are parsing for
  127031. * @param rootUrl Defines the rootUrl to load from
  127032. */
  127033. parse(source: any, scene: Scene, rootUrl: string): void;
  127034. }
  127035. }
  127036. declare module BABYLON {
  127037. /**
  127038. * @hidden
  127039. */
  127040. export interface IMaterialSheenDefines {
  127041. SHEEN: boolean;
  127042. SHEEN_TEXTURE: boolean;
  127043. SHEEN_TEXTUREDIRECTUV: number;
  127044. SHEEN_LINKWITHALBEDO: boolean;
  127045. SHEEN_ROUGHNESS: boolean;
  127046. SHEEN_ALBEDOSCALING: boolean;
  127047. /** @hidden */
  127048. _areTexturesDirty: boolean;
  127049. }
  127050. /**
  127051. * Define the code related to the Sheen parameters of the pbr material.
  127052. */
  127053. export class PBRSheenConfiguration {
  127054. private _isEnabled;
  127055. /**
  127056. * Defines if the material uses sheen.
  127057. */
  127058. isEnabled: boolean;
  127059. private _linkSheenWithAlbedo;
  127060. /**
  127061. * Defines if the sheen is linked to the sheen color.
  127062. */
  127063. linkSheenWithAlbedo: boolean;
  127064. /**
  127065. * Defines the sheen intensity.
  127066. */
  127067. intensity: number;
  127068. /**
  127069. * Defines the sheen color.
  127070. */
  127071. color: Color3;
  127072. private _texture;
  127073. /**
  127074. * Stores the sheen tint values in a texture.
  127075. * rgb is tint
  127076. * a is a intensity
  127077. */
  127078. texture: Nullable<BaseTexture>;
  127079. private _roughness;
  127080. /**
  127081. * Defines the sheen roughness.
  127082. * It is not taken into account if linkSheenWithAlbedo is true.
  127083. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  127084. */
  127085. roughness: Nullable<number>;
  127086. private _albedoScaling;
  127087. /**
  127088. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  127089. * It allows the strength of the sheen effect to not depend on the base color of the material,
  127090. * making it easier to setup and tweak the effect
  127091. */
  127092. albedoScaling: boolean;
  127093. /** @hidden */
  127094. private _internalMarkAllSubMeshesAsTexturesDirty;
  127095. /** @hidden */
  127096. _markAllSubMeshesAsTexturesDirty(): void;
  127097. /**
  127098. * Instantiate a new istance of clear coat configuration.
  127099. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  127100. */
  127101. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  127102. /**
  127103. * Specifies that the submesh is ready to be used.
  127104. * @param defines the list of "defines" to update.
  127105. * @param scene defines the scene the material belongs to.
  127106. * @returns - boolean indicating that the submesh is ready or not.
  127107. */
  127108. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  127109. /**
  127110. * Checks to see if a texture is used in the material.
  127111. * @param defines the list of "defines" to update.
  127112. * @param scene defines the scene the material belongs to.
  127113. */
  127114. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  127115. /**
  127116. * Binds the material data.
  127117. * @param uniformBuffer defines the Uniform buffer to fill in.
  127118. * @param scene defines the scene the material belongs to.
  127119. * @param isFrozen defines wether the material is frozen or not.
  127120. */
  127121. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  127122. /**
  127123. * Checks to see if a texture is used in the material.
  127124. * @param texture - Base texture to use.
  127125. * @returns - Boolean specifying if a texture is used in the material.
  127126. */
  127127. hasTexture(texture: BaseTexture): boolean;
  127128. /**
  127129. * Returns an array of the actively used textures.
  127130. * @param activeTextures Array of BaseTextures
  127131. */
  127132. getActiveTextures(activeTextures: BaseTexture[]): void;
  127133. /**
  127134. * Returns the animatable textures.
  127135. * @param animatables Array of animatable textures.
  127136. */
  127137. getAnimatables(animatables: IAnimatable[]): void;
  127138. /**
  127139. * Disposes the resources of the material.
  127140. * @param forceDisposeTextures - Forces the disposal of all textures.
  127141. */
  127142. dispose(forceDisposeTextures?: boolean): void;
  127143. /**
  127144. * Get the current class name of the texture useful for serialization or dynamic coding.
  127145. * @returns "PBRSheenConfiguration"
  127146. */
  127147. getClassName(): string;
  127148. /**
  127149. * Add fallbacks to the effect fallbacks list.
  127150. * @param defines defines the Base texture to use.
  127151. * @param fallbacks defines the current fallback list.
  127152. * @param currentRank defines the current fallback rank.
  127153. * @returns the new fallback rank.
  127154. */
  127155. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  127156. /**
  127157. * Add the required uniforms to the current list.
  127158. * @param uniforms defines the current uniform list.
  127159. */
  127160. static AddUniforms(uniforms: string[]): void;
  127161. /**
  127162. * Add the required uniforms to the current buffer.
  127163. * @param uniformBuffer defines the current uniform buffer.
  127164. */
  127165. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  127166. /**
  127167. * Add the required samplers to the current list.
  127168. * @param samplers defines the current sampler list.
  127169. */
  127170. static AddSamplers(samplers: string[]): void;
  127171. /**
  127172. * Makes a duplicate of the current configuration into another one.
  127173. * @param sheenConfiguration define the config where to copy the info
  127174. */
  127175. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  127176. /**
  127177. * Serializes this BRDF configuration.
  127178. * @returns - An object with the serialized config.
  127179. */
  127180. serialize(): any;
  127181. /**
  127182. * Parses a anisotropy Configuration from a serialized object.
  127183. * @param source - Serialized object.
  127184. * @param scene Defines the scene we are parsing for
  127185. * @param rootUrl Defines the rootUrl to load from
  127186. */
  127187. parse(source: any, scene: Scene, rootUrl: string): void;
  127188. }
  127189. }
  127190. declare module BABYLON {
  127191. /**
  127192. * @hidden
  127193. */
  127194. export interface IMaterialSubSurfaceDefines {
  127195. SUBSURFACE: boolean;
  127196. SS_REFRACTION: boolean;
  127197. SS_TRANSLUCENCY: boolean;
  127198. SS_SCATERRING: boolean;
  127199. SS_THICKNESSANDMASK_TEXTURE: boolean;
  127200. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  127201. SS_REFRACTIONMAP_3D: boolean;
  127202. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  127203. SS_LODINREFRACTIONALPHA: boolean;
  127204. SS_GAMMAREFRACTION: boolean;
  127205. SS_RGBDREFRACTION: boolean;
  127206. SS_LINEARSPECULARREFRACTION: boolean;
  127207. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  127208. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  127209. /** @hidden */
  127210. _areTexturesDirty: boolean;
  127211. }
  127212. /**
  127213. * Define the code related to the sub surface parameters of the pbr material.
  127214. */
  127215. export class PBRSubSurfaceConfiguration {
  127216. private _isRefractionEnabled;
  127217. /**
  127218. * Defines if the refraction is enabled in the material.
  127219. */
  127220. isRefractionEnabled: boolean;
  127221. private _isTranslucencyEnabled;
  127222. /**
  127223. * Defines if the translucency is enabled in the material.
  127224. */
  127225. isTranslucencyEnabled: boolean;
  127226. private _isScatteringEnabled;
  127227. /**
  127228. * Defines the refraction intensity of the material.
  127229. * The refraction when enabled replaces the Diffuse part of the material.
  127230. * The intensity helps transitionning between diffuse and refraction.
  127231. */
  127232. refractionIntensity: number;
  127233. /**
  127234. * Defines the translucency intensity of the material.
  127235. * When translucency has been enabled, this defines how much of the "translucency"
  127236. * is addded to the diffuse part of the material.
  127237. */
  127238. translucencyIntensity: number;
  127239. /**
  127240. * Defines the scattering intensity of the material.
  127241. * When scattering has been enabled, this defines how much of the "scattered light"
  127242. * is addded to the diffuse part of the material.
  127243. */
  127244. scatteringIntensity: number;
  127245. private _thicknessTexture;
  127246. /**
  127247. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  127248. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  127249. * 0 would mean minimumThickness
  127250. * 1 would mean maximumThickness
  127251. * The other channels might be use as a mask to vary the different effects intensity.
  127252. */
  127253. thicknessTexture: Nullable<BaseTexture>;
  127254. private _refractionTexture;
  127255. /**
  127256. * Defines the texture to use for refraction.
  127257. */
  127258. refractionTexture: Nullable<BaseTexture>;
  127259. private _indexOfRefraction;
  127260. /**
  127261. * Defines the index of refraction used in the material.
  127262. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  127263. */
  127264. indexOfRefraction: number;
  127265. private _invertRefractionY;
  127266. /**
  127267. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  127268. */
  127269. invertRefractionY: boolean;
  127270. private _linkRefractionWithTransparency;
  127271. /**
  127272. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  127273. * Materials half opaque for instance using refraction could benefit from this control.
  127274. */
  127275. linkRefractionWithTransparency: boolean;
  127276. /**
  127277. * Defines the minimum thickness stored in the thickness map.
  127278. * If no thickness map is defined, this value will be used to simulate thickness.
  127279. */
  127280. minimumThickness: number;
  127281. /**
  127282. * Defines the maximum thickness stored in the thickness map.
  127283. */
  127284. maximumThickness: number;
  127285. /**
  127286. * Defines the volume tint of the material.
  127287. * This is used for both translucency and scattering.
  127288. */
  127289. tintColor: Color3;
  127290. /**
  127291. * Defines the distance at which the tint color should be found in the media.
  127292. * This is used for refraction only.
  127293. */
  127294. tintColorAtDistance: number;
  127295. /**
  127296. * Defines how far each channel transmit through the media.
  127297. * It is defined as a color to simplify it selection.
  127298. */
  127299. diffusionDistance: Color3;
  127300. private _useMaskFromThicknessTexture;
  127301. /**
  127302. * Stores the intensity of the different subsurface effects in the thickness texture.
  127303. * * the green channel is the translucency intensity.
  127304. * * the blue channel is the scattering intensity.
  127305. * * the alpha channel is the refraction intensity.
  127306. */
  127307. useMaskFromThicknessTexture: boolean;
  127308. /** @hidden */
  127309. private _internalMarkAllSubMeshesAsTexturesDirty;
  127310. /** @hidden */
  127311. _markAllSubMeshesAsTexturesDirty(): void;
  127312. /**
  127313. * Instantiate a new istance of sub surface configuration.
  127314. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  127315. */
  127316. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  127317. /**
  127318. * Gets wehter the submesh is ready to be used or not.
  127319. * @param defines the list of "defines" to update.
  127320. * @param scene defines the scene the material belongs to.
  127321. * @returns - boolean indicating that the submesh is ready or not.
  127322. */
  127323. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  127324. /**
  127325. * Checks to see if a texture is used in the material.
  127326. * @param defines the list of "defines" to update.
  127327. * @param scene defines the scene to the material belongs to.
  127328. */
  127329. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  127330. /**
  127331. * Binds the material data.
  127332. * @param uniformBuffer defines the Uniform buffer to fill in.
  127333. * @param scene defines the scene the material belongs to.
  127334. * @param engine defines the engine the material belongs to.
  127335. * @param isFrozen defines wether the material is frozen or not.
  127336. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  127337. */
  127338. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  127339. /**
  127340. * Unbinds the material from the mesh.
  127341. * @param activeEffect defines the effect that should be unbound from.
  127342. * @returns true if unbound, otherwise false
  127343. */
  127344. unbind(activeEffect: Effect): boolean;
  127345. /**
  127346. * Returns the texture used for refraction or null if none is used.
  127347. * @param scene defines the scene the material belongs to.
  127348. * @returns - Refraction texture if present. If no refraction texture and refraction
  127349. * is linked with transparency, returns environment texture. Otherwise, returns null.
  127350. */
  127351. private _getRefractionTexture;
  127352. /**
  127353. * Returns true if alpha blending should be disabled.
  127354. */
  127355. get disableAlphaBlending(): boolean;
  127356. /**
  127357. * Fills the list of render target textures.
  127358. * @param renderTargets the list of render targets to update
  127359. */
  127360. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  127361. /**
  127362. * Checks to see if a texture is used in the material.
  127363. * @param texture - Base texture to use.
  127364. * @returns - Boolean specifying if a texture is used in the material.
  127365. */
  127366. hasTexture(texture: BaseTexture): boolean;
  127367. /**
  127368. * Gets a boolean indicating that current material needs to register RTT
  127369. * @returns true if this uses a render target otherwise false.
  127370. */
  127371. hasRenderTargetTextures(): boolean;
  127372. /**
  127373. * Returns an array of the actively used textures.
  127374. * @param activeTextures Array of BaseTextures
  127375. */
  127376. getActiveTextures(activeTextures: BaseTexture[]): void;
  127377. /**
  127378. * Returns the animatable textures.
  127379. * @param animatables Array of animatable textures.
  127380. */
  127381. getAnimatables(animatables: IAnimatable[]): void;
  127382. /**
  127383. * Disposes the resources of the material.
  127384. * @param forceDisposeTextures - Forces the disposal of all textures.
  127385. */
  127386. dispose(forceDisposeTextures?: boolean): void;
  127387. /**
  127388. * Get the current class name of the texture useful for serialization or dynamic coding.
  127389. * @returns "PBRSubSurfaceConfiguration"
  127390. */
  127391. getClassName(): string;
  127392. /**
  127393. * Add fallbacks to the effect fallbacks list.
  127394. * @param defines defines the Base texture to use.
  127395. * @param fallbacks defines the current fallback list.
  127396. * @param currentRank defines the current fallback rank.
  127397. * @returns the new fallback rank.
  127398. */
  127399. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  127400. /**
  127401. * Add the required uniforms to the current list.
  127402. * @param uniforms defines the current uniform list.
  127403. */
  127404. static AddUniforms(uniforms: string[]): void;
  127405. /**
  127406. * Add the required samplers to the current list.
  127407. * @param samplers defines the current sampler list.
  127408. */
  127409. static AddSamplers(samplers: string[]): void;
  127410. /**
  127411. * Add the required uniforms to the current buffer.
  127412. * @param uniformBuffer defines the current uniform buffer.
  127413. */
  127414. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  127415. /**
  127416. * Makes a duplicate of the current configuration into another one.
  127417. * @param configuration define the config where to copy the info
  127418. */
  127419. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  127420. /**
  127421. * Serializes this Sub Surface configuration.
  127422. * @returns - An object with the serialized config.
  127423. */
  127424. serialize(): any;
  127425. /**
  127426. * Parses a anisotropy Configuration from a serialized object.
  127427. * @param source - Serialized object.
  127428. * @param scene Defines the scene we are parsing for
  127429. * @param rootUrl Defines the rootUrl to load from
  127430. */
  127431. parse(source: any, scene: Scene, rootUrl: string): void;
  127432. }
  127433. }
  127434. declare module BABYLON {
  127435. /** @hidden */
  127436. export var pbrFragmentDeclaration: {
  127437. name: string;
  127438. shader: string;
  127439. };
  127440. }
  127441. declare module BABYLON {
  127442. /** @hidden */
  127443. export var pbrUboDeclaration: {
  127444. name: string;
  127445. shader: string;
  127446. };
  127447. }
  127448. declare module BABYLON {
  127449. /** @hidden */
  127450. export var pbrFragmentExtraDeclaration: {
  127451. name: string;
  127452. shader: string;
  127453. };
  127454. }
  127455. declare module BABYLON {
  127456. /** @hidden */
  127457. export var pbrFragmentSamplersDeclaration: {
  127458. name: string;
  127459. shader: string;
  127460. };
  127461. }
  127462. declare module BABYLON {
  127463. /** @hidden */
  127464. export var pbrHelperFunctions: {
  127465. name: string;
  127466. shader: string;
  127467. };
  127468. }
  127469. declare module BABYLON {
  127470. /** @hidden */
  127471. export var harmonicsFunctions: {
  127472. name: string;
  127473. shader: string;
  127474. };
  127475. }
  127476. declare module BABYLON {
  127477. /** @hidden */
  127478. export var pbrDirectLightingSetupFunctions: {
  127479. name: string;
  127480. shader: string;
  127481. };
  127482. }
  127483. declare module BABYLON {
  127484. /** @hidden */
  127485. export var pbrDirectLightingFalloffFunctions: {
  127486. name: string;
  127487. shader: string;
  127488. };
  127489. }
  127490. declare module BABYLON {
  127491. /** @hidden */
  127492. export var pbrBRDFFunctions: {
  127493. name: string;
  127494. shader: string;
  127495. };
  127496. }
  127497. declare module BABYLON {
  127498. /** @hidden */
  127499. export var pbrDirectLightingFunctions: {
  127500. name: string;
  127501. shader: string;
  127502. };
  127503. }
  127504. declare module BABYLON {
  127505. /** @hidden */
  127506. export var pbrIBLFunctions: {
  127507. name: string;
  127508. shader: string;
  127509. };
  127510. }
  127511. declare module BABYLON {
  127512. /** @hidden */
  127513. export var pbrBlockAlbedoOpacity: {
  127514. name: string;
  127515. shader: string;
  127516. };
  127517. }
  127518. declare module BABYLON {
  127519. /** @hidden */
  127520. export var pbrBlockReflectivity: {
  127521. name: string;
  127522. shader: string;
  127523. };
  127524. }
  127525. declare module BABYLON {
  127526. /** @hidden */
  127527. export var pbrBlockAmbientOcclusion: {
  127528. name: string;
  127529. shader: string;
  127530. };
  127531. }
  127532. declare module BABYLON {
  127533. /** @hidden */
  127534. export var pbrBlockAlphaFresnel: {
  127535. name: string;
  127536. shader: string;
  127537. };
  127538. }
  127539. declare module BABYLON {
  127540. /** @hidden */
  127541. export var pbrBlockAnisotropic: {
  127542. name: string;
  127543. shader: string;
  127544. };
  127545. }
  127546. declare module BABYLON {
  127547. /** @hidden */
  127548. export var pbrBlockReflection: {
  127549. name: string;
  127550. shader: string;
  127551. };
  127552. }
  127553. declare module BABYLON {
  127554. /** @hidden */
  127555. export var pbrBlockSheen: {
  127556. name: string;
  127557. shader: string;
  127558. };
  127559. }
  127560. declare module BABYLON {
  127561. /** @hidden */
  127562. export var pbrBlockClearcoat: {
  127563. name: string;
  127564. shader: string;
  127565. };
  127566. }
  127567. declare module BABYLON {
  127568. /** @hidden */
  127569. export var pbrBlockSubSurface: {
  127570. name: string;
  127571. shader: string;
  127572. };
  127573. }
  127574. declare module BABYLON {
  127575. /** @hidden */
  127576. export var pbrBlockNormalGeometric: {
  127577. name: string;
  127578. shader: string;
  127579. };
  127580. }
  127581. declare module BABYLON {
  127582. /** @hidden */
  127583. export var pbrBlockNormalFinal: {
  127584. name: string;
  127585. shader: string;
  127586. };
  127587. }
  127588. declare module BABYLON {
  127589. /** @hidden */
  127590. export var pbrBlockGeometryInfo: {
  127591. name: string;
  127592. shader: string;
  127593. };
  127594. }
  127595. declare module BABYLON {
  127596. /** @hidden */
  127597. export var pbrBlockReflectance0: {
  127598. name: string;
  127599. shader: string;
  127600. };
  127601. }
  127602. declare module BABYLON {
  127603. /** @hidden */
  127604. export var pbrBlockReflectance: {
  127605. name: string;
  127606. shader: string;
  127607. };
  127608. }
  127609. declare module BABYLON {
  127610. /** @hidden */
  127611. export var pbrBlockDirectLighting: {
  127612. name: string;
  127613. shader: string;
  127614. };
  127615. }
  127616. declare module BABYLON {
  127617. /** @hidden */
  127618. export var pbrBlockFinalLitComponents: {
  127619. name: string;
  127620. shader: string;
  127621. };
  127622. }
  127623. declare module BABYLON {
  127624. /** @hidden */
  127625. export var pbrBlockFinalUnlitComponents: {
  127626. name: string;
  127627. shader: string;
  127628. };
  127629. }
  127630. declare module BABYLON {
  127631. /** @hidden */
  127632. export var pbrBlockFinalColorComposition: {
  127633. name: string;
  127634. shader: string;
  127635. };
  127636. }
  127637. declare module BABYLON {
  127638. /** @hidden */
  127639. export var pbrBlockImageProcessing: {
  127640. name: string;
  127641. shader: string;
  127642. };
  127643. }
  127644. declare module BABYLON {
  127645. /** @hidden */
  127646. export var pbrDebug: {
  127647. name: string;
  127648. shader: string;
  127649. };
  127650. }
  127651. declare module BABYLON {
  127652. /** @hidden */
  127653. export var pbrPixelShader: {
  127654. name: string;
  127655. shader: string;
  127656. };
  127657. }
  127658. declare module BABYLON {
  127659. /** @hidden */
  127660. export var pbrVertexDeclaration: {
  127661. name: string;
  127662. shader: string;
  127663. };
  127664. }
  127665. declare module BABYLON {
  127666. /** @hidden */
  127667. export var pbrVertexShader: {
  127668. name: string;
  127669. shader: string;
  127670. };
  127671. }
  127672. declare module BABYLON {
  127673. /**
  127674. * Manages the defines for the PBR Material.
  127675. * @hidden
  127676. */
  127677. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  127678. PBR: boolean;
  127679. MAINUV1: boolean;
  127680. MAINUV2: boolean;
  127681. UV1: boolean;
  127682. UV2: boolean;
  127683. ALBEDO: boolean;
  127684. GAMMAALBEDO: boolean;
  127685. ALBEDODIRECTUV: number;
  127686. VERTEXCOLOR: boolean;
  127687. AMBIENT: boolean;
  127688. AMBIENTDIRECTUV: number;
  127689. AMBIENTINGRAYSCALE: boolean;
  127690. OPACITY: boolean;
  127691. VERTEXALPHA: boolean;
  127692. OPACITYDIRECTUV: number;
  127693. OPACITYRGB: boolean;
  127694. ALPHATEST: boolean;
  127695. DEPTHPREPASS: boolean;
  127696. ALPHABLEND: boolean;
  127697. ALPHAFROMALBEDO: boolean;
  127698. ALPHATESTVALUE: string;
  127699. SPECULAROVERALPHA: boolean;
  127700. RADIANCEOVERALPHA: boolean;
  127701. ALPHAFRESNEL: boolean;
  127702. LINEARALPHAFRESNEL: boolean;
  127703. PREMULTIPLYALPHA: boolean;
  127704. EMISSIVE: boolean;
  127705. EMISSIVEDIRECTUV: number;
  127706. REFLECTIVITY: boolean;
  127707. REFLECTIVITYDIRECTUV: number;
  127708. SPECULARTERM: boolean;
  127709. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  127710. MICROSURFACEAUTOMATIC: boolean;
  127711. LODBASEDMICROSFURACE: boolean;
  127712. MICROSURFACEMAP: boolean;
  127713. MICROSURFACEMAPDIRECTUV: number;
  127714. METALLICWORKFLOW: boolean;
  127715. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  127716. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  127717. METALLNESSSTOREINMETALMAPBLUE: boolean;
  127718. AOSTOREINMETALMAPRED: boolean;
  127719. METALLICF0FACTORFROMMETALLICMAP: boolean;
  127720. ENVIRONMENTBRDF: boolean;
  127721. ENVIRONMENTBRDF_RGBD: boolean;
  127722. NORMAL: boolean;
  127723. TANGENT: boolean;
  127724. BUMP: boolean;
  127725. BUMPDIRECTUV: number;
  127726. OBJECTSPACE_NORMALMAP: boolean;
  127727. PARALLAX: boolean;
  127728. PARALLAXOCCLUSION: boolean;
  127729. NORMALXYSCALE: boolean;
  127730. LIGHTMAP: boolean;
  127731. LIGHTMAPDIRECTUV: number;
  127732. USELIGHTMAPASSHADOWMAP: boolean;
  127733. GAMMALIGHTMAP: boolean;
  127734. RGBDLIGHTMAP: boolean;
  127735. REFLECTION: boolean;
  127736. REFLECTIONMAP_3D: boolean;
  127737. REFLECTIONMAP_SPHERICAL: boolean;
  127738. REFLECTIONMAP_PLANAR: boolean;
  127739. REFLECTIONMAP_CUBIC: boolean;
  127740. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  127741. REFLECTIONMAP_PROJECTION: boolean;
  127742. REFLECTIONMAP_SKYBOX: boolean;
  127743. REFLECTIONMAP_EXPLICIT: boolean;
  127744. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  127745. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  127746. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  127747. INVERTCUBICMAP: boolean;
  127748. USESPHERICALFROMREFLECTIONMAP: boolean;
  127749. USEIRRADIANCEMAP: boolean;
  127750. SPHERICAL_HARMONICS: boolean;
  127751. USESPHERICALINVERTEX: boolean;
  127752. REFLECTIONMAP_OPPOSITEZ: boolean;
  127753. LODINREFLECTIONALPHA: boolean;
  127754. GAMMAREFLECTION: boolean;
  127755. RGBDREFLECTION: boolean;
  127756. LINEARSPECULARREFLECTION: boolean;
  127757. RADIANCEOCCLUSION: boolean;
  127758. HORIZONOCCLUSION: boolean;
  127759. INSTANCES: boolean;
  127760. NUM_BONE_INFLUENCERS: number;
  127761. BonesPerMesh: number;
  127762. BONETEXTURE: boolean;
  127763. NONUNIFORMSCALING: boolean;
  127764. MORPHTARGETS: boolean;
  127765. MORPHTARGETS_NORMAL: boolean;
  127766. MORPHTARGETS_TANGENT: boolean;
  127767. MORPHTARGETS_UV: boolean;
  127768. NUM_MORPH_INFLUENCERS: number;
  127769. IMAGEPROCESSING: boolean;
  127770. VIGNETTE: boolean;
  127771. VIGNETTEBLENDMODEMULTIPLY: boolean;
  127772. VIGNETTEBLENDMODEOPAQUE: boolean;
  127773. TONEMAPPING: boolean;
  127774. TONEMAPPING_ACES: boolean;
  127775. CONTRAST: boolean;
  127776. COLORCURVES: boolean;
  127777. COLORGRADING: boolean;
  127778. COLORGRADING3D: boolean;
  127779. SAMPLER3DGREENDEPTH: boolean;
  127780. SAMPLER3DBGRMAP: boolean;
  127781. IMAGEPROCESSINGPOSTPROCESS: boolean;
  127782. EXPOSURE: boolean;
  127783. MULTIVIEW: boolean;
  127784. USEPHYSICALLIGHTFALLOFF: boolean;
  127785. USEGLTFLIGHTFALLOFF: boolean;
  127786. TWOSIDEDLIGHTING: boolean;
  127787. SHADOWFLOAT: boolean;
  127788. CLIPPLANE: boolean;
  127789. CLIPPLANE2: boolean;
  127790. CLIPPLANE3: boolean;
  127791. CLIPPLANE4: boolean;
  127792. CLIPPLANE5: boolean;
  127793. CLIPPLANE6: boolean;
  127794. POINTSIZE: boolean;
  127795. FOG: boolean;
  127796. LOGARITHMICDEPTH: boolean;
  127797. FORCENORMALFORWARD: boolean;
  127798. SPECULARAA: boolean;
  127799. CLEARCOAT: boolean;
  127800. CLEARCOAT_DEFAULTIOR: boolean;
  127801. CLEARCOAT_TEXTURE: boolean;
  127802. CLEARCOAT_TEXTUREDIRECTUV: number;
  127803. CLEARCOAT_BUMP: boolean;
  127804. CLEARCOAT_BUMPDIRECTUV: number;
  127805. CLEARCOAT_TINT: boolean;
  127806. CLEARCOAT_TINT_TEXTURE: boolean;
  127807. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  127808. ANISOTROPIC: boolean;
  127809. ANISOTROPIC_TEXTURE: boolean;
  127810. ANISOTROPIC_TEXTUREDIRECTUV: number;
  127811. BRDF_V_HEIGHT_CORRELATED: boolean;
  127812. MS_BRDF_ENERGY_CONSERVATION: boolean;
  127813. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  127814. SHEEN: boolean;
  127815. SHEEN_TEXTURE: boolean;
  127816. SHEEN_TEXTUREDIRECTUV: number;
  127817. SHEEN_LINKWITHALBEDO: boolean;
  127818. SHEEN_ROUGHNESS: boolean;
  127819. SHEEN_ALBEDOSCALING: boolean;
  127820. SUBSURFACE: boolean;
  127821. SS_REFRACTION: boolean;
  127822. SS_TRANSLUCENCY: boolean;
  127823. SS_SCATERRING: boolean;
  127824. SS_THICKNESSANDMASK_TEXTURE: boolean;
  127825. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  127826. SS_REFRACTIONMAP_3D: boolean;
  127827. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  127828. SS_LODINREFRACTIONALPHA: boolean;
  127829. SS_GAMMAREFRACTION: boolean;
  127830. SS_RGBDREFRACTION: boolean;
  127831. SS_LINEARSPECULARREFRACTION: boolean;
  127832. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  127833. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  127834. UNLIT: boolean;
  127835. DEBUGMODE: number;
  127836. /**
  127837. * Initializes the PBR Material defines.
  127838. */
  127839. constructor();
  127840. /**
  127841. * Resets the PBR Material defines.
  127842. */
  127843. reset(): void;
  127844. }
  127845. /**
  127846. * The Physically based material base class of BJS.
  127847. *
  127848. * This offers the main features of a standard PBR material.
  127849. * For more information, please refer to the documentation :
  127850. * https://doc.babylonjs.com/how_to/physically_based_rendering
  127851. */
  127852. export abstract class PBRBaseMaterial extends PushMaterial {
  127853. /**
  127854. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  127855. */
  127856. static readonly PBRMATERIAL_OPAQUE: number;
  127857. /**
  127858. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  127859. */
  127860. static readonly PBRMATERIAL_ALPHATEST: number;
  127861. /**
  127862. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  127863. */
  127864. static readonly PBRMATERIAL_ALPHABLEND: number;
  127865. /**
  127866. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  127867. * They are also discarded below the alpha cutoff threshold to improve performances.
  127868. */
  127869. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  127870. /**
  127871. * Defines the default value of how much AO map is occluding the analytical lights
  127872. * (point spot...).
  127873. */
  127874. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  127875. /**
  127876. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  127877. */
  127878. static readonly LIGHTFALLOFF_PHYSICAL: number;
  127879. /**
  127880. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  127881. * to enhance interoperability with other engines.
  127882. */
  127883. static readonly LIGHTFALLOFF_GLTF: number;
  127884. /**
  127885. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  127886. * to enhance interoperability with other materials.
  127887. */
  127888. static readonly LIGHTFALLOFF_STANDARD: number;
  127889. /**
  127890. * Intensity of the direct lights e.g. the four lights available in your scene.
  127891. * This impacts both the direct diffuse and specular highlights.
  127892. */
  127893. protected _directIntensity: number;
  127894. /**
  127895. * Intensity of the emissive part of the material.
  127896. * This helps controlling the emissive effect without modifying the emissive color.
  127897. */
  127898. protected _emissiveIntensity: number;
  127899. /**
  127900. * Intensity of the environment e.g. how much the environment will light the object
  127901. * either through harmonics for rough material or through the refelction for shiny ones.
  127902. */
  127903. protected _environmentIntensity: number;
  127904. /**
  127905. * This is a special control allowing the reduction of the specular highlights coming from the
  127906. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  127907. */
  127908. protected _specularIntensity: number;
  127909. /**
  127910. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  127911. */
  127912. private _lightingInfos;
  127913. /**
  127914. * Debug Control allowing disabling the bump map on this material.
  127915. */
  127916. protected _disableBumpMap: boolean;
  127917. /**
  127918. * AKA Diffuse Texture in standard nomenclature.
  127919. */
  127920. protected _albedoTexture: Nullable<BaseTexture>;
  127921. /**
  127922. * AKA Occlusion Texture in other nomenclature.
  127923. */
  127924. protected _ambientTexture: Nullable<BaseTexture>;
  127925. /**
  127926. * AKA Occlusion Texture Intensity in other nomenclature.
  127927. */
  127928. protected _ambientTextureStrength: number;
  127929. /**
  127930. * Defines how much the AO map is occluding the analytical lights (point spot...).
  127931. * 1 means it completely occludes it
  127932. * 0 mean it has no impact
  127933. */
  127934. protected _ambientTextureImpactOnAnalyticalLights: number;
  127935. /**
  127936. * Stores the alpha values in a texture.
  127937. */
  127938. protected _opacityTexture: Nullable<BaseTexture>;
  127939. /**
  127940. * Stores the reflection values in a texture.
  127941. */
  127942. protected _reflectionTexture: Nullable<BaseTexture>;
  127943. /**
  127944. * Stores the emissive values in a texture.
  127945. */
  127946. protected _emissiveTexture: Nullable<BaseTexture>;
  127947. /**
  127948. * AKA Specular texture in other nomenclature.
  127949. */
  127950. protected _reflectivityTexture: Nullable<BaseTexture>;
  127951. /**
  127952. * Used to switch from specular/glossiness to metallic/roughness workflow.
  127953. */
  127954. protected _metallicTexture: Nullable<BaseTexture>;
  127955. /**
  127956. * Specifies the metallic scalar of the metallic/roughness workflow.
  127957. * Can also be used to scale the metalness values of the metallic texture.
  127958. */
  127959. protected _metallic: Nullable<number>;
  127960. /**
  127961. * Specifies the roughness scalar of the metallic/roughness workflow.
  127962. * Can also be used to scale the roughness values of the metallic texture.
  127963. */
  127964. protected _roughness: Nullable<number>;
  127965. /**
  127966. * Specifies the an F0 factor to help configuring the material F0.
  127967. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  127968. * to 0.5 the previously hard coded value stays the same.
  127969. * Can also be used to scale the F0 values of the metallic texture.
  127970. */
  127971. protected _metallicF0Factor: number;
  127972. /**
  127973. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  127974. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  127975. * your expectation as it multiplies with the texture data.
  127976. */
  127977. protected _useMetallicF0FactorFromMetallicTexture: boolean;
  127978. /**
  127979. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  127980. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  127981. */
  127982. protected _microSurfaceTexture: Nullable<BaseTexture>;
  127983. /**
  127984. * Stores surface normal data used to displace a mesh in a texture.
  127985. */
  127986. protected _bumpTexture: Nullable<BaseTexture>;
  127987. /**
  127988. * Stores the pre-calculated light information of a mesh in a texture.
  127989. */
  127990. protected _lightmapTexture: Nullable<BaseTexture>;
  127991. /**
  127992. * The color of a material in ambient lighting.
  127993. */
  127994. protected _ambientColor: Color3;
  127995. /**
  127996. * AKA Diffuse Color in other nomenclature.
  127997. */
  127998. protected _albedoColor: Color3;
  127999. /**
  128000. * AKA Specular Color in other nomenclature.
  128001. */
  128002. protected _reflectivityColor: Color3;
  128003. /**
  128004. * The color applied when light is reflected from a material.
  128005. */
  128006. protected _reflectionColor: Color3;
  128007. /**
  128008. * The color applied when light is emitted from a material.
  128009. */
  128010. protected _emissiveColor: Color3;
  128011. /**
  128012. * AKA Glossiness in other nomenclature.
  128013. */
  128014. protected _microSurface: number;
  128015. /**
  128016. * Specifies that the material will use the light map as a show map.
  128017. */
  128018. protected _useLightmapAsShadowmap: boolean;
  128019. /**
  128020. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  128021. * makes the reflect vector face the model (under horizon).
  128022. */
  128023. protected _useHorizonOcclusion: boolean;
  128024. /**
  128025. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  128026. * too much the area relying on ambient texture to define their ambient occlusion.
  128027. */
  128028. protected _useRadianceOcclusion: boolean;
  128029. /**
  128030. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  128031. */
  128032. protected _useAlphaFromAlbedoTexture: boolean;
  128033. /**
  128034. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  128035. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  128036. */
  128037. protected _useSpecularOverAlpha: boolean;
  128038. /**
  128039. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  128040. */
  128041. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  128042. /**
  128043. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  128044. */
  128045. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  128046. /**
  128047. * Specifies if the metallic texture contains the roughness information in its green channel.
  128048. */
  128049. protected _useRoughnessFromMetallicTextureGreen: boolean;
  128050. /**
  128051. * Specifies if the metallic texture contains the metallness information in its blue channel.
  128052. */
  128053. protected _useMetallnessFromMetallicTextureBlue: boolean;
  128054. /**
  128055. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  128056. */
  128057. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  128058. /**
  128059. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  128060. */
  128061. protected _useAmbientInGrayScale: boolean;
  128062. /**
  128063. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  128064. * The material will try to infer what glossiness each pixel should be.
  128065. */
  128066. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  128067. /**
  128068. * Defines the falloff type used in this material.
  128069. * It by default is Physical.
  128070. */
  128071. protected _lightFalloff: number;
  128072. /**
  128073. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  128074. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  128075. */
  128076. protected _useRadianceOverAlpha: boolean;
  128077. /**
  128078. * Allows using an object space normal map (instead of tangent space).
  128079. */
  128080. protected _useObjectSpaceNormalMap: boolean;
  128081. /**
  128082. * Allows using the bump map in parallax mode.
  128083. */
  128084. protected _useParallax: boolean;
  128085. /**
  128086. * Allows using the bump map in parallax occlusion mode.
  128087. */
  128088. protected _useParallaxOcclusion: boolean;
  128089. /**
  128090. * Controls the scale bias of the parallax mode.
  128091. */
  128092. protected _parallaxScaleBias: number;
  128093. /**
  128094. * If sets to true, disables all the lights affecting the material.
  128095. */
  128096. protected _disableLighting: boolean;
  128097. /**
  128098. * Number of Simultaneous lights allowed on the material.
  128099. */
  128100. protected _maxSimultaneousLights: number;
  128101. /**
  128102. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  128103. */
  128104. protected _invertNormalMapX: boolean;
  128105. /**
  128106. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  128107. */
  128108. protected _invertNormalMapY: boolean;
  128109. /**
  128110. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  128111. */
  128112. protected _twoSidedLighting: boolean;
  128113. /**
  128114. * Defines the alpha limits in alpha test mode.
  128115. */
  128116. protected _alphaCutOff: number;
  128117. /**
  128118. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  128119. */
  128120. protected _forceAlphaTest: boolean;
  128121. /**
  128122. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  128123. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  128124. */
  128125. protected _useAlphaFresnel: boolean;
  128126. /**
  128127. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  128128. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  128129. */
  128130. protected _useLinearAlphaFresnel: boolean;
  128131. /**
  128132. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  128133. * from cos thetav and roughness:
  128134. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  128135. */
  128136. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  128137. /**
  128138. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  128139. */
  128140. protected _forceIrradianceInFragment: boolean;
  128141. /**
  128142. * Force normal to face away from face.
  128143. */
  128144. protected _forceNormalForward: boolean;
  128145. /**
  128146. * Enables specular anti aliasing in the PBR shader.
  128147. * It will both interacts on the Geometry for analytical and IBL lighting.
  128148. * It also prefilter the roughness map based on the bump values.
  128149. */
  128150. protected _enableSpecularAntiAliasing: boolean;
  128151. /**
  128152. * Default configuration related to image processing available in the PBR Material.
  128153. */
  128154. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  128155. /**
  128156. * Keep track of the image processing observer to allow dispose and replace.
  128157. */
  128158. private _imageProcessingObserver;
  128159. /**
  128160. * Attaches a new image processing configuration to the PBR Material.
  128161. * @param configuration
  128162. */
  128163. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  128164. /**
  128165. * Stores the available render targets.
  128166. */
  128167. private _renderTargets;
  128168. /**
  128169. * Sets the global ambient color for the material used in lighting calculations.
  128170. */
  128171. private _globalAmbientColor;
  128172. /**
  128173. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  128174. */
  128175. private _useLogarithmicDepth;
  128176. /**
  128177. * If set to true, no lighting calculations will be applied.
  128178. */
  128179. private _unlit;
  128180. private _debugMode;
  128181. /**
  128182. * @hidden
  128183. * This is reserved for the inspector.
  128184. * Defines the material debug mode.
  128185. * It helps seeing only some components of the material while troubleshooting.
  128186. */
  128187. debugMode: number;
  128188. /**
  128189. * @hidden
  128190. * This is reserved for the inspector.
  128191. * Specify from where on screen the debug mode should start.
  128192. * The value goes from -1 (full screen) to 1 (not visible)
  128193. * It helps with side by side comparison against the final render
  128194. * This defaults to -1
  128195. */
  128196. private debugLimit;
  128197. /**
  128198. * @hidden
  128199. * This is reserved for the inspector.
  128200. * As the default viewing range might not be enough (if the ambient is really small for instance)
  128201. * You can use the factor to better multiply the final value.
  128202. */
  128203. private debugFactor;
  128204. /**
  128205. * Defines the clear coat layer parameters for the material.
  128206. */
  128207. readonly clearCoat: PBRClearCoatConfiguration;
  128208. /**
  128209. * Defines the anisotropic parameters for the material.
  128210. */
  128211. readonly anisotropy: PBRAnisotropicConfiguration;
  128212. /**
  128213. * Defines the BRDF parameters for the material.
  128214. */
  128215. readonly brdf: PBRBRDFConfiguration;
  128216. /**
  128217. * Defines the Sheen parameters for the material.
  128218. */
  128219. readonly sheen: PBRSheenConfiguration;
  128220. /**
  128221. * Defines the SubSurface parameters for the material.
  128222. */
  128223. readonly subSurface: PBRSubSurfaceConfiguration;
  128224. protected _rebuildInParallel: boolean;
  128225. /**
  128226. * Instantiates a new PBRMaterial instance.
  128227. *
  128228. * @param name The material name
  128229. * @param scene The scene the material will be use in.
  128230. */
  128231. constructor(name: string, scene: Scene);
  128232. /**
  128233. * Gets a boolean indicating that current material needs to register RTT
  128234. */
  128235. get hasRenderTargetTextures(): boolean;
  128236. /**
  128237. * Gets the name of the material class.
  128238. */
  128239. getClassName(): string;
  128240. /**
  128241. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  128242. */
  128243. get useLogarithmicDepth(): boolean;
  128244. /**
  128245. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  128246. */
  128247. set useLogarithmicDepth(value: boolean);
  128248. /**
  128249. * Returns true if alpha blending should be disabled.
  128250. */
  128251. protected get _disableAlphaBlending(): boolean;
  128252. /**
  128253. * Specifies whether or not this material should be rendered in alpha blend mode.
  128254. */
  128255. needAlphaBlending(): boolean;
  128256. /**
  128257. * Specifies whether or not this material should be rendered in alpha test mode.
  128258. */
  128259. needAlphaTesting(): boolean;
  128260. /**
  128261. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  128262. */
  128263. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  128264. /**
  128265. * Gets the texture used for the alpha test.
  128266. */
  128267. getAlphaTestTexture(): Nullable<BaseTexture>;
  128268. /**
  128269. * Specifies that the submesh is ready to be used.
  128270. * @param mesh - BJS mesh.
  128271. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  128272. * @param useInstances - Specifies that instances should be used.
  128273. * @returns - boolean indicating that the submesh is ready or not.
  128274. */
  128275. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  128276. /**
  128277. * Specifies if the material uses metallic roughness workflow.
  128278. * @returns boolean specifiying if the material uses metallic roughness workflow.
  128279. */
  128280. isMetallicWorkflow(): boolean;
  128281. private _prepareEffect;
  128282. private _prepareDefines;
  128283. /**
  128284. * Force shader compilation
  128285. */
  128286. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  128287. /**
  128288. * Initializes the uniform buffer layout for the shader.
  128289. */
  128290. buildUniformLayout(): void;
  128291. /**
  128292. * Unbinds the material from the mesh
  128293. */
  128294. unbind(): void;
  128295. /**
  128296. * Binds the submesh data.
  128297. * @param world - The world matrix.
  128298. * @param mesh - The BJS mesh.
  128299. * @param subMesh - A submesh of the BJS mesh.
  128300. */
  128301. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  128302. /**
  128303. * Returns the animatable textures.
  128304. * @returns - Array of animatable textures.
  128305. */
  128306. getAnimatables(): IAnimatable[];
  128307. /**
  128308. * Returns the texture used for reflections.
  128309. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  128310. */
  128311. private _getReflectionTexture;
  128312. /**
  128313. * Returns an array of the actively used textures.
  128314. * @returns - Array of BaseTextures
  128315. */
  128316. getActiveTextures(): BaseTexture[];
  128317. /**
  128318. * Checks to see if a texture is used in the material.
  128319. * @param texture - Base texture to use.
  128320. * @returns - Boolean specifying if a texture is used in the material.
  128321. */
  128322. hasTexture(texture: BaseTexture): boolean;
  128323. /**
  128324. * Disposes the resources of the material.
  128325. * @param forceDisposeEffect - Forces the disposal of effects.
  128326. * @param forceDisposeTextures - Forces the disposal of all textures.
  128327. */
  128328. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  128329. }
  128330. }
  128331. declare module BABYLON {
  128332. /**
  128333. * The Physically based material of BJS.
  128334. *
  128335. * This offers the main features of a standard PBR material.
  128336. * For more information, please refer to the documentation :
  128337. * https://doc.babylonjs.com/how_to/physically_based_rendering
  128338. */
  128339. export class PBRMaterial extends PBRBaseMaterial {
  128340. /**
  128341. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  128342. */
  128343. static readonly PBRMATERIAL_OPAQUE: number;
  128344. /**
  128345. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  128346. */
  128347. static readonly PBRMATERIAL_ALPHATEST: number;
  128348. /**
  128349. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  128350. */
  128351. static readonly PBRMATERIAL_ALPHABLEND: number;
  128352. /**
  128353. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  128354. * They are also discarded below the alpha cutoff threshold to improve performances.
  128355. */
  128356. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  128357. /**
  128358. * Defines the default value of how much AO map is occluding the analytical lights
  128359. * (point spot...).
  128360. */
  128361. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  128362. /**
  128363. * Intensity of the direct lights e.g. the four lights available in your scene.
  128364. * This impacts both the direct diffuse and specular highlights.
  128365. */
  128366. directIntensity: number;
  128367. /**
  128368. * Intensity of the emissive part of the material.
  128369. * This helps controlling the emissive effect without modifying the emissive color.
  128370. */
  128371. emissiveIntensity: number;
  128372. /**
  128373. * Intensity of the environment e.g. how much the environment will light the object
  128374. * either through harmonics for rough material or through the refelction for shiny ones.
  128375. */
  128376. environmentIntensity: number;
  128377. /**
  128378. * This is a special control allowing the reduction of the specular highlights coming from the
  128379. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  128380. */
  128381. specularIntensity: number;
  128382. /**
  128383. * Debug Control allowing disabling the bump map on this material.
  128384. */
  128385. disableBumpMap: boolean;
  128386. /**
  128387. * AKA Diffuse Texture in standard nomenclature.
  128388. */
  128389. albedoTexture: BaseTexture;
  128390. /**
  128391. * AKA Occlusion Texture in other nomenclature.
  128392. */
  128393. ambientTexture: BaseTexture;
  128394. /**
  128395. * AKA Occlusion Texture Intensity in other nomenclature.
  128396. */
  128397. ambientTextureStrength: number;
  128398. /**
  128399. * Defines how much the AO map is occluding the analytical lights (point spot...).
  128400. * 1 means it completely occludes it
  128401. * 0 mean it has no impact
  128402. */
  128403. ambientTextureImpactOnAnalyticalLights: number;
  128404. /**
  128405. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  128406. */
  128407. opacityTexture: BaseTexture;
  128408. /**
  128409. * Stores the reflection values in a texture.
  128410. */
  128411. reflectionTexture: Nullable<BaseTexture>;
  128412. /**
  128413. * Stores the emissive values in a texture.
  128414. */
  128415. emissiveTexture: BaseTexture;
  128416. /**
  128417. * AKA Specular texture in other nomenclature.
  128418. */
  128419. reflectivityTexture: BaseTexture;
  128420. /**
  128421. * Used to switch from specular/glossiness to metallic/roughness workflow.
  128422. */
  128423. metallicTexture: BaseTexture;
  128424. /**
  128425. * Specifies the metallic scalar of the metallic/roughness workflow.
  128426. * Can also be used to scale the metalness values of the metallic texture.
  128427. */
  128428. metallic: Nullable<number>;
  128429. /**
  128430. * Specifies the roughness scalar of the metallic/roughness workflow.
  128431. * Can also be used to scale the roughness values of the metallic texture.
  128432. */
  128433. roughness: Nullable<number>;
  128434. /**
  128435. * Specifies the an F0 factor to help configuring the material F0.
  128436. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  128437. * to 0.5 the previously hard coded value stays the same.
  128438. * Can also be used to scale the F0 values of the metallic texture.
  128439. */
  128440. metallicF0Factor: number;
  128441. /**
  128442. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  128443. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  128444. * your expectation as it multiplies with the texture data.
  128445. */
  128446. useMetallicF0FactorFromMetallicTexture: boolean;
  128447. /**
  128448. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  128449. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  128450. */
  128451. microSurfaceTexture: BaseTexture;
  128452. /**
  128453. * Stores surface normal data used to displace a mesh in a texture.
  128454. */
  128455. bumpTexture: BaseTexture;
  128456. /**
  128457. * Stores the pre-calculated light information of a mesh in a texture.
  128458. */
  128459. lightmapTexture: BaseTexture;
  128460. /**
  128461. * Stores the refracted light information in a texture.
  128462. */
  128463. get refractionTexture(): Nullable<BaseTexture>;
  128464. set refractionTexture(value: Nullable<BaseTexture>);
  128465. /**
  128466. * The color of a material in ambient lighting.
  128467. */
  128468. ambientColor: Color3;
  128469. /**
  128470. * AKA Diffuse Color in other nomenclature.
  128471. */
  128472. albedoColor: Color3;
  128473. /**
  128474. * AKA Specular Color in other nomenclature.
  128475. */
  128476. reflectivityColor: Color3;
  128477. /**
  128478. * The color reflected from the material.
  128479. */
  128480. reflectionColor: Color3;
  128481. /**
  128482. * The color emitted from the material.
  128483. */
  128484. emissiveColor: Color3;
  128485. /**
  128486. * AKA Glossiness in other nomenclature.
  128487. */
  128488. microSurface: number;
  128489. /**
  128490. * source material index of refraction (IOR)' / 'destination material IOR.
  128491. */
  128492. get indexOfRefraction(): number;
  128493. set indexOfRefraction(value: number);
  128494. /**
  128495. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  128496. */
  128497. get invertRefractionY(): boolean;
  128498. set invertRefractionY(value: boolean);
  128499. /**
  128500. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  128501. * Materials half opaque for instance using refraction could benefit from this control.
  128502. */
  128503. get linkRefractionWithTransparency(): boolean;
  128504. set linkRefractionWithTransparency(value: boolean);
  128505. /**
  128506. * If true, the light map contains occlusion information instead of lighting info.
  128507. */
  128508. useLightmapAsShadowmap: boolean;
  128509. /**
  128510. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  128511. */
  128512. useAlphaFromAlbedoTexture: boolean;
  128513. /**
  128514. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  128515. */
  128516. forceAlphaTest: boolean;
  128517. /**
  128518. * Defines the alpha limits in alpha test mode.
  128519. */
  128520. alphaCutOff: number;
  128521. /**
  128522. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  128523. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  128524. */
  128525. useSpecularOverAlpha: boolean;
  128526. /**
  128527. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  128528. */
  128529. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  128530. /**
  128531. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  128532. */
  128533. useRoughnessFromMetallicTextureAlpha: boolean;
  128534. /**
  128535. * Specifies if the metallic texture contains the roughness information in its green channel.
  128536. */
  128537. useRoughnessFromMetallicTextureGreen: boolean;
  128538. /**
  128539. * Specifies if the metallic texture contains the metallness information in its blue channel.
  128540. */
  128541. useMetallnessFromMetallicTextureBlue: boolean;
  128542. /**
  128543. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  128544. */
  128545. useAmbientOcclusionFromMetallicTextureRed: boolean;
  128546. /**
  128547. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  128548. */
  128549. useAmbientInGrayScale: boolean;
  128550. /**
  128551. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  128552. * The material will try to infer what glossiness each pixel should be.
  128553. */
  128554. useAutoMicroSurfaceFromReflectivityMap: boolean;
  128555. /**
  128556. * BJS is using an harcoded light falloff based on a manually sets up range.
  128557. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  128558. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  128559. */
  128560. get usePhysicalLightFalloff(): boolean;
  128561. /**
  128562. * BJS is using an harcoded light falloff based on a manually sets up range.
  128563. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  128564. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  128565. */
  128566. set usePhysicalLightFalloff(value: boolean);
  128567. /**
  128568. * In order to support the falloff compatibility with gltf, a special mode has been added
  128569. * to reproduce the gltf light falloff.
  128570. */
  128571. get useGLTFLightFalloff(): boolean;
  128572. /**
  128573. * In order to support the falloff compatibility with gltf, a special mode has been added
  128574. * to reproduce the gltf light falloff.
  128575. */
  128576. set useGLTFLightFalloff(value: boolean);
  128577. /**
  128578. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  128579. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  128580. */
  128581. useRadianceOverAlpha: boolean;
  128582. /**
  128583. * Allows using an object space normal map (instead of tangent space).
  128584. */
  128585. useObjectSpaceNormalMap: boolean;
  128586. /**
  128587. * Allows using the bump map in parallax mode.
  128588. */
  128589. useParallax: boolean;
  128590. /**
  128591. * Allows using the bump map in parallax occlusion mode.
  128592. */
  128593. useParallaxOcclusion: boolean;
  128594. /**
  128595. * Controls the scale bias of the parallax mode.
  128596. */
  128597. parallaxScaleBias: number;
  128598. /**
  128599. * If sets to true, disables all the lights affecting the material.
  128600. */
  128601. disableLighting: boolean;
  128602. /**
  128603. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  128604. */
  128605. forceIrradianceInFragment: boolean;
  128606. /**
  128607. * Number of Simultaneous lights allowed on the material.
  128608. */
  128609. maxSimultaneousLights: number;
  128610. /**
  128611. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  128612. */
  128613. invertNormalMapX: boolean;
  128614. /**
  128615. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  128616. */
  128617. invertNormalMapY: boolean;
  128618. /**
  128619. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  128620. */
  128621. twoSidedLighting: boolean;
  128622. /**
  128623. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  128624. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  128625. */
  128626. useAlphaFresnel: boolean;
  128627. /**
  128628. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  128629. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  128630. */
  128631. useLinearAlphaFresnel: boolean;
  128632. /**
  128633. * Let user defines the brdf lookup texture used for IBL.
  128634. * A default 8bit version is embedded but you could point at :
  128635. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  128636. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  128637. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  128638. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  128639. */
  128640. environmentBRDFTexture: Nullable<BaseTexture>;
  128641. /**
  128642. * Force normal to face away from face.
  128643. */
  128644. forceNormalForward: boolean;
  128645. /**
  128646. * Enables specular anti aliasing in the PBR shader.
  128647. * It will both interacts on the Geometry for analytical and IBL lighting.
  128648. * It also prefilter the roughness map based on the bump values.
  128649. */
  128650. enableSpecularAntiAliasing: boolean;
  128651. /**
  128652. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  128653. * makes the reflect vector face the model (under horizon).
  128654. */
  128655. useHorizonOcclusion: boolean;
  128656. /**
  128657. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  128658. * too much the area relying on ambient texture to define their ambient occlusion.
  128659. */
  128660. useRadianceOcclusion: boolean;
  128661. /**
  128662. * If set to true, no lighting calculations will be applied.
  128663. */
  128664. unlit: boolean;
  128665. /**
  128666. * Gets the image processing configuration used either in this material.
  128667. */
  128668. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  128669. /**
  128670. * Sets the Default image processing configuration used either in the this material.
  128671. *
  128672. * If sets to null, the scene one is in use.
  128673. */
  128674. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  128675. /**
  128676. * Gets wether the color curves effect is enabled.
  128677. */
  128678. get cameraColorCurvesEnabled(): boolean;
  128679. /**
  128680. * Sets wether the color curves effect is enabled.
  128681. */
  128682. set cameraColorCurvesEnabled(value: boolean);
  128683. /**
  128684. * Gets wether the color grading effect is enabled.
  128685. */
  128686. get cameraColorGradingEnabled(): boolean;
  128687. /**
  128688. * Gets wether the color grading effect is enabled.
  128689. */
  128690. set cameraColorGradingEnabled(value: boolean);
  128691. /**
  128692. * Gets wether tonemapping is enabled or not.
  128693. */
  128694. get cameraToneMappingEnabled(): boolean;
  128695. /**
  128696. * Sets wether tonemapping is enabled or not
  128697. */
  128698. set cameraToneMappingEnabled(value: boolean);
  128699. /**
  128700. * The camera exposure used on this material.
  128701. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  128702. * This corresponds to a photographic exposure.
  128703. */
  128704. get cameraExposure(): number;
  128705. /**
  128706. * The camera exposure used on this material.
  128707. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  128708. * This corresponds to a photographic exposure.
  128709. */
  128710. set cameraExposure(value: number);
  128711. /**
  128712. * Gets The camera contrast used on this material.
  128713. */
  128714. get cameraContrast(): number;
  128715. /**
  128716. * Sets The camera contrast used on this material.
  128717. */
  128718. set cameraContrast(value: number);
  128719. /**
  128720. * Gets the Color Grading 2D Lookup Texture.
  128721. */
  128722. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  128723. /**
  128724. * Sets the Color Grading 2D Lookup Texture.
  128725. */
  128726. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  128727. /**
  128728. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  128729. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  128730. * 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;
  128731. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  128732. */
  128733. get cameraColorCurves(): Nullable<ColorCurves>;
  128734. /**
  128735. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  128736. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  128737. * 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;
  128738. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  128739. */
  128740. set cameraColorCurves(value: Nullable<ColorCurves>);
  128741. /**
  128742. * Instantiates a new PBRMaterial instance.
  128743. *
  128744. * @param name The material name
  128745. * @param scene The scene the material will be use in.
  128746. */
  128747. constructor(name: string, scene: Scene);
  128748. /**
  128749. * Returns the name of this material class.
  128750. */
  128751. getClassName(): string;
  128752. /**
  128753. * Makes a duplicate of the current material.
  128754. * @param name - name to use for the new material.
  128755. */
  128756. clone(name: string): PBRMaterial;
  128757. /**
  128758. * Serializes this PBR Material.
  128759. * @returns - An object with the serialized material.
  128760. */
  128761. serialize(): any;
  128762. /**
  128763. * Parses a PBR Material from a serialized object.
  128764. * @param source - Serialized object.
  128765. * @param scene - BJS scene instance.
  128766. * @param rootUrl - url for the scene object
  128767. * @returns - PBRMaterial
  128768. */
  128769. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  128770. }
  128771. }
  128772. declare module BABYLON {
  128773. /**
  128774. * Direct draw surface info
  128775. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  128776. */
  128777. export interface DDSInfo {
  128778. /**
  128779. * Width of the texture
  128780. */
  128781. width: number;
  128782. /**
  128783. * Width of the texture
  128784. */
  128785. height: number;
  128786. /**
  128787. * Number of Mipmaps for the texture
  128788. * @see https://en.wikipedia.org/wiki/Mipmap
  128789. */
  128790. mipmapCount: number;
  128791. /**
  128792. * If the textures format is a known fourCC format
  128793. * @see https://www.fourcc.org/
  128794. */
  128795. isFourCC: boolean;
  128796. /**
  128797. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  128798. */
  128799. isRGB: boolean;
  128800. /**
  128801. * If the texture is a lumincance format
  128802. */
  128803. isLuminance: boolean;
  128804. /**
  128805. * If this is a cube texture
  128806. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  128807. */
  128808. isCube: boolean;
  128809. /**
  128810. * If the texture is a compressed format eg. FOURCC_DXT1
  128811. */
  128812. isCompressed: boolean;
  128813. /**
  128814. * The dxgiFormat of the texture
  128815. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  128816. */
  128817. dxgiFormat: number;
  128818. /**
  128819. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  128820. */
  128821. textureType: number;
  128822. /**
  128823. * Sphericle polynomial created for the dds texture
  128824. */
  128825. sphericalPolynomial?: SphericalPolynomial;
  128826. }
  128827. /**
  128828. * Class used to provide DDS decompression tools
  128829. */
  128830. export class DDSTools {
  128831. /**
  128832. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  128833. */
  128834. static StoreLODInAlphaChannel: boolean;
  128835. /**
  128836. * Gets DDS information from an array buffer
  128837. * @param data defines the array buffer view to read data from
  128838. * @returns the DDS information
  128839. */
  128840. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  128841. private static _FloatView;
  128842. private static _Int32View;
  128843. private static _ToHalfFloat;
  128844. private static _FromHalfFloat;
  128845. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  128846. private static _GetHalfFloatRGBAArrayBuffer;
  128847. private static _GetFloatRGBAArrayBuffer;
  128848. private static _GetFloatAsUIntRGBAArrayBuffer;
  128849. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  128850. private static _GetRGBAArrayBuffer;
  128851. private static _ExtractLongWordOrder;
  128852. private static _GetRGBArrayBuffer;
  128853. private static _GetLuminanceArrayBuffer;
  128854. /**
  128855. * Uploads DDS Levels to a Babylon Texture
  128856. * @hidden
  128857. */
  128858. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  128859. }
  128860. interface ThinEngine {
  128861. /**
  128862. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  128863. * @param rootUrl defines the url where the file to load is located
  128864. * @param scene defines the current scene
  128865. * @param lodScale defines scale to apply to the mip map selection
  128866. * @param lodOffset defines offset to apply to the mip map selection
  128867. * @param onLoad defines an optional callback raised when the texture is loaded
  128868. * @param onError defines an optional callback raised if there is an issue to load the texture
  128869. * @param format defines the format of the data
  128870. * @param forcedExtension defines the extension to use to pick the right loader
  128871. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  128872. * @returns the cube texture as an InternalTexture
  128873. */
  128874. 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;
  128875. }
  128876. }
  128877. declare module BABYLON {
  128878. /**
  128879. * Implementation of the DDS Texture Loader.
  128880. * @hidden
  128881. */
  128882. export class _DDSTextureLoader implements IInternalTextureLoader {
  128883. /**
  128884. * Defines wether the loader supports cascade loading the different faces.
  128885. */
  128886. readonly supportCascades: boolean;
  128887. /**
  128888. * This returns if the loader support the current file information.
  128889. * @param extension defines the file extension of the file being loaded
  128890. * @returns true if the loader can load the specified file
  128891. */
  128892. canLoad(extension: string): boolean;
  128893. /**
  128894. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  128895. * @param data contains the texture data
  128896. * @param texture defines the BabylonJS internal texture
  128897. * @param createPolynomials will be true if polynomials have been requested
  128898. * @param onLoad defines the callback to trigger once the texture is ready
  128899. * @param onError defines the callback to trigger in case of error
  128900. */
  128901. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  128902. /**
  128903. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  128904. * @param data contains the texture data
  128905. * @param texture defines the BabylonJS internal texture
  128906. * @param callback defines the method to call once ready to upload
  128907. */
  128908. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  128909. }
  128910. }
  128911. declare module BABYLON {
  128912. /**
  128913. * Implementation of the ENV Texture Loader.
  128914. * @hidden
  128915. */
  128916. export class _ENVTextureLoader implements IInternalTextureLoader {
  128917. /**
  128918. * Defines wether the loader supports cascade loading the different faces.
  128919. */
  128920. readonly supportCascades: boolean;
  128921. /**
  128922. * This returns if the loader support the current file information.
  128923. * @param extension defines the file extension of the file being loaded
  128924. * @returns true if the loader can load the specified file
  128925. */
  128926. canLoad(extension: string): boolean;
  128927. /**
  128928. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  128929. * @param data contains the texture data
  128930. * @param texture defines the BabylonJS internal texture
  128931. * @param createPolynomials will be true if polynomials have been requested
  128932. * @param onLoad defines the callback to trigger once the texture is ready
  128933. * @param onError defines the callback to trigger in case of error
  128934. */
  128935. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  128936. /**
  128937. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  128938. * @param data contains the texture data
  128939. * @param texture defines the BabylonJS internal texture
  128940. * @param callback defines the method to call once ready to upload
  128941. */
  128942. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  128943. }
  128944. }
  128945. declare module BABYLON {
  128946. /**
  128947. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  128948. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  128949. */
  128950. export class KhronosTextureContainer {
  128951. /** contents of the KTX container file */
  128952. data: ArrayBufferView;
  128953. private static HEADER_LEN;
  128954. private static COMPRESSED_2D;
  128955. private static COMPRESSED_3D;
  128956. private static TEX_2D;
  128957. private static TEX_3D;
  128958. /**
  128959. * Gets the openGL type
  128960. */
  128961. glType: number;
  128962. /**
  128963. * Gets the openGL type size
  128964. */
  128965. glTypeSize: number;
  128966. /**
  128967. * Gets the openGL format
  128968. */
  128969. glFormat: number;
  128970. /**
  128971. * Gets the openGL internal format
  128972. */
  128973. glInternalFormat: number;
  128974. /**
  128975. * Gets the base internal format
  128976. */
  128977. glBaseInternalFormat: number;
  128978. /**
  128979. * Gets image width in pixel
  128980. */
  128981. pixelWidth: number;
  128982. /**
  128983. * Gets image height in pixel
  128984. */
  128985. pixelHeight: number;
  128986. /**
  128987. * Gets image depth in pixels
  128988. */
  128989. pixelDepth: number;
  128990. /**
  128991. * Gets the number of array elements
  128992. */
  128993. numberOfArrayElements: number;
  128994. /**
  128995. * Gets the number of faces
  128996. */
  128997. numberOfFaces: number;
  128998. /**
  128999. * Gets the number of mipmap levels
  129000. */
  129001. numberOfMipmapLevels: number;
  129002. /**
  129003. * Gets the bytes of key value data
  129004. */
  129005. bytesOfKeyValueData: number;
  129006. /**
  129007. * Gets the load type
  129008. */
  129009. loadType: number;
  129010. /**
  129011. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  129012. */
  129013. isInvalid: boolean;
  129014. /**
  129015. * Creates a new KhronosTextureContainer
  129016. * @param data contents of the KTX container file
  129017. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  129018. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  129019. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  129020. */
  129021. constructor(
  129022. /** contents of the KTX container file */
  129023. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  129024. /**
  129025. * Uploads KTX content to a Babylon Texture.
  129026. * It is assumed that the texture has already been created & is currently bound
  129027. * @hidden
  129028. */
  129029. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  129030. private _upload2DCompressedLevels;
  129031. /**
  129032. * Checks if the given data starts with a KTX file identifier.
  129033. * @param data the data to check
  129034. * @returns true if the data is a KTX file or false otherwise
  129035. */
  129036. static IsValid(data: ArrayBufferView): boolean;
  129037. }
  129038. }
  129039. declare module BABYLON {
  129040. /**
  129041. * Class for loading KTX2 files
  129042. * !!! Experimental Extension Subject to Changes !!!
  129043. * @hidden
  129044. */
  129045. export class KhronosTextureContainer2 {
  129046. private static _ModulePromise;
  129047. private static _TranscodeFormat;
  129048. constructor(engine: ThinEngine);
  129049. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture): Promise<void>;
  129050. private _determineTranscodeFormat;
  129051. /**
  129052. * Checks if the given data starts with a KTX2 file identifier.
  129053. * @param data the data to check
  129054. * @returns true if the data is a KTX2 file or false otherwise
  129055. */
  129056. static IsValid(data: ArrayBufferView): boolean;
  129057. }
  129058. }
  129059. declare module BABYLON {
  129060. /**
  129061. * Implementation of the KTX Texture Loader.
  129062. * @hidden
  129063. */
  129064. export class _KTXTextureLoader implements IInternalTextureLoader {
  129065. /**
  129066. * Defines wether the loader supports cascade loading the different faces.
  129067. */
  129068. readonly supportCascades: boolean;
  129069. /**
  129070. * This returns if the loader support the current file information.
  129071. * @param extension defines the file extension of the file being loaded
  129072. * @returns true if the loader can load the specified file
  129073. */
  129074. canLoad(extension: string): boolean;
  129075. /**
  129076. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  129077. * @param data contains the texture data
  129078. * @param texture defines the BabylonJS internal texture
  129079. * @param createPolynomials will be true if polynomials have been requested
  129080. * @param onLoad defines the callback to trigger once the texture is ready
  129081. * @param onError defines the callback to trigger in case of error
  129082. */
  129083. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  129084. /**
  129085. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  129086. * @param data contains the texture data
  129087. * @param texture defines the BabylonJS internal texture
  129088. * @param callback defines the method to call once ready to upload
  129089. */
  129090. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  129091. }
  129092. }
  129093. declare module BABYLON {
  129094. /** @hidden */
  129095. export var _forceSceneHelpersToBundle: boolean;
  129096. interface Scene {
  129097. /**
  129098. * Creates a default light for the scene.
  129099. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  129100. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  129101. */
  129102. createDefaultLight(replace?: boolean): void;
  129103. /**
  129104. * Creates a default camera for the scene.
  129105. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  129106. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  129107. * @param replace has default false, when true replaces the active camera in the scene
  129108. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  129109. */
  129110. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  129111. /**
  129112. * Creates a default camera and a default light.
  129113. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  129114. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  129115. * @param replace has the default false, when true replaces the active camera/light in the scene
  129116. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  129117. */
  129118. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  129119. /**
  129120. * Creates a new sky box
  129121. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  129122. * @param environmentTexture defines the texture to use as environment texture
  129123. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  129124. * @param scale defines the overall scale of the skybox
  129125. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  129126. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  129127. * @returns a new mesh holding the sky box
  129128. */
  129129. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  129130. /**
  129131. * Creates a new environment
  129132. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  129133. * @param options defines the options you can use to configure the environment
  129134. * @returns the new EnvironmentHelper
  129135. */
  129136. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  129137. /**
  129138. * Creates a new VREXperienceHelper
  129139. * @see http://doc.babylonjs.com/how_to/webvr_helper
  129140. * @param webVROptions defines the options used to create the new VREXperienceHelper
  129141. * @returns a new VREXperienceHelper
  129142. */
  129143. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  129144. /**
  129145. * Creates a new WebXRDefaultExperience
  129146. * @see http://doc.babylonjs.com/how_to/webxr
  129147. * @param options experience options
  129148. * @returns a promise for a new WebXRDefaultExperience
  129149. */
  129150. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  129151. }
  129152. }
  129153. declare module BABYLON {
  129154. /**
  129155. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  129156. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  129157. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  129158. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  129159. */
  129160. export class VideoDome extends TransformNode {
  129161. /**
  129162. * Define the video source as a Monoscopic panoramic 360 video.
  129163. */
  129164. static readonly MODE_MONOSCOPIC: number;
  129165. /**
  129166. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  129167. */
  129168. static readonly MODE_TOPBOTTOM: number;
  129169. /**
  129170. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  129171. */
  129172. static readonly MODE_SIDEBYSIDE: number;
  129173. private _halfDome;
  129174. private _useDirectMapping;
  129175. /**
  129176. * The video texture being displayed on the sphere
  129177. */
  129178. protected _videoTexture: VideoTexture;
  129179. /**
  129180. * Gets the video texture being displayed on the sphere
  129181. */
  129182. get videoTexture(): VideoTexture;
  129183. /**
  129184. * The skybox material
  129185. */
  129186. protected _material: BackgroundMaterial;
  129187. /**
  129188. * The surface used for the skybox
  129189. */
  129190. protected _mesh: Mesh;
  129191. /**
  129192. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  129193. */
  129194. private _halfDomeMask;
  129195. /**
  129196. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  129197. * Also see the options.resolution property.
  129198. */
  129199. get fovMultiplier(): number;
  129200. set fovMultiplier(value: number);
  129201. private _videoMode;
  129202. /**
  129203. * Gets or set the current video mode for the video. It can be:
  129204. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  129205. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  129206. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  129207. */
  129208. get videoMode(): number;
  129209. set videoMode(value: number);
  129210. /**
  129211. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  129212. *
  129213. */
  129214. get halfDome(): boolean;
  129215. /**
  129216. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  129217. */
  129218. set halfDome(enabled: boolean);
  129219. /**
  129220. * Oberserver used in Stereoscopic VR Mode.
  129221. */
  129222. private _onBeforeCameraRenderObserver;
  129223. /**
  129224. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  129225. * @param name Element's name, child elements will append suffixes for their own names.
  129226. * @param urlsOrVideo defines the url(s) or the video element to use
  129227. * @param options An object containing optional or exposed sub element properties
  129228. */
  129229. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  129230. resolution?: number;
  129231. clickToPlay?: boolean;
  129232. autoPlay?: boolean;
  129233. loop?: boolean;
  129234. size?: number;
  129235. poster?: string;
  129236. faceForward?: boolean;
  129237. useDirectMapping?: boolean;
  129238. halfDomeMode?: boolean;
  129239. }, scene: Scene);
  129240. private _changeVideoMode;
  129241. /**
  129242. * Releases resources associated with this node.
  129243. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  129244. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  129245. */
  129246. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  129247. }
  129248. }
  129249. declare module BABYLON {
  129250. /**
  129251. * This class can be used to get instrumentation data from a Babylon engine
  129252. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  129253. */
  129254. export class EngineInstrumentation implements IDisposable {
  129255. /**
  129256. * Define the instrumented engine.
  129257. */
  129258. engine: Engine;
  129259. private _captureGPUFrameTime;
  129260. private _gpuFrameTimeToken;
  129261. private _gpuFrameTime;
  129262. private _captureShaderCompilationTime;
  129263. private _shaderCompilationTime;
  129264. private _onBeginFrameObserver;
  129265. private _onEndFrameObserver;
  129266. private _onBeforeShaderCompilationObserver;
  129267. private _onAfterShaderCompilationObserver;
  129268. /**
  129269. * Gets the perf counter used for GPU frame time
  129270. */
  129271. get gpuFrameTimeCounter(): PerfCounter;
  129272. /**
  129273. * Gets the GPU frame time capture status
  129274. */
  129275. get captureGPUFrameTime(): boolean;
  129276. /**
  129277. * Enable or disable the GPU frame time capture
  129278. */
  129279. set captureGPUFrameTime(value: boolean);
  129280. /**
  129281. * Gets the perf counter used for shader compilation time
  129282. */
  129283. get shaderCompilationTimeCounter(): PerfCounter;
  129284. /**
  129285. * Gets the shader compilation time capture status
  129286. */
  129287. get captureShaderCompilationTime(): boolean;
  129288. /**
  129289. * Enable or disable the shader compilation time capture
  129290. */
  129291. set captureShaderCompilationTime(value: boolean);
  129292. /**
  129293. * Instantiates a new engine instrumentation.
  129294. * This class can be used to get instrumentation data from a Babylon engine
  129295. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  129296. * @param engine Defines the engine to instrument
  129297. */
  129298. constructor(
  129299. /**
  129300. * Define the instrumented engine.
  129301. */
  129302. engine: Engine);
  129303. /**
  129304. * Dispose and release associated resources.
  129305. */
  129306. dispose(): void;
  129307. }
  129308. }
  129309. declare module BABYLON {
  129310. /**
  129311. * This class can be used to get instrumentation data from a Babylon engine
  129312. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  129313. */
  129314. export class SceneInstrumentation implements IDisposable {
  129315. /**
  129316. * Defines the scene to instrument
  129317. */
  129318. scene: Scene;
  129319. private _captureActiveMeshesEvaluationTime;
  129320. private _activeMeshesEvaluationTime;
  129321. private _captureRenderTargetsRenderTime;
  129322. private _renderTargetsRenderTime;
  129323. private _captureFrameTime;
  129324. private _frameTime;
  129325. private _captureRenderTime;
  129326. private _renderTime;
  129327. private _captureInterFrameTime;
  129328. private _interFrameTime;
  129329. private _captureParticlesRenderTime;
  129330. private _particlesRenderTime;
  129331. private _captureSpritesRenderTime;
  129332. private _spritesRenderTime;
  129333. private _capturePhysicsTime;
  129334. private _physicsTime;
  129335. private _captureAnimationsTime;
  129336. private _animationsTime;
  129337. private _captureCameraRenderTime;
  129338. private _cameraRenderTime;
  129339. private _onBeforeActiveMeshesEvaluationObserver;
  129340. private _onAfterActiveMeshesEvaluationObserver;
  129341. private _onBeforeRenderTargetsRenderObserver;
  129342. private _onAfterRenderTargetsRenderObserver;
  129343. private _onAfterRenderObserver;
  129344. private _onBeforeDrawPhaseObserver;
  129345. private _onAfterDrawPhaseObserver;
  129346. private _onBeforeAnimationsObserver;
  129347. private _onBeforeParticlesRenderingObserver;
  129348. private _onAfterParticlesRenderingObserver;
  129349. private _onBeforeSpritesRenderingObserver;
  129350. private _onAfterSpritesRenderingObserver;
  129351. private _onBeforePhysicsObserver;
  129352. private _onAfterPhysicsObserver;
  129353. private _onAfterAnimationsObserver;
  129354. private _onBeforeCameraRenderObserver;
  129355. private _onAfterCameraRenderObserver;
  129356. /**
  129357. * Gets the perf counter used for active meshes evaluation time
  129358. */
  129359. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  129360. /**
  129361. * Gets the active meshes evaluation time capture status
  129362. */
  129363. get captureActiveMeshesEvaluationTime(): boolean;
  129364. /**
  129365. * Enable or disable the active meshes evaluation time capture
  129366. */
  129367. set captureActiveMeshesEvaluationTime(value: boolean);
  129368. /**
  129369. * Gets the perf counter used for render targets render time
  129370. */
  129371. get renderTargetsRenderTimeCounter(): PerfCounter;
  129372. /**
  129373. * Gets the render targets render time capture status
  129374. */
  129375. get captureRenderTargetsRenderTime(): boolean;
  129376. /**
  129377. * Enable or disable the render targets render time capture
  129378. */
  129379. set captureRenderTargetsRenderTime(value: boolean);
  129380. /**
  129381. * Gets the perf counter used for particles render time
  129382. */
  129383. get particlesRenderTimeCounter(): PerfCounter;
  129384. /**
  129385. * Gets the particles render time capture status
  129386. */
  129387. get captureParticlesRenderTime(): boolean;
  129388. /**
  129389. * Enable or disable the particles render time capture
  129390. */
  129391. set captureParticlesRenderTime(value: boolean);
  129392. /**
  129393. * Gets the perf counter used for sprites render time
  129394. */
  129395. get spritesRenderTimeCounter(): PerfCounter;
  129396. /**
  129397. * Gets the sprites render time capture status
  129398. */
  129399. get captureSpritesRenderTime(): boolean;
  129400. /**
  129401. * Enable or disable the sprites render time capture
  129402. */
  129403. set captureSpritesRenderTime(value: boolean);
  129404. /**
  129405. * Gets the perf counter used for physics time
  129406. */
  129407. get physicsTimeCounter(): PerfCounter;
  129408. /**
  129409. * Gets the physics time capture status
  129410. */
  129411. get capturePhysicsTime(): boolean;
  129412. /**
  129413. * Enable or disable the physics time capture
  129414. */
  129415. set capturePhysicsTime(value: boolean);
  129416. /**
  129417. * Gets the perf counter used for animations time
  129418. */
  129419. get animationsTimeCounter(): PerfCounter;
  129420. /**
  129421. * Gets the animations time capture status
  129422. */
  129423. get captureAnimationsTime(): boolean;
  129424. /**
  129425. * Enable or disable the animations time capture
  129426. */
  129427. set captureAnimationsTime(value: boolean);
  129428. /**
  129429. * Gets the perf counter used for frame time capture
  129430. */
  129431. get frameTimeCounter(): PerfCounter;
  129432. /**
  129433. * Gets the frame time capture status
  129434. */
  129435. get captureFrameTime(): boolean;
  129436. /**
  129437. * Enable or disable the frame time capture
  129438. */
  129439. set captureFrameTime(value: boolean);
  129440. /**
  129441. * Gets the perf counter used for inter-frames time capture
  129442. */
  129443. get interFrameTimeCounter(): PerfCounter;
  129444. /**
  129445. * Gets the inter-frames time capture status
  129446. */
  129447. get captureInterFrameTime(): boolean;
  129448. /**
  129449. * Enable or disable the inter-frames time capture
  129450. */
  129451. set captureInterFrameTime(value: boolean);
  129452. /**
  129453. * Gets the perf counter used for render time capture
  129454. */
  129455. get renderTimeCounter(): PerfCounter;
  129456. /**
  129457. * Gets the render time capture status
  129458. */
  129459. get captureRenderTime(): boolean;
  129460. /**
  129461. * Enable or disable the render time capture
  129462. */
  129463. set captureRenderTime(value: boolean);
  129464. /**
  129465. * Gets the perf counter used for camera render time capture
  129466. */
  129467. get cameraRenderTimeCounter(): PerfCounter;
  129468. /**
  129469. * Gets the camera render time capture status
  129470. */
  129471. get captureCameraRenderTime(): boolean;
  129472. /**
  129473. * Enable or disable the camera render time capture
  129474. */
  129475. set captureCameraRenderTime(value: boolean);
  129476. /**
  129477. * Gets the perf counter used for draw calls
  129478. */
  129479. get drawCallsCounter(): PerfCounter;
  129480. /**
  129481. * Instantiates a new scene instrumentation.
  129482. * This class can be used to get instrumentation data from a Babylon engine
  129483. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  129484. * @param scene Defines the scene to instrument
  129485. */
  129486. constructor(
  129487. /**
  129488. * Defines the scene to instrument
  129489. */
  129490. scene: Scene);
  129491. /**
  129492. * Dispose and release associated resources.
  129493. */
  129494. dispose(): void;
  129495. }
  129496. }
  129497. declare module BABYLON {
  129498. /** @hidden */
  129499. export var glowMapGenerationPixelShader: {
  129500. name: string;
  129501. shader: string;
  129502. };
  129503. }
  129504. declare module BABYLON {
  129505. /** @hidden */
  129506. export var glowMapGenerationVertexShader: {
  129507. name: string;
  129508. shader: string;
  129509. };
  129510. }
  129511. declare module BABYLON {
  129512. /**
  129513. * Effect layer options. This helps customizing the behaviour
  129514. * of the effect layer.
  129515. */
  129516. export interface IEffectLayerOptions {
  129517. /**
  129518. * Multiplication factor apply to the canvas size to compute the render target size
  129519. * used to generated the objects (the smaller the faster).
  129520. */
  129521. mainTextureRatio: number;
  129522. /**
  129523. * Enforces a fixed size texture to ensure effect stability across devices.
  129524. */
  129525. mainTextureFixedSize?: number;
  129526. /**
  129527. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  129528. */
  129529. alphaBlendingMode: number;
  129530. /**
  129531. * The camera attached to the layer.
  129532. */
  129533. camera: Nullable<Camera>;
  129534. /**
  129535. * The rendering group to draw the layer in.
  129536. */
  129537. renderingGroupId: number;
  129538. }
  129539. /**
  129540. * The effect layer Helps adding post process effect blended with the main pass.
  129541. *
  129542. * This can be for instance use to generate glow or higlight effects on the scene.
  129543. *
  129544. * The effect layer class can not be used directly and is intented to inherited from to be
  129545. * customized per effects.
  129546. */
  129547. export abstract class EffectLayer {
  129548. private _vertexBuffers;
  129549. private _indexBuffer;
  129550. private _cachedDefines;
  129551. private _effectLayerMapGenerationEffect;
  129552. private _effectLayerOptions;
  129553. private _mergeEffect;
  129554. protected _scene: Scene;
  129555. protected _engine: Engine;
  129556. protected _maxSize: number;
  129557. protected _mainTextureDesiredSize: ISize;
  129558. protected _mainTexture: RenderTargetTexture;
  129559. protected _shouldRender: boolean;
  129560. protected _postProcesses: PostProcess[];
  129561. protected _textures: BaseTexture[];
  129562. protected _emissiveTextureAndColor: {
  129563. texture: Nullable<BaseTexture>;
  129564. color: Color4;
  129565. };
  129566. /**
  129567. * The name of the layer
  129568. */
  129569. name: string;
  129570. /**
  129571. * The clear color of the texture used to generate the glow map.
  129572. */
  129573. neutralColor: Color4;
  129574. /**
  129575. * Specifies whether the highlight layer is enabled or not.
  129576. */
  129577. isEnabled: boolean;
  129578. /**
  129579. * Gets the camera attached to the layer.
  129580. */
  129581. get camera(): Nullable<Camera>;
  129582. /**
  129583. * Gets the rendering group id the layer should render in.
  129584. */
  129585. get renderingGroupId(): number;
  129586. set renderingGroupId(renderingGroupId: number);
  129587. /**
  129588. * An event triggered when the effect layer has been disposed.
  129589. */
  129590. onDisposeObservable: Observable<EffectLayer>;
  129591. /**
  129592. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  129593. */
  129594. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  129595. /**
  129596. * An event triggered when the generated texture is being merged in the scene.
  129597. */
  129598. onBeforeComposeObservable: Observable<EffectLayer>;
  129599. /**
  129600. * An event triggered when the mesh is rendered into the effect render target.
  129601. */
  129602. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  129603. /**
  129604. * An event triggered after the mesh has been rendered into the effect render target.
  129605. */
  129606. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  129607. /**
  129608. * An event triggered when the generated texture has been merged in the scene.
  129609. */
  129610. onAfterComposeObservable: Observable<EffectLayer>;
  129611. /**
  129612. * An event triggered when the efffect layer changes its size.
  129613. */
  129614. onSizeChangedObservable: Observable<EffectLayer>;
  129615. /** @hidden */
  129616. static _SceneComponentInitialization: (scene: Scene) => void;
  129617. /**
  129618. * Instantiates a new effect Layer and references it in the scene.
  129619. * @param name The name of the layer
  129620. * @param scene The scene to use the layer in
  129621. */
  129622. constructor(
  129623. /** The Friendly of the effect in the scene */
  129624. name: string, scene: Scene);
  129625. /**
  129626. * Get the effect name of the layer.
  129627. * @return The effect name
  129628. */
  129629. abstract getEffectName(): string;
  129630. /**
  129631. * Checks for the readiness of the element composing the layer.
  129632. * @param subMesh the mesh to check for
  129633. * @param useInstances specify whether or not to use instances to render the mesh
  129634. * @return true if ready otherwise, false
  129635. */
  129636. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  129637. /**
  129638. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  129639. * @returns true if the effect requires stencil during the main canvas render pass.
  129640. */
  129641. abstract needStencil(): boolean;
  129642. /**
  129643. * Create the merge effect. This is the shader use to blit the information back
  129644. * to the main canvas at the end of the scene rendering.
  129645. * @returns The effect containing the shader used to merge the effect on the main canvas
  129646. */
  129647. protected abstract _createMergeEffect(): Effect;
  129648. /**
  129649. * Creates the render target textures and post processes used in the effect layer.
  129650. */
  129651. protected abstract _createTextureAndPostProcesses(): void;
  129652. /**
  129653. * Implementation specific of rendering the generating effect on the main canvas.
  129654. * @param effect The effect used to render through
  129655. */
  129656. protected abstract _internalRender(effect: Effect): void;
  129657. /**
  129658. * Sets the required values for both the emissive texture and and the main color.
  129659. */
  129660. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  129661. /**
  129662. * Free any resources and references associated to a mesh.
  129663. * Internal use
  129664. * @param mesh The mesh to free.
  129665. */
  129666. abstract _disposeMesh(mesh: Mesh): void;
  129667. /**
  129668. * Serializes this layer (Glow or Highlight for example)
  129669. * @returns a serialized layer object
  129670. */
  129671. abstract serialize?(): any;
  129672. /**
  129673. * Initializes the effect layer with the required options.
  129674. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  129675. */
  129676. protected _init(options: Partial<IEffectLayerOptions>): void;
  129677. /**
  129678. * Generates the index buffer of the full screen quad blending to the main canvas.
  129679. */
  129680. private _generateIndexBuffer;
  129681. /**
  129682. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  129683. */
  129684. private _generateVertexBuffer;
  129685. /**
  129686. * Sets the main texture desired size which is the closest power of two
  129687. * of the engine canvas size.
  129688. */
  129689. private _setMainTextureSize;
  129690. /**
  129691. * Creates the main texture for the effect layer.
  129692. */
  129693. protected _createMainTexture(): void;
  129694. /**
  129695. * Adds specific effects defines.
  129696. * @param defines The defines to add specifics to.
  129697. */
  129698. protected _addCustomEffectDefines(defines: string[]): void;
  129699. /**
  129700. * Checks for the readiness of the element composing the layer.
  129701. * @param subMesh the mesh to check for
  129702. * @param useInstances specify whether or not to use instances to render the mesh
  129703. * @param emissiveTexture the associated emissive texture used to generate the glow
  129704. * @return true if ready otherwise, false
  129705. */
  129706. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  129707. /**
  129708. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  129709. */
  129710. render(): void;
  129711. /**
  129712. * Determine if a given mesh will be used in the current effect.
  129713. * @param mesh mesh to test
  129714. * @returns true if the mesh will be used
  129715. */
  129716. hasMesh(mesh: AbstractMesh): boolean;
  129717. /**
  129718. * Returns true if the layer contains information to display, otherwise false.
  129719. * @returns true if the glow layer should be rendered
  129720. */
  129721. shouldRender(): boolean;
  129722. /**
  129723. * Returns true if the mesh should render, otherwise false.
  129724. * @param mesh The mesh to render
  129725. * @returns true if it should render otherwise false
  129726. */
  129727. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  129728. /**
  129729. * Returns true if the mesh can be rendered, otherwise false.
  129730. * @param mesh The mesh to render
  129731. * @param material The material used on the mesh
  129732. * @returns true if it can be rendered otherwise false
  129733. */
  129734. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  129735. /**
  129736. * Returns true if the mesh should render, otherwise false.
  129737. * @param mesh The mesh to render
  129738. * @returns true if it should render otherwise false
  129739. */
  129740. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  129741. /**
  129742. * Renders the submesh passed in parameter to the generation map.
  129743. */
  129744. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  129745. /**
  129746. * Defines whether the current material of the mesh should be use to render the effect.
  129747. * @param mesh defines the current mesh to render
  129748. */
  129749. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  129750. /**
  129751. * Rebuild the required buffers.
  129752. * @hidden Internal use only.
  129753. */
  129754. _rebuild(): void;
  129755. /**
  129756. * Dispose only the render target textures and post process.
  129757. */
  129758. private _disposeTextureAndPostProcesses;
  129759. /**
  129760. * Dispose the highlight layer and free resources.
  129761. */
  129762. dispose(): void;
  129763. /**
  129764. * Gets the class name of the effect layer
  129765. * @returns the string with the class name of the effect layer
  129766. */
  129767. getClassName(): string;
  129768. /**
  129769. * Creates an effect layer from parsed effect layer data
  129770. * @param parsedEffectLayer defines effect layer data
  129771. * @param scene defines the current scene
  129772. * @param rootUrl defines the root URL containing the effect layer information
  129773. * @returns a parsed effect Layer
  129774. */
  129775. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  129776. }
  129777. }
  129778. declare module BABYLON {
  129779. interface AbstractScene {
  129780. /**
  129781. * The list of effect layers (highlights/glow) added to the scene
  129782. * @see http://doc.babylonjs.com/how_to/highlight_layer
  129783. * @see http://doc.babylonjs.com/how_to/glow_layer
  129784. */
  129785. effectLayers: Array<EffectLayer>;
  129786. /**
  129787. * Removes the given effect layer from this scene.
  129788. * @param toRemove defines the effect layer to remove
  129789. * @returns the index of the removed effect layer
  129790. */
  129791. removeEffectLayer(toRemove: EffectLayer): number;
  129792. /**
  129793. * Adds the given effect layer to this scene
  129794. * @param newEffectLayer defines the effect layer to add
  129795. */
  129796. addEffectLayer(newEffectLayer: EffectLayer): void;
  129797. }
  129798. /**
  129799. * Defines the layer scene component responsible to manage any effect layers
  129800. * in a given scene.
  129801. */
  129802. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  129803. /**
  129804. * The component name helpfull to identify the component in the list of scene components.
  129805. */
  129806. readonly name: string;
  129807. /**
  129808. * The scene the component belongs to.
  129809. */
  129810. scene: Scene;
  129811. private _engine;
  129812. private _renderEffects;
  129813. private _needStencil;
  129814. private _previousStencilState;
  129815. /**
  129816. * Creates a new instance of the component for the given scene
  129817. * @param scene Defines the scene to register the component in
  129818. */
  129819. constructor(scene: Scene);
  129820. /**
  129821. * Registers the component in a given scene
  129822. */
  129823. register(): void;
  129824. /**
  129825. * Rebuilds the elements related to this component in case of
  129826. * context lost for instance.
  129827. */
  129828. rebuild(): void;
  129829. /**
  129830. * Serializes the component data to the specified json object
  129831. * @param serializationObject The object to serialize to
  129832. */
  129833. serialize(serializationObject: any): void;
  129834. /**
  129835. * Adds all the elements from the container to the scene
  129836. * @param container the container holding the elements
  129837. */
  129838. addFromContainer(container: AbstractScene): void;
  129839. /**
  129840. * Removes all the elements in the container from the scene
  129841. * @param container contains the elements to remove
  129842. * @param dispose if the removed element should be disposed (default: false)
  129843. */
  129844. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  129845. /**
  129846. * Disposes the component and the associated ressources.
  129847. */
  129848. dispose(): void;
  129849. private _isReadyForMesh;
  129850. private _renderMainTexture;
  129851. private _setStencil;
  129852. private _setStencilBack;
  129853. private _draw;
  129854. private _drawCamera;
  129855. private _drawRenderingGroup;
  129856. }
  129857. }
  129858. declare module BABYLON {
  129859. /** @hidden */
  129860. export var glowMapMergePixelShader: {
  129861. name: string;
  129862. shader: string;
  129863. };
  129864. }
  129865. declare module BABYLON {
  129866. /** @hidden */
  129867. export var glowMapMergeVertexShader: {
  129868. name: string;
  129869. shader: string;
  129870. };
  129871. }
  129872. declare module BABYLON {
  129873. interface AbstractScene {
  129874. /**
  129875. * Return a the first highlight layer of the scene with a given name.
  129876. * @param name The name of the highlight layer to look for.
  129877. * @return The highlight layer if found otherwise null.
  129878. */
  129879. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  129880. }
  129881. /**
  129882. * Glow layer options. This helps customizing the behaviour
  129883. * of the glow layer.
  129884. */
  129885. export interface IGlowLayerOptions {
  129886. /**
  129887. * Multiplication factor apply to the canvas size to compute the render target size
  129888. * used to generated the glowing objects (the smaller the faster).
  129889. */
  129890. mainTextureRatio: number;
  129891. /**
  129892. * Enforces a fixed size texture to ensure resize independant blur.
  129893. */
  129894. mainTextureFixedSize?: number;
  129895. /**
  129896. * How big is the kernel of the blur texture.
  129897. */
  129898. blurKernelSize: number;
  129899. /**
  129900. * The camera attached to the layer.
  129901. */
  129902. camera: Nullable<Camera>;
  129903. /**
  129904. * Enable MSAA by chosing the number of samples.
  129905. */
  129906. mainTextureSamples?: number;
  129907. /**
  129908. * The rendering group to draw the layer in.
  129909. */
  129910. renderingGroupId: number;
  129911. }
  129912. /**
  129913. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  129914. *
  129915. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  129916. *
  129917. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  129918. */
  129919. export class GlowLayer extends EffectLayer {
  129920. /**
  129921. * Effect Name of the layer.
  129922. */
  129923. static readonly EffectName: string;
  129924. /**
  129925. * The default blur kernel size used for the glow.
  129926. */
  129927. static DefaultBlurKernelSize: number;
  129928. /**
  129929. * The default texture size ratio used for the glow.
  129930. */
  129931. static DefaultTextureRatio: number;
  129932. /**
  129933. * Sets the kernel size of the blur.
  129934. */
  129935. set blurKernelSize(value: number);
  129936. /**
  129937. * Gets the kernel size of the blur.
  129938. */
  129939. get blurKernelSize(): number;
  129940. /**
  129941. * Sets the glow intensity.
  129942. */
  129943. set intensity(value: number);
  129944. /**
  129945. * Gets the glow intensity.
  129946. */
  129947. get intensity(): number;
  129948. private _options;
  129949. private _intensity;
  129950. private _horizontalBlurPostprocess1;
  129951. private _verticalBlurPostprocess1;
  129952. private _horizontalBlurPostprocess2;
  129953. private _verticalBlurPostprocess2;
  129954. private _blurTexture1;
  129955. private _blurTexture2;
  129956. private _postProcesses1;
  129957. private _postProcesses2;
  129958. private _includedOnlyMeshes;
  129959. private _excludedMeshes;
  129960. private _meshesUsingTheirOwnMaterials;
  129961. /**
  129962. * Callback used to let the user override the color selection on a per mesh basis
  129963. */
  129964. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  129965. /**
  129966. * Callback used to let the user override the texture selection on a per mesh basis
  129967. */
  129968. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  129969. /**
  129970. * Instantiates a new glow Layer and references it to the scene.
  129971. * @param name The name of the layer
  129972. * @param scene The scene to use the layer in
  129973. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  129974. */
  129975. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  129976. /**
  129977. * Get the effect name of the layer.
  129978. * @return The effect name
  129979. */
  129980. getEffectName(): string;
  129981. /**
  129982. * Create the merge effect. This is the shader use to blit the information back
  129983. * to the main canvas at the end of the scene rendering.
  129984. */
  129985. protected _createMergeEffect(): Effect;
  129986. /**
  129987. * Creates the render target textures and post processes used in the glow layer.
  129988. */
  129989. protected _createTextureAndPostProcesses(): void;
  129990. /**
  129991. * Checks for the readiness of the element composing the layer.
  129992. * @param subMesh the mesh to check for
  129993. * @param useInstances specify wether or not to use instances to render the mesh
  129994. * @param emissiveTexture the associated emissive texture used to generate the glow
  129995. * @return true if ready otherwise, false
  129996. */
  129997. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  129998. /**
  129999. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  130000. */
  130001. needStencil(): boolean;
  130002. /**
  130003. * Returns true if the mesh can be rendered, otherwise false.
  130004. * @param mesh The mesh to render
  130005. * @param material The material used on the mesh
  130006. * @returns true if it can be rendered otherwise false
  130007. */
  130008. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  130009. /**
  130010. * Implementation specific of rendering the generating effect on the main canvas.
  130011. * @param effect The effect used to render through
  130012. */
  130013. protected _internalRender(effect: Effect): void;
  130014. /**
  130015. * Sets the required values for both the emissive texture and and the main color.
  130016. */
  130017. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  130018. /**
  130019. * Returns true if the mesh should render, otherwise false.
  130020. * @param mesh The mesh to render
  130021. * @returns true if it should render otherwise false
  130022. */
  130023. protected _shouldRenderMesh(mesh: Mesh): boolean;
  130024. /**
  130025. * Adds specific effects defines.
  130026. * @param defines The defines to add specifics to.
  130027. */
  130028. protected _addCustomEffectDefines(defines: string[]): void;
  130029. /**
  130030. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  130031. * @param mesh The mesh to exclude from the glow layer
  130032. */
  130033. addExcludedMesh(mesh: Mesh): void;
  130034. /**
  130035. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  130036. * @param mesh The mesh to remove
  130037. */
  130038. removeExcludedMesh(mesh: Mesh): void;
  130039. /**
  130040. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  130041. * @param mesh The mesh to include in the glow layer
  130042. */
  130043. addIncludedOnlyMesh(mesh: Mesh): void;
  130044. /**
  130045. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  130046. * @param mesh The mesh to remove
  130047. */
  130048. removeIncludedOnlyMesh(mesh: Mesh): void;
  130049. /**
  130050. * Determine if a given mesh will be used in the glow layer
  130051. * @param mesh The mesh to test
  130052. * @returns true if the mesh will be highlighted by the current glow layer
  130053. */
  130054. hasMesh(mesh: AbstractMesh): boolean;
  130055. /**
  130056. * Defines whether the current material of the mesh should be use to render the effect.
  130057. * @param mesh defines the current mesh to render
  130058. */
  130059. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  130060. /**
  130061. * Add a mesh to be rendered through its own material and not with emissive only.
  130062. * @param mesh The mesh for which we need to use its material
  130063. */
  130064. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  130065. /**
  130066. * Remove a mesh from being rendered through its own material and not with emissive only.
  130067. * @param mesh The mesh for which we need to not use its material
  130068. */
  130069. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  130070. /**
  130071. * Free any resources and references associated to a mesh.
  130072. * Internal use
  130073. * @param mesh The mesh to free.
  130074. * @hidden
  130075. */
  130076. _disposeMesh(mesh: Mesh): void;
  130077. /**
  130078. * Gets the class name of the effect layer
  130079. * @returns the string with the class name of the effect layer
  130080. */
  130081. getClassName(): string;
  130082. /**
  130083. * Serializes this glow layer
  130084. * @returns a serialized glow layer object
  130085. */
  130086. serialize(): any;
  130087. /**
  130088. * Creates a Glow Layer from parsed glow layer data
  130089. * @param parsedGlowLayer defines glow layer data
  130090. * @param scene defines the current scene
  130091. * @param rootUrl defines the root URL containing the glow layer information
  130092. * @returns a parsed Glow Layer
  130093. */
  130094. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  130095. }
  130096. }
  130097. declare module BABYLON {
  130098. /** @hidden */
  130099. export var glowBlurPostProcessPixelShader: {
  130100. name: string;
  130101. shader: string;
  130102. };
  130103. }
  130104. declare module BABYLON {
  130105. interface AbstractScene {
  130106. /**
  130107. * Return a the first highlight layer of the scene with a given name.
  130108. * @param name The name of the highlight layer to look for.
  130109. * @return The highlight layer if found otherwise null.
  130110. */
  130111. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  130112. }
  130113. /**
  130114. * Highlight layer options. This helps customizing the behaviour
  130115. * of the highlight layer.
  130116. */
  130117. export interface IHighlightLayerOptions {
  130118. /**
  130119. * Multiplication factor apply to the canvas size to compute the render target size
  130120. * used to generated the glowing objects (the smaller the faster).
  130121. */
  130122. mainTextureRatio: number;
  130123. /**
  130124. * Enforces a fixed size texture to ensure resize independant blur.
  130125. */
  130126. mainTextureFixedSize?: number;
  130127. /**
  130128. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  130129. * of the picture to blur (the smaller the faster).
  130130. */
  130131. blurTextureSizeRatio: number;
  130132. /**
  130133. * How big in texel of the blur texture is the vertical blur.
  130134. */
  130135. blurVerticalSize: number;
  130136. /**
  130137. * How big in texel of the blur texture is the horizontal blur.
  130138. */
  130139. blurHorizontalSize: number;
  130140. /**
  130141. * Alpha blending mode used to apply the blur. Default is combine.
  130142. */
  130143. alphaBlendingMode: number;
  130144. /**
  130145. * The camera attached to the layer.
  130146. */
  130147. camera: Nullable<Camera>;
  130148. /**
  130149. * Should we display highlight as a solid stroke?
  130150. */
  130151. isStroke?: boolean;
  130152. /**
  130153. * The rendering group to draw the layer in.
  130154. */
  130155. renderingGroupId: number;
  130156. }
  130157. /**
  130158. * The highlight layer Helps adding a glow effect around a mesh.
  130159. *
  130160. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  130161. * glowy meshes to your scene.
  130162. *
  130163. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  130164. */
  130165. export class HighlightLayer extends EffectLayer {
  130166. name: string;
  130167. /**
  130168. * Effect Name of the highlight layer.
  130169. */
  130170. static readonly EffectName: string;
  130171. /**
  130172. * The neutral color used during the preparation of the glow effect.
  130173. * This is black by default as the blend operation is a blend operation.
  130174. */
  130175. static NeutralColor: Color4;
  130176. /**
  130177. * Stencil value used for glowing meshes.
  130178. */
  130179. static GlowingMeshStencilReference: number;
  130180. /**
  130181. * Stencil value used for the other meshes in the scene.
  130182. */
  130183. static NormalMeshStencilReference: number;
  130184. /**
  130185. * Specifies whether or not the inner glow is ACTIVE in the layer.
  130186. */
  130187. innerGlow: boolean;
  130188. /**
  130189. * Specifies whether or not the outer glow is ACTIVE in the layer.
  130190. */
  130191. outerGlow: boolean;
  130192. /**
  130193. * Specifies the horizontal size of the blur.
  130194. */
  130195. set blurHorizontalSize(value: number);
  130196. /**
  130197. * Specifies the vertical size of the blur.
  130198. */
  130199. set blurVerticalSize(value: number);
  130200. /**
  130201. * Gets the horizontal size of the blur.
  130202. */
  130203. get blurHorizontalSize(): number;
  130204. /**
  130205. * Gets the vertical size of the blur.
  130206. */
  130207. get blurVerticalSize(): number;
  130208. /**
  130209. * An event triggered when the highlight layer is being blurred.
  130210. */
  130211. onBeforeBlurObservable: Observable<HighlightLayer>;
  130212. /**
  130213. * An event triggered when the highlight layer has been blurred.
  130214. */
  130215. onAfterBlurObservable: Observable<HighlightLayer>;
  130216. private _instanceGlowingMeshStencilReference;
  130217. private _options;
  130218. private _downSamplePostprocess;
  130219. private _horizontalBlurPostprocess;
  130220. private _verticalBlurPostprocess;
  130221. private _blurTexture;
  130222. private _meshes;
  130223. private _excludedMeshes;
  130224. /**
  130225. * Instantiates a new highlight Layer and references it to the scene..
  130226. * @param name The name of the layer
  130227. * @param scene The scene to use the layer in
  130228. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  130229. */
  130230. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  130231. /**
  130232. * Get the effect name of the layer.
  130233. * @return The effect name
  130234. */
  130235. getEffectName(): string;
  130236. /**
  130237. * Create the merge effect. This is the shader use to blit the information back
  130238. * to the main canvas at the end of the scene rendering.
  130239. */
  130240. protected _createMergeEffect(): Effect;
  130241. /**
  130242. * Creates the render target textures and post processes used in the highlight layer.
  130243. */
  130244. protected _createTextureAndPostProcesses(): void;
  130245. /**
  130246. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  130247. */
  130248. needStencil(): boolean;
  130249. /**
  130250. * Checks for the readiness of the element composing the layer.
  130251. * @param subMesh the mesh to check for
  130252. * @param useInstances specify wether or not to use instances to render the mesh
  130253. * @param emissiveTexture the associated emissive texture used to generate the glow
  130254. * @return true if ready otherwise, false
  130255. */
  130256. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  130257. /**
  130258. * Implementation specific of rendering the generating effect on the main canvas.
  130259. * @param effect The effect used to render through
  130260. */
  130261. protected _internalRender(effect: Effect): void;
  130262. /**
  130263. * Returns true if the layer contains information to display, otherwise false.
  130264. */
  130265. shouldRender(): boolean;
  130266. /**
  130267. * Returns true if the mesh should render, otherwise false.
  130268. * @param mesh The mesh to render
  130269. * @returns true if it should render otherwise false
  130270. */
  130271. protected _shouldRenderMesh(mesh: Mesh): boolean;
  130272. /**
  130273. * Adds specific effects defines.
  130274. * @param defines The defines to add specifics to.
  130275. */
  130276. protected _addCustomEffectDefines(defines: string[]): void;
  130277. /**
  130278. * Sets the required values for both the emissive texture and and the main color.
  130279. */
  130280. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  130281. /**
  130282. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  130283. * @param mesh The mesh to exclude from the highlight layer
  130284. */
  130285. addExcludedMesh(mesh: Mesh): void;
  130286. /**
  130287. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  130288. * @param mesh The mesh to highlight
  130289. */
  130290. removeExcludedMesh(mesh: Mesh): void;
  130291. /**
  130292. * Determine if a given mesh will be highlighted by the current HighlightLayer
  130293. * @param mesh mesh to test
  130294. * @returns true if the mesh will be highlighted by the current HighlightLayer
  130295. */
  130296. hasMesh(mesh: AbstractMesh): boolean;
  130297. /**
  130298. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  130299. * @param mesh The mesh to highlight
  130300. * @param color The color of the highlight
  130301. * @param glowEmissiveOnly Extract the glow from the emissive texture
  130302. */
  130303. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  130304. /**
  130305. * Remove a mesh from the highlight layer in order to make it stop glowing.
  130306. * @param mesh The mesh to highlight
  130307. */
  130308. removeMesh(mesh: Mesh): void;
  130309. /**
  130310. * Remove all the meshes currently referenced in the highlight layer
  130311. */
  130312. removeAllMeshes(): void;
  130313. /**
  130314. * Force the stencil to the normal expected value for none glowing parts
  130315. */
  130316. private _defaultStencilReference;
  130317. /**
  130318. * Free any resources and references associated to a mesh.
  130319. * Internal use
  130320. * @param mesh The mesh to free.
  130321. * @hidden
  130322. */
  130323. _disposeMesh(mesh: Mesh): void;
  130324. /**
  130325. * Dispose the highlight layer and free resources.
  130326. */
  130327. dispose(): void;
  130328. /**
  130329. * Gets the class name of the effect layer
  130330. * @returns the string with the class name of the effect layer
  130331. */
  130332. getClassName(): string;
  130333. /**
  130334. * Serializes this Highlight layer
  130335. * @returns a serialized Highlight layer object
  130336. */
  130337. serialize(): any;
  130338. /**
  130339. * Creates a Highlight layer from parsed Highlight layer data
  130340. * @param parsedHightlightLayer defines the Highlight layer data
  130341. * @param scene defines the current scene
  130342. * @param rootUrl defines the root URL containing the Highlight layer information
  130343. * @returns a parsed Highlight layer
  130344. */
  130345. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  130346. }
  130347. }
  130348. declare module BABYLON {
  130349. interface AbstractScene {
  130350. /**
  130351. * The list of layers (background and foreground) of the scene
  130352. */
  130353. layers: Array<Layer>;
  130354. }
  130355. /**
  130356. * Defines the layer scene component responsible to manage any layers
  130357. * in a given scene.
  130358. */
  130359. export class LayerSceneComponent implements ISceneComponent {
  130360. /**
  130361. * The component name helpfull to identify the component in the list of scene components.
  130362. */
  130363. readonly name: string;
  130364. /**
  130365. * The scene the component belongs to.
  130366. */
  130367. scene: Scene;
  130368. private _engine;
  130369. /**
  130370. * Creates a new instance of the component for the given scene
  130371. * @param scene Defines the scene to register the component in
  130372. */
  130373. constructor(scene: Scene);
  130374. /**
  130375. * Registers the component in a given scene
  130376. */
  130377. register(): void;
  130378. /**
  130379. * Rebuilds the elements related to this component in case of
  130380. * context lost for instance.
  130381. */
  130382. rebuild(): void;
  130383. /**
  130384. * Disposes the component and the associated ressources.
  130385. */
  130386. dispose(): void;
  130387. private _draw;
  130388. private _drawCameraPredicate;
  130389. private _drawCameraBackground;
  130390. private _drawCameraForeground;
  130391. private _drawRenderTargetPredicate;
  130392. private _drawRenderTargetBackground;
  130393. private _drawRenderTargetForeground;
  130394. /**
  130395. * Adds all the elements from the container to the scene
  130396. * @param container the container holding the elements
  130397. */
  130398. addFromContainer(container: AbstractScene): void;
  130399. /**
  130400. * Removes all the elements in the container from the scene
  130401. * @param container contains the elements to remove
  130402. * @param dispose if the removed element should be disposed (default: false)
  130403. */
  130404. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  130405. }
  130406. }
  130407. declare module BABYLON {
  130408. /** @hidden */
  130409. export var layerPixelShader: {
  130410. name: string;
  130411. shader: string;
  130412. };
  130413. }
  130414. declare module BABYLON {
  130415. /** @hidden */
  130416. export var layerVertexShader: {
  130417. name: string;
  130418. shader: string;
  130419. };
  130420. }
  130421. declare module BABYLON {
  130422. /**
  130423. * This represents a full screen 2d layer.
  130424. * This can be useful to display a picture in the background of your scene for instance.
  130425. * @see https://www.babylonjs-playground.com/#08A2BS#1
  130426. */
  130427. export class Layer {
  130428. /**
  130429. * Define the name of the layer.
  130430. */
  130431. name: string;
  130432. /**
  130433. * Define the texture the layer should display.
  130434. */
  130435. texture: Nullable<Texture>;
  130436. /**
  130437. * Is the layer in background or foreground.
  130438. */
  130439. isBackground: boolean;
  130440. /**
  130441. * Define the color of the layer (instead of texture).
  130442. */
  130443. color: Color4;
  130444. /**
  130445. * Define the scale of the layer in order to zoom in out of the texture.
  130446. */
  130447. scale: Vector2;
  130448. /**
  130449. * Define an offset for the layer in order to shift the texture.
  130450. */
  130451. offset: Vector2;
  130452. /**
  130453. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  130454. */
  130455. alphaBlendingMode: number;
  130456. /**
  130457. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  130458. * Alpha test will not mix with the background color in case of transparency.
  130459. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  130460. */
  130461. alphaTest: boolean;
  130462. /**
  130463. * Define a mask to restrict the layer to only some of the scene cameras.
  130464. */
  130465. layerMask: number;
  130466. /**
  130467. * Define the list of render target the layer is visible into.
  130468. */
  130469. renderTargetTextures: RenderTargetTexture[];
  130470. /**
  130471. * Define if the layer is only used in renderTarget or if it also
  130472. * renders in the main frame buffer of the canvas.
  130473. */
  130474. renderOnlyInRenderTargetTextures: boolean;
  130475. private _scene;
  130476. private _vertexBuffers;
  130477. private _indexBuffer;
  130478. private _effect;
  130479. private _previousDefines;
  130480. /**
  130481. * An event triggered when the layer is disposed.
  130482. */
  130483. onDisposeObservable: Observable<Layer>;
  130484. private _onDisposeObserver;
  130485. /**
  130486. * Back compatibility with callback before the onDisposeObservable existed.
  130487. * The set callback will be triggered when the layer has been disposed.
  130488. */
  130489. set onDispose(callback: () => void);
  130490. /**
  130491. * An event triggered before rendering the scene
  130492. */
  130493. onBeforeRenderObservable: Observable<Layer>;
  130494. private _onBeforeRenderObserver;
  130495. /**
  130496. * Back compatibility with callback before the onBeforeRenderObservable existed.
  130497. * The set callback will be triggered just before rendering the layer.
  130498. */
  130499. set onBeforeRender(callback: () => void);
  130500. /**
  130501. * An event triggered after rendering the scene
  130502. */
  130503. onAfterRenderObservable: Observable<Layer>;
  130504. private _onAfterRenderObserver;
  130505. /**
  130506. * Back compatibility with callback before the onAfterRenderObservable existed.
  130507. * The set callback will be triggered just after rendering the layer.
  130508. */
  130509. set onAfterRender(callback: () => void);
  130510. /**
  130511. * Instantiates a new layer.
  130512. * This represents a full screen 2d layer.
  130513. * This can be useful to display a picture in the background of your scene for instance.
  130514. * @see https://www.babylonjs-playground.com/#08A2BS#1
  130515. * @param name Define the name of the layer in the scene
  130516. * @param imgUrl Define the url of the texture to display in the layer
  130517. * @param scene Define the scene the layer belongs to
  130518. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  130519. * @param color Defines a color for the layer
  130520. */
  130521. constructor(
  130522. /**
  130523. * Define the name of the layer.
  130524. */
  130525. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  130526. private _createIndexBuffer;
  130527. /** @hidden */
  130528. _rebuild(): void;
  130529. /**
  130530. * Renders the layer in the scene.
  130531. */
  130532. render(): void;
  130533. /**
  130534. * Disposes and releases the associated ressources.
  130535. */
  130536. dispose(): void;
  130537. }
  130538. }
  130539. declare module BABYLON {
  130540. /** @hidden */
  130541. export var lensFlarePixelShader: {
  130542. name: string;
  130543. shader: string;
  130544. };
  130545. }
  130546. declare module BABYLON {
  130547. /** @hidden */
  130548. export var lensFlareVertexShader: {
  130549. name: string;
  130550. shader: string;
  130551. };
  130552. }
  130553. declare module BABYLON {
  130554. /**
  130555. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  130556. * It is usually composed of several `lensFlare`.
  130557. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  130558. */
  130559. export class LensFlareSystem {
  130560. /**
  130561. * Define the name of the lens flare system
  130562. */
  130563. name: string;
  130564. /**
  130565. * List of lens flares used in this system.
  130566. */
  130567. lensFlares: LensFlare[];
  130568. /**
  130569. * Define a limit from the border the lens flare can be visible.
  130570. */
  130571. borderLimit: number;
  130572. /**
  130573. * Define a viewport border we do not want to see the lens flare in.
  130574. */
  130575. viewportBorder: number;
  130576. /**
  130577. * Define a predicate which could limit the list of meshes able to occlude the effect.
  130578. */
  130579. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  130580. /**
  130581. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  130582. */
  130583. layerMask: number;
  130584. /**
  130585. * Define the id of the lens flare system in the scene.
  130586. * (equal to name by default)
  130587. */
  130588. id: string;
  130589. private _scene;
  130590. private _emitter;
  130591. private _vertexBuffers;
  130592. private _indexBuffer;
  130593. private _effect;
  130594. private _positionX;
  130595. private _positionY;
  130596. private _isEnabled;
  130597. /** @hidden */
  130598. static _SceneComponentInitialization: (scene: Scene) => void;
  130599. /**
  130600. * Instantiates a lens flare system.
  130601. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  130602. * It is usually composed of several `lensFlare`.
  130603. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  130604. * @param name Define the name of the lens flare system in the scene
  130605. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  130606. * @param scene Define the scene the lens flare system belongs to
  130607. */
  130608. constructor(
  130609. /**
  130610. * Define the name of the lens flare system
  130611. */
  130612. name: string, emitter: any, scene: Scene);
  130613. /**
  130614. * Define if the lens flare system is enabled.
  130615. */
  130616. get isEnabled(): boolean;
  130617. set isEnabled(value: boolean);
  130618. /**
  130619. * Get the scene the effects belongs to.
  130620. * @returns the scene holding the lens flare system
  130621. */
  130622. getScene(): Scene;
  130623. /**
  130624. * Get the emitter of the lens flare system.
  130625. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  130626. * @returns the emitter of the lens flare system
  130627. */
  130628. getEmitter(): any;
  130629. /**
  130630. * Set the emitter of the lens flare system.
  130631. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  130632. * @param newEmitter Define the new emitter of the system
  130633. */
  130634. setEmitter(newEmitter: any): void;
  130635. /**
  130636. * Get the lens flare system emitter position.
  130637. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  130638. * @returns the position
  130639. */
  130640. getEmitterPosition(): Vector3;
  130641. /**
  130642. * @hidden
  130643. */
  130644. computeEffectivePosition(globalViewport: Viewport): boolean;
  130645. /** @hidden */
  130646. _isVisible(): boolean;
  130647. /**
  130648. * @hidden
  130649. */
  130650. render(): boolean;
  130651. /**
  130652. * Dispose and release the lens flare with its associated resources.
  130653. */
  130654. dispose(): void;
  130655. /**
  130656. * Parse a lens flare system from a JSON repressentation
  130657. * @param parsedLensFlareSystem Define the JSON to parse
  130658. * @param scene Define the scene the parsed system should be instantiated in
  130659. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  130660. * @returns the parsed system
  130661. */
  130662. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  130663. /**
  130664. * Serialize the current Lens Flare System into a JSON representation.
  130665. * @returns the serialized JSON
  130666. */
  130667. serialize(): any;
  130668. }
  130669. }
  130670. declare module BABYLON {
  130671. /**
  130672. * This represents one of the lens effect in a `lensFlareSystem`.
  130673. * It controls one of the indiviual texture used in the effect.
  130674. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  130675. */
  130676. export class LensFlare {
  130677. /**
  130678. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  130679. */
  130680. size: number;
  130681. /**
  130682. * 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.
  130683. */
  130684. position: number;
  130685. /**
  130686. * Define the lens color.
  130687. */
  130688. color: Color3;
  130689. /**
  130690. * Define the lens texture.
  130691. */
  130692. texture: Nullable<Texture>;
  130693. /**
  130694. * Define the alpha mode to render this particular lens.
  130695. */
  130696. alphaMode: number;
  130697. private _system;
  130698. /**
  130699. * Creates a new Lens Flare.
  130700. * This represents one of the lens effect in a `lensFlareSystem`.
  130701. * It controls one of the indiviual texture used in the effect.
  130702. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  130703. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  130704. * @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.
  130705. * @param color Define the lens color
  130706. * @param imgUrl Define the lens texture url
  130707. * @param system Define the `lensFlareSystem` this flare is part of
  130708. * @returns The newly created Lens Flare
  130709. */
  130710. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  130711. /**
  130712. * Instantiates a new Lens Flare.
  130713. * This represents one of the lens effect in a `lensFlareSystem`.
  130714. * It controls one of the indiviual texture used in the effect.
  130715. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  130716. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  130717. * @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.
  130718. * @param color Define the lens color
  130719. * @param imgUrl Define the lens texture url
  130720. * @param system Define the `lensFlareSystem` this flare is part of
  130721. */
  130722. constructor(
  130723. /**
  130724. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  130725. */
  130726. size: number,
  130727. /**
  130728. * 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.
  130729. */
  130730. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  130731. /**
  130732. * Dispose and release the lens flare with its associated resources.
  130733. */
  130734. dispose(): void;
  130735. }
  130736. }
  130737. declare module BABYLON {
  130738. interface AbstractScene {
  130739. /**
  130740. * The list of lens flare system added to the scene
  130741. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  130742. */
  130743. lensFlareSystems: Array<LensFlareSystem>;
  130744. /**
  130745. * Removes the given lens flare system from this scene.
  130746. * @param toRemove The lens flare system to remove
  130747. * @returns The index of the removed lens flare system
  130748. */
  130749. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  130750. /**
  130751. * Adds the given lens flare system to this scene
  130752. * @param newLensFlareSystem The lens flare system to add
  130753. */
  130754. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  130755. /**
  130756. * Gets a lens flare system using its name
  130757. * @param name defines the name to look for
  130758. * @returns the lens flare system or null if not found
  130759. */
  130760. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  130761. /**
  130762. * Gets a lens flare system using its id
  130763. * @param id defines the id to look for
  130764. * @returns the lens flare system or null if not found
  130765. */
  130766. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  130767. }
  130768. /**
  130769. * Defines the lens flare scene component responsible to manage any lens flares
  130770. * in a given scene.
  130771. */
  130772. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  130773. /**
  130774. * The component name helpfull to identify the component in the list of scene components.
  130775. */
  130776. readonly name: string;
  130777. /**
  130778. * The scene the component belongs to.
  130779. */
  130780. scene: Scene;
  130781. /**
  130782. * Creates a new instance of the component for the given scene
  130783. * @param scene Defines the scene to register the component in
  130784. */
  130785. constructor(scene: Scene);
  130786. /**
  130787. * Registers the component in a given scene
  130788. */
  130789. register(): void;
  130790. /**
  130791. * Rebuilds the elements related to this component in case of
  130792. * context lost for instance.
  130793. */
  130794. rebuild(): void;
  130795. /**
  130796. * Adds all the elements from the container to the scene
  130797. * @param container the container holding the elements
  130798. */
  130799. addFromContainer(container: AbstractScene): void;
  130800. /**
  130801. * Removes all the elements in the container from the scene
  130802. * @param container contains the elements to remove
  130803. * @param dispose if the removed element should be disposed (default: false)
  130804. */
  130805. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  130806. /**
  130807. * Serializes the component data to the specified json object
  130808. * @param serializationObject The object to serialize to
  130809. */
  130810. serialize(serializationObject: any): void;
  130811. /**
  130812. * Disposes the component and the associated ressources.
  130813. */
  130814. dispose(): void;
  130815. private _draw;
  130816. }
  130817. }
  130818. declare module BABYLON {
  130819. /** @hidden */
  130820. export var depthPixelShader: {
  130821. name: string;
  130822. shader: string;
  130823. };
  130824. }
  130825. declare module BABYLON {
  130826. /** @hidden */
  130827. export var depthVertexShader: {
  130828. name: string;
  130829. shader: string;
  130830. };
  130831. }
  130832. declare module BABYLON {
  130833. /**
  130834. * This represents a depth renderer in Babylon.
  130835. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  130836. */
  130837. export class DepthRenderer {
  130838. private _scene;
  130839. private _depthMap;
  130840. private _effect;
  130841. private readonly _storeNonLinearDepth;
  130842. private readonly _clearColor;
  130843. /** Get if the depth renderer is using packed depth or not */
  130844. readonly isPacked: boolean;
  130845. private _cachedDefines;
  130846. private _camera;
  130847. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  130848. enabled: boolean;
  130849. /**
  130850. * Specifiess that the depth renderer will only be used within
  130851. * the camera it is created for.
  130852. * This can help forcing its rendering during the camera processing.
  130853. */
  130854. useOnlyInActiveCamera: boolean;
  130855. /** @hidden */
  130856. static _SceneComponentInitialization: (scene: Scene) => void;
  130857. /**
  130858. * Instantiates a depth renderer
  130859. * @param scene The scene the renderer belongs to
  130860. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  130861. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  130862. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  130863. */
  130864. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  130865. /**
  130866. * Creates the depth rendering effect and checks if the effect is ready.
  130867. * @param subMesh The submesh to be used to render the depth map of
  130868. * @param useInstances If multiple world instances should be used
  130869. * @returns if the depth renderer is ready to render the depth map
  130870. */
  130871. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  130872. /**
  130873. * Gets the texture which the depth map will be written to.
  130874. * @returns The depth map texture
  130875. */
  130876. getDepthMap(): RenderTargetTexture;
  130877. /**
  130878. * Disposes of the depth renderer.
  130879. */
  130880. dispose(): void;
  130881. }
  130882. }
  130883. declare module BABYLON {
  130884. /** @hidden */
  130885. export var minmaxReduxPixelShader: {
  130886. name: string;
  130887. shader: string;
  130888. };
  130889. }
  130890. declare module BABYLON {
  130891. /**
  130892. * This class computes a min/max reduction from a texture: it means it computes the minimum
  130893. * and maximum values from all values of the texture.
  130894. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  130895. * The source values are read from the red channel of the texture.
  130896. */
  130897. export class MinMaxReducer {
  130898. /**
  130899. * Observable triggered when the computation has been performed
  130900. */
  130901. onAfterReductionPerformed: Observable<{
  130902. min: number;
  130903. max: number;
  130904. }>;
  130905. protected _camera: Camera;
  130906. protected _sourceTexture: Nullable<RenderTargetTexture>;
  130907. protected _reductionSteps: Nullable<Array<PostProcess>>;
  130908. protected _postProcessManager: PostProcessManager;
  130909. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  130910. protected _forceFullscreenViewport: boolean;
  130911. /**
  130912. * Creates a min/max reducer
  130913. * @param camera The camera to use for the post processes
  130914. */
  130915. constructor(camera: Camera);
  130916. /**
  130917. * Gets the texture used to read the values from.
  130918. */
  130919. get sourceTexture(): Nullable<RenderTargetTexture>;
  130920. /**
  130921. * Sets the source texture to read the values from.
  130922. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  130923. * because in such textures '1' value must not be taken into account to compute the maximum
  130924. * as this value is used to clear the texture.
  130925. * Note that the computation is not activated by calling this function, you must call activate() for that!
  130926. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  130927. * @param depthRedux Indicates if the texture is a depth texture or not
  130928. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  130929. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  130930. */
  130931. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  130932. /**
  130933. * Defines the refresh rate of the computation.
  130934. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  130935. */
  130936. get refreshRate(): number;
  130937. set refreshRate(value: number);
  130938. protected _activated: boolean;
  130939. /**
  130940. * Gets the activation status of the reducer
  130941. */
  130942. get activated(): boolean;
  130943. /**
  130944. * Activates the reduction computation.
  130945. * When activated, the observers registered in onAfterReductionPerformed are
  130946. * called after the compuation is performed
  130947. */
  130948. activate(): void;
  130949. /**
  130950. * Deactivates the reduction computation.
  130951. */
  130952. deactivate(): void;
  130953. /**
  130954. * Disposes the min/max reducer
  130955. * @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.
  130956. */
  130957. dispose(disposeAll?: boolean): void;
  130958. }
  130959. }
  130960. declare module BABYLON {
  130961. /**
  130962. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  130963. */
  130964. export class DepthReducer extends MinMaxReducer {
  130965. private _depthRenderer;
  130966. private _depthRendererId;
  130967. /**
  130968. * Gets the depth renderer used for the computation.
  130969. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  130970. */
  130971. get depthRenderer(): Nullable<DepthRenderer>;
  130972. /**
  130973. * Creates a depth reducer
  130974. * @param camera The camera used to render the depth texture
  130975. */
  130976. constructor(camera: Camera);
  130977. /**
  130978. * Sets the depth renderer to use to generate the depth map
  130979. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  130980. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  130981. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  130982. */
  130983. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  130984. /** @hidden */
  130985. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  130986. /**
  130987. * Activates the reduction computation.
  130988. * When activated, the observers registered in onAfterReductionPerformed are
  130989. * called after the compuation is performed
  130990. */
  130991. activate(): void;
  130992. /**
  130993. * Deactivates the reduction computation.
  130994. */
  130995. deactivate(): void;
  130996. /**
  130997. * Disposes the depth reducer
  130998. * @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.
  130999. */
  131000. dispose(disposeAll?: boolean): void;
  131001. }
  131002. }
  131003. declare module BABYLON {
  131004. /**
  131005. * A CSM implementation allowing casting shadows on large scenes.
  131006. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  131007. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  131008. */
  131009. export class CascadedShadowGenerator extends ShadowGenerator {
  131010. private static readonly frustumCornersNDCSpace;
  131011. /**
  131012. * Name of the CSM class
  131013. */
  131014. static CLASSNAME: string;
  131015. /**
  131016. * Defines the default number of cascades used by the CSM.
  131017. */
  131018. static readonly DEFAULT_CASCADES_COUNT: number;
  131019. /**
  131020. * Defines the minimum number of cascades used by the CSM.
  131021. */
  131022. static readonly MIN_CASCADES_COUNT: number;
  131023. /**
  131024. * Defines the maximum number of cascades used by the CSM.
  131025. */
  131026. static readonly MAX_CASCADES_COUNT: number;
  131027. protected _validateFilter(filter: number): number;
  131028. /**
  131029. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  131030. */
  131031. penumbraDarkness: number;
  131032. private _numCascades;
  131033. /**
  131034. * Gets or set the number of cascades used by the CSM.
  131035. */
  131036. get numCascades(): number;
  131037. set numCascades(value: number);
  131038. /**
  131039. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  131040. * The trade off is that you lose some precision in the shadow rendering when enabling this setting.
  131041. */
  131042. stabilizeCascades: boolean;
  131043. private _freezeShadowCastersBoundingInfo;
  131044. private _freezeShadowCastersBoundingInfoObservable;
  131045. /**
  131046. * Enables or disables the shadow casters bounding info computation.
  131047. * If your shadow casters don't move, you can disable this feature.
  131048. * If it is enabled, the bounding box computation is done every frame.
  131049. */
  131050. get freezeShadowCastersBoundingInfo(): boolean;
  131051. set freezeShadowCastersBoundingInfo(freeze: boolean);
  131052. private _scbiMin;
  131053. private _scbiMax;
  131054. protected _computeShadowCastersBoundingInfo(): void;
  131055. protected _shadowCastersBoundingInfo: BoundingInfo;
  131056. /**
  131057. * Gets or sets the shadow casters bounding info.
  131058. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  131059. * so that the system won't overwrite the bounds you provide
  131060. */
  131061. get shadowCastersBoundingInfo(): BoundingInfo;
  131062. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  131063. protected _breaksAreDirty: boolean;
  131064. protected _minDistance: number;
  131065. protected _maxDistance: number;
  131066. /**
  131067. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  131068. *
  131069. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  131070. * If you don't know these values, simply leave them to their defaults and don't call this function.
  131071. * @param min minimal distance for the breaks (default to 0.)
  131072. * @param max maximal distance for the breaks (default to 1.)
  131073. */
  131074. setMinMaxDistance(min: number, max: number): void;
  131075. /** Gets the minimal distance used in the cascade break computation */
  131076. get minDistance(): number;
  131077. /** Gets the maximal distance used in the cascade break computation */
  131078. get maxDistance(): number;
  131079. /**
  131080. * Gets the class name of that object
  131081. * @returns "CascadedShadowGenerator"
  131082. */
  131083. getClassName(): string;
  131084. private _cascadeMinExtents;
  131085. private _cascadeMaxExtents;
  131086. /**
  131087. * Gets a cascade minimum extents
  131088. * @param cascadeIndex index of the cascade
  131089. * @returns the minimum cascade extents
  131090. */
  131091. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  131092. /**
  131093. * Gets a cascade maximum extents
  131094. * @param cascadeIndex index of the cascade
  131095. * @returns the maximum cascade extents
  131096. */
  131097. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  131098. private _cascades;
  131099. private _currentLayer;
  131100. private _viewSpaceFrustumsZ;
  131101. private _viewMatrices;
  131102. private _projectionMatrices;
  131103. private _transformMatrices;
  131104. private _transformMatricesAsArray;
  131105. private _frustumLengths;
  131106. private _lightSizeUVCorrection;
  131107. private _depthCorrection;
  131108. private _frustumCornersWorldSpace;
  131109. private _frustumCenter;
  131110. private _shadowCameraPos;
  131111. private _shadowMaxZ;
  131112. /**
  131113. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  131114. * It defaults to camera.maxZ
  131115. */
  131116. get shadowMaxZ(): number;
  131117. /**
  131118. * Sets the shadow max z distance.
  131119. */
  131120. set shadowMaxZ(value: number);
  131121. protected _debug: boolean;
  131122. /**
  131123. * Gets or sets the debug flag.
  131124. * When enabled, the cascades are materialized by different colors on the screen.
  131125. */
  131126. get debug(): boolean;
  131127. set debug(dbg: boolean);
  131128. private _depthClamp;
  131129. /**
  131130. * Gets or sets the depth clamping value.
  131131. *
  131132. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  131133. * to account for the shadow casters far away.
  131134. *
  131135. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  131136. */
  131137. get depthClamp(): boolean;
  131138. set depthClamp(value: boolean);
  131139. private _cascadeBlendPercentage;
  131140. /**
  131141. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  131142. * It defaults to 0.1 (10% blending).
  131143. */
  131144. get cascadeBlendPercentage(): number;
  131145. set cascadeBlendPercentage(value: number);
  131146. private _lambda;
  131147. /**
  131148. * Gets or set the lambda parameter.
  131149. * This parameter is used to split the camera frustum and create the cascades.
  131150. * 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.
  131151. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  131152. */
  131153. get lambda(): number;
  131154. set lambda(value: number);
  131155. /**
  131156. * Gets the view matrix corresponding to a given cascade
  131157. * @param cascadeNum cascade to retrieve the view matrix from
  131158. * @returns the cascade view matrix
  131159. */
  131160. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  131161. /**
  131162. * Gets the projection matrix corresponding to a given cascade
  131163. * @param cascadeNum cascade to retrieve the projection matrix from
  131164. * @returns the cascade projection matrix
  131165. */
  131166. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  131167. /**
  131168. * Gets the transformation matrix corresponding to a given cascade
  131169. * @param cascadeNum cascade to retrieve the transformation matrix from
  131170. * @returns the cascade transformation matrix
  131171. */
  131172. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  131173. private _depthRenderer;
  131174. /**
  131175. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  131176. *
  131177. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  131178. *
  131179. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  131180. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  131181. * @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
  131182. */
  131183. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  131184. private _depthReducer;
  131185. private _autoCalcDepthBounds;
  131186. /**
  131187. * Gets or sets the autoCalcDepthBounds property.
  131188. *
  131189. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  131190. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  131191. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  131192. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  131193. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  131194. */
  131195. get autoCalcDepthBounds(): boolean;
  131196. set autoCalcDepthBounds(value: boolean);
  131197. /**
  131198. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  131199. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  131200. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  131201. * for setting the refresh rate on the renderer yourself!
  131202. */
  131203. get autoCalcDepthBoundsRefreshRate(): number;
  131204. set autoCalcDepthBoundsRefreshRate(value: number);
  131205. /**
  131206. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  131207. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  131208. * you change the camera near/far planes!
  131209. */
  131210. splitFrustum(): void;
  131211. private _splitFrustum;
  131212. private _computeMatrices;
  131213. private _computeFrustumInWorldSpace;
  131214. private _computeCascadeFrustum;
  131215. /**
  131216. * Support test.
  131217. */
  131218. static get IsSupported(): boolean;
  131219. /** @hidden */
  131220. static _SceneComponentInitialization: (scene: Scene) => void;
  131221. /**
  131222. * Creates a Cascaded Shadow Generator object.
  131223. * A ShadowGenerator is the required tool to use the shadows.
  131224. * Each directional light casting shadows needs to use its own ShadowGenerator.
  131225. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  131226. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  131227. * @param light The directional light object generating the shadows.
  131228. * @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.
  131229. */
  131230. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  131231. protected _initializeGenerator(): void;
  131232. protected _createTargetRenderTexture(): void;
  131233. protected _initializeShadowMap(): void;
  131234. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  131235. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  131236. /**
  131237. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  131238. * @param defines Defines of the material we want to update
  131239. * @param lightIndex Index of the light in the enabled light list of the material
  131240. */
  131241. prepareDefines(defines: any, lightIndex: number): void;
  131242. /**
  131243. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  131244. * defined in the generator but impacting the effect).
  131245. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  131246. * @param effect The effect we are binfing the information for
  131247. */
  131248. bindShadowLight(lightIndex: string, effect: Effect): void;
  131249. /**
  131250. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  131251. * (eq to view projection * shadow projection matrices)
  131252. * @returns The transform matrix used to create the shadow map
  131253. */
  131254. getTransformMatrix(): Matrix;
  131255. /**
  131256. * Disposes the ShadowGenerator.
  131257. * Returns nothing.
  131258. */
  131259. dispose(): void;
  131260. /**
  131261. * Serializes the shadow generator setup to a json object.
  131262. * @returns The serialized JSON object
  131263. */
  131264. serialize(): any;
  131265. /**
  131266. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  131267. * @param parsedShadowGenerator The JSON object to parse
  131268. * @param scene The scene to create the shadow map for
  131269. * @returns The parsed shadow generator
  131270. */
  131271. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  131272. }
  131273. }
  131274. declare module BABYLON {
  131275. /**
  131276. * Defines the shadow generator component responsible to manage any shadow generators
  131277. * in a given scene.
  131278. */
  131279. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  131280. /**
  131281. * The component name helpfull to identify the component in the list of scene components.
  131282. */
  131283. readonly name: string;
  131284. /**
  131285. * The scene the component belongs to.
  131286. */
  131287. scene: Scene;
  131288. /**
  131289. * Creates a new instance of the component for the given scene
  131290. * @param scene Defines the scene to register the component in
  131291. */
  131292. constructor(scene: Scene);
  131293. /**
  131294. * Registers the component in a given scene
  131295. */
  131296. register(): void;
  131297. /**
  131298. * Rebuilds the elements related to this component in case of
  131299. * context lost for instance.
  131300. */
  131301. rebuild(): void;
  131302. /**
  131303. * Serializes the component data to the specified json object
  131304. * @param serializationObject The object to serialize to
  131305. */
  131306. serialize(serializationObject: any): void;
  131307. /**
  131308. * Adds all the elements from the container to the scene
  131309. * @param container the container holding the elements
  131310. */
  131311. addFromContainer(container: AbstractScene): void;
  131312. /**
  131313. * Removes all the elements in the container from the scene
  131314. * @param container contains the elements to remove
  131315. * @param dispose if the removed element should be disposed (default: false)
  131316. */
  131317. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  131318. /**
  131319. * Rebuilds the elements related to this component in case of
  131320. * context lost for instance.
  131321. */
  131322. dispose(): void;
  131323. private _gatherRenderTargets;
  131324. }
  131325. }
  131326. declare module BABYLON {
  131327. /**
  131328. * A point light is a light defined by an unique point in world space.
  131329. * The light is emitted in every direction from this point.
  131330. * A good example of a point light is a standard light bulb.
  131331. * Documentation: https://doc.babylonjs.com/babylon101/lights
  131332. */
  131333. export class PointLight extends ShadowLight {
  131334. private _shadowAngle;
  131335. /**
  131336. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  131337. * This specifies what angle the shadow will use to be created.
  131338. *
  131339. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  131340. */
  131341. get shadowAngle(): number;
  131342. /**
  131343. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  131344. * This specifies what angle the shadow will use to be created.
  131345. *
  131346. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  131347. */
  131348. set shadowAngle(value: number);
  131349. /**
  131350. * Gets the direction if it has been set.
  131351. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  131352. */
  131353. get direction(): Vector3;
  131354. /**
  131355. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  131356. */
  131357. set direction(value: Vector3);
  131358. /**
  131359. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  131360. * A PointLight emits the light in every direction.
  131361. * It can cast shadows.
  131362. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  131363. * ```javascript
  131364. * var pointLight = new PointLight("pl", camera.position, scene);
  131365. * ```
  131366. * Documentation : https://doc.babylonjs.com/babylon101/lights
  131367. * @param name The light friendly name
  131368. * @param position The position of the point light in the scene
  131369. * @param scene The scene the lights belongs to
  131370. */
  131371. constructor(name: string, position: Vector3, scene: Scene);
  131372. /**
  131373. * Returns the string "PointLight"
  131374. * @returns the class name
  131375. */
  131376. getClassName(): string;
  131377. /**
  131378. * Returns the integer 0.
  131379. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  131380. */
  131381. getTypeID(): number;
  131382. /**
  131383. * Specifies wether or not the shadowmap should be a cube texture.
  131384. * @returns true if the shadowmap needs to be a cube texture.
  131385. */
  131386. needCube(): boolean;
  131387. /**
  131388. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  131389. * @param faceIndex The index of the face we are computed the direction to generate shadow
  131390. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  131391. */
  131392. getShadowDirection(faceIndex?: number): Vector3;
  131393. /**
  131394. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  131395. * - fov = PI / 2
  131396. * - aspect ratio : 1.0
  131397. * - z-near and far equal to the active camera minZ and maxZ.
  131398. * Returns the PointLight.
  131399. */
  131400. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  131401. protected _buildUniformLayout(): void;
  131402. /**
  131403. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  131404. * @param effect The effect to update
  131405. * @param lightIndex The index of the light in the effect to update
  131406. * @returns The point light
  131407. */
  131408. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  131409. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  131410. /**
  131411. * Prepares the list of defines specific to the light type.
  131412. * @param defines the list of defines
  131413. * @param lightIndex defines the index of the light for the effect
  131414. */
  131415. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  131416. }
  131417. }
  131418. declare module BABYLON {
  131419. /**
  131420. * Header information of HDR texture files.
  131421. */
  131422. export interface HDRInfo {
  131423. /**
  131424. * The height of the texture in pixels.
  131425. */
  131426. height: number;
  131427. /**
  131428. * The width of the texture in pixels.
  131429. */
  131430. width: number;
  131431. /**
  131432. * The index of the beginning of the data in the binary file.
  131433. */
  131434. dataPosition: number;
  131435. }
  131436. /**
  131437. * This groups tools to convert HDR texture to native colors array.
  131438. */
  131439. export class HDRTools {
  131440. private static Ldexp;
  131441. private static Rgbe2float;
  131442. private static readStringLine;
  131443. /**
  131444. * Reads header information from an RGBE texture stored in a native array.
  131445. * More information on this format are available here:
  131446. * https://en.wikipedia.org/wiki/RGBE_image_format
  131447. *
  131448. * @param uint8array The binary file stored in native array.
  131449. * @return The header information.
  131450. */
  131451. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  131452. /**
  131453. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  131454. * This RGBE texture needs to store the information as a panorama.
  131455. *
  131456. * More information on this format are available here:
  131457. * https://en.wikipedia.org/wiki/RGBE_image_format
  131458. *
  131459. * @param buffer The binary file stored in an array buffer.
  131460. * @param size The expected size of the extracted cubemap.
  131461. * @return The Cube Map information.
  131462. */
  131463. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  131464. /**
  131465. * Returns the pixels data extracted from an RGBE texture.
  131466. * This pixels will be stored left to right up to down in the R G B order in one array.
  131467. *
  131468. * More information on this format are available here:
  131469. * https://en.wikipedia.org/wiki/RGBE_image_format
  131470. *
  131471. * @param uint8array The binary file stored in an array buffer.
  131472. * @param hdrInfo The header information of the file.
  131473. * @return The pixels data in RGB right to left up to down order.
  131474. */
  131475. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  131476. private static RGBE_ReadPixels_RLE;
  131477. }
  131478. }
  131479. declare module BABYLON {
  131480. /**
  131481. * This represents a texture coming from an HDR input.
  131482. *
  131483. * The only supported format is currently panorama picture stored in RGBE format.
  131484. * Example of such files can be found on HDRLib: http://hdrlib.com/
  131485. */
  131486. export class HDRCubeTexture extends BaseTexture {
  131487. private static _facesMapping;
  131488. private _generateHarmonics;
  131489. private _noMipmap;
  131490. private _textureMatrix;
  131491. private _size;
  131492. private _onLoad;
  131493. private _onError;
  131494. /**
  131495. * The texture URL.
  131496. */
  131497. url: string;
  131498. /**
  131499. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  131500. */
  131501. coordinatesMode: number;
  131502. protected _isBlocking: boolean;
  131503. /**
  131504. * Sets wether or not the texture is blocking during loading.
  131505. */
  131506. set isBlocking(value: boolean);
  131507. /**
  131508. * Gets wether or not the texture is blocking during loading.
  131509. */
  131510. get isBlocking(): boolean;
  131511. protected _rotationY: number;
  131512. /**
  131513. * Sets texture matrix rotation angle around Y axis in radians.
  131514. */
  131515. set rotationY(value: number);
  131516. /**
  131517. * Gets texture matrix rotation angle around Y axis radians.
  131518. */
  131519. get rotationY(): number;
  131520. /**
  131521. * Gets or sets the center of the bounding box associated with the cube texture
  131522. * It must define where the camera used to render the texture was set
  131523. */
  131524. boundingBoxPosition: Vector3;
  131525. private _boundingBoxSize;
  131526. /**
  131527. * Gets or sets the size of the bounding box associated with the cube texture
  131528. * When defined, the cubemap will switch to local mode
  131529. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  131530. * @example https://www.babylonjs-playground.com/#RNASML
  131531. */
  131532. set boundingBoxSize(value: Vector3);
  131533. get boundingBoxSize(): Vector3;
  131534. /**
  131535. * Instantiates an HDRTexture from the following parameters.
  131536. *
  131537. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  131538. * @param sceneOrEngine The scene or engine the texture will be used in
  131539. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  131540. * @param noMipmap Forces to not generate the mipmap if true
  131541. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  131542. * @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)
  131543. * @param reserved Reserved flag for internal use.
  131544. */
  131545. constructor(url: string, sceneOrEngine: Scene | ThinEngine, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  131546. /**
  131547. * Get the current class name of the texture useful for serialization or dynamic coding.
  131548. * @returns "HDRCubeTexture"
  131549. */
  131550. getClassName(): string;
  131551. /**
  131552. * Occurs when the file is raw .hdr file.
  131553. */
  131554. private loadTexture;
  131555. clone(): HDRCubeTexture;
  131556. delayLoad(): void;
  131557. /**
  131558. * Get the texture reflection matrix used to rotate/transform the reflection.
  131559. * @returns the reflection matrix
  131560. */
  131561. getReflectionTextureMatrix(): Matrix;
  131562. /**
  131563. * Set the texture reflection matrix used to rotate/transform the reflection.
  131564. * @param value Define the reflection matrix to set
  131565. */
  131566. setReflectionTextureMatrix(value: Matrix): void;
  131567. /**
  131568. * Parses a JSON representation of an HDR Texture in order to create the texture
  131569. * @param parsedTexture Define the JSON representation
  131570. * @param scene Define the scene the texture should be created in
  131571. * @param rootUrl Define the root url in case we need to load relative dependencies
  131572. * @returns the newly created texture after parsing
  131573. */
  131574. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  131575. serialize(): any;
  131576. }
  131577. }
  131578. declare module BABYLON {
  131579. /**
  131580. * Class used to control physics engine
  131581. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  131582. */
  131583. export class PhysicsEngine implements IPhysicsEngine {
  131584. private _physicsPlugin;
  131585. /**
  131586. * Global value used to control the smallest number supported by the simulation
  131587. */
  131588. static Epsilon: number;
  131589. private _impostors;
  131590. private _joints;
  131591. private _subTimeStep;
  131592. /**
  131593. * Gets the gravity vector used by the simulation
  131594. */
  131595. gravity: Vector3;
  131596. /**
  131597. * Factory used to create the default physics plugin.
  131598. * @returns The default physics plugin
  131599. */
  131600. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  131601. /**
  131602. * Creates a new Physics Engine
  131603. * @param gravity defines the gravity vector used by the simulation
  131604. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  131605. */
  131606. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  131607. /**
  131608. * Sets the gravity vector used by the simulation
  131609. * @param gravity defines the gravity vector to use
  131610. */
  131611. setGravity(gravity: Vector3): void;
  131612. /**
  131613. * Set the time step of the physics engine.
  131614. * Default is 1/60.
  131615. * To slow it down, enter 1/600 for example.
  131616. * To speed it up, 1/30
  131617. * @param newTimeStep defines the new timestep to apply to this world.
  131618. */
  131619. setTimeStep(newTimeStep?: number): void;
  131620. /**
  131621. * Get the time step of the physics engine.
  131622. * @returns the current time step
  131623. */
  131624. getTimeStep(): number;
  131625. /**
  131626. * Set the sub time step of the physics engine.
  131627. * Default is 0 meaning there is no sub steps
  131628. * To increase physics resolution precision, set a small value (like 1 ms)
  131629. * @param subTimeStep defines the new sub timestep used for physics resolution.
  131630. */
  131631. setSubTimeStep(subTimeStep?: number): void;
  131632. /**
  131633. * Get the sub time step of the physics engine.
  131634. * @returns the current sub time step
  131635. */
  131636. getSubTimeStep(): number;
  131637. /**
  131638. * Release all resources
  131639. */
  131640. dispose(): void;
  131641. /**
  131642. * Gets the name of the current physics plugin
  131643. * @returns the name of the plugin
  131644. */
  131645. getPhysicsPluginName(): string;
  131646. /**
  131647. * Adding a new impostor for the impostor tracking.
  131648. * This will be done by the impostor itself.
  131649. * @param impostor the impostor to add
  131650. */
  131651. addImpostor(impostor: PhysicsImpostor): void;
  131652. /**
  131653. * Remove an impostor from the engine.
  131654. * This impostor and its mesh will not longer be updated by the physics engine.
  131655. * @param impostor the impostor to remove
  131656. */
  131657. removeImpostor(impostor: PhysicsImpostor): void;
  131658. /**
  131659. * Add a joint to the physics engine
  131660. * @param mainImpostor defines the main impostor to which the joint is added.
  131661. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  131662. * @param joint defines the joint that will connect both impostors.
  131663. */
  131664. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  131665. /**
  131666. * Removes a joint from the simulation
  131667. * @param mainImpostor defines the impostor used with the joint
  131668. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  131669. * @param joint defines the joint to remove
  131670. */
  131671. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  131672. /**
  131673. * Called by the scene. No need to call it.
  131674. * @param delta defines the timespam between frames
  131675. */
  131676. _step(delta: number): void;
  131677. /**
  131678. * Gets the current plugin used to run the simulation
  131679. * @returns current plugin
  131680. */
  131681. getPhysicsPlugin(): IPhysicsEnginePlugin;
  131682. /**
  131683. * Gets the list of physic impostors
  131684. * @returns an array of PhysicsImpostor
  131685. */
  131686. getImpostors(): Array<PhysicsImpostor>;
  131687. /**
  131688. * Gets the impostor for a physics enabled object
  131689. * @param object defines the object impersonated by the impostor
  131690. * @returns the PhysicsImpostor or null if not found
  131691. */
  131692. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  131693. /**
  131694. * Gets the impostor for a physics body object
  131695. * @param body defines physics body used by the impostor
  131696. * @returns the PhysicsImpostor or null if not found
  131697. */
  131698. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  131699. /**
  131700. * Does a raycast in the physics world
  131701. * @param from when should the ray start?
  131702. * @param to when should the ray end?
  131703. * @returns PhysicsRaycastResult
  131704. */
  131705. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  131706. }
  131707. }
  131708. declare module BABYLON {
  131709. /** @hidden */
  131710. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  131711. private _useDeltaForWorldStep;
  131712. world: any;
  131713. name: string;
  131714. private _physicsMaterials;
  131715. private _fixedTimeStep;
  131716. private _cannonRaycastResult;
  131717. private _raycastResult;
  131718. private _physicsBodysToRemoveAfterStep;
  131719. BJSCANNON: any;
  131720. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  131721. setGravity(gravity: Vector3): void;
  131722. setTimeStep(timeStep: number): void;
  131723. getTimeStep(): number;
  131724. executeStep(delta: number): void;
  131725. private _removeMarkedPhysicsBodiesFromWorld;
  131726. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  131727. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  131728. generatePhysicsBody(impostor: PhysicsImpostor): void;
  131729. private _processChildMeshes;
  131730. removePhysicsBody(impostor: PhysicsImpostor): void;
  131731. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  131732. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  131733. private _addMaterial;
  131734. private _checkWithEpsilon;
  131735. private _createShape;
  131736. private _createHeightmap;
  131737. private _minus90X;
  131738. private _plus90X;
  131739. private _tmpPosition;
  131740. private _tmpDeltaPosition;
  131741. private _tmpUnityRotation;
  131742. private _updatePhysicsBodyTransformation;
  131743. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  131744. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  131745. isSupported(): boolean;
  131746. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  131747. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  131748. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  131749. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  131750. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  131751. getBodyMass(impostor: PhysicsImpostor): number;
  131752. getBodyFriction(impostor: PhysicsImpostor): number;
  131753. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  131754. getBodyRestitution(impostor: PhysicsImpostor): number;
  131755. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  131756. sleepBody(impostor: PhysicsImpostor): void;
  131757. wakeUpBody(impostor: PhysicsImpostor): void;
  131758. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  131759. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  131760. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  131761. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  131762. getRadius(impostor: PhysicsImpostor): number;
  131763. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  131764. dispose(): void;
  131765. private _extendNamespace;
  131766. /**
  131767. * Does a raycast in the physics world
  131768. * @param from when should the ray start?
  131769. * @param to when should the ray end?
  131770. * @returns PhysicsRaycastResult
  131771. */
  131772. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  131773. }
  131774. }
  131775. declare module BABYLON {
  131776. /** @hidden */
  131777. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  131778. private _useDeltaForWorldStep;
  131779. world: any;
  131780. name: string;
  131781. BJSOIMO: any;
  131782. private _raycastResult;
  131783. private _fixedTimeStep;
  131784. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, oimoInjection?: any);
  131785. setGravity(gravity: Vector3): void;
  131786. setTimeStep(timeStep: number): void;
  131787. getTimeStep(): number;
  131788. private _tmpImpostorsArray;
  131789. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  131790. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  131791. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  131792. generatePhysicsBody(impostor: PhysicsImpostor): void;
  131793. private _tmpPositionVector;
  131794. removePhysicsBody(impostor: PhysicsImpostor): void;
  131795. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  131796. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  131797. isSupported(): boolean;
  131798. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  131799. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  131800. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  131801. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  131802. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  131803. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  131804. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  131805. getBodyMass(impostor: PhysicsImpostor): number;
  131806. getBodyFriction(impostor: PhysicsImpostor): number;
  131807. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  131808. getBodyRestitution(impostor: PhysicsImpostor): number;
  131809. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  131810. sleepBody(impostor: PhysicsImpostor): void;
  131811. wakeUpBody(impostor: PhysicsImpostor): void;
  131812. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  131813. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  131814. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  131815. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  131816. getRadius(impostor: PhysicsImpostor): number;
  131817. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  131818. dispose(): void;
  131819. /**
  131820. * Does a raycast in the physics world
  131821. * @param from when should the ray start?
  131822. * @param to when should the ray end?
  131823. * @returns PhysicsRaycastResult
  131824. */
  131825. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  131826. }
  131827. }
  131828. declare module BABYLON {
  131829. /**
  131830. * Class containing static functions to help procedurally build meshes
  131831. */
  131832. export class RibbonBuilder {
  131833. /**
  131834. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  131835. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  131836. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  131837. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  131838. * * 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
  131839. * * 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
  131840. * * 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
  131841. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  131842. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  131843. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  131844. * * 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
  131845. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  131846. * * 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
  131847. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  131848. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  131849. * @param name defines the name of the mesh
  131850. * @param options defines the options used to create the mesh
  131851. * @param scene defines the hosting scene
  131852. * @returns the ribbon mesh
  131853. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  131854. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  131855. */
  131856. static CreateRibbon(name: string, options: {
  131857. pathArray: Vector3[][];
  131858. closeArray?: boolean;
  131859. closePath?: boolean;
  131860. offset?: number;
  131861. updatable?: boolean;
  131862. sideOrientation?: number;
  131863. frontUVs?: Vector4;
  131864. backUVs?: Vector4;
  131865. instance?: Mesh;
  131866. invertUV?: boolean;
  131867. uvs?: Vector2[];
  131868. colors?: Color4[];
  131869. }, scene?: Nullable<Scene>): Mesh;
  131870. }
  131871. }
  131872. declare module BABYLON {
  131873. /**
  131874. * Class containing static functions to help procedurally build meshes
  131875. */
  131876. export class ShapeBuilder {
  131877. /**
  131878. * 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.
  131879. * * 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.
  131880. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  131881. * * 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.
  131882. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  131883. * * 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
  131884. * * 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
  131885. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  131886. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  131887. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  131888. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  131889. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  131890. * @param name defines the name of the mesh
  131891. * @param options defines the options used to create the mesh
  131892. * @param scene defines the hosting scene
  131893. * @returns the extruded shape mesh
  131894. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  131895. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  131896. */
  131897. static ExtrudeShape(name: string, options: {
  131898. shape: Vector3[];
  131899. path: Vector3[];
  131900. scale?: number;
  131901. rotation?: number;
  131902. cap?: number;
  131903. updatable?: boolean;
  131904. sideOrientation?: number;
  131905. frontUVs?: Vector4;
  131906. backUVs?: Vector4;
  131907. instance?: Mesh;
  131908. invertUV?: boolean;
  131909. }, scene?: Nullable<Scene>): Mesh;
  131910. /**
  131911. * Creates an custom extruded shape mesh.
  131912. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  131913. * * 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.
  131914. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  131915. * * 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
  131916. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  131917. * * 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
  131918. * * It must returns a float value that will be the scale value applied to the shape on each path point
  131919. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  131920. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  131921. * * 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
  131922. * * 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
  131923. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  131924. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  131925. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  131926. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  131927. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  131928. * @param name defines the name of the mesh
  131929. * @param options defines the options used to create the mesh
  131930. * @param scene defines the hosting scene
  131931. * @returns the custom extruded shape mesh
  131932. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  131933. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  131934. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  131935. */
  131936. static ExtrudeShapeCustom(name: string, options: {
  131937. shape: Vector3[];
  131938. path: Vector3[];
  131939. scaleFunction?: any;
  131940. rotationFunction?: any;
  131941. ribbonCloseArray?: boolean;
  131942. ribbonClosePath?: boolean;
  131943. cap?: number;
  131944. updatable?: boolean;
  131945. sideOrientation?: number;
  131946. frontUVs?: Vector4;
  131947. backUVs?: Vector4;
  131948. instance?: Mesh;
  131949. invertUV?: boolean;
  131950. }, scene?: Nullable<Scene>): Mesh;
  131951. private static _ExtrudeShapeGeneric;
  131952. }
  131953. }
  131954. declare module BABYLON {
  131955. /**
  131956. * AmmoJS Physics plugin
  131957. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  131958. * @see https://github.com/kripken/ammo.js/
  131959. */
  131960. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  131961. private _useDeltaForWorldStep;
  131962. /**
  131963. * Reference to the Ammo library
  131964. */
  131965. bjsAMMO: any;
  131966. /**
  131967. * Created ammoJS world which physics bodies are added to
  131968. */
  131969. world: any;
  131970. /**
  131971. * Name of the plugin
  131972. */
  131973. name: string;
  131974. private _timeStep;
  131975. private _fixedTimeStep;
  131976. private _maxSteps;
  131977. private _tmpQuaternion;
  131978. private _tmpAmmoTransform;
  131979. private _tmpAmmoQuaternion;
  131980. private _tmpAmmoConcreteContactResultCallback;
  131981. private _collisionConfiguration;
  131982. private _dispatcher;
  131983. private _overlappingPairCache;
  131984. private _solver;
  131985. private _softBodySolver;
  131986. private _tmpAmmoVectorA;
  131987. private _tmpAmmoVectorB;
  131988. private _tmpAmmoVectorC;
  131989. private _tmpAmmoVectorD;
  131990. private _tmpContactCallbackResult;
  131991. private _tmpAmmoVectorRCA;
  131992. private _tmpAmmoVectorRCB;
  131993. private _raycastResult;
  131994. private static readonly DISABLE_COLLISION_FLAG;
  131995. private static readonly KINEMATIC_FLAG;
  131996. private static readonly DISABLE_DEACTIVATION_FLAG;
  131997. /**
  131998. * Initializes the ammoJS plugin
  131999. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  132000. * @param ammoInjection can be used to inject your own ammo reference
  132001. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  132002. */
  132003. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  132004. /**
  132005. * Sets the gravity of the physics world (m/(s^2))
  132006. * @param gravity Gravity to set
  132007. */
  132008. setGravity(gravity: Vector3): void;
  132009. /**
  132010. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  132011. * @param timeStep timestep to use in seconds
  132012. */
  132013. setTimeStep(timeStep: number): void;
  132014. /**
  132015. * 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)
  132016. * @param fixedTimeStep fixedTimeStep to use in seconds
  132017. */
  132018. setFixedTimeStep(fixedTimeStep: number): void;
  132019. /**
  132020. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  132021. * @param maxSteps the maximum number of steps by the physics engine per frame
  132022. */
  132023. setMaxSteps(maxSteps: number): void;
  132024. /**
  132025. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  132026. * @returns the current timestep in seconds
  132027. */
  132028. getTimeStep(): number;
  132029. /**
  132030. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  132031. */
  132032. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  132033. private _isImpostorInContact;
  132034. private _isImpostorPairInContact;
  132035. private _stepSimulation;
  132036. /**
  132037. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  132038. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  132039. * After the step the babylon meshes are set to the position of the physics imposters
  132040. * @param delta amount of time to step forward
  132041. * @param impostors array of imposters to update before/after the step
  132042. */
  132043. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  132044. /**
  132045. * Update babylon mesh to match physics world object
  132046. * @param impostor imposter to match
  132047. */
  132048. private _afterSoftStep;
  132049. /**
  132050. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  132051. * @param impostor imposter to match
  132052. */
  132053. private _ropeStep;
  132054. /**
  132055. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  132056. * @param impostor imposter to match
  132057. */
  132058. private _softbodyOrClothStep;
  132059. private _tmpMatrix;
  132060. /**
  132061. * Applies an impulse on the imposter
  132062. * @param impostor imposter to apply impulse to
  132063. * @param force amount of force to be applied to the imposter
  132064. * @param contactPoint the location to apply the impulse on the imposter
  132065. */
  132066. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  132067. /**
  132068. * Applies a force on the imposter
  132069. * @param impostor imposter to apply force
  132070. * @param force amount of force to be applied to the imposter
  132071. * @param contactPoint the location to apply the force on the imposter
  132072. */
  132073. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  132074. /**
  132075. * Creates a physics body using the plugin
  132076. * @param impostor the imposter to create the physics body on
  132077. */
  132078. generatePhysicsBody(impostor: PhysicsImpostor): void;
  132079. /**
  132080. * Removes the physics body from the imposter and disposes of the body's memory
  132081. * @param impostor imposter to remove the physics body from
  132082. */
  132083. removePhysicsBody(impostor: PhysicsImpostor): void;
  132084. /**
  132085. * Generates a joint
  132086. * @param impostorJoint the imposter joint to create the joint with
  132087. */
  132088. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  132089. /**
  132090. * Removes a joint
  132091. * @param impostorJoint the imposter joint to remove the joint from
  132092. */
  132093. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  132094. private _addMeshVerts;
  132095. /**
  132096. * Initialise the soft body vertices to match its object's (mesh) vertices
  132097. * Softbody vertices (nodes) are in world space and to match this
  132098. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  132099. * @param impostor to create the softbody for
  132100. */
  132101. private _softVertexData;
  132102. /**
  132103. * Create an impostor's soft body
  132104. * @param impostor to create the softbody for
  132105. */
  132106. private _createSoftbody;
  132107. /**
  132108. * Create cloth for an impostor
  132109. * @param impostor to create the softbody for
  132110. */
  132111. private _createCloth;
  132112. /**
  132113. * Create rope for an impostor
  132114. * @param impostor to create the softbody for
  132115. */
  132116. private _createRope;
  132117. /**
  132118. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  132119. * @param impostor to create the custom physics shape for
  132120. */
  132121. private _createCustom;
  132122. private _addHullVerts;
  132123. private _createShape;
  132124. /**
  132125. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  132126. * @param impostor imposter containing the physics body and babylon object
  132127. */
  132128. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  132129. /**
  132130. * Sets the babylon object's position/rotation from the physics body's position/rotation
  132131. * @param impostor imposter containing the physics body and babylon object
  132132. * @param newPosition new position
  132133. * @param newRotation new rotation
  132134. */
  132135. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  132136. /**
  132137. * If this plugin is supported
  132138. * @returns true if its supported
  132139. */
  132140. isSupported(): boolean;
  132141. /**
  132142. * Sets the linear velocity of the physics body
  132143. * @param impostor imposter to set the velocity on
  132144. * @param velocity velocity to set
  132145. */
  132146. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  132147. /**
  132148. * Sets the angular velocity of the physics body
  132149. * @param impostor imposter to set the velocity on
  132150. * @param velocity velocity to set
  132151. */
  132152. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  132153. /**
  132154. * gets the linear velocity
  132155. * @param impostor imposter to get linear velocity from
  132156. * @returns linear velocity
  132157. */
  132158. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  132159. /**
  132160. * gets the angular velocity
  132161. * @param impostor imposter to get angular velocity from
  132162. * @returns angular velocity
  132163. */
  132164. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  132165. /**
  132166. * Sets the mass of physics body
  132167. * @param impostor imposter to set the mass on
  132168. * @param mass mass to set
  132169. */
  132170. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  132171. /**
  132172. * Gets the mass of the physics body
  132173. * @param impostor imposter to get the mass from
  132174. * @returns mass
  132175. */
  132176. getBodyMass(impostor: PhysicsImpostor): number;
  132177. /**
  132178. * Gets friction of the impostor
  132179. * @param impostor impostor to get friction from
  132180. * @returns friction value
  132181. */
  132182. getBodyFriction(impostor: PhysicsImpostor): number;
  132183. /**
  132184. * Sets friction of the impostor
  132185. * @param impostor impostor to set friction on
  132186. * @param friction friction value
  132187. */
  132188. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  132189. /**
  132190. * Gets restitution of the impostor
  132191. * @param impostor impostor to get restitution from
  132192. * @returns restitution value
  132193. */
  132194. getBodyRestitution(impostor: PhysicsImpostor): number;
  132195. /**
  132196. * Sets resitution of the impostor
  132197. * @param impostor impostor to set resitution on
  132198. * @param restitution resitution value
  132199. */
  132200. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  132201. /**
  132202. * Gets pressure inside the impostor
  132203. * @param impostor impostor to get pressure from
  132204. * @returns pressure value
  132205. */
  132206. getBodyPressure(impostor: PhysicsImpostor): number;
  132207. /**
  132208. * Sets pressure inside a soft body impostor
  132209. * Cloth and rope must remain 0 pressure
  132210. * @param impostor impostor to set pressure on
  132211. * @param pressure pressure value
  132212. */
  132213. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  132214. /**
  132215. * Gets stiffness of the impostor
  132216. * @param impostor impostor to get stiffness from
  132217. * @returns pressure value
  132218. */
  132219. getBodyStiffness(impostor: PhysicsImpostor): number;
  132220. /**
  132221. * Sets stiffness of the impostor
  132222. * @param impostor impostor to set stiffness on
  132223. * @param stiffness stiffness value from 0 to 1
  132224. */
  132225. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  132226. /**
  132227. * Gets velocityIterations of the impostor
  132228. * @param impostor impostor to get velocity iterations from
  132229. * @returns velocityIterations value
  132230. */
  132231. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  132232. /**
  132233. * Sets velocityIterations of the impostor
  132234. * @param impostor impostor to set velocity iterations on
  132235. * @param velocityIterations velocityIterations value
  132236. */
  132237. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  132238. /**
  132239. * Gets positionIterations of the impostor
  132240. * @param impostor impostor to get position iterations from
  132241. * @returns positionIterations value
  132242. */
  132243. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  132244. /**
  132245. * Sets positionIterations of the impostor
  132246. * @param impostor impostor to set position on
  132247. * @param positionIterations positionIterations value
  132248. */
  132249. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  132250. /**
  132251. * Append an anchor to a cloth object
  132252. * @param impostor is the cloth impostor to add anchor to
  132253. * @param otherImpostor is the rigid impostor to anchor to
  132254. * @param width ratio across width from 0 to 1
  132255. * @param height ratio up height from 0 to 1
  132256. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  132257. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  132258. */
  132259. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  132260. /**
  132261. * Append an hook to a rope object
  132262. * @param impostor is the rope impostor to add hook to
  132263. * @param otherImpostor is the rigid impostor to hook to
  132264. * @param length ratio along the rope from 0 to 1
  132265. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  132266. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  132267. */
  132268. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  132269. /**
  132270. * Sleeps the physics body and stops it from being active
  132271. * @param impostor impostor to sleep
  132272. */
  132273. sleepBody(impostor: PhysicsImpostor): void;
  132274. /**
  132275. * Activates the physics body
  132276. * @param impostor impostor to activate
  132277. */
  132278. wakeUpBody(impostor: PhysicsImpostor): void;
  132279. /**
  132280. * Updates the distance parameters of the joint
  132281. * @param joint joint to update
  132282. * @param maxDistance maximum distance of the joint
  132283. * @param minDistance minimum distance of the joint
  132284. */
  132285. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  132286. /**
  132287. * Sets a motor on the joint
  132288. * @param joint joint to set motor on
  132289. * @param speed speed of the motor
  132290. * @param maxForce maximum force of the motor
  132291. * @param motorIndex index of the motor
  132292. */
  132293. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  132294. /**
  132295. * Sets the motors limit
  132296. * @param joint joint to set limit on
  132297. * @param upperLimit upper limit
  132298. * @param lowerLimit lower limit
  132299. */
  132300. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  132301. /**
  132302. * Syncs the position and rotation of a mesh with the impostor
  132303. * @param mesh mesh to sync
  132304. * @param impostor impostor to update the mesh with
  132305. */
  132306. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  132307. /**
  132308. * Gets the radius of the impostor
  132309. * @param impostor impostor to get radius from
  132310. * @returns the radius
  132311. */
  132312. getRadius(impostor: PhysicsImpostor): number;
  132313. /**
  132314. * Gets the box size of the impostor
  132315. * @param impostor impostor to get box size from
  132316. * @param result the resulting box size
  132317. */
  132318. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  132319. /**
  132320. * Disposes of the impostor
  132321. */
  132322. dispose(): void;
  132323. /**
  132324. * Does a raycast in the physics world
  132325. * @param from when should the ray start?
  132326. * @param to when should the ray end?
  132327. * @returns PhysicsRaycastResult
  132328. */
  132329. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  132330. }
  132331. }
  132332. declare module BABYLON {
  132333. interface AbstractScene {
  132334. /**
  132335. * The list of reflection probes added to the scene
  132336. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  132337. */
  132338. reflectionProbes: Array<ReflectionProbe>;
  132339. /**
  132340. * Removes the given reflection probe from this scene.
  132341. * @param toRemove The reflection probe to remove
  132342. * @returns The index of the removed reflection probe
  132343. */
  132344. removeReflectionProbe(toRemove: ReflectionProbe): number;
  132345. /**
  132346. * Adds the given reflection probe to this scene.
  132347. * @param newReflectionProbe The reflection probe to add
  132348. */
  132349. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  132350. }
  132351. /**
  132352. * Class used to generate realtime reflection / refraction cube textures
  132353. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  132354. */
  132355. export class ReflectionProbe {
  132356. /** defines the name of the probe */
  132357. name: string;
  132358. private _scene;
  132359. private _renderTargetTexture;
  132360. private _projectionMatrix;
  132361. private _viewMatrix;
  132362. private _target;
  132363. private _add;
  132364. private _attachedMesh;
  132365. private _invertYAxis;
  132366. /** Gets or sets probe position (center of the cube map) */
  132367. position: Vector3;
  132368. /**
  132369. * Creates a new reflection probe
  132370. * @param name defines the name of the probe
  132371. * @param size defines the texture resolution (for each face)
  132372. * @param scene defines the hosting scene
  132373. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  132374. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  132375. */
  132376. constructor(
  132377. /** defines the name of the probe */
  132378. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  132379. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  132380. get samples(): number;
  132381. set samples(value: number);
  132382. /** Gets or sets the refresh rate to use (on every frame by default) */
  132383. get refreshRate(): number;
  132384. set refreshRate(value: number);
  132385. /**
  132386. * Gets the hosting scene
  132387. * @returns a Scene
  132388. */
  132389. getScene(): Scene;
  132390. /** Gets the internal CubeTexture used to render to */
  132391. get cubeTexture(): RenderTargetTexture;
  132392. /** Gets the list of meshes to render */
  132393. get renderList(): Nullable<AbstractMesh[]>;
  132394. /**
  132395. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  132396. * @param mesh defines the mesh to attach to
  132397. */
  132398. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  132399. /**
  132400. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  132401. * @param renderingGroupId The rendering group id corresponding to its index
  132402. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  132403. */
  132404. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  132405. /**
  132406. * Clean all associated resources
  132407. */
  132408. dispose(): void;
  132409. /**
  132410. * Converts the reflection probe information to a readable string for debug purpose.
  132411. * @param fullDetails Supports for multiple levels of logging within scene loading
  132412. * @returns the human readable reflection probe info
  132413. */
  132414. toString(fullDetails?: boolean): string;
  132415. /**
  132416. * Get the class name of the relfection probe.
  132417. * @returns "ReflectionProbe"
  132418. */
  132419. getClassName(): string;
  132420. /**
  132421. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  132422. * @returns The JSON representation of the texture
  132423. */
  132424. serialize(): any;
  132425. /**
  132426. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  132427. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  132428. * @param scene Define the scene the parsed reflection probe should be instantiated in
  132429. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  132430. * @returns The parsed reflection probe if successful
  132431. */
  132432. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  132433. }
  132434. }
  132435. declare module BABYLON {
  132436. /** @hidden */
  132437. export var _BabylonLoaderRegistered: boolean;
  132438. /**
  132439. * Helps setting up some configuration for the babylon file loader.
  132440. */
  132441. export class BabylonFileLoaderConfiguration {
  132442. /**
  132443. * The loader does not allow injecting custom physix engine into the plugins.
  132444. * Unfortunately in ES6, we need to manually inject them into the plugin.
  132445. * So you could set this variable to your engine import to make it work.
  132446. */
  132447. static LoaderInjectedPhysicsEngine: any;
  132448. }
  132449. }
  132450. declare module BABYLON {
  132451. /**
  132452. * The Physically based simple base material of BJS.
  132453. *
  132454. * This enables better naming and convention enforcements on top of the pbrMaterial.
  132455. * It is used as the base class for both the specGloss and metalRough conventions.
  132456. */
  132457. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  132458. /**
  132459. * Number of Simultaneous lights allowed on the material.
  132460. */
  132461. maxSimultaneousLights: number;
  132462. /**
  132463. * If sets to true, disables all the lights affecting the material.
  132464. */
  132465. disableLighting: boolean;
  132466. /**
  132467. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  132468. */
  132469. environmentTexture: BaseTexture;
  132470. /**
  132471. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  132472. */
  132473. invertNormalMapX: boolean;
  132474. /**
  132475. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  132476. */
  132477. invertNormalMapY: boolean;
  132478. /**
  132479. * Normal map used in the model.
  132480. */
  132481. normalTexture: BaseTexture;
  132482. /**
  132483. * Emissivie color used to self-illuminate the model.
  132484. */
  132485. emissiveColor: Color3;
  132486. /**
  132487. * Emissivie texture used to self-illuminate the model.
  132488. */
  132489. emissiveTexture: BaseTexture;
  132490. /**
  132491. * Occlusion Channel Strenght.
  132492. */
  132493. occlusionStrength: number;
  132494. /**
  132495. * Occlusion Texture of the material (adding extra occlusion effects).
  132496. */
  132497. occlusionTexture: BaseTexture;
  132498. /**
  132499. * Defines the alpha limits in alpha test mode.
  132500. */
  132501. alphaCutOff: number;
  132502. /**
  132503. * Gets the current double sided mode.
  132504. */
  132505. get doubleSided(): boolean;
  132506. /**
  132507. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  132508. */
  132509. set doubleSided(value: boolean);
  132510. /**
  132511. * Stores the pre-calculated light information of a mesh in a texture.
  132512. */
  132513. lightmapTexture: BaseTexture;
  132514. /**
  132515. * If true, the light map contains occlusion information instead of lighting info.
  132516. */
  132517. useLightmapAsShadowmap: boolean;
  132518. /**
  132519. * Instantiates a new PBRMaterial instance.
  132520. *
  132521. * @param name The material name
  132522. * @param scene The scene the material will be use in.
  132523. */
  132524. constructor(name: string, scene: Scene);
  132525. getClassName(): string;
  132526. }
  132527. }
  132528. declare module BABYLON {
  132529. /**
  132530. * The PBR material of BJS following the metal roughness convention.
  132531. *
  132532. * This fits to the PBR convention in the GLTF definition:
  132533. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  132534. */
  132535. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  132536. /**
  132537. * The base color has two different interpretations depending on the value of metalness.
  132538. * When the material is a metal, the base color is the specific measured reflectance value
  132539. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  132540. * of the material.
  132541. */
  132542. baseColor: Color3;
  132543. /**
  132544. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  132545. * well as opacity information in the alpha channel.
  132546. */
  132547. baseTexture: BaseTexture;
  132548. /**
  132549. * Specifies the metallic scalar value of the material.
  132550. * Can also be used to scale the metalness values of the metallic texture.
  132551. */
  132552. metallic: number;
  132553. /**
  132554. * Specifies the roughness scalar value of the material.
  132555. * Can also be used to scale the roughness values of the metallic texture.
  132556. */
  132557. roughness: number;
  132558. /**
  132559. * Texture containing both the metallic value in the B channel and the
  132560. * roughness value in the G channel to keep better precision.
  132561. */
  132562. metallicRoughnessTexture: BaseTexture;
  132563. /**
  132564. * Instantiates a new PBRMetalRoughnessMaterial instance.
  132565. *
  132566. * @param name The material name
  132567. * @param scene The scene the material will be use in.
  132568. */
  132569. constructor(name: string, scene: Scene);
  132570. /**
  132571. * Return the currrent class name of the material.
  132572. */
  132573. getClassName(): string;
  132574. /**
  132575. * Makes a duplicate of the current material.
  132576. * @param name - name to use for the new material.
  132577. */
  132578. clone(name: string): PBRMetallicRoughnessMaterial;
  132579. /**
  132580. * Serialize the material to a parsable JSON object.
  132581. */
  132582. serialize(): any;
  132583. /**
  132584. * Parses a JSON object correponding to the serialize function.
  132585. */
  132586. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  132587. }
  132588. }
  132589. declare module BABYLON {
  132590. /**
  132591. * The PBR material of BJS following the specular glossiness convention.
  132592. *
  132593. * This fits to the PBR convention in the GLTF definition:
  132594. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  132595. */
  132596. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  132597. /**
  132598. * Specifies the diffuse color of the material.
  132599. */
  132600. diffuseColor: Color3;
  132601. /**
  132602. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  132603. * channel.
  132604. */
  132605. diffuseTexture: BaseTexture;
  132606. /**
  132607. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  132608. */
  132609. specularColor: Color3;
  132610. /**
  132611. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  132612. */
  132613. glossiness: number;
  132614. /**
  132615. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  132616. */
  132617. specularGlossinessTexture: BaseTexture;
  132618. /**
  132619. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  132620. *
  132621. * @param name The material name
  132622. * @param scene The scene the material will be use in.
  132623. */
  132624. constructor(name: string, scene: Scene);
  132625. /**
  132626. * Return the currrent class name of the material.
  132627. */
  132628. getClassName(): string;
  132629. /**
  132630. * Makes a duplicate of the current material.
  132631. * @param name - name to use for the new material.
  132632. */
  132633. clone(name: string): PBRSpecularGlossinessMaterial;
  132634. /**
  132635. * Serialize the material to a parsable JSON object.
  132636. */
  132637. serialize(): any;
  132638. /**
  132639. * Parses a JSON object correponding to the serialize function.
  132640. */
  132641. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  132642. }
  132643. }
  132644. declare module BABYLON {
  132645. /**
  132646. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  132647. * It can help converting any input color in a desired output one. This can then be used to create effects
  132648. * from sepia, black and white to sixties or futuristic rendering...
  132649. *
  132650. * The only supported format is currently 3dl.
  132651. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  132652. */
  132653. export class ColorGradingTexture extends BaseTexture {
  132654. /**
  132655. * The texture URL.
  132656. */
  132657. url: string;
  132658. /**
  132659. * Empty line regex stored for GC.
  132660. */
  132661. private static _noneEmptyLineRegex;
  132662. private _textureMatrix;
  132663. private _onLoad;
  132664. /**
  132665. * Instantiates a ColorGradingTexture from the following parameters.
  132666. *
  132667. * @param url The location of the color gradind data (currently only supporting 3dl)
  132668. * @param sceneOrEngine The scene or engine the texture will be used in
  132669. * @param onLoad defines a callback triggered when the texture has been loaded
  132670. */
  132671. constructor(url: string, sceneOrEngine: Scene | ThinEngine, onLoad?: Nullable<() => void>);
  132672. /**
  132673. * Fires the onload event from the constructor if requested.
  132674. */
  132675. private _triggerOnLoad;
  132676. /**
  132677. * Returns the texture matrix used in most of the material.
  132678. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  132679. */
  132680. getTextureMatrix(): Matrix;
  132681. /**
  132682. * Occurs when the file being loaded is a .3dl LUT file.
  132683. */
  132684. private load3dlTexture;
  132685. /**
  132686. * Starts the loading process of the texture.
  132687. */
  132688. private loadTexture;
  132689. /**
  132690. * Clones the color gradind texture.
  132691. */
  132692. clone(): ColorGradingTexture;
  132693. /**
  132694. * Called during delayed load for textures.
  132695. */
  132696. delayLoad(): void;
  132697. /**
  132698. * Parses a color grading texture serialized by Babylon.
  132699. * @param parsedTexture The texture information being parsedTexture
  132700. * @param scene The scene to load the texture in
  132701. * @param rootUrl The root url of the data assets to load
  132702. * @return A color gradind texture
  132703. */
  132704. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  132705. /**
  132706. * Serializes the LUT texture to json format.
  132707. */
  132708. serialize(): any;
  132709. }
  132710. }
  132711. declare module BABYLON {
  132712. /**
  132713. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  132714. */
  132715. export class EquiRectangularCubeTexture extends BaseTexture {
  132716. /** The six faces of the cube. */
  132717. private static _FacesMapping;
  132718. private _noMipmap;
  132719. private _onLoad;
  132720. private _onError;
  132721. /** The size of the cubemap. */
  132722. private _size;
  132723. /** The buffer of the image. */
  132724. private _buffer;
  132725. /** The width of the input image. */
  132726. private _width;
  132727. /** The height of the input image. */
  132728. private _height;
  132729. /** The URL to the image. */
  132730. url: string;
  132731. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  132732. coordinatesMode: number;
  132733. /**
  132734. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  132735. * @param url The location of the image
  132736. * @param scene The scene the texture will be used in
  132737. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  132738. * @param noMipmap Forces to not generate the mipmap if true
  132739. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  132740. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  132741. * @param onLoad — defines a callback called when texture is loaded
  132742. * @param onError — defines a callback called if there is an error
  132743. */
  132744. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  132745. /**
  132746. * Load the image data, by putting the image on a canvas and extracting its buffer.
  132747. */
  132748. private loadImage;
  132749. /**
  132750. * Convert the image buffer into a cubemap and create a CubeTexture.
  132751. */
  132752. private loadTexture;
  132753. /**
  132754. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  132755. * @param buffer The ArrayBuffer that should be converted.
  132756. * @returns The buffer as Float32Array.
  132757. */
  132758. private getFloat32ArrayFromArrayBuffer;
  132759. /**
  132760. * Get the current class name of the texture useful for serialization or dynamic coding.
  132761. * @returns "EquiRectangularCubeTexture"
  132762. */
  132763. getClassName(): string;
  132764. /**
  132765. * Create a clone of the current EquiRectangularCubeTexture and return it.
  132766. * @returns A clone of the current EquiRectangularCubeTexture.
  132767. */
  132768. clone(): EquiRectangularCubeTexture;
  132769. }
  132770. }
  132771. declare module BABYLON {
  132772. /**
  132773. * Based on jsTGALoader - Javascript loader for TGA file
  132774. * By Vincent Thibault
  132775. * @see http://blog.robrowser.com/javascript-tga-loader.html
  132776. */
  132777. export class TGATools {
  132778. private static _TYPE_INDEXED;
  132779. private static _TYPE_RGB;
  132780. private static _TYPE_GREY;
  132781. private static _TYPE_RLE_INDEXED;
  132782. private static _TYPE_RLE_RGB;
  132783. private static _TYPE_RLE_GREY;
  132784. private static _ORIGIN_MASK;
  132785. private static _ORIGIN_SHIFT;
  132786. private static _ORIGIN_BL;
  132787. private static _ORIGIN_BR;
  132788. private static _ORIGIN_UL;
  132789. private static _ORIGIN_UR;
  132790. /**
  132791. * Gets the header of a TGA file
  132792. * @param data defines the TGA data
  132793. * @returns the header
  132794. */
  132795. static GetTGAHeader(data: Uint8Array): any;
  132796. /**
  132797. * Uploads TGA content to a Babylon Texture
  132798. * @hidden
  132799. */
  132800. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  132801. /** @hidden */
  132802. 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;
  132803. /** @hidden */
  132804. 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;
  132805. /** @hidden */
  132806. 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;
  132807. /** @hidden */
  132808. 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;
  132809. /** @hidden */
  132810. 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;
  132811. /** @hidden */
  132812. 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;
  132813. }
  132814. }
  132815. declare module BABYLON {
  132816. /**
  132817. * Implementation of the TGA Texture Loader.
  132818. * @hidden
  132819. */
  132820. export class _TGATextureLoader implements IInternalTextureLoader {
  132821. /**
  132822. * Defines wether the loader supports cascade loading the different faces.
  132823. */
  132824. readonly supportCascades: boolean;
  132825. /**
  132826. * This returns if the loader support the current file information.
  132827. * @param extension defines the file extension of the file being loaded
  132828. * @returns true if the loader can load the specified file
  132829. */
  132830. canLoad(extension: string): boolean;
  132831. /**
  132832. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  132833. * @param data contains the texture data
  132834. * @param texture defines the BabylonJS internal texture
  132835. * @param createPolynomials will be true if polynomials have been requested
  132836. * @param onLoad defines the callback to trigger once the texture is ready
  132837. * @param onError defines the callback to trigger in case of error
  132838. */
  132839. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  132840. /**
  132841. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  132842. * @param data contains the texture data
  132843. * @param texture defines the BabylonJS internal texture
  132844. * @param callback defines the method to call once ready to upload
  132845. */
  132846. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  132847. }
  132848. }
  132849. declare module BABYLON {
  132850. /**
  132851. * Info about the .basis files
  132852. */
  132853. class BasisFileInfo {
  132854. /**
  132855. * If the file has alpha
  132856. */
  132857. hasAlpha: boolean;
  132858. /**
  132859. * Info about each image of the basis file
  132860. */
  132861. images: Array<{
  132862. levels: Array<{
  132863. width: number;
  132864. height: number;
  132865. transcodedPixels: ArrayBufferView;
  132866. }>;
  132867. }>;
  132868. }
  132869. /**
  132870. * Result of transcoding a basis file
  132871. */
  132872. class TranscodeResult {
  132873. /**
  132874. * Info about the .basis file
  132875. */
  132876. fileInfo: BasisFileInfo;
  132877. /**
  132878. * Format to use when loading the file
  132879. */
  132880. format: number;
  132881. }
  132882. /**
  132883. * Configuration options for the Basis transcoder
  132884. */
  132885. export class BasisTranscodeConfiguration {
  132886. /**
  132887. * Supported compression formats used to determine the supported output format of the transcoder
  132888. */
  132889. supportedCompressionFormats?: {
  132890. /**
  132891. * etc1 compression format
  132892. */
  132893. etc1?: boolean;
  132894. /**
  132895. * s3tc compression format
  132896. */
  132897. s3tc?: boolean;
  132898. /**
  132899. * pvrtc compression format
  132900. */
  132901. pvrtc?: boolean;
  132902. /**
  132903. * etc2 compression format
  132904. */
  132905. etc2?: boolean;
  132906. };
  132907. /**
  132908. * If mipmap levels should be loaded for transcoded images (Default: true)
  132909. */
  132910. loadMipmapLevels?: boolean;
  132911. /**
  132912. * Index of a single image to load (Default: all images)
  132913. */
  132914. loadSingleImage?: number;
  132915. }
  132916. /**
  132917. * Used to load .Basis files
  132918. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  132919. */
  132920. export class BasisTools {
  132921. private static _IgnoreSupportedFormats;
  132922. /**
  132923. * URL to use when loading the basis transcoder
  132924. */
  132925. static JSModuleURL: string;
  132926. /**
  132927. * URL to use when loading the wasm module for the transcoder
  132928. */
  132929. static WasmModuleURL: string;
  132930. /**
  132931. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  132932. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  132933. * @returns internal format corresponding to the Basis format
  132934. */
  132935. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  132936. private static _WorkerPromise;
  132937. private static _Worker;
  132938. private static _actionId;
  132939. private static _CreateWorkerAsync;
  132940. /**
  132941. * Transcodes a loaded image file to compressed pixel data
  132942. * @param data image data to transcode
  132943. * @param config configuration options for the transcoding
  132944. * @returns a promise resulting in the transcoded image
  132945. */
  132946. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  132947. /**
  132948. * Loads a texture from the transcode result
  132949. * @param texture texture load to
  132950. * @param transcodeResult the result of transcoding the basis file to load from
  132951. */
  132952. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  132953. }
  132954. }
  132955. declare module BABYLON {
  132956. /**
  132957. * Loader for .basis file format
  132958. */
  132959. export class _BasisTextureLoader implements IInternalTextureLoader {
  132960. /**
  132961. * Defines whether the loader supports cascade loading the different faces.
  132962. */
  132963. readonly supportCascades: boolean;
  132964. /**
  132965. * This returns if the loader support the current file information.
  132966. * @param extension defines the file extension of the file being loaded
  132967. * @returns true if the loader can load the specified file
  132968. */
  132969. canLoad(extension: string): boolean;
  132970. /**
  132971. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  132972. * @param data contains the texture data
  132973. * @param texture defines the BabylonJS internal texture
  132974. * @param createPolynomials will be true if polynomials have been requested
  132975. * @param onLoad defines the callback to trigger once the texture is ready
  132976. * @param onError defines the callback to trigger in case of error
  132977. */
  132978. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  132979. /**
  132980. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  132981. * @param data contains the texture data
  132982. * @param texture defines the BabylonJS internal texture
  132983. * @param callback defines the method to call once ready to upload
  132984. */
  132985. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  132986. }
  132987. }
  132988. declare module BABYLON {
  132989. /**
  132990. * 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.
  132991. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  132992. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  132993. */
  132994. export class CustomProceduralTexture extends ProceduralTexture {
  132995. private _animate;
  132996. private _time;
  132997. private _config;
  132998. private _texturePath;
  132999. /**
  133000. * Instantiates a new Custom Procedural Texture.
  133001. * 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.
  133002. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  133003. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  133004. * @param name Define the name of the texture
  133005. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  133006. * @param size Define the size of the texture to create
  133007. * @param scene Define the scene the texture belongs to
  133008. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  133009. * @param generateMipMaps Define if the texture should creates mip maps or not
  133010. */
  133011. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  133012. private _loadJson;
  133013. /**
  133014. * Is the texture ready to be used ? (rendered at least once)
  133015. * @returns true if ready, otherwise, false.
  133016. */
  133017. isReady(): boolean;
  133018. /**
  133019. * Render the texture to its associated render target.
  133020. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  133021. */
  133022. render(useCameraPostProcess?: boolean): void;
  133023. /**
  133024. * Update the list of dependant textures samplers in the shader.
  133025. */
  133026. updateTextures(): void;
  133027. /**
  133028. * Update the uniform values of the procedural texture in the shader.
  133029. */
  133030. updateShaderUniforms(): void;
  133031. /**
  133032. * Define if the texture animates or not.
  133033. */
  133034. get animate(): boolean;
  133035. set animate(value: boolean);
  133036. }
  133037. }
  133038. declare module BABYLON {
  133039. /** @hidden */
  133040. export var noisePixelShader: {
  133041. name: string;
  133042. shader: string;
  133043. };
  133044. }
  133045. declare module BABYLON {
  133046. /**
  133047. * Class used to generate noise procedural textures
  133048. */
  133049. export class NoiseProceduralTexture extends ProceduralTexture {
  133050. private _time;
  133051. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  133052. brightness: number;
  133053. /** Defines the number of octaves to process */
  133054. octaves: number;
  133055. /** Defines the level of persistence (0.8 by default) */
  133056. persistence: number;
  133057. /** Gets or sets animation speed factor (default is 1) */
  133058. animationSpeedFactor: number;
  133059. /**
  133060. * Creates a new NoiseProceduralTexture
  133061. * @param name defines the name fo the texture
  133062. * @param size defines the size of the texture (default is 256)
  133063. * @param scene defines the hosting scene
  133064. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  133065. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  133066. */
  133067. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  133068. private _updateShaderUniforms;
  133069. protected _getDefines(): string;
  133070. /** Generate the current state of the procedural texture */
  133071. render(useCameraPostProcess?: boolean): void;
  133072. /**
  133073. * Serializes this noise procedural texture
  133074. * @returns a serialized noise procedural texture object
  133075. */
  133076. serialize(): any;
  133077. /**
  133078. * Clone the texture.
  133079. * @returns the cloned texture
  133080. */
  133081. clone(): NoiseProceduralTexture;
  133082. /**
  133083. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  133084. * @param parsedTexture defines parsed texture data
  133085. * @param scene defines the current scene
  133086. * @param rootUrl defines the root URL containing noise procedural texture information
  133087. * @returns a parsed NoiseProceduralTexture
  133088. */
  133089. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  133090. }
  133091. }
  133092. declare module BABYLON {
  133093. /**
  133094. * Raw cube texture where the raw buffers are passed in
  133095. */
  133096. export class RawCubeTexture extends CubeTexture {
  133097. /**
  133098. * Creates a cube texture where the raw buffers are passed in.
  133099. * @param scene defines the scene the texture is attached to
  133100. * @param data defines the array of data to use to create each face
  133101. * @param size defines the size of the textures
  133102. * @param format defines the format of the data
  133103. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  133104. * @param generateMipMaps defines if the engine should generate the mip levels
  133105. * @param invertY defines if data must be stored with Y axis inverted
  133106. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  133107. * @param compression defines the compression used (null by default)
  133108. */
  133109. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  133110. /**
  133111. * Updates the raw cube texture.
  133112. * @param data defines the data to store
  133113. * @param format defines the data format
  133114. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  133115. * @param invertY defines if data must be stored with Y axis inverted
  133116. * @param compression defines the compression used (null by default)
  133117. * @param level defines which level of the texture to update
  133118. */
  133119. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  133120. /**
  133121. * Updates a raw cube texture with RGBD encoded data.
  133122. * @param data defines the array of data [mipmap][face] to use to create each face
  133123. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  133124. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  133125. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  133126. * @returns a promsie that resolves when the operation is complete
  133127. */
  133128. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  133129. /**
  133130. * Clones the raw cube texture.
  133131. * @return a new cube texture
  133132. */
  133133. clone(): CubeTexture;
  133134. /** @hidden */
  133135. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  133136. }
  133137. }
  133138. declare module BABYLON {
  133139. /**
  133140. * Class used to store 3D textures containing user data
  133141. */
  133142. export class RawTexture3D extends Texture {
  133143. /** Gets or sets the texture format to use */
  133144. format: number;
  133145. /**
  133146. * Create a new RawTexture3D
  133147. * @param data defines the data of the texture
  133148. * @param width defines the width of the texture
  133149. * @param height defines the height of the texture
  133150. * @param depth defines the depth of the texture
  133151. * @param format defines the texture format to use
  133152. * @param scene defines the hosting scene
  133153. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  133154. * @param invertY defines if texture must be stored with Y axis inverted
  133155. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  133156. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  133157. */
  133158. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  133159. /** Gets or sets the texture format to use */
  133160. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  133161. /**
  133162. * Update the texture with new data
  133163. * @param data defines the data to store in the texture
  133164. */
  133165. update(data: ArrayBufferView): void;
  133166. }
  133167. }
  133168. declare module BABYLON {
  133169. /**
  133170. * Class used to store 2D array textures containing user data
  133171. */
  133172. export class RawTexture2DArray extends Texture {
  133173. /** Gets or sets the texture format to use */
  133174. format: number;
  133175. /**
  133176. * Create a new RawTexture2DArray
  133177. * @param data defines the data of the texture
  133178. * @param width defines the width of the texture
  133179. * @param height defines the height of the texture
  133180. * @param depth defines the number of layers of the texture
  133181. * @param format defines the texture format to use
  133182. * @param scene defines the hosting scene
  133183. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  133184. * @param invertY defines if texture must be stored with Y axis inverted
  133185. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  133186. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  133187. */
  133188. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  133189. /** Gets or sets the texture format to use */
  133190. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  133191. /**
  133192. * Update the texture with new data
  133193. * @param data defines the data to store in the texture
  133194. */
  133195. update(data: ArrayBufferView): void;
  133196. }
  133197. }
  133198. declare module BABYLON {
  133199. /**
  133200. * Creates a refraction texture used by refraction channel of the standard material.
  133201. * It is like a mirror but to see through a material.
  133202. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  133203. */
  133204. export class RefractionTexture extends RenderTargetTexture {
  133205. /**
  133206. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  133207. * 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.
  133208. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  133209. */
  133210. refractionPlane: Plane;
  133211. /**
  133212. * Define how deep under the surface we should see.
  133213. */
  133214. depth: number;
  133215. /**
  133216. * Creates a refraction texture used by refraction channel of the standard material.
  133217. * It is like a mirror but to see through a material.
  133218. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  133219. * @param name Define the texture name
  133220. * @param size Define the size of the underlying texture
  133221. * @param scene Define the scene the refraction belongs to
  133222. * @param generateMipMaps Define if we need to generate mips level for the refraction
  133223. */
  133224. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  133225. /**
  133226. * Clone the refraction texture.
  133227. * @returns the cloned texture
  133228. */
  133229. clone(): RefractionTexture;
  133230. /**
  133231. * Serialize the texture to a JSON representation you could use in Parse later on
  133232. * @returns the serialized JSON representation
  133233. */
  133234. serialize(): any;
  133235. }
  133236. }
  133237. declare module BABYLON {
  133238. /**
  133239. * Defines the options related to the creation of an HtmlElementTexture
  133240. */
  133241. export interface IHtmlElementTextureOptions {
  133242. /**
  133243. * Defines wether mip maps should be created or not.
  133244. */
  133245. generateMipMaps?: boolean;
  133246. /**
  133247. * Defines the sampling mode of the texture.
  133248. */
  133249. samplingMode?: number;
  133250. /**
  133251. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  133252. */
  133253. engine: Nullable<ThinEngine>;
  133254. /**
  133255. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  133256. */
  133257. scene: Nullable<Scene>;
  133258. }
  133259. /**
  133260. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  133261. * To be as efficient as possible depending on your constraints nothing aside the first upload
  133262. * is automatically managed.
  133263. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  133264. * in your application.
  133265. *
  133266. * As the update is not automatic, you need to call them manually.
  133267. */
  133268. export class HtmlElementTexture extends BaseTexture {
  133269. /**
  133270. * The texture URL.
  133271. */
  133272. element: HTMLVideoElement | HTMLCanvasElement;
  133273. private static readonly DefaultOptions;
  133274. private _textureMatrix;
  133275. private _isVideo;
  133276. private _generateMipMaps;
  133277. private _samplingMode;
  133278. /**
  133279. * Instantiates a HtmlElementTexture from the following parameters.
  133280. *
  133281. * @param name Defines the name of the texture
  133282. * @param element Defines the video or canvas the texture is filled with
  133283. * @param options Defines the other none mandatory texture creation options
  133284. */
  133285. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  133286. private _createInternalTexture;
  133287. /**
  133288. * Returns the texture matrix used in most of the material.
  133289. */
  133290. getTextureMatrix(): Matrix;
  133291. /**
  133292. * Updates the content of the texture.
  133293. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  133294. */
  133295. update(invertY?: Nullable<boolean>): void;
  133296. }
  133297. }
  133298. declare module BABYLON {
  133299. /**
  133300. * Defines the basic options interface of a TexturePacker Frame
  133301. */
  133302. export interface ITexturePackerFrame {
  133303. /**
  133304. * The frame ID
  133305. */
  133306. id: number;
  133307. /**
  133308. * The frames Scale
  133309. */
  133310. scale: Vector2;
  133311. /**
  133312. * The Frames offset
  133313. */
  133314. offset: Vector2;
  133315. }
  133316. /**
  133317. * This is a support class for frame Data on texture packer sets.
  133318. */
  133319. export class TexturePackerFrame implements ITexturePackerFrame {
  133320. /**
  133321. * The frame ID
  133322. */
  133323. id: number;
  133324. /**
  133325. * The frames Scale
  133326. */
  133327. scale: Vector2;
  133328. /**
  133329. * The Frames offset
  133330. */
  133331. offset: Vector2;
  133332. /**
  133333. * Initializes a texture package frame.
  133334. * @param id The numerical frame identifier
  133335. * @param scale Scalar Vector2 for UV frame
  133336. * @param offset Vector2 for the frame position in UV units.
  133337. * @returns TexturePackerFrame
  133338. */
  133339. constructor(id: number, scale: Vector2, offset: Vector2);
  133340. }
  133341. }
  133342. declare module BABYLON {
  133343. /**
  133344. * Defines the basic options interface of a TexturePacker
  133345. */
  133346. export interface ITexturePackerOptions {
  133347. /**
  133348. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  133349. */
  133350. map?: string[];
  133351. /**
  133352. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  133353. */
  133354. uvsIn?: string;
  133355. /**
  133356. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  133357. */
  133358. uvsOut?: string;
  133359. /**
  133360. * number representing the layout style. Defaults to LAYOUT_STRIP
  133361. */
  133362. layout?: number;
  133363. /**
  133364. * number of columns if using custom column count layout(2). This defaults to 4.
  133365. */
  133366. colnum?: number;
  133367. /**
  133368. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  133369. */
  133370. updateInputMeshes?: boolean;
  133371. /**
  133372. * boolean flag to dispose all the source textures. Defaults to true.
  133373. */
  133374. disposeSources?: boolean;
  133375. /**
  133376. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  133377. */
  133378. fillBlanks?: boolean;
  133379. /**
  133380. * string value representing the context fill style color. Defaults to 'black'.
  133381. */
  133382. customFillColor?: string;
  133383. /**
  133384. * Width and Height Value of each Frame in the TexturePacker Sets
  133385. */
  133386. frameSize?: number;
  133387. /**
  133388. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  133389. */
  133390. paddingRatio?: number;
  133391. /**
  133392. * Number that declares the fill method for the padding gutter.
  133393. */
  133394. paddingMode?: number;
  133395. /**
  133396. * If in SUBUV_COLOR padding mode what color to use.
  133397. */
  133398. paddingColor?: Color3 | Color4;
  133399. }
  133400. /**
  133401. * Defines the basic interface of a TexturePacker JSON File
  133402. */
  133403. export interface ITexturePackerJSON {
  133404. /**
  133405. * The frame ID
  133406. */
  133407. name: string;
  133408. /**
  133409. * The base64 channel data
  133410. */
  133411. sets: any;
  133412. /**
  133413. * The options of the Packer
  133414. */
  133415. options: ITexturePackerOptions;
  133416. /**
  133417. * The frame data of the Packer
  133418. */
  133419. frames: Array<number>;
  133420. }
  133421. /**
  133422. * This is a support class that generates a series of packed texture sets.
  133423. * @see https://doc.babylonjs.com/babylon101/materials
  133424. */
  133425. export class TexturePacker {
  133426. /** Packer Layout Constant 0 */
  133427. static readonly LAYOUT_STRIP: number;
  133428. /** Packer Layout Constant 1 */
  133429. static readonly LAYOUT_POWER2: number;
  133430. /** Packer Layout Constant 2 */
  133431. static readonly LAYOUT_COLNUM: number;
  133432. /** Packer Layout Constant 0 */
  133433. static readonly SUBUV_WRAP: number;
  133434. /** Packer Layout Constant 1 */
  133435. static readonly SUBUV_EXTEND: number;
  133436. /** Packer Layout Constant 2 */
  133437. static readonly SUBUV_COLOR: number;
  133438. /** The Name of the Texture Package */
  133439. name: string;
  133440. /** The scene scope of the TexturePacker */
  133441. scene: Scene;
  133442. /** The Meshes to target */
  133443. meshes: AbstractMesh[];
  133444. /** Arguments passed with the Constructor */
  133445. options: ITexturePackerOptions;
  133446. /** The promise that is started upon initialization */
  133447. promise: Nullable<Promise<TexturePacker | string>>;
  133448. /** The Container object for the channel sets that are generated */
  133449. sets: object;
  133450. /** The Container array for the frames that are generated */
  133451. frames: TexturePackerFrame[];
  133452. /** The expected number of textures the system is parsing. */
  133453. private _expecting;
  133454. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  133455. private _paddingValue;
  133456. /**
  133457. * Initializes a texture package series from an array of meshes or a single mesh.
  133458. * @param name The name of the package
  133459. * @param meshes The target meshes to compose the package from
  133460. * @param options The arguments that texture packer should follow while building.
  133461. * @param scene The scene which the textures are scoped to.
  133462. * @returns TexturePacker
  133463. */
  133464. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  133465. /**
  133466. * Starts the package process
  133467. * @param resolve The promises resolution function
  133468. * @returns TexturePacker
  133469. */
  133470. private _createFrames;
  133471. /**
  133472. * Calculates the Size of the Channel Sets
  133473. * @returns Vector2
  133474. */
  133475. private _calculateSize;
  133476. /**
  133477. * Calculates the UV data for the frames.
  133478. * @param baseSize the base frameSize
  133479. * @param padding the base frame padding
  133480. * @param dtSize size of the Dynamic Texture for that channel
  133481. * @param dtUnits is 1/dtSize
  133482. * @param update flag to update the input meshes
  133483. */
  133484. private _calculateMeshUVFrames;
  133485. /**
  133486. * Calculates the frames Offset.
  133487. * @param index of the frame
  133488. * @returns Vector2
  133489. */
  133490. private _getFrameOffset;
  133491. /**
  133492. * Updates a Mesh to the frame data
  133493. * @param mesh that is the target
  133494. * @param frameID or the frame index
  133495. */
  133496. private _updateMeshUV;
  133497. /**
  133498. * Updates a Meshes materials to use the texture packer channels
  133499. * @param m is the mesh to target
  133500. * @param force all channels on the packer to be set.
  133501. */
  133502. private _updateTextureReferences;
  133503. /**
  133504. * Public method to set a Mesh to a frame
  133505. * @param m that is the target
  133506. * @param frameID or the frame index
  133507. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  133508. */
  133509. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  133510. /**
  133511. * Starts the async promise to compile the texture packer.
  133512. * @returns Promise<void>
  133513. */
  133514. processAsync(): Promise<void>;
  133515. /**
  133516. * Disposes all textures associated with this packer
  133517. */
  133518. dispose(): void;
  133519. /**
  133520. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  133521. * @param imageType is the image type to use.
  133522. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  133523. */
  133524. download(imageType?: string, quality?: number): void;
  133525. /**
  133526. * Public method to load a texturePacker JSON file.
  133527. * @param data of the JSON file in string format.
  133528. */
  133529. updateFromJSON(data: string): void;
  133530. }
  133531. }
  133532. declare module BABYLON {
  133533. /**
  133534. * Enum used to define the target of a block
  133535. */
  133536. export enum NodeMaterialBlockTargets {
  133537. /** Vertex shader */
  133538. Vertex = 1,
  133539. /** Fragment shader */
  133540. Fragment = 2,
  133541. /** Neutral */
  133542. Neutral = 4,
  133543. /** Vertex and Fragment */
  133544. VertexAndFragment = 3
  133545. }
  133546. }
  133547. declare module BABYLON {
  133548. /**
  133549. * Defines the kind of connection point for node based material
  133550. */
  133551. export enum NodeMaterialBlockConnectionPointTypes {
  133552. /** Float */
  133553. Float = 1,
  133554. /** Int */
  133555. Int = 2,
  133556. /** Vector2 */
  133557. Vector2 = 4,
  133558. /** Vector3 */
  133559. Vector3 = 8,
  133560. /** Vector4 */
  133561. Vector4 = 16,
  133562. /** Color3 */
  133563. Color3 = 32,
  133564. /** Color4 */
  133565. Color4 = 64,
  133566. /** Matrix */
  133567. Matrix = 128,
  133568. /** Custom object */
  133569. Object = 256,
  133570. /** Detect type based on connection */
  133571. AutoDetect = 1024,
  133572. /** Output type that will be defined by input type */
  133573. BasedOnInput = 2048
  133574. }
  133575. }
  133576. declare module BABYLON {
  133577. /**
  133578. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  133579. */
  133580. export enum NodeMaterialBlockConnectionPointMode {
  133581. /** Value is an uniform */
  133582. Uniform = 0,
  133583. /** Value is a mesh attribute */
  133584. Attribute = 1,
  133585. /** Value is a varying between vertex and fragment shaders */
  133586. Varying = 2,
  133587. /** Mode is undefined */
  133588. Undefined = 3
  133589. }
  133590. }
  133591. declare module BABYLON {
  133592. /**
  133593. * Enum used to define system values e.g. values automatically provided by the system
  133594. */
  133595. export enum NodeMaterialSystemValues {
  133596. /** World */
  133597. World = 1,
  133598. /** View */
  133599. View = 2,
  133600. /** Projection */
  133601. Projection = 3,
  133602. /** ViewProjection */
  133603. ViewProjection = 4,
  133604. /** WorldView */
  133605. WorldView = 5,
  133606. /** WorldViewProjection */
  133607. WorldViewProjection = 6,
  133608. /** CameraPosition */
  133609. CameraPosition = 7,
  133610. /** Fog Color */
  133611. FogColor = 8,
  133612. /** Delta time */
  133613. DeltaTime = 9
  133614. }
  133615. }
  133616. declare module BABYLON {
  133617. /**
  133618. * Enum used to define the material modes
  133619. */
  133620. export enum NodeMaterialModes {
  133621. /** Regular material */
  133622. Material = 0,
  133623. /** For post process */
  133624. PostProcess = 1
  133625. }
  133626. }
  133627. declare module BABYLON {
  133628. /**
  133629. * Root class for all node material optimizers
  133630. */
  133631. export class NodeMaterialOptimizer {
  133632. /**
  133633. * Function used to optimize a NodeMaterial graph
  133634. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  133635. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  133636. */
  133637. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  133638. }
  133639. }
  133640. declare module BABYLON {
  133641. /**
  133642. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  133643. */
  133644. export class TransformBlock extends NodeMaterialBlock {
  133645. /**
  133646. * Defines the value to use to complement W value to transform it to a Vector4
  133647. */
  133648. complementW: number;
  133649. /**
  133650. * Defines the value to use to complement z value to transform it to a Vector4
  133651. */
  133652. complementZ: number;
  133653. /**
  133654. * Creates a new TransformBlock
  133655. * @param name defines the block name
  133656. */
  133657. constructor(name: string);
  133658. /**
  133659. * Gets the current class name
  133660. * @returns the class name
  133661. */
  133662. getClassName(): string;
  133663. /**
  133664. * Gets the vector input
  133665. */
  133666. get vector(): NodeMaterialConnectionPoint;
  133667. /**
  133668. * Gets the output component
  133669. */
  133670. get output(): NodeMaterialConnectionPoint;
  133671. /**
  133672. * Gets the xyz output component
  133673. */
  133674. get xyz(): NodeMaterialConnectionPoint;
  133675. /**
  133676. * Gets the matrix transform input
  133677. */
  133678. get transform(): NodeMaterialConnectionPoint;
  133679. protected _buildBlock(state: NodeMaterialBuildState): this;
  133680. serialize(): any;
  133681. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  133682. protected _dumpPropertiesCode(): string;
  133683. }
  133684. }
  133685. declare module BABYLON {
  133686. /**
  133687. * Block used to output the vertex position
  133688. */
  133689. export class VertexOutputBlock extends NodeMaterialBlock {
  133690. /**
  133691. * Creates a new VertexOutputBlock
  133692. * @param name defines the block name
  133693. */
  133694. constructor(name: string);
  133695. /**
  133696. * Gets the current class name
  133697. * @returns the class name
  133698. */
  133699. getClassName(): string;
  133700. /**
  133701. * Gets the vector input component
  133702. */
  133703. get vector(): NodeMaterialConnectionPoint;
  133704. protected _buildBlock(state: NodeMaterialBuildState): this;
  133705. }
  133706. }
  133707. declare module BABYLON {
  133708. /**
  133709. * Block used to output the final color
  133710. */
  133711. export class FragmentOutputBlock extends NodeMaterialBlock {
  133712. /**
  133713. * Create a new FragmentOutputBlock
  133714. * @param name defines the block name
  133715. */
  133716. constructor(name: string);
  133717. /**
  133718. * Gets the current class name
  133719. * @returns the class name
  133720. */
  133721. getClassName(): string;
  133722. /**
  133723. * Gets the rgba input component
  133724. */
  133725. get rgba(): NodeMaterialConnectionPoint;
  133726. /**
  133727. * Gets the rgb input component
  133728. */
  133729. get rgb(): NodeMaterialConnectionPoint;
  133730. /**
  133731. * Gets the a input component
  133732. */
  133733. get a(): NodeMaterialConnectionPoint;
  133734. protected _buildBlock(state: NodeMaterialBuildState): this;
  133735. }
  133736. }
  133737. declare module BABYLON {
  133738. /**
  133739. * Base block used to read a reflection texture from a sampler
  133740. */
  133741. export abstract class ReflectionTextureBaseBlock extends NodeMaterialBlock {
  133742. /** @hidden */
  133743. _define3DName: string;
  133744. /** @hidden */
  133745. _defineCubicName: string;
  133746. /** @hidden */
  133747. _defineExplicitName: string;
  133748. /** @hidden */
  133749. _defineProjectionName: string;
  133750. /** @hidden */
  133751. _defineLocalCubicName: string;
  133752. /** @hidden */
  133753. _defineSphericalName: string;
  133754. /** @hidden */
  133755. _definePlanarName: string;
  133756. /** @hidden */
  133757. _defineEquirectangularName: string;
  133758. /** @hidden */
  133759. _defineMirroredEquirectangularFixedName: string;
  133760. /** @hidden */
  133761. _defineEquirectangularFixedName: string;
  133762. /** @hidden */
  133763. _defineSkyboxName: string;
  133764. /** @hidden */
  133765. _defineOppositeZ: string;
  133766. /** @hidden */
  133767. _cubeSamplerName: string;
  133768. /** @hidden */
  133769. _2DSamplerName: string;
  133770. protected _positionUVWName: string;
  133771. protected _directionWName: string;
  133772. protected _reflectionVectorName: string;
  133773. /** @hidden */
  133774. _reflectionCoordsName: string;
  133775. /** @hidden */
  133776. _reflectionMatrixName: string;
  133777. protected _reflectionColorName: string;
  133778. /**
  133779. * Gets or sets the texture associated with the node
  133780. */
  133781. texture: Nullable<BaseTexture>;
  133782. /**
  133783. * Create a new ReflectionTextureBaseBlock
  133784. * @param name defines the block name
  133785. */
  133786. constructor(name: string);
  133787. /**
  133788. * Gets the current class name
  133789. * @returns the class name
  133790. */
  133791. getClassName(): string;
  133792. /**
  133793. * Gets the world position input component
  133794. */
  133795. abstract get position(): NodeMaterialConnectionPoint;
  133796. /**
  133797. * Gets the world position input component
  133798. */
  133799. abstract get worldPosition(): NodeMaterialConnectionPoint;
  133800. /**
  133801. * Gets the world normal input component
  133802. */
  133803. abstract get worldNormal(): NodeMaterialConnectionPoint;
  133804. /**
  133805. * Gets the world input component
  133806. */
  133807. abstract get world(): NodeMaterialConnectionPoint;
  133808. /**
  133809. * Gets the camera (or eye) position component
  133810. */
  133811. abstract get cameraPosition(): NodeMaterialConnectionPoint;
  133812. /**
  133813. * Gets the view input component
  133814. */
  133815. abstract get view(): NodeMaterialConnectionPoint;
  133816. protected _getTexture(): Nullable<BaseTexture>;
  133817. autoConfigure(material: NodeMaterial): void;
  133818. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  133819. isReady(): boolean;
  133820. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  133821. /**
  133822. * Gets the code to inject in the vertex shader
  133823. * @param state current state of the node material building
  133824. * @returns the shader code
  133825. */
  133826. handleVertexSide(state: NodeMaterialBuildState): string;
  133827. /**
  133828. * Handles the inits for the fragment code path
  133829. * @param state node material build state
  133830. */
  133831. handleFragmentSideInits(state: NodeMaterialBuildState): void;
  133832. /**
  133833. * Generates the reflection coords code for the fragment code path
  133834. * @param worldNormalVarName name of the world normal variable
  133835. * @param worldPos name of the world position variable. If not provided, will use the world position connected to this block
  133836. * @param onlyReflectionVector if true, generates code only for the reflection vector computation, not for the reflection coordinates
  133837. * @returns the shader code
  133838. */
  133839. handleFragmentSideCodeReflectionCoords(worldNormalVarName: string, worldPos?: string, onlyReflectionVector?: boolean): string;
  133840. /**
  133841. * Generates the reflection color code for the fragment code path
  133842. * @param lodVarName name of the lod variable
  133843. * @param swizzleLookupTexture swizzle to use for the final color variable
  133844. * @returns the shader code
  133845. */
  133846. handleFragmentSideCodeReflectionColor(lodVarName?: string, swizzleLookupTexture?: string): string;
  133847. /**
  133848. * Generates the code corresponding to the connected output points
  133849. * @param state node material build state
  133850. * @param varName name of the variable to output
  133851. * @returns the shader code
  133852. */
  133853. writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  133854. protected _buildBlock(state: NodeMaterialBuildState): this;
  133855. protected _dumpPropertiesCode(): string;
  133856. serialize(): any;
  133857. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  133858. }
  133859. }
  133860. declare module BABYLON {
  133861. /**
  133862. * Defines a connection point to be used for points with a custom object type
  133863. */
  133864. export class NodeMaterialConnectionPointCustomObject<T extends NodeMaterialBlock> extends NodeMaterialConnectionPoint {
  133865. private _blockType;
  133866. private _blockName;
  133867. private _nameForCheking?;
  133868. /**
  133869. * Creates a new connection point
  133870. * @param name defines the connection point name
  133871. * @param ownerBlock defines the block hosting this connection point
  133872. * @param direction defines the direction of the connection point
  133873. */
  133874. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection, _blockType: new (...args: any[]) => T, _blockName: string, _nameForCheking?: string | undefined);
  133875. /**
  133876. * Gets a number indicating if the current point can be connected to another point
  133877. * @param connectionPoint defines the other connection point
  133878. * @returns a number defining the compatibility state
  133879. */
  133880. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  133881. /**
  133882. * Creates a block suitable to be used as an input for this input point.
  133883. * If null is returned, a block based on the point type will be created.
  133884. * @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
  133885. */
  133886. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  133887. }
  133888. }
  133889. declare module BABYLON {
  133890. /**
  133891. * Enum defining the type of properties that can be edited in the property pages in the NME
  133892. */
  133893. export enum PropertyTypeForEdition {
  133894. /** property is a boolean */
  133895. Boolean = 0,
  133896. /** property is a float */
  133897. Float = 1,
  133898. /** property is a Vector2 */
  133899. Vector2 = 2,
  133900. /** property is a list of values */
  133901. List = 3
  133902. }
  133903. /**
  133904. * Interface that defines an option in a variable of type list
  133905. */
  133906. export interface IEditablePropertyListOption {
  133907. /** label of the option */
  133908. "label": string;
  133909. /** value of the option */
  133910. "value": number;
  133911. }
  133912. /**
  133913. * Interface that defines the options available for an editable property
  133914. */
  133915. export interface IEditablePropertyOption {
  133916. /** min value */
  133917. "min"?: number;
  133918. /** max value */
  133919. "max"?: number;
  133920. /** notifiers: indicates which actions to take when the property is changed */
  133921. "notifiers"?: {
  133922. /** the material should be rebuilt */
  133923. "rebuild"?: boolean;
  133924. /** the preview should be updated */
  133925. "update"?: boolean;
  133926. };
  133927. /** list of the options for a variable of type list */
  133928. "options"?: IEditablePropertyListOption[];
  133929. }
  133930. /**
  133931. * Interface that describes an editable property
  133932. */
  133933. export interface IPropertyDescriptionForEdition {
  133934. /** name of the property */
  133935. "propertyName": string;
  133936. /** display name of the property */
  133937. "displayName": string;
  133938. /** type of the property */
  133939. "type": PropertyTypeForEdition;
  133940. /** group of the property - all properties with the same group value will be displayed in a specific section */
  133941. "groupName": string;
  133942. /** options for the property */
  133943. "options": IEditablePropertyOption;
  133944. }
  133945. /**
  133946. * Decorator that flags a property in a node material block as being editable
  133947. */
  133948. export function editableInPropertyPage(displayName: string, propertyType?: PropertyTypeForEdition, groupName?: string, options?: IEditablePropertyOption): (target: any, propertyKey: string) => void;
  133949. }
  133950. declare module BABYLON {
  133951. /**
  133952. * Block used to implement the refraction part of the sub surface module of the PBR material
  133953. */
  133954. export class RefractionBlock extends NodeMaterialBlock {
  133955. /** @hidden */
  133956. _define3DName: string;
  133957. /** @hidden */
  133958. _refractionMatrixName: string;
  133959. /** @hidden */
  133960. _defineLODRefractionAlpha: string;
  133961. /** @hidden */
  133962. _defineLinearSpecularRefraction: string;
  133963. /** @hidden */
  133964. _defineOppositeZ: string;
  133965. /** @hidden */
  133966. _cubeSamplerName: string;
  133967. /** @hidden */
  133968. _2DSamplerName: string;
  133969. /** @hidden */
  133970. _vRefractionMicrosurfaceInfosName: string;
  133971. /** @hidden */
  133972. _vRefractionInfosName: string;
  133973. private _scene;
  133974. /**
  133975. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  133976. * Materials half opaque for instance using refraction could benefit from this control.
  133977. */
  133978. linkRefractionWithTransparency: boolean;
  133979. /**
  133980. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  133981. */
  133982. invertRefractionY: boolean;
  133983. /**
  133984. * Gets or sets the texture associated with the node
  133985. */
  133986. texture: Nullable<BaseTexture>;
  133987. /**
  133988. * Create a new RefractionBlock
  133989. * @param name defines the block name
  133990. */
  133991. constructor(name: string);
  133992. /**
  133993. * Gets the current class name
  133994. * @returns the class name
  133995. */
  133996. getClassName(): string;
  133997. /**
  133998. * Gets the intensity input component
  133999. */
  134000. get intensity(): NodeMaterialConnectionPoint;
  134001. /**
  134002. * Gets the index of refraction input component
  134003. */
  134004. get indexOfRefraction(): NodeMaterialConnectionPoint;
  134005. /**
  134006. * Gets the tint at distance input component
  134007. */
  134008. get tintAtDistance(): NodeMaterialConnectionPoint;
  134009. /**
  134010. * Gets the view input component
  134011. */
  134012. get view(): NodeMaterialConnectionPoint;
  134013. /**
  134014. * Gets the refraction object output component
  134015. */
  134016. get refraction(): NodeMaterialConnectionPoint;
  134017. /**
  134018. * Returns true if the block has a texture
  134019. */
  134020. get hasTexture(): boolean;
  134021. protected _getTexture(): Nullable<BaseTexture>;
  134022. autoConfigure(material: NodeMaterial): void;
  134023. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  134024. isReady(): boolean;
  134025. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  134026. /**
  134027. * Gets the main code of the block (fragment side)
  134028. * @param state current state of the node material building
  134029. * @returns the shader code
  134030. */
  134031. getCode(state: NodeMaterialBuildState): string;
  134032. protected _buildBlock(state: NodeMaterialBuildState): this;
  134033. protected _dumpPropertiesCode(): string;
  134034. serialize(): any;
  134035. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  134036. }
  134037. }
  134038. declare module BABYLON {
  134039. /**
  134040. * Base block used as input for post process
  134041. */
  134042. export class CurrentScreenBlock extends NodeMaterialBlock {
  134043. private _samplerName;
  134044. private _linearDefineName;
  134045. private _gammaDefineName;
  134046. private _mainUVName;
  134047. private _tempTextureRead;
  134048. /**
  134049. * Gets or sets the texture associated with the node
  134050. */
  134051. texture: Nullable<BaseTexture>;
  134052. /**
  134053. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  134054. */
  134055. convertToGammaSpace: boolean;
  134056. /**
  134057. * Gets or sets a boolean indicating if content needs to be converted to linear space
  134058. */
  134059. convertToLinearSpace: boolean;
  134060. /**
  134061. * Create a new CurrentScreenBlock
  134062. * @param name defines the block name
  134063. */
  134064. constructor(name: string);
  134065. /**
  134066. * Gets the current class name
  134067. * @returns the class name
  134068. */
  134069. getClassName(): string;
  134070. /**
  134071. * Gets the uv input component
  134072. */
  134073. get uv(): NodeMaterialConnectionPoint;
  134074. /**
  134075. * Gets the rgba output component
  134076. */
  134077. get rgba(): NodeMaterialConnectionPoint;
  134078. /**
  134079. * Gets the rgb output component
  134080. */
  134081. get rgb(): NodeMaterialConnectionPoint;
  134082. /**
  134083. * Gets the r output component
  134084. */
  134085. get r(): NodeMaterialConnectionPoint;
  134086. /**
  134087. * Gets the g output component
  134088. */
  134089. get g(): NodeMaterialConnectionPoint;
  134090. /**
  134091. * Gets the b output component
  134092. */
  134093. get b(): NodeMaterialConnectionPoint;
  134094. /**
  134095. * Gets the a output component
  134096. */
  134097. get a(): NodeMaterialConnectionPoint;
  134098. /**
  134099. * Initialize the block and prepare the context for build
  134100. * @param state defines the state that will be used for the build
  134101. */
  134102. initialize(state: NodeMaterialBuildState): void;
  134103. get target(): NodeMaterialBlockTargets;
  134104. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  134105. isReady(): boolean;
  134106. private _injectVertexCode;
  134107. private _writeTextureRead;
  134108. private _writeOutput;
  134109. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  134110. serialize(): any;
  134111. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  134112. }
  134113. }
  134114. declare module BABYLON {
  134115. /**
  134116. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  134117. */
  134118. export class VectorMergerBlock extends NodeMaterialBlock {
  134119. /**
  134120. * Create a new VectorMergerBlock
  134121. * @param name defines the block name
  134122. */
  134123. constructor(name: string);
  134124. /**
  134125. * Gets the current class name
  134126. * @returns the class name
  134127. */
  134128. getClassName(): string;
  134129. /**
  134130. * Gets the xyz component (input)
  134131. */
  134132. get xyzIn(): NodeMaterialConnectionPoint;
  134133. /**
  134134. * Gets the xy component (input)
  134135. */
  134136. get xyIn(): NodeMaterialConnectionPoint;
  134137. /**
  134138. * Gets the x component (input)
  134139. */
  134140. get x(): NodeMaterialConnectionPoint;
  134141. /**
  134142. * Gets the y component (input)
  134143. */
  134144. get y(): NodeMaterialConnectionPoint;
  134145. /**
  134146. * Gets the z component (input)
  134147. */
  134148. get z(): NodeMaterialConnectionPoint;
  134149. /**
  134150. * Gets the w component (input)
  134151. */
  134152. get w(): NodeMaterialConnectionPoint;
  134153. /**
  134154. * Gets the xyzw component (output)
  134155. */
  134156. get xyzw(): NodeMaterialConnectionPoint;
  134157. /**
  134158. * Gets the xyz component (output)
  134159. */
  134160. get xyzOut(): NodeMaterialConnectionPoint;
  134161. /**
  134162. * Gets the xy component (output)
  134163. */
  134164. get xyOut(): NodeMaterialConnectionPoint;
  134165. /**
  134166. * Gets the xy component (output)
  134167. * @deprecated Please use xyOut instead.
  134168. */
  134169. get xy(): NodeMaterialConnectionPoint;
  134170. /**
  134171. * Gets the xyz component (output)
  134172. * @deprecated Please use xyzOut instead.
  134173. */
  134174. get xyz(): NodeMaterialConnectionPoint;
  134175. protected _buildBlock(state: NodeMaterialBuildState): this;
  134176. }
  134177. }
  134178. declare module BABYLON {
  134179. /**
  134180. * Block used to remap a float from a range to a new one
  134181. */
  134182. export class RemapBlock extends NodeMaterialBlock {
  134183. /**
  134184. * Gets or sets the source range
  134185. */
  134186. sourceRange: Vector2;
  134187. /**
  134188. * Gets or sets the target range
  134189. */
  134190. targetRange: Vector2;
  134191. /**
  134192. * Creates a new RemapBlock
  134193. * @param name defines the block name
  134194. */
  134195. constructor(name: string);
  134196. /**
  134197. * Gets the current class name
  134198. * @returns the class name
  134199. */
  134200. getClassName(): string;
  134201. /**
  134202. * Gets the input component
  134203. */
  134204. get input(): NodeMaterialConnectionPoint;
  134205. /**
  134206. * Gets the source min input component
  134207. */
  134208. get sourceMin(): NodeMaterialConnectionPoint;
  134209. /**
  134210. * Gets the source max input component
  134211. */
  134212. get sourceMax(): NodeMaterialConnectionPoint;
  134213. /**
  134214. * Gets the target min input component
  134215. */
  134216. get targetMin(): NodeMaterialConnectionPoint;
  134217. /**
  134218. * Gets the target max input component
  134219. */
  134220. get targetMax(): NodeMaterialConnectionPoint;
  134221. /**
  134222. * Gets the output component
  134223. */
  134224. get output(): NodeMaterialConnectionPoint;
  134225. protected _buildBlock(state: NodeMaterialBuildState): this;
  134226. protected _dumpPropertiesCode(): string;
  134227. serialize(): any;
  134228. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  134229. }
  134230. }
  134231. declare module BABYLON {
  134232. /**
  134233. * Block used to multiply 2 values
  134234. */
  134235. export class MultiplyBlock extends NodeMaterialBlock {
  134236. /**
  134237. * Creates a new MultiplyBlock
  134238. * @param name defines the block name
  134239. */
  134240. constructor(name: string);
  134241. /**
  134242. * Gets the current class name
  134243. * @returns the class name
  134244. */
  134245. getClassName(): string;
  134246. /**
  134247. * Gets the left operand input component
  134248. */
  134249. get left(): NodeMaterialConnectionPoint;
  134250. /**
  134251. * Gets the right operand input component
  134252. */
  134253. get right(): NodeMaterialConnectionPoint;
  134254. /**
  134255. * Gets the output component
  134256. */
  134257. get output(): NodeMaterialConnectionPoint;
  134258. protected _buildBlock(state: NodeMaterialBuildState): this;
  134259. }
  134260. }
  134261. declare module BABYLON {
  134262. /**
  134263. * Interface used to configure the node material editor
  134264. */
  134265. export interface INodeMaterialEditorOptions {
  134266. /** Define the URl to load node editor script */
  134267. editorURL?: string;
  134268. }
  134269. /** @hidden */
  134270. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  134271. NORMAL: boolean;
  134272. TANGENT: boolean;
  134273. UV1: boolean;
  134274. /** BONES */
  134275. NUM_BONE_INFLUENCERS: number;
  134276. BonesPerMesh: number;
  134277. BONETEXTURE: boolean;
  134278. /** MORPH TARGETS */
  134279. MORPHTARGETS: boolean;
  134280. MORPHTARGETS_NORMAL: boolean;
  134281. MORPHTARGETS_TANGENT: boolean;
  134282. MORPHTARGETS_UV: boolean;
  134283. NUM_MORPH_INFLUENCERS: number;
  134284. /** IMAGE PROCESSING */
  134285. IMAGEPROCESSING: boolean;
  134286. VIGNETTE: boolean;
  134287. VIGNETTEBLENDMODEMULTIPLY: boolean;
  134288. VIGNETTEBLENDMODEOPAQUE: boolean;
  134289. TONEMAPPING: boolean;
  134290. TONEMAPPING_ACES: boolean;
  134291. CONTRAST: boolean;
  134292. EXPOSURE: boolean;
  134293. COLORCURVES: boolean;
  134294. COLORGRADING: boolean;
  134295. COLORGRADING3D: boolean;
  134296. SAMPLER3DGREENDEPTH: boolean;
  134297. SAMPLER3DBGRMAP: boolean;
  134298. IMAGEPROCESSINGPOSTPROCESS: boolean;
  134299. /** MISC. */
  134300. BUMPDIRECTUV: number;
  134301. constructor();
  134302. setValue(name: string, value: any, markAsUnprocessedIfDirty?: boolean): void;
  134303. }
  134304. /**
  134305. * Class used to configure NodeMaterial
  134306. */
  134307. export interface INodeMaterialOptions {
  134308. /**
  134309. * Defines if blocks should emit comments
  134310. */
  134311. emitComments: boolean;
  134312. }
  134313. /**
  134314. * Class used to create a node based material built by assembling shader blocks
  134315. */
  134316. export class NodeMaterial extends PushMaterial {
  134317. private static _BuildIdGenerator;
  134318. private _options;
  134319. private _vertexCompilationState;
  134320. private _fragmentCompilationState;
  134321. private _sharedData;
  134322. private _buildId;
  134323. private _buildWasSuccessful;
  134324. private _cachedWorldViewMatrix;
  134325. private _cachedWorldViewProjectionMatrix;
  134326. private _optimizers;
  134327. private _animationFrame;
  134328. /** Define the Url to load node editor script */
  134329. static EditorURL: string;
  134330. /** Define the Url to load snippets */
  134331. static SnippetUrl: string;
  134332. /** Gets or sets a boolean indicating that node materials should not deserialize textures from json / snippet content */
  134333. static IgnoreTexturesAtLoadTime: boolean;
  134334. private BJSNODEMATERIALEDITOR;
  134335. /** Get the inspector from bundle or global */
  134336. private _getGlobalNodeMaterialEditor;
  134337. /**
  134338. * Snippet ID if the material was created from the snippet server
  134339. */
  134340. snippetId: string;
  134341. /**
  134342. * Gets or sets data used by visual editor
  134343. * @see https://nme.babylonjs.com
  134344. */
  134345. editorData: any;
  134346. /**
  134347. * 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)
  134348. */
  134349. ignoreAlpha: boolean;
  134350. /**
  134351. * Defines the maximum number of lights that can be used in the material
  134352. */
  134353. maxSimultaneousLights: number;
  134354. /**
  134355. * Observable raised when the material is built
  134356. */
  134357. onBuildObservable: Observable<NodeMaterial>;
  134358. /**
  134359. * Gets or sets the root nodes of the material vertex shader
  134360. */
  134361. _vertexOutputNodes: NodeMaterialBlock[];
  134362. /**
  134363. * Gets or sets the root nodes of the material fragment (pixel) shader
  134364. */
  134365. _fragmentOutputNodes: NodeMaterialBlock[];
  134366. /** Gets or sets options to control the node material overall behavior */
  134367. get options(): INodeMaterialOptions;
  134368. set options(options: INodeMaterialOptions);
  134369. /**
  134370. * Default configuration related to image processing available in the standard Material.
  134371. */
  134372. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  134373. /**
  134374. * Gets the image processing configuration used either in this material.
  134375. */
  134376. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  134377. /**
  134378. * Sets the Default image processing configuration used either in the this material.
  134379. *
  134380. * If sets to null, the scene one is in use.
  134381. */
  134382. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  134383. /**
  134384. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  134385. */
  134386. attachedBlocks: NodeMaterialBlock[];
  134387. /**
  134388. * Specifies the mode of the node material
  134389. * @hidden
  134390. */
  134391. _mode: NodeMaterialModes;
  134392. /**
  134393. * Gets the mode property
  134394. */
  134395. get mode(): NodeMaterialModes;
  134396. /**
  134397. * Create a new node based material
  134398. * @param name defines the material name
  134399. * @param scene defines the hosting scene
  134400. * @param options defines creation option
  134401. */
  134402. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  134403. /**
  134404. * Gets the current class name of the material e.g. "NodeMaterial"
  134405. * @returns the class name
  134406. */
  134407. getClassName(): string;
  134408. /**
  134409. * Keep track of the image processing observer to allow dispose and replace.
  134410. */
  134411. private _imageProcessingObserver;
  134412. /**
  134413. * Attaches a new image processing configuration to the Standard Material.
  134414. * @param configuration
  134415. */
  134416. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  134417. /**
  134418. * Get a block by its name
  134419. * @param name defines the name of the block to retrieve
  134420. * @returns the required block or null if not found
  134421. */
  134422. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  134423. /**
  134424. * Get a block by its name
  134425. * @param predicate defines the predicate used to find the good candidate
  134426. * @returns the required block or null if not found
  134427. */
  134428. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  134429. /**
  134430. * Get an input block by its name
  134431. * @param predicate defines the predicate used to find the good candidate
  134432. * @returns the required input block or null if not found
  134433. */
  134434. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  134435. /**
  134436. * Gets the list of input blocks attached to this material
  134437. * @returns an array of InputBlocks
  134438. */
  134439. getInputBlocks(): InputBlock[];
  134440. /**
  134441. * Adds a new optimizer to the list of optimizers
  134442. * @param optimizer defines the optimizers to add
  134443. * @returns the current material
  134444. */
  134445. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  134446. /**
  134447. * Remove an optimizer from the list of optimizers
  134448. * @param optimizer defines the optimizers to remove
  134449. * @returns the current material
  134450. */
  134451. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  134452. /**
  134453. * Add a new block to the list of output nodes
  134454. * @param node defines the node to add
  134455. * @returns the current material
  134456. */
  134457. addOutputNode(node: NodeMaterialBlock): this;
  134458. /**
  134459. * Remove a block from the list of root nodes
  134460. * @param node defines the node to remove
  134461. * @returns the current material
  134462. */
  134463. removeOutputNode(node: NodeMaterialBlock): this;
  134464. private _addVertexOutputNode;
  134465. private _removeVertexOutputNode;
  134466. private _addFragmentOutputNode;
  134467. private _removeFragmentOutputNode;
  134468. /**
  134469. * Specifies if the material will require alpha blending
  134470. * @returns a boolean specifying if alpha blending is needed
  134471. */
  134472. needAlphaBlending(): boolean;
  134473. /**
  134474. * Specifies if this material should be rendered in alpha test mode
  134475. * @returns a boolean specifying if an alpha test is needed.
  134476. */
  134477. needAlphaTesting(): boolean;
  134478. private _initializeBlock;
  134479. private _resetDualBlocks;
  134480. /**
  134481. * Remove a block from the current node material
  134482. * @param block defines the block to remove
  134483. */
  134484. removeBlock(block: NodeMaterialBlock): void;
  134485. /**
  134486. * Build the material and generates the inner effect
  134487. * @param verbose defines if the build should log activity
  134488. */
  134489. build(verbose?: boolean): void;
  134490. /**
  134491. * Runs an otpimization phase to try to improve the shader code
  134492. */
  134493. optimize(): void;
  134494. private _prepareDefinesForAttributes;
  134495. /**
  134496. * Create a post process from the material
  134497. * @param camera The camera to apply the render pass to.
  134498. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  134499. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  134500. * @param engine The engine which the post process will be applied. (default: current engine)
  134501. * @param reusable If the post process can be reused on the same frame. (default: false)
  134502. * @param textureType Type of textures used when performing the post process. (default: 0)
  134503. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  134504. * @returns the post process created
  134505. */
  134506. createPostProcess(camera: Nullable<Camera>, options?: number | PostProcessOptions, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, textureFormat?: number): PostProcess;
  134507. private _processDefines;
  134508. /**
  134509. * Get if the submesh is ready to be used and all its information available.
  134510. * Child classes can use it to update shaders
  134511. * @param mesh defines the mesh to check
  134512. * @param subMesh defines which submesh to check
  134513. * @param useInstances specifies that instances should be used
  134514. * @returns a boolean indicating that the submesh is ready or not
  134515. */
  134516. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  134517. /**
  134518. * Get a string representing the shaders built by the current node graph
  134519. */
  134520. get compiledShaders(): string;
  134521. /**
  134522. * Binds the world matrix to the material
  134523. * @param world defines the world transformation matrix
  134524. */
  134525. bindOnlyWorldMatrix(world: Matrix): void;
  134526. /**
  134527. * Binds the submesh to this material by preparing the effect and shader to draw
  134528. * @param world defines the world transformation matrix
  134529. * @param mesh defines the mesh containing the submesh
  134530. * @param subMesh defines the submesh to bind the material to
  134531. */
  134532. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  134533. /**
  134534. * Gets the active textures from the material
  134535. * @returns an array of textures
  134536. */
  134537. getActiveTextures(): BaseTexture[];
  134538. /**
  134539. * Gets the list of texture blocks
  134540. * @returns an array of texture blocks
  134541. */
  134542. getTextureBlocks(): (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock)[];
  134543. /**
  134544. * Specifies if the material uses a texture
  134545. * @param texture defines the texture to check against the material
  134546. * @returns a boolean specifying if the material uses the texture
  134547. */
  134548. hasTexture(texture: BaseTexture): boolean;
  134549. /**
  134550. * Disposes the material
  134551. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  134552. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  134553. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  134554. */
  134555. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  134556. /** Creates the node editor window. */
  134557. private _createNodeEditor;
  134558. /**
  134559. * Launch the node material editor
  134560. * @param config Define the configuration of the editor
  134561. * @return a promise fulfilled when the node editor is visible
  134562. */
  134563. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  134564. /**
  134565. * Clear the current material
  134566. */
  134567. clear(): void;
  134568. /**
  134569. * Clear the current material and set it to a default state
  134570. */
  134571. setToDefault(): void;
  134572. /**
  134573. * Clear the current material and set it to a default state for post process
  134574. */
  134575. setToDefaultPostProcess(): void;
  134576. /**
  134577. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  134578. * @param url defines the url to load from
  134579. * @returns a promise that will fullfil when the material is fully loaded
  134580. */
  134581. loadAsync(url: string): Promise<void>;
  134582. private _gatherBlocks;
  134583. /**
  134584. * Generate a string containing the code declaration required to create an equivalent of this material
  134585. * @returns a string
  134586. */
  134587. generateCode(): string;
  134588. /**
  134589. * Serializes this material in a JSON representation
  134590. * @returns the serialized material object
  134591. */
  134592. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  134593. private _restoreConnections;
  134594. /**
  134595. * Clear the current graph and load a new one from a serialization object
  134596. * @param source defines the JSON representation of the material
  134597. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  134598. */
  134599. loadFromSerialization(source: any, rootUrl?: string): void;
  134600. /**
  134601. * Makes a duplicate of the current material.
  134602. * @param name - name to use for the new material.
  134603. */
  134604. clone(name: string): NodeMaterial;
  134605. /**
  134606. * Creates a node material from parsed material data
  134607. * @param source defines the JSON representation of the material
  134608. * @param scene defines the hosting scene
  134609. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  134610. * @returns a new node material
  134611. */
  134612. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  134613. /**
  134614. * Creates a node material from a snippet saved in a remote file
  134615. * @param name defines the name of the material to create
  134616. * @param url defines the url to load from
  134617. * @param scene defines the hosting scene
  134618. * @returns a promise that will resolve to the new node material
  134619. */
  134620. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  134621. /**
  134622. * Creates a node material from a snippet saved by the node material editor
  134623. * @param snippetId defines the snippet to load
  134624. * @param scene defines the hosting scene
  134625. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  134626. * @param nodeMaterial defines a node material to update (instead of creating a new one)
  134627. * @returns a promise that will resolve to the new node material
  134628. */
  134629. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string, nodeMaterial?: NodeMaterial): Promise<NodeMaterial>;
  134630. /**
  134631. * Creates a new node material set to default basic configuration
  134632. * @param name defines the name of the material
  134633. * @param scene defines the hosting scene
  134634. * @returns a new NodeMaterial
  134635. */
  134636. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  134637. }
  134638. }
  134639. declare module BABYLON {
  134640. /**
  134641. * Block used to read a texture from a sampler
  134642. */
  134643. export class TextureBlock extends NodeMaterialBlock {
  134644. private _defineName;
  134645. private _linearDefineName;
  134646. private _gammaDefineName;
  134647. private _tempTextureRead;
  134648. private _samplerName;
  134649. private _transformedUVName;
  134650. private _textureTransformName;
  134651. private _textureInfoName;
  134652. private _mainUVName;
  134653. private _mainUVDefineName;
  134654. /**
  134655. * Gets or sets the texture associated with the node
  134656. */
  134657. texture: Nullable<Texture>;
  134658. /**
  134659. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  134660. */
  134661. convertToGammaSpace: boolean;
  134662. /**
  134663. * Gets or sets a boolean indicating if content needs to be converted to linear space
  134664. */
  134665. convertToLinearSpace: boolean;
  134666. /**
  134667. * Create a new TextureBlock
  134668. * @param name defines the block name
  134669. */
  134670. constructor(name: string);
  134671. /**
  134672. * Gets the current class name
  134673. * @returns the class name
  134674. */
  134675. getClassName(): string;
  134676. /**
  134677. * Gets the uv input component
  134678. */
  134679. get uv(): NodeMaterialConnectionPoint;
  134680. /**
  134681. * Gets the rgba output component
  134682. */
  134683. get rgba(): NodeMaterialConnectionPoint;
  134684. /**
  134685. * Gets the rgb output component
  134686. */
  134687. get rgb(): NodeMaterialConnectionPoint;
  134688. /**
  134689. * Gets the r output component
  134690. */
  134691. get r(): NodeMaterialConnectionPoint;
  134692. /**
  134693. * Gets the g output component
  134694. */
  134695. get g(): NodeMaterialConnectionPoint;
  134696. /**
  134697. * Gets the b output component
  134698. */
  134699. get b(): NodeMaterialConnectionPoint;
  134700. /**
  134701. * Gets the a output component
  134702. */
  134703. get a(): NodeMaterialConnectionPoint;
  134704. get target(): NodeMaterialBlockTargets;
  134705. autoConfigure(material: NodeMaterial): void;
  134706. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  134707. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  134708. isReady(): boolean;
  134709. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  134710. private get _isMixed();
  134711. private _injectVertexCode;
  134712. private _writeTextureRead;
  134713. private _writeOutput;
  134714. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  134715. protected _dumpPropertiesCode(): string;
  134716. serialize(): any;
  134717. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  134718. }
  134719. }
  134720. declare module BABYLON {
  134721. /**
  134722. * Class used to store shared data between 2 NodeMaterialBuildState
  134723. */
  134724. export class NodeMaterialBuildStateSharedData {
  134725. /**
  134726. * Gets the list of emitted varyings
  134727. */
  134728. temps: string[];
  134729. /**
  134730. * Gets the list of emitted varyings
  134731. */
  134732. varyings: string[];
  134733. /**
  134734. * Gets the varying declaration string
  134735. */
  134736. varyingDeclaration: string;
  134737. /**
  134738. * Input blocks
  134739. */
  134740. inputBlocks: InputBlock[];
  134741. /**
  134742. * Input blocks
  134743. */
  134744. textureBlocks: (ReflectionTextureBaseBlock | TextureBlock | RefractionBlock | CurrentScreenBlock)[];
  134745. /**
  134746. * Bindable blocks (Blocks that need to set data to the effect)
  134747. */
  134748. bindableBlocks: NodeMaterialBlock[];
  134749. /**
  134750. * List of blocks that can provide a compilation fallback
  134751. */
  134752. blocksWithFallbacks: NodeMaterialBlock[];
  134753. /**
  134754. * List of blocks that can provide a define update
  134755. */
  134756. blocksWithDefines: NodeMaterialBlock[];
  134757. /**
  134758. * List of blocks that can provide a repeatable content
  134759. */
  134760. repeatableContentBlocks: NodeMaterialBlock[];
  134761. /**
  134762. * List of blocks that can provide a dynamic list of uniforms
  134763. */
  134764. dynamicUniformBlocks: NodeMaterialBlock[];
  134765. /**
  134766. * List of blocks that can block the isReady function for the material
  134767. */
  134768. blockingBlocks: NodeMaterialBlock[];
  134769. /**
  134770. * Gets the list of animated inputs
  134771. */
  134772. animatedInputs: InputBlock[];
  134773. /**
  134774. * Build Id used to avoid multiple recompilations
  134775. */
  134776. buildId: number;
  134777. /** List of emitted variables */
  134778. variableNames: {
  134779. [key: string]: number;
  134780. };
  134781. /** List of emitted defines */
  134782. defineNames: {
  134783. [key: string]: number;
  134784. };
  134785. /** Should emit comments? */
  134786. emitComments: boolean;
  134787. /** Emit build activity */
  134788. verbose: boolean;
  134789. /** Gets or sets the hosting scene */
  134790. scene: Scene;
  134791. /**
  134792. * Gets the compilation hints emitted at compilation time
  134793. */
  134794. hints: {
  134795. needWorldViewMatrix: boolean;
  134796. needWorldViewProjectionMatrix: boolean;
  134797. needAlphaBlending: boolean;
  134798. needAlphaTesting: boolean;
  134799. };
  134800. /**
  134801. * List of compilation checks
  134802. */
  134803. checks: {
  134804. emitVertex: boolean;
  134805. emitFragment: boolean;
  134806. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  134807. };
  134808. /** Creates a new shared data */
  134809. constructor();
  134810. /**
  134811. * Emits console errors and exceptions if there is a failing check
  134812. */
  134813. emitErrors(): void;
  134814. }
  134815. }
  134816. declare module BABYLON {
  134817. /**
  134818. * Class used to store node based material build state
  134819. */
  134820. export class NodeMaterialBuildState {
  134821. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  134822. supportUniformBuffers: boolean;
  134823. /**
  134824. * Gets the list of emitted attributes
  134825. */
  134826. attributes: string[];
  134827. /**
  134828. * Gets the list of emitted uniforms
  134829. */
  134830. uniforms: string[];
  134831. /**
  134832. * Gets the list of emitted constants
  134833. */
  134834. constants: string[];
  134835. /**
  134836. * Gets the list of emitted samplers
  134837. */
  134838. samplers: string[];
  134839. /**
  134840. * Gets the list of emitted functions
  134841. */
  134842. functions: {
  134843. [key: string]: string;
  134844. };
  134845. /**
  134846. * Gets the list of emitted extensions
  134847. */
  134848. extensions: {
  134849. [key: string]: string;
  134850. };
  134851. /**
  134852. * Gets the target of the compilation state
  134853. */
  134854. target: NodeMaterialBlockTargets;
  134855. /**
  134856. * Gets the list of emitted counters
  134857. */
  134858. counters: {
  134859. [key: string]: number;
  134860. };
  134861. /**
  134862. * Shared data between multiple NodeMaterialBuildState instances
  134863. */
  134864. sharedData: NodeMaterialBuildStateSharedData;
  134865. /** @hidden */
  134866. _vertexState: NodeMaterialBuildState;
  134867. /** @hidden */
  134868. _attributeDeclaration: string;
  134869. /** @hidden */
  134870. _uniformDeclaration: string;
  134871. /** @hidden */
  134872. _constantDeclaration: string;
  134873. /** @hidden */
  134874. _samplerDeclaration: string;
  134875. /** @hidden */
  134876. _varyingTransfer: string;
  134877. /** @hidden */
  134878. _injectAtEnd: string;
  134879. private _repeatableContentAnchorIndex;
  134880. /** @hidden */
  134881. _builtCompilationString: string;
  134882. /**
  134883. * Gets the emitted compilation strings
  134884. */
  134885. compilationString: string;
  134886. /**
  134887. * Finalize the compilation strings
  134888. * @param state defines the current compilation state
  134889. */
  134890. finalize(state: NodeMaterialBuildState): void;
  134891. /** @hidden */
  134892. get _repeatableContentAnchor(): string;
  134893. /** @hidden */
  134894. _getFreeVariableName(prefix: string): string;
  134895. /** @hidden */
  134896. _getFreeDefineName(prefix: string): string;
  134897. /** @hidden */
  134898. _excludeVariableName(name: string): void;
  134899. /** @hidden */
  134900. _emit2DSampler(name: string): void;
  134901. /** @hidden */
  134902. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  134903. /** @hidden */
  134904. _emitExtension(name: string, extension: string, define?: string): void;
  134905. /** @hidden */
  134906. _emitFunction(name: string, code: string, comments: string): void;
  134907. /** @hidden */
  134908. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  134909. replaceStrings?: {
  134910. search: RegExp;
  134911. replace: string;
  134912. }[];
  134913. repeatKey?: string;
  134914. }): string;
  134915. /** @hidden */
  134916. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  134917. repeatKey?: string;
  134918. removeAttributes?: boolean;
  134919. removeUniforms?: boolean;
  134920. removeVaryings?: boolean;
  134921. removeIfDef?: boolean;
  134922. replaceStrings?: {
  134923. search: RegExp;
  134924. replace: string;
  134925. }[];
  134926. }, storeKey?: string): void;
  134927. /** @hidden */
  134928. _registerTempVariable(name: string): boolean;
  134929. /** @hidden */
  134930. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  134931. /** @hidden */
  134932. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  134933. /** @hidden */
  134934. _emitFloat(value: number): string;
  134935. }
  134936. }
  134937. declare module BABYLON {
  134938. /**
  134939. * Defines a block that can be used inside a node based material
  134940. */
  134941. export class NodeMaterialBlock {
  134942. private _buildId;
  134943. private _buildTarget;
  134944. private _target;
  134945. private _isFinalMerger;
  134946. private _isInput;
  134947. protected _isUnique: boolean;
  134948. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  134949. inputsAreExclusive: boolean;
  134950. /** @hidden */
  134951. _codeVariableName: string;
  134952. /** @hidden */
  134953. _inputs: NodeMaterialConnectionPoint[];
  134954. /** @hidden */
  134955. _outputs: NodeMaterialConnectionPoint[];
  134956. /** @hidden */
  134957. _preparationId: number;
  134958. /**
  134959. * Gets or sets the name of the block
  134960. */
  134961. name: string;
  134962. /**
  134963. * Gets or sets the unique id of the node
  134964. */
  134965. uniqueId: number;
  134966. /**
  134967. * Gets or sets the comments associated with this block
  134968. */
  134969. comments: string;
  134970. /**
  134971. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  134972. */
  134973. get isUnique(): boolean;
  134974. /**
  134975. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  134976. */
  134977. get isFinalMerger(): boolean;
  134978. /**
  134979. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  134980. */
  134981. get isInput(): boolean;
  134982. /**
  134983. * Gets or sets the build Id
  134984. */
  134985. get buildId(): number;
  134986. set buildId(value: number);
  134987. /**
  134988. * Gets or sets the target of the block
  134989. */
  134990. get target(): NodeMaterialBlockTargets;
  134991. set target(value: NodeMaterialBlockTargets);
  134992. /**
  134993. * Gets the list of input points
  134994. */
  134995. get inputs(): NodeMaterialConnectionPoint[];
  134996. /** Gets the list of output points */
  134997. get outputs(): NodeMaterialConnectionPoint[];
  134998. /**
  134999. * Find an input by its name
  135000. * @param name defines the name of the input to look for
  135001. * @returns the input or null if not found
  135002. */
  135003. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  135004. /**
  135005. * Find an output by its name
  135006. * @param name defines the name of the outputto look for
  135007. * @returns the output or null if not found
  135008. */
  135009. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  135010. /**
  135011. * Creates a new NodeMaterialBlock
  135012. * @param name defines the block name
  135013. * @param target defines the target of that block (Vertex by default)
  135014. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  135015. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  135016. */
  135017. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  135018. /**
  135019. * Initialize the block and prepare the context for build
  135020. * @param state defines the state that will be used for the build
  135021. */
  135022. initialize(state: NodeMaterialBuildState): void;
  135023. /**
  135024. * Bind data to effect. Will only be called for blocks with isBindable === true
  135025. * @param effect defines the effect to bind data to
  135026. * @param nodeMaterial defines the hosting NodeMaterial
  135027. * @param mesh defines the mesh that will be rendered
  135028. * @param subMesh defines the submesh that will be rendered
  135029. */
  135030. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  135031. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  135032. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  135033. protected _writeFloat(value: number): string;
  135034. /**
  135035. * Gets the current class name e.g. "NodeMaterialBlock"
  135036. * @returns the class name
  135037. */
  135038. getClassName(): string;
  135039. /**
  135040. * Register a new input. Must be called inside a block constructor
  135041. * @param name defines the connection point name
  135042. * @param type defines the connection point type
  135043. * @param isOptional defines a boolean indicating that this input can be omitted
  135044. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  135045. * @param point an already created connection point. If not provided, create a new one
  135046. * @returns the current block
  135047. */
  135048. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  135049. /**
  135050. * Register a new output. Must be called inside a block constructor
  135051. * @param name defines the connection point name
  135052. * @param type defines the connection point type
  135053. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  135054. * @param point an already created connection point. If not provided, create a new one
  135055. * @returns the current block
  135056. */
  135057. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  135058. /**
  135059. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  135060. * @param forOutput defines an optional connection point to check compatibility with
  135061. * @returns the first available input or null
  135062. */
  135063. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  135064. /**
  135065. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  135066. * @param forBlock defines an optional block to check compatibility with
  135067. * @returns the first available input or null
  135068. */
  135069. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  135070. /**
  135071. * Gets the sibling of the given output
  135072. * @param current defines the current output
  135073. * @returns the next output in the list or null
  135074. */
  135075. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  135076. /**
  135077. * Connect current block with another block
  135078. * @param other defines the block to connect with
  135079. * @param options define the various options to help pick the right connections
  135080. * @returns the current block
  135081. */
  135082. connectTo(other: NodeMaterialBlock, options?: {
  135083. input?: string;
  135084. output?: string;
  135085. outputSwizzle?: string;
  135086. }): this | undefined;
  135087. protected _buildBlock(state: NodeMaterialBuildState): void;
  135088. /**
  135089. * Add uniforms, samplers and uniform buffers at compilation time
  135090. * @param state defines the state to update
  135091. * @param nodeMaterial defines the node material requesting the update
  135092. * @param defines defines the material defines to update
  135093. * @param uniformBuffers defines the list of uniform buffer names
  135094. */
  135095. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  135096. /**
  135097. * Add potential fallbacks if shader compilation fails
  135098. * @param mesh defines the mesh to be rendered
  135099. * @param fallbacks defines the current prioritized list of fallbacks
  135100. */
  135101. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  135102. /**
  135103. * Initialize defines for shader compilation
  135104. * @param mesh defines the mesh to be rendered
  135105. * @param nodeMaterial defines the node material requesting the update
  135106. * @param defines defines the material defines to update
  135107. * @param useInstances specifies that instances should be used
  135108. */
  135109. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  135110. /**
  135111. * Update defines for shader compilation
  135112. * @param mesh defines the mesh to be rendered
  135113. * @param nodeMaterial defines the node material requesting the update
  135114. * @param defines defines the material defines to update
  135115. * @param useInstances specifies that instances should be used
  135116. */
  135117. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  135118. /**
  135119. * Lets the block try to connect some inputs automatically
  135120. * @param material defines the hosting NodeMaterial
  135121. */
  135122. autoConfigure(material: NodeMaterial): void;
  135123. /**
  135124. * Function called when a block is declared as repeatable content generator
  135125. * @param vertexShaderState defines the current compilation state for the vertex shader
  135126. * @param fragmentShaderState defines the current compilation state for the fragment shader
  135127. * @param mesh defines the mesh to be rendered
  135128. * @param defines defines the material defines to update
  135129. */
  135130. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  135131. /**
  135132. * Checks if the block is ready
  135133. * @param mesh defines the mesh to be rendered
  135134. * @param nodeMaterial defines the node material requesting the update
  135135. * @param defines defines the material defines to update
  135136. * @param useInstances specifies that instances should be used
  135137. * @returns true if the block is ready
  135138. */
  135139. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  135140. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  135141. private _processBuild;
  135142. /**
  135143. * Compile the current node and generate the shader code
  135144. * @param state defines the current compilation state (uniforms, samplers, current string)
  135145. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  135146. * @returns true if already built
  135147. */
  135148. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  135149. protected _inputRename(name: string): string;
  135150. protected _outputRename(name: string): string;
  135151. protected _dumpPropertiesCode(): string;
  135152. /** @hidden */
  135153. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  135154. /** @hidden */
  135155. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  135156. /**
  135157. * Clone the current block to a new identical block
  135158. * @param scene defines the hosting scene
  135159. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  135160. * @returns a copy of the current block
  135161. */
  135162. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  135163. /**
  135164. * Serializes this block in a JSON representation
  135165. * @returns the serialized block object
  135166. */
  135167. serialize(): any;
  135168. /** @hidden */
  135169. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  135170. private _deserializePortDisplayNames;
  135171. /**
  135172. * Release resources
  135173. */
  135174. dispose(): void;
  135175. }
  135176. }
  135177. declare module BABYLON {
  135178. /**
  135179. * Enum defining the type of animations supported by InputBlock
  135180. */
  135181. export enum AnimatedInputBlockTypes {
  135182. /** No animation */
  135183. None = 0,
  135184. /** Time based animation. Will only work for floats */
  135185. Time = 1
  135186. }
  135187. }
  135188. declare module BABYLON {
  135189. /**
  135190. * Block used to expose an input value
  135191. */
  135192. export class InputBlock extends NodeMaterialBlock {
  135193. private _mode;
  135194. private _associatedVariableName;
  135195. private _storedValue;
  135196. private _valueCallback;
  135197. private _type;
  135198. private _animationType;
  135199. /** Gets or set a value used to limit the range of float values */
  135200. min: number;
  135201. /** Gets or set a value used to limit the range of float values */
  135202. max: number;
  135203. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  135204. isBoolean: boolean;
  135205. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  135206. matrixMode: number;
  135207. /** @hidden */
  135208. _systemValue: Nullable<NodeMaterialSystemValues>;
  135209. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  135210. visibleInInspector: boolean;
  135211. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  135212. isConstant: boolean;
  135213. /** Gets or sets the group to use to display this block in the Inspector */
  135214. groupInInspector: string;
  135215. /** Gets an observable raised when the value is changed */
  135216. onValueChangedObservable: Observable<InputBlock>;
  135217. /**
  135218. * Gets or sets the connection point type (default is float)
  135219. */
  135220. get type(): NodeMaterialBlockConnectionPointTypes;
  135221. /**
  135222. * Creates a new InputBlock
  135223. * @param name defines the block name
  135224. * @param target defines the target of that block (Vertex by default)
  135225. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  135226. */
  135227. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  135228. /**
  135229. * Gets the output component
  135230. */
  135231. get output(): NodeMaterialConnectionPoint;
  135232. /**
  135233. * Set the source of this connection point to a vertex attribute
  135234. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  135235. * @returns the current connection point
  135236. */
  135237. setAsAttribute(attributeName?: string): InputBlock;
  135238. /**
  135239. * Set the source of this connection point to a system value
  135240. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  135241. * @returns the current connection point
  135242. */
  135243. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  135244. /**
  135245. * Gets or sets the value of that point.
  135246. * Please note that this value will be ignored if valueCallback is defined
  135247. */
  135248. get value(): any;
  135249. set value(value: any);
  135250. /**
  135251. * Gets or sets a callback used to get the value of that point.
  135252. * Please note that setting this value will force the connection point to ignore the value property
  135253. */
  135254. get valueCallback(): () => any;
  135255. set valueCallback(value: () => any);
  135256. /**
  135257. * Gets or sets the associated variable name in the shader
  135258. */
  135259. get associatedVariableName(): string;
  135260. set associatedVariableName(value: string);
  135261. /** Gets or sets the type of animation applied to the input */
  135262. get animationType(): AnimatedInputBlockTypes;
  135263. set animationType(value: AnimatedInputBlockTypes);
  135264. /**
  135265. * Gets a boolean indicating that this connection point not defined yet
  135266. */
  135267. get isUndefined(): boolean;
  135268. /**
  135269. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  135270. * In this case the connection point name must be the name of the uniform to use.
  135271. * Can only be set on inputs
  135272. */
  135273. get isUniform(): boolean;
  135274. set isUniform(value: boolean);
  135275. /**
  135276. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  135277. * In this case the connection point name must be the name of the attribute to use
  135278. * Can only be set on inputs
  135279. */
  135280. get isAttribute(): boolean;
  135281. set isAttribute(value: boolean);
  135282. /**
  135283. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  135284. * Can only be set on exit points
  135285. */
  135286. get isVarying(): boolean;
  135287. set isVarying(value: boolean);
  135288. /**
  135289. * Gets a boolean indicating that the current connection point is a system value
  135290. */
  135291. get isSystemValue(): boolean;
  135292. /**
  135293. * Gets or sets the current well known value or null if not defined as a system value
  135294. */
  135295. get systemValue(): Nullable<NodeMaterialSystemValues>;
  135296. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  135297. /**
  135298. * Gets the current class name
  135299. * @returns the class name
  135300. */
  135301. getClassName(): string;
  135302. /**
  135303. * Animate the input if animationType !== None
  135304. * @param scene defines the rendering scene
  135305. */
  135306. animate(scene: Scene): void;
  135307. private _emitDefine;
  135308. initialize(state: NodeMaterialBuildState): void;
  135309. /**
  135310. * Set the input block to its default value (based on its type)
  135311. */
  135312. setDefaultValue(): void;
  135313. private _emitConstant;
  135314. private _emit;
  135315. /** @hidden */
  135316. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  135317. /** @hidden */
  135318. _transmit(effect: Effect, scene: Scene): void;
  135319. protected _buildBlock(state: NodeMaterialBuildState): void;
  135320. protected _dumpPropertiesCode(): string;
  135321. dispose(): void;
  135322. serialize(): any;
  135323. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  135324. }
  135325. }
  135326. declare module BABYLON {
  135327. /**
  135328. * Enum used to define the compatibility state between two connection points
  135329. */
  135330. export enum NodeMaterialConnectionPointCompatibilityStates {
  135331. /** Points are compatibles */
  135332. Compatible = 0,
  135333. /** Points are incompatible because of their types */
  135334. TypeIncompatible = 1,
  135335. /** Points are incompatible because of their targets (vertex vs fragment) */
  135336. TargetIncompatible = 2
  135337. }
  135338. /**
  135339. * Defines the direction of a connection point
  135340. */
  135341. export enum NodeMaterialConnectionPointDirection {
  135342. /** Input */
  135343. Input = 0,
  135344. /** Output */
  135345. Output = 1
  135346. }
  135347. /**
  135348. * Defines a connection point for a block
  135349. */
  135350. export class NodeMaterialConnectionPoint {
  135351. /** @hidden */
  135352. _ownerBlock: NodeMaterialBlock;
  135353. /** @hidden */
  135354. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  135355. private _endpoints;
  135356. private _associatedVariableName;
  135357. private _direction;
  135358. /** @hidden */
  135359. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  135360. /** @hidden */
  135361. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  135362. private _type;
  135363. /** @hidden */
  135364. _enforceAssociatedVariableName: boolean;
  135365. /** Gets the direction of the point */
  135366. get direction(): NodeMaterialConnectionPointDirection;
  135367. /** Indicates that this connection point needs dual validation before being connected to another point */
  135368. needDualDirectionValidation: boolean;
  135369. /**
  135370. * Gets or sets the additional types supported by this connection point
  135371. */
  135372. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  135373. /**
  135374. * Gets or sets the additional types excluded by this connection point
  135375. */
  135376. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  135377. /**
  135378. * Observable triggered when this point is connected
  135379. */
  135380. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  135381. /**
  135382. * Gets or sets the associated variable name in the shader
  135383. */
  135384. get associatedVariableName(): string;
  135385. set associatedVariableName(value: string);
  135386. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  135387. get innerType(): NodeMaterialBlockConnectionPointTypes;
  135388. /**
  135389. * Gets or sets the connection point type (default is float)
  135390. */
  135391. get type(): NodeMaterialBlockConnectionPointTypes;
  135392. set type(value: NodeMaterialBlockConnectionPointTypes);
  135393. /**
  135394. * Gets or sets the connection point name
  135395. */
  135396. name: string;
  135397. /**
  135398. * Gets or sets the connection point name
  135399. */
  135400. displayName: string;
  135401. /**
  135402. * Gets or sets a boolean indicating that this connection point can be omitted
  135403. */
  135404. isOptional: boolean;
  135405. /**
  135406. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  135407. */
  135408. define: string;
  135409. /** @hidden */
  135410. _prioritizeVertex: boolean;
  135411. private _target;
  135412. /** Gets or sets the target of that connection point */
  135413. get target(): NodeMaterialBlockTargets;
  135414. set target(value: NodeMaterialBlockTargets);
  135415. /**
  135416. * Gets a boolean indicating that the current point is connected to another NodeMaterialBlock
  135417. */
  135418. get isConnected(): boolean;
  135419. /**
  135420. * Gets a boolean indicating that the current point is connected to an input block
  135421. */
  135422. get isConnectedToInputBlock(): boolean;
  135423. /**
  135424. * Gets a the connected input block (if any)
  135425. */
  135426. get connectInputBlock(): Nullable<InputBlock>;
  135427. /** Get the other side of the connection (if any) */
  135428. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  135429. /** Get the block that owns this connection point */
  135430. get ownerBlock(): NodeMaterialBlock;
  135431. /** Get the block connected on the other side of this connection (if any) */
  135432. get sourceBlock(): Nullable<NodeMaterialBlock>;
  135433. /** Get the block connected on the endpoints of this connection (if any) */
  135434. get connectedBlocks(): Array<NodeMaterialBlock>;
  135435. /** Gets the list of connected endpoints */
  135436. get endpoints(): NodeMaterialConnectionPoint[];
  135437. /** Gets a boolean indicating if that output point is connected to at least one input */
  135438. get hasEndpoints(): boolean;
  135439. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  135440. get isConnectedInVertexShader(): boolean;
  135441. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  135442. get isConnectedInFragmentShader(): boolean;
  135443. /**
  135444. * Creates a block suitable to be used as an input for this input point.
  135445. * If null is returned, a block based on the point type will be created.
  135446. * @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
  135447. */
  135448. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  135449. /**
  135450. * Creates a new connection point
  135451. * @param name defines the connection point name
  135452. * @param ownerBlock defines the block hosting this connection point
  135453. * @param direction defines the direction of the connection point
  135454. */
  135455. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  135456. /**
  135457. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  135458. * @returns the class name
  135459. */
  135460. getClassName(): string;
  135461. /**
  135462. * Gets a boolean indicating if the current point can be connected to another point
  135463. * @param connectionPoint defines the other connection point
  135464. * @returns a boolean
  135465. */
  135466. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  135467. /**
  135468. * Gets a number indicating if the current point can be connected to another point
  135469. * @param connectionPoint defines the other connection point
  135470. * @returns a number defining the compatibility state
  135471. */
  135472. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  135473. /**
  135474. * Connect this point to another connection point
  135475. * @param connectionPoint defines the other connection point
  135476. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  135477. * @returns the current connection point
  135478. */
  135479. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  135480. /**
  135481. * Disconnect this point from one of his endpoint
  135482. * @param endpoint defines the other connection point
  135483. * @returns the current connection point
  135484. */
  135485. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  135486. /**
  135487. * Serializes this point in a JSON representation
  135488. * @param isInput defines if the connection point is an input (default is true)
  135489. * @returns the serialized point object
  135490. */
  135491. serialize(isInput?: boolean): any;
  135492. /**
  135493. * Release resources
  135494. */
  135495. dispose(): void;
  135496. }
  135497. }
  135498. declare module BABYLON {
  135499. /**
  135500. * Block used to add support for vertex skinning (bones)
  135501. */
  135502. export class BonesBlock extends NodeMaterialBlock {
  135503. /**
  135504. * Creates a new BonesBlock
  135505. * @param name defines the block name
  135506. */
  135507. constructor(name: string);
  135508. /**
  135509. * Initialize the block and prepare the context for build
  135510. * @param state defines the state that will be used for the build
  135511. */
  135512. initialize(state: NodeMaterialBuildState): void;
  135513. /**
  135514. * Gets the current class name
  135515. * @returns the class name
  135516. */
  135517. getClassName(): string;
  135518. /**
  135519. * Gets the matrix indices input component
  135520. */
  135521. get matricesIndices(): NodeMaterialConnectionPoint;
  135522. /**
  135523. * Gets the matrix weights input component
  135524. */
  135525. get matricesWeights(): NodeMaterialConnectionPoint;
  135526. /**
  135527. * Gets the extra matrix indices input component
  135528. */
  135529. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  135530. /**
  135531. * Gets the extra matrix weights input component
  135532. */
  135533. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  135534. /**
  135535. * Gets the world input component
  135536. */
  135537. get world(): NodeMaterialConnectionPoint;
  135538. /**
  135539. * Gets the output component
  135540. */
  135541. get output(): NodeMaterialConnectionPoint;
  135542. autoConfigure(material: NodeMaterial): void;
  135543. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  135544. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  135545. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  135546. protected _buildBlock(state: NodeMaterialBuildState): this;
  135547. }
  135548. }
  135549. declare module BABYLON {
  135550. /**
  135551. * Block used to add support for instances
  135552. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  135553. */
  135554. export class InstancesBlock extends NodeMaterialBlock {
  135555. /**
  135556. * Creates a new InstancesBlock
  135557. * @param name defines the block name
  135558. */
  135559. constructor(name: string);
  135560. /**
  135561. * Gets the current class name
  135562. * @returns the class name
  135563. */
  135564. getClassName(): string;
  135565. /**
  135566. * Gets the first world row input component
  135567. */
  135568. get world0(): NodeMaterialConnectionPoint;
  135569. /**
  135570. * Gets the second world row input component
  135571. */
  135572. get world1(): NodeMaterialConnectionPoint;
  135573. /**
  135574. * Gets the third world row input component
  135575. */
  135576. get world2(): NodeMaterialConnectionPoint;
  135577. /**
  135578. * Gets the forth world row input component
  135579. */
  135580. get world3(): NodeMaterialConnectionPoint;
  135581. /**
  135582. * Gets the world input component
  135583. */
  135584. get world(): NodeMaterialConnectionPoint;
  135585. /**
  135586. * Gets the output component
  135587. */
  135588. get output(): NodeMaterialConnectionPoint;
  135589. /**
  135590. * Gets the isntanceID component
  135591. */
  135592. get instanceID(): NodeMaterialConnectionPoint;
  135593. autoConfigure(material: NodeMaterial): void;
  135594. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  135595. protected _buildBlock(state: NodeMaterialBuildState): this;
  135596. }
  135597. }
  135598. declare module BABYLON {
  135599. /**
  135600. * Block used to add morph targets support to vertex shader
  135601. */
  135602. export class MorphTargetsBlock extends NodeMaterialBlock {
  135603. private _repeatableContentAnchor;
  135604. /**
  135605. * Create a new MorphTargetsBlock
  135606. * @param name defines the block name
  135607. */
  135608. constructor(name: string);
  135609. /**
  135610. * Gets the current class name
  135611. * @returns the class name
  135612. */
  135613. getClassName(): string;
  135614. /**
  135615. * Gets the position input component
  135616. */
  135617. get position(): NodeMaterialConnectionPoint;
  135618. /**
  135619. * Gets the normal input component
  135620. */
  135621. get normal(): NodeMaterialConnectionPoint;
  135622. /**
  135623. * Gets the tangent input component
  135624. */
  135625. get tangent(): NodeMaterialConnectionPoint;
  135626. /**
  135627. * Gets the tangent input component
  135628. */
  135629. get uv(): NodeMaterialConnectionPoint;
  135630. /**
  135631. * Gets the position output component
  135632. */
  135633. get positionOutput(): NodeMaterialConnectionPoint;
  135634. /**
  135635. * Gets the normal output component
  135636. */
  135637. get normalOutput(): NodeMaterialConnectionPoint;
  135638. /**
  135639. * Gets the tangent output component
  135640. */
  135641. get tangentOutput(): NodeMaterialConnectionPoint;
  135642. /**
  135643. * Gets the tangent output component
  135644. */
  135645. get uvOutput(): NodeMaterialConnectionPoint;
  135646. initialize(state: NodeMaterialBuildState): void;
  135647. autoConfigure(material: NodeMaterial): void;
  135648. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  135649. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  135650. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  135651. protected _buildBlock(state: NodeMaterialBuildState): this;
  135652. }
  135653. }
  135654. declare module BABYLON {
  135655. /**
  135656. * Block used to get data information from a light
  135657. */
  135658. export class LightInformationBlock extends NodeMaterialBlock {
  135659. private _lightDataUniformName;
  135660. private _lightColorUniformName;
  135661. private _lightTypeDefineName;
  135662. /**
  135663. * Gets or sets the light associated with this block
  135664. */
  135665. light: Nullable<Light>;
  135666. /**
  135667. * Creates a new LightInformationBlock
  135668. * @param name defines the block name
  135669. */
  135670. constructor(name: string);
  135671. /**
  135672. * Gets the current class name
  135673. * @returns the class name
  135674. */
  135675. getClassName(): string;
  135676. /**
  135677. * Gets the world position input component
  135678. */
  135679. get worldPosition(): NodeMaterialConnectionPoint;
  135680. /**
  135681. * Gets the direction output component
  135682. */
  135683. get direction(): NodeMaterialConnectionPoint;
  135684. /**
  135685. * Gets the direction output component
  135686. */
  135687. get color(): NodeMaterialConnectionPoint;
  135688. /**
  135689. * Gets the direction output component
  135690. */
  135691. get intensity(): NodeMaterialConnectionPoint;
  135692. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  135693. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  135694. protected _buildBlock(state: NodeMaterialBuildState): this;
  135695. serialize(): any;
  135696. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  135697. }
  135698. }
  135699. declare module BABYLON {
  135700. /**
  135701. * Block used to add image processing support to fragment shader
  135702. */
  135703. export class ImageProcessingBlock extends NodeMaterialBlock {
  135704. /**
  135705. * Create a new ImageProcessingBlock
  135706. * @param name defines the block name
  135707. */
  135708. constructor(name: string);
  135709. /**
  135710. * Gets the current class name
  135711. * @returns the class name
  135712. */
  135713. getClassName(): string;
  135714. /**
  135715. * Gets the color input component
  135716. */
  135717. get color(): NodeMaterialConnectionPoint;
  135718. /**
  135719. * Gets the output component
  135720. */
  135721. get output(): NodeMaterialConnectionPoint;
  135722. /**
  135723. * Initialize the block and prepare the context for build
  135724. * @param state defines the state that will be used for the build
  135725. */
  135726. initialize(state: NodeMaterialBuildState): void;
  135727. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  135728. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  135729. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  135730. protected _buildBlock(state: NodeMaterialBuildState): this;
  135731. }
  135732. }
  135733. declare module BABYLON {
  135734. /**
  135735. * Block used to pertub normals based on a normal map
  135736. */
  135737. export class PerturbNormalBlock extends NodeMaterialBlock {
  135738. private _tangentSpaceParameterName;
  135739. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  135740. invertX: boolean;
  135741. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  135742. invertY: boolean;
  135743. /**
  135744. * Create a new PerturbNormalBlock
  135745. * @param name defines the block name
  135746. */
  135747. constructor(name: string);
  135748. /**
  135749. * Gets the current class name
  135750. * @returns the class name
  135751. */
  135752. getClassName(): string;
  135753. /**
  135754. * Gets the world position input component
  135755. */
  135756. get worldPosition(): NodeMaterialConnectionPoint;
  135757. /**
  135758. * Gets the world normal input component
  135759. */
  135760. get worldNormal(): NodeMaterialConnectionPoint;
  135761. /**
  135762. * Gets the world tangent input component
  135763. */
  135764. get worldTangent(): NodeMaterialConnectionPoint;
  135765. /**
  135766. * Gets the uv input component
  135767. */
  135768. get uv(): NodeMaterialConnectionPoint;
  135769. /**
  135770. * Gets the normal map color input component
  135771. */
  135772. get normalMapColor(): NodeMaterialConnectionPoint;
  135773. /**
  135774. * Gets the strength input component
  135775. */
  135776. get strength(): NodeMaterialConnectionPoint;
  135777. /**
  135778. * Gets the output component
  135779. */
  135780. get output(): NodeMaterialConnectionPoint;
  135781. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  135782. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  135783. autoConfigure(material: NodeMaterial): void;
  135784. protected _buildBlock(state: NodeMaterialBuildState): this;
  135785. protected _dumpPropertiesCode(): string;
  135786. serialize(): any;
  135787. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  135788. }
  135789. }
  135790. declare module BABYLON {
  135791. /**
  135792. * Block used to discard a pixel if a value is smaller than a cutoff
  135793. */
  135794. export class DiscardBlock extends NodeMaterialBlock {
  135795. /**
  135796. * Create a new DiscardBlock
  135797. * @param name defines the block name
  135798. */
  135799. constructor(name: string);
  135800. /**
  135801. * Gets the current class name
  135802. * @returns the class name
  135803. */
  135804. getClassName(): string;
  135805. /**
  135806. * Gets the color input component
  135807. */
  135808. get value(): NodeMaterialConnectionPoint;
  135809. /**
  135810. * Gets the cutoff input component
  135811. */
  135812. get cutoff(): NodeMaterialConnectionPoint;
  135813. protected _buildBlock(state: NodeMaterialBuildState): this;
  135814. }
  135815. }
  135816. declare module BABYLON {
  135817. /**
  135818. * Block used to test if the fragment shader is front facing
  135819. */
  135820. export class FrontFacingBlock extends NodeMaterialBlock {
  135821. /**
  135822. * Creates a new FrontFacingBlock
  135823. * @param name defines the block name
  135824. */
  135825. constructor(name: string);
  135826. /**
  135827. * Gets the current class name
  135828. * @returns the class name
  135829. */
  135830. getClassName(): string;
  135831. /**
  135832. * Gets the output component
  135833. */
  135834. get output(): NodeMaterialConnectionPoint;
  135835. protected _buildBlock(state: NodeMaterialBuildState): this;
  135836. }
  135837. }
  135838. declare module BABYLON {
  135839. /**
  135840. * Block used to get the derivative value on x and y of a given input
  135841. */
  135842. export class DerivativeBlock extends NodeMaterialBlock {
  135843. /**
  135844. * Create a new DerivativeBlock
  135845. * @param name defines the block name
  135846. */
  135847. constructor(name: string);
  135848. /**
  135849. * Gets the current class name
  135850. * @returns the class name
  135851. */
  135852. getClassName(): string;
  135853. /**
  135854. * Gets the input component
  135855. */
  135856. get input(): NodeMaterialConnectionPoint;
  135857. /**
  135858. * Gets the derivative output on x
  135859. */
  135860. get dx(): NodeMaterialConnectionPoint;
  135861. /**
  135862. * Gets the derivative output on y
  135863. */
  135864. get dy(): NodeMaterialConnectionPoint;
  135865. protected _buildBlock(state: NodeMaterialBuildState): this;
  135866. }
  135867. }
  135868. declare module BABYLON {
  135869. /**
  135870. * Block used to add support for scene fog
  135871. */
  135872. export class FogBlock extends NodeMaterialBlock {
  135873. private _fogDistanceName;
  135874. private _fogParameters;
  135875. /**
  135876. * Create a new FogBlock
  135877. * @param name defines the block name
  135878. */
  135879. constructor(name: string);
  135880. /**
  135881. * Gets the current class name
  135882. * @returns the class name
  135883. */
  135884. getClassName(): string;
  135885. /**
  135886. * Gets the world position input component
  135887. */
  135888. get worldPosition(): NodeMaterialConnectionPoint;
  135889. /**
  135890. * Gets the view input component
  135891. */
  135892. get view(): NodeMaterialConnectionPoint;
  135893. /**
  135894. * Gets the color input component
  135895. */
  135896. get input(): NodeMaterialConnectionPoint;
  135897. /**
  135898. * Gets the fog color input component
  135899. */
  135900. get fogColor(): NodeMaterialConnectionPoint;
  135901. /**
  135902. * Gets the output component
  135903. */
  135904. get output(): NodeMaterialConnectionPoint;
  135905. autoConfigure(material: NodeMaterial): void;
  135906. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  135907. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  135908. protected _buildBlock(state: NodeMaterialBuildState): this;
  135909. }
  135910. }
  135911. declare module BABYLON {
  135912. /**
  135913. * Block used to add light in the fragment shader
  135914. */
  135915. export class LightBlock extends NodeMaterialBlock {
  135916. private _lightId;
  135917. /**
  135918. * Gets or sets the light associated with this block
  135919. */
  135920. light: Nullable<Light>;
  135921. /**
  135922. * Create a new LightBlock
  135923. * @param name defines the block name
  135924. */
  135925. constructor(name: string);
  135926. /**
  135927. * Gets the current class name
  135928. * @returns the class name
  135929. */
  135930. getClassName(): string;
  135931. /**
  135932. * Gets the world position input component
  135933. */
  135934. get worldPosition(): NodeMaterialConnectionPoint;
  135935. /**
  135936. * Gets the world normal input component
  135937. */
  135938. get worldNormal(): NodeMaterialConnectionPoint;
  135939. /**
  135940. * Gets the camera (or eye) position component
  135941. */
  135942. get cameraPosition(): NodeMaterialConnectionPoint;
  135943. /**
  135944. * Gets the glossiness component
  135945. */
  135946. get glossiness(): NodeMaterialConnectionPoint;
  135947. /**
  135948. * Gets the glossinness power component
  135949. */
  135950. get glossPower(): NodeMaterialConnectionPoint;
  135951. /**
  135952. * Gets the diffuse color component
  135953. */
  135954. get diffuseColor(): NodeMaterialConnectionPoint;
  135955. /**
  135956. * Gets the specular color component
  135957. */
  135958. get specularColor(): NodeMaterialConnectionPoint;
  135959. /**
  135960. * Gets the diffuse output component
  135961. */
  135962. get diffuseOutput(): NodeMaterialConnectionPoint;
  135963. /**
  135964. * Gets the specular output component
  135965. */
  135966. get specularOutput(): NodeMaterialConnectionPoint;
  135967. /**
  135968. * Gets the shadow output component
  135969. */
  135970. get shadow(): NodeMaterialConnectionPoint;
  135971. autoConfigure(material: NodeMaterial): void;
  135972. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  135973. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  135974. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  135975. private _injectVertexCode;
  135976. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  135977. serialize(): any;
  135978. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  135979. }
  135980. }
  135981. declare module BABYLON {
  135982. /**
  135983. * Block used to read a reflection texture from a sampler
  135984. */
  135985. export class ReflectionTextureBlock extends ReflectionTextureBaseBlock {
  135986. /**
  135987. * Create a new ReflectionTextureBlock
  135988. * @param name defines the block name
  135989. */
  135990. constructor(name: string);
  135991. /**
  135992. * Gets the current class name
  135993. * @returns the class name
  135994. */
  135995. getClassName(): string;
  135996. /**
  135997. * Gets the world position input component
  135998. */
  135999. get position(): NodeMaterialConnectionPoint;
  136000. /**
  136001. * Gets the world position input component
  136002. */
  136003. get worldPosition(): NodeMaterialConnectionPoint;
  136004. /**
  136005. * Gets the world normal input component
  136006. */
  136007. get worldNormal(): NodeMaterialConnectionPoint;
  136008. /**
  136009. * Gets the world input component
  136010. */
  136011. get world(): NodeMaterialConnectionPoint;
  136012. /**
  136013. * Gets the camera (or eye) position component
  136014. */
  136015. get cameraPosition(): NodeMaterialConnectionPoint;
  136016. /**
  136017. * Gets the view input component
  136018. */
  136019. get view(): NodeMaterialConnectionPoint;
  136020. /**
  136021. * Gets the rgb output component
  136022. */
  136023. get rgb(): NodeMaterialConnectionPoint;
  136024. /**
  136025. * Gets the r output component
  136026. */
  136027. get r(): NodeMaterialConnectionPoint;
  136028. /**
  136029. * Gets the g output component
  136030. */
  136031. get g(): NodeMaterialConnectionPoint;
  136032. /**
  136033. * Gets the b output component
  136034. */
  136035. get b(): NodeMaterialConnectionPoint;
  136036. autoConfigure(material: NodeMaterial): void;
  136037. protected _buildBlock(state: NodeMaterialBuildState): this;
  136038. }
  136039. }
  136040. declare module BABYLON {
  136041. /**
  136042. * Block used to add 2 vectors
  136043. */
  136044. export class AddBlock extends NodeMaterialBlock {
  136045. /**
  136046. * Creates a new AddBlock
  136047. * @param name defines the block name
  136048. */
  136049. constructor(name: string);
  136050. /**
  136051. * Gets the current class name
  136052. * @returns the class name
  136053. */
  136054. getClassName(): string;
  136055. /**
  136056. * Gets the left operand input component
  136057. */
  136058. get left(): NodeMaterialConnectionPoint;
  136059. /**
  136060. * Gets the right operand input component
  136061. */
  136062. get right(): NodeMaterialConnectionPoint;
  136063. /**
  136064. * Gets the output component
  136065. */
  136066. get output(): NodeMaterialConnectionPoint;
  136067. protected _buildBlock(state: NodeMaterialBuildState): this;
  136068. }
  136069. }
  136070. declare module BABYLON {
  136071. /**
  136072. * Block used to scale a vector by a float
  136073. */
  136074. export class ScaleBlock extends NodeMaterialBlock {
  136075. /**
  136076. * Creates a new ScaleBlock
  136077. * @param name defines the block name
  136078. */
  136079. constructor(name: string);
  136080. /**
  136081. * Gets the current class name
  136082. * @returns the class name
  136083. */
  136084. getClassName(): string;
  136085. /**
  136086. * Gets the input component
  136087. */
  136088. get input(): NodeMaterialConnectionPoint;
  136089. /**
  136090. * Gets the factor input component
  136091. */
  136092. get factor(): NodeMaterialConnectionPoint;
  136093. /**
  136094. * Gets the output component
  136095. */
  136096. get output(): NodeMaterialConnectionPoint;
  136097. protected _buildBlock(state: NodeMaterialBuildState): this;
  136098. }
  136099. }
  136100. declare module BABYLON {
  136101. /**
  136102. * Block used to clamp a float
  136103. */
  136104. export class ClampBlock extends NodeMaterialBlock {
  136105. /** Gets or sets the minimum range */
  136106. minimum: number;
  136107. /** Gets or sets the maximum range */
  136108. maximum: number;
  136109. /**
  136110. * Creates a new ClampBlock
  136111. * @param name defines the block name
  136112. */
  136113. constructor(name: string);
  136114. /**
  136115. * Gets the current class name
  136116. * @returns the class name
  136117. */
  136118. getClassName(): string;
  136119. /**
  136120. * Gets the value input component
  136121. */
  136122. get value(): NodeMaterialConnectionPoint;
  136123. /**
  136124. * Gets the output component
  136125. */
  136126. get output(): NodeMaterialConnectionPoint;
  136127. protected _buildBlock(state: NodeMaterialBuildState): this;
  136128. protected _dumpPropertiesCode(): string;
  136129. serialize(): any;
  136130. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  136131. }
  136132. }
  136133. declare module BABYLON {
  136134. /**
  136135. * Block used to apply a cross product between 2 vectors
  136136. */
  136137. export class CrossBlock extends NodeMaterialBlock {
  136138. /**
  136139. * Creates a new CrossBlock
  136140. * @param name defines the block name
  136141. */
  136142. constructor(name: string);
  136143. /**
  136144. * Gets the current class name
  136145. * @returns the class name
  136146. */
  136147. getClassName(): string;
  136148. /**
  136149. * Gets the left operand input component
  136150. */
  136151. get left(): NodeMaterialConnectionPoint;
  136152. /**
  136153. * Gets the right operand input component
  136154. */
  136155. get right(): NodeMaterialConnectionPoint;
  136156. /**
  136157. * Gets the output component
  136158. */
  136159. get output(): NodeMaterialConnectionPoint;
  136160. protected _buildBlock(state: NodeMaterialBuildState): this;
  136161. }
  136162. }
  136163. declare module BABYLON {
  136164. /**
  136165. * Block used to apply a dot product between 2 vectors
  136166. */
  136167. export class DotBlock extends NodeMaterialBlock {
  136168. /**
  136169. * Creates a new DotBlock
  136170. * @param name defines the block name
  136171. */
  136172. constructor(name: string);
  136173. /**
  136174. * Gets the current class name
  136175. * @returns the class name
  136176. */
  136177. getClassName(): string;
  136178. /**
  136179. * Gets the left operand input component
  136180. */
  136181. get left(): NodeMaterialConnectionPoint;
  136182. /**
  136183. * Gets the right operand input component
  136184. */
  136185. get right(): NodeMaterialConnectionPoint;
  136186. /**
  136187. * Gets the output component
  136188. */
  136189. get output(): NodeMaterialConnectionPoint;
  136190. protected _buildBlock(state: NodeMaterialBuildState): this;
  136191. }
  136192. }
  136193. declare module BABYLON {
  136194. /**
  136195. * Block used to normalize a vector
  136196. */
  136197. export class NormalizeBlock extends NodeMaterialBlock {
  136198. /**
  136199. * Creates a new NormalizeBlock
  136200. * @param name defines the block name
  136201. */
  136202. constructor(name: string);
  136203. /**
  136204. * Gets the current class name
  136205. * @returns the class name
  136206. */
  136207. getClassName(): string;
  136208. /**
  136209. * Gets the input component
  136210. */
  136211. get input(): NodeMaterialConnectionPoint;
  136212. /**
  136213. * Gets the output component
  136214. */
  136215. get output(): NodeMaterialConnectionPoint;
  136216. protected _buildBlock(state: NodeMaterialBuildState): this;
  136217. }
  136218. }
  136219. declare module BABYLON {
  136220. /**
  136221. * Operations supported by the Trigonometry block
  136222. */
  136223. export enum TrigonometryBlockOperations {
  136224. /** Cos */
  136225. Cos = 0,
  136226. /** Sin */
  136227. Sin = 1,
  136228. /** Abs */
  136229. Abs = 2,
  136230. /** Exp */
  136231. Exp = 3,
  136232. /** Exp2 */
  136233. Exp2 = 4,
  136234. /** Round */
  136235. Round = 5,
  136236. /** Floor */
  136237. Floor = 6,
  136238. /** Ceiling */
  136239. Ceiling = 7,
  136240. /** Square root */
  136241. Sqrt = 8,
  136242. /** Log */
  136243. Log = 9,
  136244. /** Tangent */
  136245. Tan = 10,
  136246. /** Arc tangent */
  136247. ArcTan = 11,
  136248. /** Arc cosinus */
  136249. ArcCos = 12,
  136250. /** Arc sinus */
  136251. ArcSin = 13,
  136252. /** Fraction */
  136253. Fract = 14,
  136254. /** Sign */
  136255. Sign = 15,
  136256. /** To radians (from degrees) */
  136257. Radians = 16,
  136258. /** To degrees (from radians) */
  136259. Degrees = 17
  136260. }
  136261. /**
  136262. * Block used to apply trigonometry operation to floats
  136263. */
  136264. export class TrigonometryBlock extends NodeMaterialBlock {
  136265. /**
  136266. * Gets or sets the operation applied by the block
  136267. */
  136268. operation: TrigonometryBlockOperations;
  136269. /**
  136270. * Creates a new TrigonometryBlock
  136271. * @param name defines the block name
  136272. */
  136273. constructor(name: string);
  136274. /**
  136275. * Gets the current class name
  136276. * @returns the class name
  136277. */
  136278. getClassName(): string;
  136279. /**
  136280. * Gets the input component
  136281. */
  136282. get input(): NodeMaterialConnectionPoint;
  136283. /**
  136284. * Gets the output component
  136285. */
  136286. get output(): NodeMaterialConnectionPoint;
  136287. protected _buildBlock(state: NodeMaterialBuildState): this;
  136288. serialize(): any;
  136289. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  136290. protected _dumpPropertiesCode(): string;
  136291. }
  136292. }
  136293. declare module BABYLON {
  136294. /**
  136295. * Block used to create a Color3/4 out of individual inputs (one for each component)
  136296. */
  136297. export class ColorMergerBlock extends NodeMaterialBlock {
  136298. /**
  136299. * Create a new ColorMergerBlock
  136300. * @param name defines the block name
  136301. */
  136302. constructor(name: string);
  136303. /**
  136304. * Gets the current class name
  136305. * @returns the class name
  136306. */
  136307. getClassName(): string;
  136308. /**
  136309. * Gets the rgb component (input)
  136310. */
  136311. get rgbIn(): NodeMaterialConnectionPoint;
  136312. /**
  136313. * Gets the r component (input)
  136314. */
  136315. get r(): NodeMaterialConnectionPoint;
  136316. /**
  136317. * Gets the g component (input)
  136318. */
  136319. get g(): NodeMaterialConnectionPoint;
  136320. /**
  136321. * Gets the b component (input)
  136322. */
  136323. get b(): NodeMaterialConnectionPoint;
  136324. /**
  136325. * Gets the a component (input)
  136326. */
  136327. get a(): NodeMaterialConnectionPoint;
  136328. /**
  136329. * Gets the rgba component (output)
  136330. */
  136331. get rgba(): NodeMaterialConnectionPoint;
  136332. /**
  136333. * Gets the rgb component (output)
  136334. */
  136335. get rgbOut(): NodeMaterialConnectionPoint;
  136336. /**
  136337. * Gets the rgb component (output)
  136338. * @deprecated Please use rgbOut instead.
  136339. */
  136340. get rgb(): NodeMaterialConnectionPoint;
  136341. protected _buildBlock(state: NodeMaterialBuildState): this;
  136342. }
  136343. }
  136344. declare module BABYLON {
  136345. /**
  136346. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  136347. */
  136348. export class ColorSplitterBlock extends NodeMaterialBlock {
  136349. /**
  136350. * Create a new ColorSplitterBlock
  136351. * @param name defines the block name
  136352. */
  136353. constructor(name: string);
  136354. /**
  136355. * Gets the current class name
  136356. * @returns the class name
  136357. */
  136358. getClassName(): string;
  136359. /**
  136360. * Gets the rgba component (input)
  136361. */
  136362. get rgba(): NodeMaterialConnectionPoint;
  136363. /**
  136364. * Gets the rgb component (input)
  136365. */
  136366. get rgbIn(): NodeMaterialConnectionPoint;
  136367. /**
  136368. * Gets the rgb component (output)
  136369. */
  136370. get rgbOut(): NodeMaterialConnectionPoint;
  136371. /**
  136372. * Gets the r component (output)
  136373. */
  136374. get r(): NodeMaterialConnectionPoint;
  136375. /**
  136376. * Gets the g component (output)
  136377. */
  136378. get g(): NodeMaterialConnectionPoint;
  136379. /**
  136380. * Gets the b component (output)
  136381. */
  136382. get b(): NodeMaterialConnectionPoint;
  136383. /**
  136384. * Gets the a component (output)
  136385. */
  136386. get a(): NodeMaterialConnectionPoint;
  136387. protected _inputRename(name: string): string;
  136388. protected _outputRename(name: string): string;
  136389. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  136390. }
  136391. }
  136392. declare module BABYLON {
  136393. /**
  136394. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  136395. */
  136396. export class VectorSplitterBlock extends NodeMaterialBlock {
  136397. /**
  136398. * Create a new VectorSplitterBlock
  136399. * @param name defines the block name
  136400. */
  136401. constructor(name: string);
  136402. /**
  136403. * Gets the current class name
  136404. * @returns the class name
  136405. */
  136406. getClassName(): string;
  136407. /**
  136408. * Gets the xyzw component (input)
  136409. */
  136410. get xyzw(): NodeMaterialConnectionPoint;
  136411. /**
  136412. * Gets the xyz component (input)
  136413. */
  136414. get xyzIn(): NodeMaterialConnectionPoint;
  136415. /**
  136416. * Gets the xy component (input)
  136417. */
  136418. get xyIn(): NodeMaterialConnectionPoint;
  136419. /**
  136420. * Gets the xyz component (output)
  136421. */
  136422. get xyzOut(): NodeMaterialConnectionPoint;
  136423. /**
  136424. * Gets the xy component (output)
  136425. */
  136426. get xyOut(): NodeMaterialConnectionPoint;
  136427. /**
  136428. * Gets the x component (output)
  136429. */
  136430. get x(): NodeMaterialConnectionPoint;
  136431. /**
  136432. * Gets the y component (output)
  136433. */
  136434. get y(): NodeMaterialConnectionPoint;
  136435. /**
  136436. * Gets the z component (output)
  136437. */
  136438. get z(): NodeMaterialConnectionPoint;
  136439. /**
  136440. * Gets the w component (output)
  136441. */
  136442. get w(): NodeMaterialConnectionPoint;
  136443. protected _inputRename(name: string): string;
  136444. protected _outputRename(name: string): string;
  136445. protected _buildBlock(state: NodeMaterialBuildState): this;
  136446. }
  136447. }
  136448. declare module BABYLON {
  136449. /**
  136450. * Block used to lerp between 2 values
  136451. */
  136452. export class LerpBlock extends NodeMaterialBlock {
  136453. /**
  136454. * Creates a new LerpBlock
  136455. * @param name defines the block name
  136456. */
  136457. constructor(name: string);
  136458. /**
  136459. * Gets the current class name
  136460. * @returns the class name
  136461. */
  136462. getClassName(): string;
  136463. /**
  136464. * Gets the left operand input component
  136465. */
  136466. get left(): NodeMaterialConnectionPoint;
  136467. /**
  136468. * Gets the right operand input component
  136469. */
  136470. get right(): NodeMaterialConnectionPoint;
  136471. /**
  136472. * Gets the gradient operand input component
  136473. */
  136474. get gradient(): NodeMaterialConnectionPoint;
  136475. /**
  136476. * Gets the output component
  136477. */
  136478. get output(): NodeMaterialConnectionPoint;
  136479. protected _buildBlock(state: NodeMaterialBuildState): this;
  136480. }
  136481. }
  136482. declare module BABYLON {
  136483. /**
  136484. * Block used to divide 2 vectors
  136485. */
  136486. export class DivideBlock extends NodeMaterialBlock {
  136487. /**
  136488. * Creates a new DivideBlock
  136489. * @param name defines the block name
  136490. */
  136491. constructor(name: string);
  136492. /**
  136493. * Gets the current class name
  136494. * @returns the class name
  136495. */
  136496. getClassName(): string;
  136497. /**
  136498. * Gets the left operand input component
  136499. */
  136500. get left(): NodeMaterialConnectionPoint;
  136501. /**
  136502. * Gets the right operand input component
  136503. */
  136504. get right(): NodeMaterialConnectionPoint;
  136505. /**
  136506. * Gets the output component
  136507. */
  136508. get output(): NodeMaterialConnectionPoint;
  136509. protected _buildBlock(state: NodeMaterialBuildState): this;
  136510. }
  136511. }
  136512. declare module BABYLON {
  136513. /**
  136514. * Block used to subtract 2 vectors
  136515. */
  136516. export class SubtractBlock extends NodeMaterialBlock {
  136517. /**
  136518. * Creates a new SubtractBlock
  136519. * @param name defines the block name
  136520. */
  136521. constructor(name: string);
  136522. /**
  136523. * Gets the current class name
  136524. * @returns the class name
  136525. */
  136526. getClassName(): string;
  136527. /**
  136528. * Gets the left operand input component
  136529. */
  136530. get left(): NodeMaterialConnectionPoint;
  136531. /**
  136532. * Gets the right operand input component
  136533. */
  136534. get right(): NodeMaterialConnectionPoint;
  136535. /**
  136536. * Gets the output component
  136537. */
  136538. get output(): NodeMaterialConnectionPoint;
  136539. protected _buildBlock(state: NodeMaterialBuildState): this;
  136540. }
  136541. }
  136542. declare module BABYLON {
  136543. /**
  136544. * Block used to step a value
  136545. */
  136546. export class StepBlock extends NodeMaterialBlock {
  136547. /**
  136548. * Creates a new StepBlock
  136549. * @param name defines the block name
  136550. */
  136551. constructor(name: string);
  136552. /**
  136553. * Gets the current class name
  136554. * @returns the class name
  136555. */
  136556. getClassName(): string;
  136557. /**
  136558. * Gets the value operand input component
  136559. */
  136560. get value(): NodeMaterialConnectionPoint;
  136561. /**
  136562. * Gets the edge operand input component
  136563. */
  136564. get edge(): NodeMaterialConnectionPoint;
  136565. /**
  136566. * Gets the output component
  136567. */
  136568. get output(): NodeMaterialConnectionPoint;
  136569. protected _buildBlock(state: NodeMaterialBuildState): this;
  136570. }
  136571. }
  136572. declare module BABYLON {
  136573. /**
  136574. * Block used to get the opposite (1 - x) of a value
  136575. */
  136576. export class OneMinusBlock extends NodeMaterialBlock {
  136577. /**
  136578. * Creates a new OneMinusBlock
  136579. * @param name defines the block name
  136580. */
  136581. constructor(name: string);
  136582. /**
  136583. * Gets the current class name
  136584. * @returns the class name
  136585. */
  136586. getClassName(): string;
  136587. /**
  136588. * Gets the input component
  136589. */
  136590. get input(): NodeMaterialConnectionPoint;
  136591. /**
  136592. * Gets the output component
  136593. */
  136594. get output(): NodeMaterialConnectionPoint;
  136595. protected _buildBlock(state: NodeMaterialBuildState): this;
  136596. }
  136597. }
  136598. declare module BABYLON {
  136599. /**
  136600. * Block used to get the view direction
  136601. */
  136602. export class ViewDirectionBlock extends NodeMaterialBlock {
  136603. /**
  136604. * Creates a new ViewDirectionBlock
  136605. * @param name defines the block name
  136606. */
  136607. constructor(name: string);
  136608. /**
  136609. * Gets the current class name
  136610. * @returns the class name
  136611. */
  136612. getClassName(): string;
  136613. /**
  136614. * Gets the world position component
  136615. */
  136616. get worldPosition(): NodeMaterialConnectionPoint;
  136617. /**
  136618. * Gets the camera position component
  136619. */
  136620. get cameraPosition(): NodeMaterialConnectionPoint;
  136621. /**
  136622. * Gets the output component
  136623. */
  136624. get output(): NodeMaterialConnectionPoint;
  136625. autoConfigure(material: NodeMaterial): void;
  136626. protected _buildBlock(state: NodeMaterialBuildState): this;
  136627. }
  136628. }
  136629. declare module BABYLON {
  136630. /**
  136631. * Block used to compute fresnel value
  136632. */
  136633. export class FresnelBlock extends NodeMaterialBlock {
  136634. /**
  136635. * Create a new FresnelBlock
  136636. * @param name defines the block name
  136637. */
  136638. constructor(name: string);
  136639. /**
  136640. * Gets the current class name
  136641. * @returns the class name
  136642. */
  136643. getClassName(): string;
  136644. /**
  136645. * Gets the world normal input component
  136646. */
  136647. get worldNormal(): NodeMaterialConnectionPoint;
  136648. /**
  136649. * Gets the view direction input component
  136650. */
  136651. get viewDirection(): NodeMaterialConnectionPoint;
  136652. /**
  136653. * Gets the bias input component
  136654. */
  136655. get bias(): NodeMaterialConnectionPoint;
  136656. /**
  136657. * Gets the camera (or eye) position component
  136658. */
  136659. get power(): NodeMaterialConnectionPoint;
  136660. /**
  136661. * Gets the fresnel output component
  136662. */
  136663. get fresnel(): NodeMaterialConnectionPoint;
  136664. autoConfigure(material: NodeMaterial): void;
  136665. protected _buildBlock(state: NodeMaterialBuildState): this;
  136666. }
  136667. }
  136668. declare module BABYLON {
  136669. /**
  136670. * Block used to get the max of 2 values
  136671. */
  136672. export class MaxBlock extends NodeMaterialBlock {
  136673. /**
  136674. * Creates a new MaxBlock
  136675. * @param name defines the block name
  136676. */
  136677. constructor(name: string);
  136678. /**
  136679. * Gets the current class name
  136680. * @returns the class name
  136681. */
  136682. getClassName(): string;
  136683. /**
  136684. * Gets the left operand input component
  136685. */
  136686. get left(): NodeMaterialConnectionPoint;
  136687. /**
  136688. * Gets the right operand input component
  136689. */
  136690. get right(): NodeMaterialConnectionPoint;
  136691. /**
  136692. * Gets the output component
  136693. */
  136694. get output(): NodeMaterialConnectionPoint;
  136695. protected _buildBlock(state: NodeMaterialBuildState): this;
  136696. }
  136697. }
  136698. declare module BABYLON {
  136699. /**
  136700. * Block used to get the min of 2 values
  136701. */
  136702. export class MinBlock extends NodeMaterialBlock {
  136703. /**
  136704. * Creates a new MinBlock
  136705. * @param name defines the block name
  136706. */
  136707. constructor(name: string);
  136708. /**
  136709. * Gets the current class name
  136710. * @returns the class name
  136711. */
  136712. getClassName(): string;
  136713. /**
  136714. * Gets the left operand input component
  136715. */
  136716. get left(): NodeMaterialConnectionPoint;
  136717. /**
  136718. * Gets the right operand input component
  136719. */
  136720. get right(): NodeMaterialConnectionPoint;
  136721. /**
  136722. * Gets the output component
  136723. */
  136724. get output(): NodeMaterialConnectionPoint;
  136725. protected _buildBlock(state: NodeMaterialBuildState): this;
  136726. }
  136727. }
  136728. declare module BABYLON {
  136729. /**
  136730. * Block used to get the distance between 2 values
  136731. */
  136732. export class DistanceBlock extends NodeMaterialBlock {
  136733. /**
  136734. * Creates a new DistanceBlock
  136735. * @param name defines the block name
  136736. */
  136737. constructor(name: string);
  136738. /**
  136739. * Gets the current class name
  136740. * @returns the class name
  136741. */
  136742. getClassName(): string;
  136743. /**
  136744. * Gets the left operand input component
  136745. */
  136746. get left(): NodeMaterialConnectionPoint;
  136747. /**
  136748. * Gets the right operand input component
  136749. */
  136750. get right(): NodeMaterialConnectionPoint;
  136751. /**
  136752. * Gets the output component
  136753. */
  136754. get output(): NodeMaterialConnectionPoint;
  136755. protected _buildBlock(state: NodeMaterialBuildState): this;
  136756. }
  136757. }
  136758. declare module BABYLON {
  136759. /**
  136760. * Block used to get the length of a vector
  136761. */
  136762. export class LengthBlock extends NodeMaterialBlock {
  136763. /**
  136764. * Creates a new LengthBlock
  136765. * @param name defines the block name
  136766. */
  136767. constructor(name: string);
  136768. /**
  136769. * Gets the current class name
  136770. * @returns the class name
  136771. */
  136772. getClassName(): string;
  136773. /**
  136774. * Gets the value input component
  136775. */
  136776. get value(): NodeMaterialConnectionPoint;
  136777. /**
  136778. * Gets the output component
  136779. */
  136780. get output(): NodeMaterialConnectionPoint;
  136781. protected _buildBlock(state: NodeMaterialBuildState): this;
  136782. }
  136783. }
  136784. declare module BABYLON {
  136785. /**
  136786. * Block used to get negative version of a value (i.e. x * -1)
  136787. */
  136788. export class NegateBlock extends NodeMaterialBlock {
  136789. /**
  136790. * Creates a new NegateBlock
  136791. * @param name defines the block name
  136792. */
  136793. constructor(name: string);
  136794. /**
  136795. * Gets the current class name
  136796. * @returns the class name
  136797. */
  136798. getClassName(): string;
  136799. /**
  136800. * Gets the value input component
  136801. */
  136802. get value(): NodeMaterialConnectionPoint;
  136803. /**
  136804. * Gets the output component
  136805. */
  136806. get output(): NodeMaterialConnectionPoint;
  136807. protected _buildBlock(state: NodeMaterialBuildState): this;
  136808. }
  136809. }
  136810. declare module BABYLON {
  136811. /**
  136812. * Block used to get the value of the first parameter raised to the power of the second
  136813. */
  136814. export class PowBlock extends NodeMaterialBlock {
  136815. /**
  136816. * Creates a new PowBlock
  136817. * @param name defines the block name
  136818. */
  136819. constructor(name: string);
  136820. /**
  136821. * Gets the current class name
  136822. * @returns the class name
  136823. */
  136824. getClassName(): string;
  136825. /**
  136826. * Gets the value operand input component
  136827. */
  136828. get value(): NodeMaterialConnectionPoint;
  136829. /**
  136830. * Gets the power operand input component
  136831. */
  136832. get power(): NodeMaterialConnectionPoint;
  136833. /**
  136834. * Gets the output component
  136835. */
  136836. get output(): NodeMaterialConnectionPoint;
  136837. protected _buildBlock(state: NodeMaterialBuildState): this;
  136838. }
  136839. }
  136840. declare module BABYLON {
  136841. /**
  136842. * Block used to get a random number
  136843. */
  136844. export class RandomNumberBlock extends NodeMaterialBlock {
  136845. /**
  136846. * Creates a new RandomNumberBlock
  136847. * @param name defines the block name
  136848. */
  136849. constructor(name: string);
  136850. /**
  136851. * Gets the current class name
  136852. * @returns the class name
  136853. */
  136854. getClassName(): string;
  136855. /**
  136856. * Gets the seed input component
  136857. */
  136858. get seed(): NodeMaterialConnectionPoint;
  136859. /**
  136860. * Gets the output component
  136861. */
  136862. get output(): NodeMaterialConnectionPoint;
  136863. protected _buildBlock(state: NodeMaterialBuildState): this;
  136864. }
  136865. }
  136866. declare module BABYLON {
  136867. /**
  136868. * Block used to compute arc tangent of 2 values
  136869. */
  136870. export class ArcTan2Block extends NodeMaterialBlock {
  136871. /**
  136872. * Creates a new ArcTan2Block
  136873. * @param name defines the block name
  136874. */
  136875. constructor(name: string);
  136876. /**
  136877. * Gets the current class name
  136878. * @returns the class name
  136879. */
  136880. getClassName(): string;
  136881. /**
  136882. * Gets the x operand input component
  136883. */
  136884. get x(): NodeMaterialConnectionPoint;
  136885. /**
  136886. * Gets the y operand input component
  136887. */
  136888. get y(): NodeMaterialConnectionPoint;
  136889. /**
  136890. * Gets the output component
  136891. */
  136892. get output(): NodeMaterialConnectionPoint;
  136893. protected _buildBlock(state: NodeMaterialBuildState): this;
  136894. }
  136895. }
  136896. declare module BABYLON {
  136897. /**
  136898. * Block used to smooth step a value
  136899. */
  136900. export class SmoothStepBlock extends NodeMaterialBlock {
  136901. /**
  136902. * Creates a new SmoothStepBlock
  136903. * @param name defines the block name
  136904. */
  136905. constructor(name: string);
  136906. /**
  136907. * Gets the current class name
  136908. * @returns the class name
  136909. */
  136910. getClassName(): string;
  136911. /**
  136912. * Gets the value operand input component
  136913. */
  136914. get value(): NodeMaterialConnectionPoint;
  136915. /**
  136916. * Gets the first edge operand input component
  136917. */
  136918. get edge0(): NodeMaterialConnectionPoint;
  136919. /**
  136920. * Gets the second edge operand input component
  136921. */
  136922. get edge1(): NodeMaterialConnectionPoint;
  136923. /**
  136924. * Gets the output component
  136925. */
  136926. get output(): NodeMaterialConnectionPoint;
  136927. protected _buildBlock(state: NodeMaterialBuildState): this;
  136928. }
  136929. }
  136930. declare module BABYLON {
  136931. /**
  136932. * Block used to get the reciprocal (1 / x) of a value
  136933. */
  136934. export class ReciprocalBlock extends NodeMaterialBlock {
  136935. /**
  136936. * Creates a new ReciprocalBlock
  136937. * @param name defines the block name
  136938. */
  136939. constructor(name: string);
  136940. /**
  136941. * Gets the current class name
  136942. * @returns the class name
  136943. */
  136944. getClassName(): string;
  136945. /**
  136946. * Gets the input component
  136947. */
  136948. get input(): NodeMaterialConnectionPoint;
  136949. /**
  136950. * Gets the output component
  136951. */
  136952. get output(): NodeMaterialConnectionPoint;
  136953. protected _buildBlock(state: NodeMaterialBuildState): this;
  136954. }
  136955. }
  136956. declare module BABYLON {
  136957. /**
  136958. * Block used to replace a color by another one
  136959. */
  136960. export class ReplaceColorBlock extends NodeMaterialBlock {
  136961. /**
  136962. * Creates a new ReplaceColorBlock
  136963. * @param name defines the block name
  136964. */
  136965. constructor(name: string);
  136966. /**
  136967. * Gets the current class name
  136968. * @returns the class name
  136969. */
  136970. getClassName(): string;
  136971. /**
  136972. * Gets the value input component
  136973. */
  136974. get value(): NodeMaterialConnectionPoint;
  136975. /**
  136976. * Gets the reference input component
  136977. */
  136978. get reference(): NodeMaterialConnectionPoint;
  136979. /**
  136980. * Gets the distance input component
  136981. */
  136982. get distance(): NodeMaterialConnectionPoint;
  136983. /**
  136984. * Gets the replacement input component
  136985. */
  136986. get replacement(): NodeMaterialConnectionPoint;
  136987. /**
  136988. * Gets the output component
  136989. */
  136990. get output(): NodeMaterialConnectionPoint;
  136991. protected _buildBlock(state: NodeMaterialBuildState): this;
  136992. }
  136993. }
  136994. declare module BABYLON {
  136995. /**
  136996. * Block used to posterize a value
  136997. * @see https://en.wikipedia.org/wiki/Posterization
  136998. */
  136999. export class PosterizeBlock extends NodeMaterialBlock {
  137000. /**
  137001. * Creates a new PosterizeBlock
  137002. * @param name defines the block name
  137003. */
  137004. constructor(name: string);
  137005. /**
  137006. * Gets the current class name
  137007. * @returns the class name
  137008. */
  137009. getClassName(): string;
  137010. /**
  137011. * Gets the value input component
  137012. */
  137013. get value(): NodeMaterialConnectionPoint;
  137014. /**
  137015. * Gets the steps input component
  137016. */
  137017. get steps(): NodeMaterialConnectionPoint;
  137018. /**
  137019. * Gets the output component
  137020. */
  137021. get output(): NodeMaterialConnectionPoint;
  137022. protected _buildBlock(state: NodeMaterialBuildState): this;
  137023. }
  137024. }
  137025. declare module BABYLON {
  137026. /**
  137027. * Operations supported by the Wave block
  137028. */
  137029. export enum WaveBlockKind {
  137030. /** SawTooth */
  137031. SawTooth = 0,
  137032. /** Square */
  137033. Square = 1,
  137034. /** Triangle */
  137035. Triangle = 2
  137036. }
  137037. /**
  137038. * Block used to apply wave operation to floats
  137039. */
  137040. export class WaveBlock extends NodeMaterialBlock {
  137041. /**
  137042. * Gets or sets the kibnd of wave to be applied by the block
  137043. */
  137044. kind: WaveBlockKind;
  137045. /**
  137046. * Creates a new WaveBlock
  137047. * @param name defines the block name
  137048. */
  137049. constructor(name: string);
  137050. /**
  137051. * Gets the current class name
  137052. * @returns the class name
  137053. */
  137054. getClassName(): string;
  137055. /**
  137056. * Gets the input component
  137057. */
  137058. get input(): NodeMaterialConnectionPoint;
  137059. /**
  137060. * Gets the output component
  137061. */
  137062. get output(): NodeMaterialConnectionPoint;
  137063. protected _buildBlock(state: NodeMaterialBuildState): this;
  137064. serialize(): any;
  137065. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  137066. }
  137067. }
  137068. declare module BABYLON {
  137069. /**
  137070. * Class used to store a color step for the GradientBlock
  137071. */
  137072. export class GradientBlockColorStep {
  137073. /**
  137074. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  137075. */
  137076. step: number;
  137077. /**
  137078. * Gets or sets the color associated with this step
  137079. */
  137080. color: Color3;
  137081. /**
  137082. * Creates a new GradientBlockColorStep
  137083. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  137084. * @param color defines the color associated with this step
  137085. */
  137086. constructor(
  137087. /**
  137088. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  137089. */
  137090. step: number,
  137091. /**
  137092. * Gets or sets the color associated with this step
  137093. */
  137094. color: Color3);
  137095. }
  137096. /**
  137097. * Block used to return a color from a gradient based on an input value between 0 and 1
  137098. */
  137099. export class GradientBlock extends NodeMaterialBlock {
  137100. /**
  137101. * Gets or sets the list of color steps
  137102. */
  137103. colorSteps: GradientBlockColorStep[];
  137104. /**
  137105. * Creates a new GradientBlock
  137106. * @param name defines the block name
  137107. */
  137108. constructor(name: string);
  137109. /**
  137110. * Gets the current class name
  137111. * @returns the class name
  137112. */
  137113. getClassName(): string;
  137114. /**
  137115. * Gets the gradient input component
  137116. */
  137117. get gradient(): NodeMaterialConnectionPoint;
  137118. /**
  137119. * Gets the output component
  137120. */
  137121. get output(): NodeMaterialConnectionPoint;
  137122. private _writeColorConstant;
  137123. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  137124. serialize(): any;
  137125. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  137126. protected _dumpPropertiesCode(): string;
  137127. }
  137128. }
  137129. declare module BABYLON {
  137130. /**
  137131. * Block used to normalize lerp between 2 values
  137132. */
  137133. export class NLerpBlock extends NodeMaterialBlock {
  137134. /**
  137135. * Creates a new NLerpBlock
  137136. * @param name defines the block name
  137137. */
  137138. constructor(name: string);
  137139. /**
  137140. * Gets the current class name
  137141. * @returns the class name
  137142. */
  137143. getClassName(): string;
  137144. /**
  137145. * Gets the left operand input component
  137146. */
  137147. get left(): NodeMaterialConnectionPoint;
  137148. /**
  137149. * Gets the right operand input component
  137150. */
  137151. get right(): NodeMaterialConnectionPoint;
  137152. /**
  137153. * Gets the gradient operand input component
  137154. */
  137155. get gradient(): NodeMaterialConnectionPoint;
  137156. /**
  137157. * Gets the output component
  137158. */
  137159. get output(): NodeMaterialConnectionPoint;
  137160. protected _buildBlock(state: NodeMaterialBuildState): this;
  137161. }
  137162. }
  137163. declare module BABYLON {
  137164. /**
  137165. * block used to Generate a Worley Noise 3D Noise Pattern
  137166. */
  137167. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  137168. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  137169. manhattanDistance: boolean;
  137170. /**
  137171. * Creates a new WorleyNoise3DBlock
  137172. * @param name defines the block name
  137173. */
  137174. constructor(name: string);
  137175. /**
  137176. * Gets the current class name
  137177. * @returns the class name
  137178. */
  137179. getClassName(): string;
  137180. /**
  137181. * Gets the seed input component
  137182. */
  137183. get seed(): NodeMaterialConnectionPoint;
  137184. /**
  137185. * Gets the jitter input component
  137186. */
  137187. get jitter(): NodeMaterialConnectionPoint;
  137188. /**
  137189. * Gets the output component
  137190. */
  137191. get output(): NodeMaterialConnectionPoint;
  137192. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  137193. /**
  137194. * Exposes the properties to the UI?
  137195. */
  137196. protected _dumpPropertiesCode(): string;
  137197. /**
  137198. * Exposes the properties to the Seralize?
  137199. */
  137200. serialize(): any;
  137201. /**
  137202. * Exposes the properties to the deseralize?
  137203. */
  137204. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  137205. }
  137206. }
  137207. declare module BABYLON {
  137208. /**
  137209. * block used to Generate a Simplex Perlin 3d Noise Pattern
  137210. */
  137211. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  137212. /**
  137213. * Creates a new SimplexPerlin3DBlock
  137214. * @param name defines the block name
  137215. */
  137216. constructor(name: string);
  137217. /**
  137218. * Gets the current class name
  137219. * @returns the class name
  137220. */
  137221. getClassName(): string;
  137222. /**
  137223. * Gets the seed operand input component
  137224. */
  137225. get seed(): NodeMaterialConnectionPoint;
  137226. /**
  137227. * Gets the output component
  137228. */
  137229. get output(): NodeMaterialConnectionPoint;
  137230. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  137231. }
  137232. }
  137233. declare module BABYLON {
  137234. /**
  137235. * Block used to blend normals
  137236. */
  137237. export class NormalBlendBlock extends NodeMaterialBlock {
  137238. /**
  137239. * Creates a new NormalBlendBlock
  137240. * @param name defines the block name
  137241. */
  137242. constructor(name: string);
  137243. /**
  137244. * Gets the current class name
  137245. * @returns the class name
  137246. */
  137247. getClassName(): string;
  137248. /**
  137249. * Gets the first input component
  137250. */
  137251. get normalMap0(): NodeMaterialConnectionPoint;
  137252. /**
  137253. * Gets the second input component
  137254. */
  137255. get normalMap1(): NodeMaterialConnectionPoint;
  137256. /**
  137257. * Gets the output component
  137258. */
  137259. get output(): NodeMaterialConnectionPoint;
  137260. protected _buildBlock(state: NodeMaterialBuildState): this;
  137261. }
  137262. }
  137263. declare module BABYLON {
  137264. /**
  137265. * Block used to rotate a 2d vector by a given angle
  137266. */
  137267. export class Rotate2dBlock extends NodeMaterialBlock {
  137268. /**
  137269. * Creates a new Rotate2dBlock
  137270. * @param name defines the block name
  137271. */
  137272. constructor(name: string);
  137273. /**
  137274. * Gets the current class name
  137275. * @returns the class name
  137276. */
  137277. getClassName(): string;
  137278. /**
  137279. * Gets the input vector
  137280. */
  137281. get input(): NodeMaterialConnectionPoint;
  137282. /**
  137283. * Gets the input angle
  137284. */
  137285. get angle(): NodeMaterialConnectionPoint;
  137286. /**
  137287. * Gets the output component
  137288. */
  137289. get output(): NodeMaterialConnectionPoint;
  137290. autoConfigure(material: NodeMaterial): void;
  137291. protected _buildBlock(state: NodeMaterialBuildState): this;
  137292. }
  137293. }
  137294. declare module BABYLON {
  137295. /**
  137296. * Block used to get the reflected vector from a direction and a normal
  137297. */
  137298. export class ReflectBlock extends NodeMaterialBlock {
  137299. /**
  137300. * Creates a new ReflectBlock
  137301. * @param name defines the block name
  137302. */
  137303. constructor(name: string);
  137304. /**
  137305. * Gets the current class name
  137306. * @returns the class name
  137307. */
  137308. getClassName(): string;
  137309. /**
  137310. * Gets the incident component
  137311. */
  137312. get incident(): NodeMaterialConnectionPoint;
  137313. /**
  137314. * Gets the normal component
  137315. */
  137316. get normal(): NodeMaterialConnectionPoint;
  137317. /**
  137318. * Gets the output component
  137319. */
  137320. get output(): NodeMaterialConnectionPoint;
  137321. protected _buildBlock(state: NodeMaterialBuildState): this;
  137322. }
  137323. }
  137324. declare module BABYLON {
  137325. /**
  137326. * Block used to get the refracted vector from a direction and a normal
  137327. */
  137328. export class RefractBlock extends NodeMaterialBlock {
  137329. /**
  137330. * Creates a new RefractBlock
  137331. * @param name defines the block name
  137332. */
  137333. constructor(name: string);
  137334. /**
  137335. * Gets the current class name
  137336. * @returns the class name
  137337. */
  137338. getClassName(): string;
  137339. /**
  137340. * Gets the incident component
  137341. */
  137342. get incident(): NodeMaterialConnectionPoint;
  137343. /**
  137344. * Gets the normal component
  137345. */
  137346. get normal(): NodeMaterialConnectionPoint;
  137347. /**
  137348. * Gets the index of refraction component
  137349. */
  137350. get ior(): NodeMaterialConnectionPoint;
  137351. /**
  137352. * Gets the output component
  137353. */
  137354. get output(): NodeMaterialConnectionPoint;
  137355. protected _buildBlock(state: NodeMaterialBuildState): this;
  137356. }
  137357. }
  137358. declare module BABYLON {
  137359. /**
  137360. * Block used to desaturate a color
  137361. */
  137362. export class DesaturateBlock extends NodeMaterialBlock {
  137363. /**
  137364. * Creates a new DesaturateBlock
  137365. * @param name defines the block name
  137366. */
  137367. constructor(name: string);
  137368. /**
  137369. * Gets the current class name
  137370. * @returns the class name
  137371. */
  137372. getClassName(): string;
  137373. /**
  137374. * Gets the color operand input component
  137375. */
  137376. get color(): NodeMaterialConnectionPoint;
  137377. /**
  137378. * Gets the level operand input component
  137379. */
  137380. get level(): NodeMaterialConnectionPoint;
  137381. /**
  137382. * Gets the output component
  137383. */
  137384. get output(): NodeMaterialConnectionPoint;
  137385. protected _buildBlock(state: NodeMaterialBuildState): this;
  137386. }
  137387. }
  137388. declare module BABYLON {
  137389. /**
  137390. * Block used to implement the ambient occlusion module of the PBR material
  137391. */
  137392. export class AmbientOcclusionBlock extends NodeMaterialBlock {
  137393. /**
  137394. * Create a new AmbientOcclusionBlock
  137395. * @param name defines the block name
  137396. */
  137397. constructor(name: string);
  137398. /**
  137399. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  137400. */
  137401. useAmbientInGrayScale: boolean;
  137402. /**
  137403. * Initialize the block and prepare the context for build
  137404. * @param state defines the state that will be used for the build
  137405. */
  137406. initialize(state: NodeMaterialBuildState): void;
  137407. /**
  137408. * Gets the current class name
  137409. * @returns the class name
  137410. */
  137411. getClassName(): string;
  137412. /**
  137413. * Gets the texture input component
  137414. */
  137415. get texture(): NodeMaterialConnectionPoint;
  137416. /**
  137417. * Gets the texture intensity component
  137418. */
  137419. get intensity(): NodeMaterialConnectionPoint;
  137420. /**
  137421. * Gets the direct light intensity input component
  137422. */
  137423. get directLightIntensity(): NodeMaterialConnectionPoint;
  137424. /**
  137425. * Gets the ambient occlusion object output component
  137426. */
  137427. get ambientOcclusion(): NodeMaterialConnectionPoint;
  137428. /**
  137429. * Gets the main code of the block (fragment side)
  137430. * @param block instance of an AmbientOcclusionBlock or null if the code must be generated without an active ambient occlusion module
  137431. * @returns the shader code
  137432. */
  137433. static GetCode(block: Nullable<AmbientOcclusionBlock>): string;
  137434. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  137435. protected _buildBlock(state: NodeMaterialBuildState): this;
  137436. protected _dumpPropertiesCode(): string;
  137437. serialize(): any;
  137438. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  137439. }
  137440. }
  137441. declare module BABYLON {
  137442. /**
  137443. * Block used to implement the reflection module of the PBR material
  137444. */
  137445. export class ReflectionBlock extends ReflectionTextureBaseBlock {
  137446. /** @hidden */
  137447. _defineLODReflectionAlpha: string;
  137448. /** @hidden */
  137449. _defineLinearSpecularReflection: string;
  137450. private _vEnvironmentIrradianceName;
  137451. /** @hidden */
  137452. _vReflectionMicrosurfaceInfosName: string;
  137453. /** @hidden */
  137454. _vReflectionInfosName: string;
  137455. private _scene;
  137456. /**
  137457. * The three properties below are set by the main PBR block prior to calling methods of this class.
  137458. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  137459. * It's less burden on the user side in the editor part.
  137460. */
  137461. /** @hidden */
  137462. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  137463. /** @hidden */
  137464. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  137465. /** @hidden */
  137466. cameraPositionConnectionPoint: NodeMaterialConnectionPoint;
  137467. /**
  137468. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  137469. * diffuse part of the IBL.
  137470. */
  137471. useSphericalHarmonics: boolean;
  137472. /**
  137473. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  137474. */
  137475. forceIrradianceInFragment: boolean;
  137476. /**
  137477. * Create a new ReflectionBlock
  137478. * @param name defines the block name
  137479. */
  137480. constructor(name: string);
  137481. /**
  137482. * Gets the current class name
  137483. * @returns the class name
  137484. */
  137485. getClassName(): string;
  137486. /**
  137487. * Gets the position input component
  137488. */
  137489. get position(): NodeMaterialConnectionPoint;
  137490. /**
  137491. * Gets the world position input component
  137492. */
  137493. get worldPosition(): NodeMaterialConnectionPoint;
  137494. /**
  137495. * Gets the world normal input component
  137496. */
  137497. get worldNormal(): NodeMaterialConnectionPoint;
  137498. /**
  137499. * Gets the world input component
  137500. */
  137501. get world(): NodeMaterialConnectionPoint;
  137502. /**
  137503. * Gets the camera (or eye) position component
  137504. */
  137505. get cameraPosition(): NodeMaterialConnectionPoint;
  137506. /**
  137507. * Gets the view input component
  137508. */
  137509. get view(): NodeMaterialConnectionPoint;
  137510. /**
  137511. * Gets the color input component
  137512. */
  137513. get color(): NodeMaterialConnectionPoint;
  137514. /**
  137515. * Gets the reflection object output component
  137516. */
  137517. get reflection(): NodeMaterialConnectionPoint;
  137518. /**
  137519. * Returns true if the block has a texture (either its own texture or the environment texture from the scene, if set)
  137520. */
  137521. get hasTexture(): boolean;
  137522. /**
  137523. * Gets the reflection color (either the name of the variable if the color input is connected, else a default value)
  137524. */
  137525. get reflectionColor(): string;
  137526. protected _getTexture(): Nullable<BaseTexture>;
  137527. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  137528. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  137529. /**
  137530. * Gets the code to inject in the vertex shader
  137531. * @param state current state of the node material building
  137532. * @returns the shader code
  137533. */
  137534. handleVertexSide(state: NodeMaterialBuildState): string;
  137535. /**
  137536. * Gets the main code of the block (fragment side)
  137537. * @param state current state of the node material building
  137538. * @param normalVarName name of the existing variable corresponding to the normal
  137539. * @returns the shader code
  137540. */
  137541. getCode(state: NodeMaterialBuildState, normalVarName: string): string;
  137542. protected _buildBlock(state: NodeMaterialBuildState): this;
  137543. protected _dumpPropertiesCode(): string;
  137544. serialize(): any;
  137545. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  137546. }
  137547. }
  137548. declare module BABYLON {
  137549. /**
  137550. * Block used to implement the sheen module of the PBR material
  137551. */
  137552. export class SheenBlock extends NodeMaterialBlock {
  137553. /**
  137554. * Create a new SheenBlock
  137555. * @param name defines the block name
  137556. */
  137557. constructor(name: string);
  137558. /**
  137559. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  137560. * It allows the strength of the sheen effect to not depend on the base color of the material,
  137561. * making it easier to setup and tweak the effect
  137562. */
  137563. albedoScaling: boolean;
  137564. /**
  137565. * Defines if the sheen is linked to the sheen color.
  137566. */
  137567. linkSheenWithAlbedo: boolean;
  137568. /**
  137569. * Initialize the block and prepare the context for build
  137570. * @param state defines the state that will be used for the build
  137571. */
  137572. initialize(state: NodeMaterialBuildState): void;
  137573. /**
  137574. * Gets the current class name
  137575. * @returns the class name
  137576. */
  137577. getClassName(): string;
  137578. /**
  137579. * Gets the intensity input component
  137580. */
  137581. get intensity(): NodeMaterialConnectionPoint;
  137582. /**
  137583. * Gets the color input component
  137584. */
  137585. get color(): NodeMaterialConnectionPoint;
  137586. /**
  137587. * Gets the roughness input component
  137588. */
  137589. get roughness(): NodeMaterialConnectionPoint;
  137590. /**
  137591. * Gets the texture input component
  137592. */
  137593. get texture(): NodeMaterialConnectionPoint;
  137594. /**
  137595. * Gets the sheen object output component
  137596. */
  137597. get sheen(): NodeMaterialConnectionPoint;
  137598. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  137599. /**
  137600. * Gets the main code of the block (fragment side)
  137601. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  137602. * @returns the shader code
  137603. */
  137604. getCode(reflectionBlock: Nullable<ReflectionBlock>): string;
  137605. protected _buildBlock(state: NodeMaterialBuildState): this;
  137606. protected _dumpPropertiesCode(): string;
  137607. serialize(): any;
  137608. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  137609. }
  137610. }
  137611. declare module BABYLON {
  137612. /**
  137613. * Block used to implement the reflectivity module of the PBR material
  137614. */
  137615. export class ReflectivityBlock extends NodeMaterialBlock {
  137616. /**
  137617. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  137618. */
  137619. useAmbientOcclusionFromMetallicTextureRed: boolean;
  137620. /**
  137621. * Specifies if the metallic texture contains the metallness information in its blue channel.
  137622. */
  137623. useMetallnessFromMetallicTextureBlue: boolean;
  137624. /**
  137625. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  137626. */
  137627. useRoughnessFromMetallicTextureAlpha: boolean;
  137628. /**
  137629. * Specifies if the metallic texture contains the roughness information in its green channel.
  137630. */
  137631. useRoughnessFromMetallicTextureGreen: boolean;
  137632. /**
  137633. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  137634. */
  137635. useMetallicF0FactorFromMetallicTexture: boolean;
  137636. /**
  137637. * Create a new ReflectivityBlock
  137638. * @param name defines the block name
  137639. */
  137640. constructor(name: string);
  137641. /**
  137642. * Initialize the block and prepare the context for build
  137643. * @param state defines the state that will be used for the build
  137644. */
  137645. initialize(state: NodeMaterialBuildState): void;
  137646. /**
  137647. * Gets the current class name
  137648. * @returns the class name
  137649. */
  137650. getClassName(): string;
  137651. /**
  137652. * Gets the metallic input component
  137653. */
  137654. get metallic(): NodeMaterialConnectionPoint;
  137655. /**
  137656. * Gets the roughness input component
  137657. */
  137658. get roughness(): NodeMaterialConnectionPoint;
  137659. /**
  137660. * Gets the texture input component
  137661. */
  137662. get texture(): NodeMaterialConnectionPoint;
  137663. /**
  137664. * Gets the reflectivity object output component
  137665. */
  137666. get reflectivity(): NodeMaterialConnectionPoint;
  137667. /**
  137668. * Gets the main code of the block (fragment side)
  137669. * @param aoIntensityVarName name of the variable with the ambient occlusion intensity
  137670. * @returns the shader code
  137671. */
  137672. getCode(aoIntensityVarName: string): string;
  137673. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  137674. protected _buildBlock(state: NodeMaterialBuildState): this;
  137675. protected _dumpPropertiesCode(): string;
  137676. serialize(): any;
  137677. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  137678. }
  137679. }
  137680. declare module BABYLON {
  137681. /**
  137682. * Block used to implement the anisotropy module of the PBR material
  137683. */
  137684. export class AnisotropyBlock extends NodeMaterialBlock {
  137685. /**
  137686. * The two properties below are set by the main PBR block prior to calling methods of this class.
  137687. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  137688. * It's less burden on the user side in the editor part.
  137689. */
  137690. /** @hidden */
  137691. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  137692. /** @hidden */
  137693. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  137694. /**
  137695. * Create a new AnisotropyBlock
  137696. * @param name defines the block name
  137697. */
  137698. constructor(name: string);
  137699. /**
  137700. * Initialize the block and prepare the context for build
  137701. * @param state defines the state that will be used for the build
  137702. */
  137703. initialize(state: NodeMaterialBuildState): void;
  137704. /**
  137705. * Gets the current class name
  137706. * @returns the class name
  137707. */
  137708. getClassName(): string;
  137709. /**
  137710. * Gets the intensity input component
  137711. */
  137712. get intensity(): NodeMaterialConnectionPoint;
  137713. /**
  137714. * Gets the direction input component
  137715. */
  137716. get direction(): NodeMaterialConnectionPoint;
  137717. /**
  137718. * Gets the texture input component
  137719. */
  137720. get texture(): NodeMaterialConnectionPoint;
  137721. /**
  137722. * Gets the uv input component
  137723. */
  137724. get uv(): NodeMaterialConnectionPoint;
  137725. /**
  137726. * Gets the worldTangent input component
  137727. */
  137728. get worldTangent(): NodeMaterialConnectionPoint;
  137729. /**
  137730. * Gets the anisotropy object output component
  137731. */
  137732. get anisotropy(): NodeMaterialConnectionPoint;
  137733. private _generateTBNSpace;
  137734. /**
  137735. * Gets the main code of the block (fragment side)
  137736. * @param state current state of the node material building
  137737. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  137738. * @returns the shader code
  137739. */
  137740. getCode(state: NodeMaterialBuildState, generateTBNSpace?: boolean): string;
  137741. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  137742. protected _buildBlock(state: NodeMaterialBuildState): this;
  137743. }
  137744. }
  137745. declare module BABYLON {
  137746. /**
  137747. * Block used to implement the clear coat module of the PBR material
  137748. */
  137749. export class ClearCoatBlock extends NodeMaterialBlock {
  137750. private _scene;
  137751. /**
  137752. * Create a new ClearCoatBlock
  137753. * @param name defines the block name
  137754. */
  137755. constructor(name: string);
  137756. /**
  137757. * Initialize the block and prepare the context for build
  137758. * @param state defines the state that will be used for the build
  137759. */
  137760. initialize(state: NodeMaterialBuildState): void;
  137761. /**
  137762. * Gets the current class name
  137763. * @returns the class name
  137764. */
  137765. getClassName(): string;
  137766. /**
  137767. * Gets the intensity input component
  137768. */
  137769. get intensity(): NodeMaterialConnectionPoint;
  137770. /**
  137771. * Gets the roughness input component
  137772. */
  137773. get roughness(): NodeMaterialConnectionPoint;
  137774. /**
  137775. * Gets the ior input component
  137776. */
  137777. get ior(): NodeMaterialConnectionPoint;
  137778. /**
  137779. * Gets the texture input component
  137780. */
  137781. get texture(): NodeMaterialConnectionPoint;
  137782. /**
  137783. * Gets the bump texture input component
  137784. */
  137785. get bumpTexture(): NodeMaterialConnectionPoint;
  137786. /**
  137787. * Gets the uv input component
  137788. */
  137789. get uv(): NodeMaterialConnectionPoint;
  137790. /**
  137791. * Gets the tint color input component
  137792. */
  137793. get tintColor(): NodeMaterialConnectionPoint;
  137794. /**
  137795. * Gets the tint "at distance" input component
  137796. */
  137797. get tintAtDistance(): NodeMaterialConnectionPoint;
  137798. /**
  137799. * Gets the tint thickness input component
  137800. */
  137801. get tintThickness(): NodeMaterialConnectionPoint;
  137802. /**
  137803. * Gets the tint texture input component
  137804. */
  137805. get tintTexture(): NodeMaterialConnectionPoint;
  137806. /**
  137807. * Gets the world tangent input component
  137808. */
  137809. get worldTangent(): NodeMaterialConnectionPoint;
  137810. /**
  137811. * Gets the clear coat object output component
  137812. */
  137813. get clearcoat(): NodeMaterialConnectionPoint;
  137814. autoConfigure(material: NodeMaterial): void;
  137815. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  137816. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  137817. private _generateTBNSpace;
  137818. /**
  137819. * Gets the main code of the block (fragment side)
  137820. * @param state current state of the node material building
  137821. * @param ccBlock instance of a ClearCoatBlock or null if the code must be generated without an active clear coat module
  137822. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  137823. * @param worldPosVarName name of the variable holding the world position
  137824. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  137825. * @param vTBNAvailable indicate that the vTBN variable is already existing because it has already been generated by another block (PerturbNormal or Anisotropy)
  137826. * @param worldNormalVarName name of the variable holding the world normal
  137827. * @returns the shader code
  137828. */
  137829. static GetCode(state: NodeMaterialBuildState, ccBlock: Nullable<ClearCoatBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string, generateTBNSpace: boolean, vTBNAvailable: boolean, worldNormalVarName: string): string;
  137830. protected _buildBlock(state: NodeMaterialBuildState): this;
  137831. }
  137832. }
  137833. declare module BABYLON {
  137834. /**
  137835. * Block used to implement the sub surface module of the PBR material
  137836. */
  137837. export class SubSurfaceBlock extends NodeMaterialBlock {
  137838. /**
  137839. * Create a new SubSurfaceBlock
  137840. * @param name defines the block name
  137841. */
  137842. constructor(name: string);
  137843. /**
  137844. * Stores the intensity of the different subsurface effects in the thickness texture.
  137845. * * the green channel is the translucency intensity.
  137846. * * the blue channel is the scattering intensity.
  137847. * * the alpha channel is the refraction intensity.
  137848. */
  137849. useMaskFromThicknessTexture: boolean;
  137850. /**
  137851. * Initialize the block and prepare the context for build
  137852. * @param state defines the state that will be used for the build
  137853. */
  137854. initialize(state: NodeMaterialBuildState): void;
  137855. /**
  137856. * Gets the current class name
  137857. * @returns the class name
  137858. */
  137859. getClassName(): string;
  137860. /**
  137861. * Gets the min thickness input component
  137862. */
  137863. get minThickness(): NodeMaterialConnectionPoint;
  137864. /**
  137865. * Gets the max thickness input component
  137866. */
  137867. get maxThickness(): NodeMaterialConnectionPoint;
  137868. /**
  137869. * Gets the thickness texture component
  137870. */
  137871. get thicknessTexture(): NodeMaterialConnectionPoint;
  137872. /**
  137873. * Gets the tint color input component
  137874. */
  137875. get tintColor(): NodeMaterialConnectionPoint;
  137876. /**
  137877. * Gets the translucency intensity input component
  137878. */
  137879. get translucencyIntensity(): NodeMaterialConnectionPoint;
  137880. /**
  137881. * Gets the translucency diffusion distance input component
  137882. */
  137883. get translucencyDiffusionDistance(): NodeMaterialConnectionPoint;
  137884. /**
  137885. * Gets the refraction object parameters
  137886. */
  137887. get refraction(): NodeMaterialConnectionPoint;
  137888. /**
  137889. * Gets the sub surface object output component
  137890. */
  137891. get subsurface(): NodeMaterialConnectionPoint;
  137892. autoConfigure(material: NodeMaterial): void;
  137893. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  137894. /**
  137895. * Gets the main code of the block (fragment side)
  137896. * @param state current state of the node material building
  137897. * @param ssBlock instance of a SubSurfaceBlock or null if the code must be generated without an active sub surface module
  137898. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  137899. * @param worldPosVarName name of the variable holding the world position
  137900. * @returns the shader code
  137901. */
  137902. static GetCode(state: NodeMaterialBuildState, ssBlock: Nullable<SubSurfaceBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string): string;
  137903. protected _buildBlock(state: NodeMaterialBuildState): this;
  137904. }
  137905. }
  137906. declare module BABYLON {
  137907. /**
  137908. * Block used to implement the PBR metallic/roughness model
  137909. */
  137910. export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
  137911. /**
  137912. * Gets or sets the light associated with this block
  137913. */
  137914. light: Nullable<Light>;
  137915. private _lightId;
  137916. private _scene;
  137917. private _environmentBRDFTexture;
  137918. private _environmentBrdfSamplerName;
  137919. private _vNormalWName;
  137920. private _invertNormalName;
  137921. /**
  137922. * Create a new ReflectionBlock
  137923. * @param name defines the block name
  137924. */
  137925. constructor(name: string);
  137926. /**
  137927. * Intensity of the direct lights e.g. the four lights available in your scene.
  137928. * This impacts both the direct diffuse and specular highlights.
  137929. */
  137930. directIntensity: number;
  137931. /**
  137932. * Intensity of the environment e.g. how much the environment will light the object
  137933. * either through harmonics for rough material or through the refelction for shiny ones.
  137934. */
  137935. environmentIntensity: number;
  137936. /**
  137937. * This is a special control allowing the reduction of the specular highlights coming from the
  137938. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  137939. */
  137940. specularIntensity: number;
  137941. /**
  137942. * Defines the falloff type used in this material.
  137943. * It by default is Physical.
  137944. */
  137945. lightFalloff: number;
  137946. /**
  137947. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  137948. */
  137949. useAlphaFromAlbedoTexture: boolean;
  137950. /**
  137951. * Specifies that alpha test should be used
  137952. */
  137953. useAlphaTest: boolean;
  137954. /**
  137955. * Defines the alpha limits in alpha test mode.
  137956. */
  137957. alphaTestCutoff: number;
  137958. /**
  137959. * Specifies that alpha blending should be used
  137960. */
  137961. useAlphaBlending: boolean;
  137962. /**
  137963. * Defines if the alpha value should be determined via the rgb values.
  137964. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  137965. */
  137966. opacityRGB: boolean;
  137967. /**
  137968. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  137969. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  137970. */
  137971. useRadianceOverAlpha: boolean;
  137972. /**
  137973. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
  137974. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  137975. */
  137976. useSpecularOverAlpha: boolean;
  137977. /**
  137978. * Enables specular anti aliasing in the PBR shader.
  137979. * It will both interacts on the Geometry for analytical and IBL lighting.
  137980. * It also prefilter the roughness map based on the bump values.
  137981. */
  137982. enableSpecularAntiAliasing: boolean;
  137983. /**
  137984. * Defines if the material uses energy conservation.
  137985. */
  137986. useEnergyConservation: boolean;
  137987. /**
  137988. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  137989. * too much the area relying on ambient texture to define their ambient occlusion.
  137990. */
  137991. useRadianceOcclusion: boolean;
  137992. /**
  137993. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  137994. * makes the reflect vector face the model (under horizon).
  137995. */
  137996. useHorizonOcclusion: boolean;
  137997. /**
  137998. * If set to true, no lighting calculations will be applied.
  137999. */
  138000. unlit: boolean;
  138001. /**
  138002. * Force normal to face away from face.
  138003. */
  138004. forceNormalForward: boolean;
  138005. /**
  138006. * Defines the material debug mode.
  138007. * It helps seeing only some components of the material while troubleshooting.
  138008. */
  138009. debugMode: number;
  138010. /**
  138011. * Specify from where on screen the debug mode should start.
  138012. * The value goes from -1 (full screen) to 1 (not visible)
  138013. * It helps with side by side comparison against the final render
  138014. * This defaults to 0
  138015. */
  138016. debugLimit: number;
  138017. /**
  138018. * As the default viewing range might not be enough (if the ambient is really small for instance)
  138019. * You can use the factor to better multiply the final value.
  138020. */
  138021. debugFactor: number;
  138022. /**
  138023. * Initialize the block and prepare the context for build
  138024. * @param state defines the state that will be used for the build
  138025. */
  138026. initialize(state: NodeMaterialBuildState): void;
  138027. /**
  138028. * Gets the current class name
  138029. * @returns the class name
  138030. */
  138031. getClassName(): string;
  138032. /**
  138033. * Gets the world position input component
  138034. */
  138035. get worldPosition(): NodeMaterialConnectionPoint;
  138036. /**
  138037. * Gets the world normal input component
  138038. */
  138039. get worldNormal(): NodeMaterialConnectionPoint;
  138040. /**
  138041. * Gets the perturbed normal input component
  138042. */
  138043. get perturbedNormal(): NodeMaterialConnectionPoint;
  138044. /**
  138045. * Gets the camera position input component
  138046. */
  138047. get cameraPosition(): NodeMaterialConnectionPoint;
  138048. /**
  138049. * Gets the base color input component
  138050. */
  138051. get baseColor(): NodeMaterialConnectionPoint;
  138052. /**
  138053. * Gets the base texture input component
  138054. */
  138055. get baseTexture(): NodeMaterialConnectionPoint;
  138056. /**
  138057. * Gets the opacity texture input component
  138058. */
  138059. get opacityTexture(): NodeMaterialConnectionPoint;
  138060. /**
  138061. * Gets the ambient color input component
  138062. */
  138063. get ambientColor(): NodeMaterialConnectionPoint;
  138064. /**
  138065. * Gets the reflectivity object parameters
  138066. */
  138067. get reflectivity(): NodeMaterialConnectionPoint;
  138068. /**
  138069. * Gets the ambient occlusion object parameters
  138070. */
  138071. get ambientOcclusion(): NodeMaterialConnectionPoint;
  138072. /**
  138073. * Gets the reflection object parameters
  138074. */
  138075. get reflection(): NodeMaterialConnectionPoint;
  138076. /**
  138077. * Gets the sheen object parameters
  138078. */
  138079. get sheen(): NodeMaterialConnectionPoint;
  138080. /**
  138081. * Gets the clear coat object parameters
  138082. */
  138083. get clearcoat(): NodeMaterialConnectionPoint;
  138084. /**
  138085. * Gets the sub surface object parameters
  138086. */
  138087. get subsurface(): NodeMaterialConnectionPoint;
  138088. /**
  138089. * Gets the anisotropy object parameters
  138090. */
  138091. get anisotropy(): NodeMaterialConnectionPoint;
  138092. /**
  138093. * Gets the ambient output component
  138094. */
  138095. get ambient(): NodeMaterialConnectionPoint;
  138096. /**
  138097. * Gets the diffuse output component
  138098. */
  138099. get diffuse(): NodeMaterialConnectionPoint;
  138100. /**
  138101. * Gets the specular output component
  138102. */
  138103. get specular(): NodeMaterialConnectionPoint;
  138104. /**
  138105. * Gets the sheen output component
  138106. */
  138107. get sheenDir(): NodeMaterialConnectionPoint;
  138108. /**
  138109. * Gets the clear coat output component
  138110. */
  138111. get clearcoatDir(): NodeMaterialConnectionPoint;
  138112. /**
  138113. * Gets the indirect diffuse output component
  138114. */
  138115. get diffuseIndirect(): NodeMaterialConnectionPoint;
  138116. /**
  138117. * Gets the indirect specular output component
  138118. */
  138119. get specularIndirect(): NodeMaterialConnectionPoint;
  138120. /**
  138121. * Gets the indirect sheen output component
  138122. */
  138123. get sheenIndirect(): NodeMaterialConnectionPoint;
  138124. /**
  138125. * Gets the indirect clear coat output component
  138126. */
  138127. get clearcoatIndirect(): NodeMaterialConnectionPoint;
  138128. /**
  138129. * Gets the refraction output component
  138130. */
  138131. get refraction(): NodeMaterialConnectionPoint;
  138132. /**
  138133. * Gets the global lighting output component
  138134. */
  138135. get lighting(): NodeMaterialConnectionPoint;
  138136. /**
  138137. * Gets the shadow output component
  138138. */
  138139. get shadow(): NodeMaterialConnectionPoint;
  138140. /**
  138141. * Gets the alpha output component
  138142. */
  138143. get alpha(): NodeMaterialConnectionPoint;
  138144. autoConfigure(material: NodeMaterial): void;
  138145. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  138146. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  138147. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  138148. private _injectVertexCode;
  138149. /**
  138150. * Gets the code corresponding to the albedo/opacity module
  138151. * @returns the shader code
  138152. */
  138153. getAlbedoOpacityCode(): string;
  138154. protected _buildBlock(state: NodeMaterialBuildState): this;
  138155. protected _dumpPropertiesCode(): string;
  138156. serialize(): any;
  138157. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  138158. }
  138159. }
  138160. declare module BABYLON {
  138161. /**
  138162. * Effect Render Options
  138163. */
  138164. export interface IEffectRendererOptions {
  138165. /**
  138166. * Defines the vertices positions.
  138167. */
  138168. positions?: number[];
  138169. /**
  138170. * Defines the indices.
  138171. */
  138172. indices?: number[];
  138173. }
  138174. /**
  138175. * Helper class to render one or more effects.
  138176. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  138177. */
  138178. export class EffectRenderer {
  138179. private engine;
  138180. private static _DefaultOptions;
  138181. private _vertexBuffers;
  138182. private _indexBuffer;
  138183. private _fullscreenViewport;
  138184. /**
  138185. * Creates an effect renderer
  138186. * @param engine the engine to use for rendering
  138187. * @param options defines the options of the effect renderer
  138188. */
  138189. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  138190. /**
  138191. * Sets the current viewport in normalized coordinates 0-1
  138192. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  138193. */
  138194. setViewport(viewport?: Viewport): void;
  138195. /**
  138196. * Binds the embedded attributes buffer to the effect.
  138197. * @param effect Defines the effect to bind the attributes for
  138198. */
  138199. bindBuffers(effect: Effect): void;
  138200. /**
  138201. * Sets the current effect wrapper to use during draw.
  138202. * The effect needs to be ready before calling this api.
  138203. * This also sets the default full screen position attribute.
  138204. * @param effectWrapper Defines the effect to draw with
  138205. */
  138206. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  138207. /**
  138208. * Draws a full screen quad.
  138209. */
  138210. draw(): void;
  138211. private isRenderTargetTexture;
  138212. /**
  138213. * renders one or more effects to a specified texture
  138214. * @param effectWrapper the effect to renderer
  138215. * @param outputTexture texture to draw to, if null it will render to the screen.
  138216. */
  138217. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  138218. /**
  138219. * Disposes of the effect renderer
  138220. */
  138221. dispose(): void;
  138222. }
  138223. /**
  138224. * Options to create an EffectWrapper
  138225. */
  138226. interface EffectWrapperCreationOptions {
  138227. /**
  138228. * Engine to use to create the effect
  138229. */
  138230. engine: ThinEngine;
  138231. /**
  138232. * Fragment shader for the effect
  138233. */
  138234. fragmentShader: string;
  138235. /**
  138236. * Vertex shader for the effect
  138237. */
  138238. vertexShader?: string;
  138239. /**
  138240. * Attributes to use in the shader
  138241. */
  138242. attributeNames?: Array<string>;
  138243. /**
  138244. * Uniforms to use in the shader
  138245. */
  138246. uniformNames?: Array<string>;
  138247. /**
  138248. * Texture sampler names to use in the shader
  138249. */
  138250. samplerNames?: Array<string>;
  138251. /**
  138252. * The friendly name of the effect displayed in Spector.
  138253. */
  138254. name?: string;
  138255. }
  138256. /**
  138257. * Wraps an effect to be used for rendering
  138258. */
  138259. export class EffectWrapper {
  138260. /**
  138261. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  138262. */
  138263. onApplyObservable: Observable<{}>;
  138264. /**
  138265. * The underlying effect
  138266. */
  138267. effect: Effect;
  138268. /**
  138269. * Creates an effect to be renderer
  138270. * @param creationOptions options to create the effect
  138271. */
  138272. constructor(creationOptions: EffectWrapperCreationOptions);
  138273. /**
  138274. * Disposes of the effect wrapper
  138275. */
  138276. dispose(): void;
  138277. }
  138278. }
  138279. declare module BABYLON {
  138280. /**
  138281. * Helper class to push actions to a pool of workers.
  138282. */
  138283. export class WorkerPool implements IDisposable {
  138284. private _workerInfos;
  138285. private _pendingActions;
  138286. /**
  138287. * Constructor
  138288. * @param workers Array of workers to use for actions
  138289. */
  138290. constructor(workers: Array<Worker>);
  138291. /**
  138292. * Terminates all workers and clears any pending actions.
  138293. */
  138294. dispose(): void;
  138295. /**
  138296. * Pushes an action to the worker pool. If all the workers are active, the action will be
  138297. * pended until a worker has completed its action.
  138298. * @param action The action to perform. Call onComplete when the action is complete.
  138299. */
  138300. push(action: (worker: Worker, onComplete: () => void) => void): void;
  138301. private _execute;
  138302. }
  138303. }
  138304. declare module BABYLON {
  138305. /**
  138306. * Configuration for Draco compression
  138307. */
  138308. export interface IDracoCompressionConfiguration {
  138309. /**
  138310. * Configuration for the decoder.
  138311. */
  138312. decoder: {
  138313. /**
  138314. * The url to the WebAssembly module.
  138315. */
  138316. wasmUrl?: string;
  138317. /**
  138318. * The url to the WebAssembly binary.
  138319. */
  138320. wasmBinaryUrl?: string;
  138321. /**
  138322. * The url to the fallback JavaScript module.
  138323. */
  138324. fallbackUrl?: string;
  138325. };
  138326. }
  138327. /**
  138328. * Draco compression (https://google.github.io/draco/)
  138329. *
  138330. * This class wraps the Draco module.
  138331. *
  138332. * **Encoder**
  138333. *
  138334. * The encoder is not currently implemented.
  138335. *
  138336. * **Decoder**
  138337. *
  138338. * 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.
  138339. *
  138340. * To update the configuration, use the following code:
  138341. * ```javascript
  138342. * DracoCompression.Configuration = {
  138343. * decoder: {
  138344. * wasmUrl: "<url to the WebAssembly library>",
  138345. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  138346. * fallbackUrl: "<url to the fallback JavaScript library>",
  138347. * }
  138348. * };
  138349. * ```
  138350. *
  138351. * 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.
  138352. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  138353. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  138354. *
  138355. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  138356. * ```javascript
  138357. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  138358. * ```
  138359. *
  138360. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  138361. */
  138362. export class DracoCompression implements IDisposable {
  138363. private _workerPoolPromise?;
  138364. private _decoderModulePromise?;
  138365. /**
  138366. * The configuration. Defaults to the following urls:
  138367. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  138368. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  138369. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  138370. */
  138371. static Configuration: IDracoCompressionConfiguration;
  138372. /**
  138373. * Returns true if the decoder configuration is available.
  138374. */
  138375. static get DecoderAvailable(): boolean;
  138376. /**
  138377. * Default number of workers to create when creating the draco compression object.
  138378. */
  138379. static DefaultNumWorkers: number;
  138380. private static GetDefaultNumWorkers;
  138381. private static _Default;
  138382. /**
  138383. * Default instance for the draco compression object.
  138384. */
  138385. static get Default(): DracoCompression;
  138386. /**
  138387. * Constructor
  138388. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  138389. */
  138390. constructor(numWorkers?: number);
  138391. /**
  138392. * Stop all async operations and release resources.
  138393. */
  138394. dispose(): void;
  138395. /**
  138396. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  138397. * @returns a promise that resolves when ready
  138398. */
  138399. whenReadyAsync(): Promise<void>;
  138400. /**
  138401. * Decode Draco compressed mesh data to vertex data.
  138402. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  138403. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  138404. * @returns A promise that resolves with the decoded vertex data
  138405. */
  138406. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  138407. [kind: string]: number;
  138408. }): Promise<VertexData>;
  138409. }
  138410. }
  138411. declare module BABYLON {
  138412. /**
  138413. * Class for building Constructive Solid Geometry
  138414. */
  138415. export class CSG {
  138416. private polygons;
  138417. /**
  138418. * The world matrix
  138419. */
  138420. matrix: Matrix;
  138421. /**
  138422. * Stores the position
  138423. */
  138424. position: Vector3;
  138425. /**
  138426. * Stores the rotation
  138427. */
  138428. rotation: Vector3;
  138429. /**
  138430. * Stores the rotation quaternion
  138431. */
  138432. rotationQuaternion: Nullable<Quaternion>;
  138433. /**
  138434. * Stores the scaling vector
  138435. */
  138436. scaling: Vector3;
  138437. /**
  138438. * Convert the Mesh to CSG
  138439. * @param mesh The Mesh to convert to CSG
  138440. * @returns A new CSG from the Mesh
  138441. */
  138442. static FromMesh(mesh: Mesh): CSG;
  138443. /**
  138444. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  138445. * @param polygons Polygons used to construct a CSG solid
  138446. */
  138447. private static FromPolygons;
  138448. /**
  138449. * Clones, or makes a deep copy, of the CSG
  138450. * @returns A new CSG
  138451. */
  138452. clone(): CSG;
  138453. /**
  138454. * Unions this CSG with another CSG
  138455. * @param csg The CSG to union against this CSG
  138456. * @returns The unioned CSG
  138457. */
  138458. union(csg: CSG): CSG;
  138459. /**
  138460. * Unions this CSG with another CSG in place
  138461. * @param csg The CSG to union against this CSG
  138462. */
  138463. unionInPlace(csg: CSG): void;
  138464. /**
  138465. * Subtracts this CSG with another CSG
  138466. * @param csg The CSG to subtract against this CSG
  138467. * @returns A new CSG
  138468. */
  138469. subtract(csg: CSG): CSG;
  138470. /**
  138471. * Subtracts this CSG with another CSG in place
  138472. * @param csg The CSG to subtact against this CSG
  138473. */
  138474. subtractInPlace(csg: CSG): void;
  138475. /**
  138476. * Intersect this CSG with another CSG
  138477. * @param csg The CSG to intersect against this CSG
  138478. * @returns A new CSG
  138479. */
  138480. intersect(csg: CSG): CSG;
  138481. /**
  138482. * Intersects this CSG with another CSG in place
  138483. * @param csg The CSG to intersect against this CSG
  138484. */
  138485. intersectInPlace(csg: CSG): void;
  138486. /**
  138487. * Return a new CSG solid with solid and empty space switched. This solid is
  138488. * not modified.
  138489. * @returns A new CSG solid with solid and empty space switched
  138490. */
  138491. inverse(): CSG;
  138492. /**
  138493. * Inverses the CSG in place
  138494. */
  138495. inverseInPlace(): void;
  138496. /**
  138497. * This is used to keep meshes transformations so they can be restored
  138498. * when we build back a Babylon Mesh
  138499. * NB : All CSG operations are performed in world coordinates
  138500. * @param csg The CSG to copy the transform attributes from
  138501. * @returns This CSG
  138502. */
  138503. copyTransformAttributes(csg: CSG): CSG;
  138504. /**
  138505. * Build Raw mesh from CSG
  138506. * Coordinates here are in world space
  138507. * @param name The name of the mesh geometry
  138508. * @param scene The Scene
  138509. * @param keepSubMeshes Specifies if the submeshes should be kept
  138510. * @returns A new Mesh
  138511. */
  138512. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  138513. /**
  138514. * Build Mesh from CSG taking material and transforms into account
  138515. * @param name The name of the Mesh
  138516. * @param material The material of the Mesh
  138517. * @param scene The Scene
  138518. * @param keepSubMeshes Specifies if submeshes should be kept
  138519. * @returns The new Mesh
  138520. */
  138521. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  138522. }
  138523. }
  138524. declare module BABYLON {
  138525. /**
  138526. * Class used to create a trail following a mesh
  138527. */
  138528. export class TrailMesh extends Mesh {
  138529. private _generator;
  138530. private _autoStart;
  138531. private _running;
  138532. private _diameter;
  138533. private _length;
  138534. private _sectionPolygonPointsCount;
  138535. private _sectionVectors;
  138536. private _sectionNormalVectors;
  138537. private _beforeRenderObserver;
  138538. /**
  138539. * @constructor
  138540. * @param name The value used by scene.getMeshByName() to do a lookup.
  138541. * @param generator The mesh or transform node to generate a trail.
  138542. * @param scene The scene to add this mesh to.
  138543. * @param diameter Diameter of trailing mesh. Default is 1.
  138544. * @param length Length of trailing mesh. Default is 60.
  138545. * @param autoStart Automatically start trailing mesh. Default true.
  138546. */
  138547. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  138548. /**
  138549. * "TrailMesh"
  138550. * @returns "TrailMesh"
  138551. */
  138552. getClassName(): string;
  138553. private _createMesh;
  138554. /**
  138555. * Start trailing mesh.
  138556. */
  138557. start(): void;
  138558. /**
  138559. * Stop trailing mesh.
  138560. */
  138561. stop(): void;
  138562. /**
  138563. * Update trailing mesh geometry.
  138564. */
  138565. update(): void;
  138566. /**
  138567. * Returns a new TrailMesh object.
  138568. * @param name is a string, the name given to the new mesh
  138569. * @param newGenerator use new generator object for cloned trail mesh
  138570. * @returns a new mesh
  138571. */
  138572. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  138573. /**
  138574. * Serializes this trail mesh
  138575. * @param serializationObject object to write serialization to
  138576. */
  138577. serialize(serializationObject: any): void;
  138578. /**
  138579. * Parses a serialized trail mesh
  138580. * @param parsedMesh the serialized mesh
  138581. * @param scene the scene to create the trail mesh in
  138582. * @returns the created trail mesh
  138583. */
  138584. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  138585. }
  138586. }
  138587. declare module BABYLON {
  138588. /**
  138589. * Class containing static functions to help procedurally build meshes
  138590. */
  138591. export class TiledBoxBuilder {
  138592. /**
  138593. * Creates a box mesh
  138594. * 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)
  138595. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  138596. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  138597. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  138598. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  138599. * @param name defines the name of the mesh
  138600. * @param options defines the options used to create the mesh
  138601. * @param scene defines the hosting scene
  138602. * @returns the box mesh
  138603. */
  138604. static CreateTiledBox(name: string, options: {
  138605. pattern?: number;
  138606. width?: number;
  138607. height?: number;
  138608. depth?: number;
  138609. tileSize?: number;
  138610. tileWidth?: number;
  138611. tileHeight?: number;
  138612. alignHorizontal?: number;
  138613. alignVertical?: number;
  138614. faceUV?: Vector4[];
  138615. faceColors?: Color4[];
  138616. sideOrientation?: number;
  138617. updatable?: boolean;
  138618. }, scene?: Nullable<Scene>): Mesh;
  138619. }
  138620. }
  138621. declare module BABYLON {
  138622. /**
  138623. * Class containing static functions to help procedurally build meshes
  138624. */
  138625. export class TorusKnotBuilder {
  138626. /**
  138627. * Creates a torus knot mesh
  138628. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  138629. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  138630. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  138631. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  138632. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  138633. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  138634. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  138635. * @param name defines the name of the mesh
  138636. * @param options defines the options used to create the mesh
  138637. * @param scene defines the hosting scene
  138638. * @returns the torus knot mesh
  138639. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  138640. */
  138641. static CreateTorusKnot(name: string, options: {
  138642. radius?: number;
  138643. tube?: number;
  138644. radialSegments?: number;
  138645. tubularSegments?: number;
  138646. p?: number;
  138647. q?: number;
  138648. updatable?: boolean;
  138649. sideOrientation?: number;
  138650. frontUVs?: Vector4;
  138651. backUVs?: Vector4;
  138652. }, scene: any): Mesh;
  138653. }
  138654. }
  138655. declare module BABYLON {
  138656. /**
  138657. * Polygon
  138658. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  138659. */
  138660. export class Polygon {
  138661. /**
  138662. * Creates a rectangle
  138663. * @param xmin bottom X coord
  138664. * @param ymin bottom Y coord
  138665. * @param xmax top X coord
  138666. * @param ymax top Y coord
  138667. * @returns points that make the resulting rectation
  138668. */
  138669. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  138670. /**
  138671. * Creates a circle
  138672. * @param radius radius of circle
  138673. * @param cx scale in x
  138674. * @param cy scale in y
  138675. * @param numberOfSides number of sides that make up the circle
  138676. * @returns points that make the resulting circle
  138677. */
  138678. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  138679. /**
  138680. * Creates a polygon from input string
  138681. * @param input Input polygon data
  138682. * @returns the parsed points
  138683. */
  138684. static Parse(input: string): Vector2[];
  138685. /**
  138686. * Starts building a polygon from x and y coordinates
  138687. * @param x x coordinate
  138688. * @param y y coordinate
  138689. * @returns the started path2
  138690. */
  138691. static StartingAt(x: number, y: number): Path2;
  138692. }
  138693. /**
  138694. * Builds a polygon
  138695. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  138696. */
  138697. export class PolygonMeshBuilder {
  138698. private _points;
  138699. private _outlinepoints;
  138700. private _holes;
  138701. private _name;
  138702. private _scene;
  138703. private _epoints;
  138704. private _eholes;
  138705. private _addToepoint;
  138706. /**
  138707. * Babylon reference to the earcut plugin.
  138708. */
  138709. bjsEarcut: any;
  138710. /**
  138711. * Creates a PolygonMeshBuilder
  138712. * @param name name of the builder
  138713. * @param contours Path of the polygon
  138714. * @param scene scene to add to when creating the mesh
  138715. * @param earcutInjection can be used to inject your own earcut reference
  138716. */
  138717. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  138718. /**
  138719. * Adds a whole within the polygon
  138720. * @param hole Array of points defining the hole
  138721. * @returns this
  138722. */
  138723. addHole(hole: Vector2[]): PolygonMeshBuilder;
  138724. /**
  138725. * Creates the polygon
  138726. * @param updatable If the mesh should be updatable
  138727. * @param depth The depth of the mesh created
  138728. * @returns the created mesh
  138729. */
  138730. build(updatable?: boolean, depth?: number): Mesh;
  138731. /**
  138732. * Creates the polygon
  138733. * @param depth The depth of the mesh created
  138734. * @returns the created VertexData
  138735. */
  138736. buildVertexData(depth?: number): VertexData;
  138737. /**
  138738. * Adds a side to the polygon
  138739. * @param positions points that make the polygon
  138740. * @param normals normals of the polygon
  138741. * @param uvs uvs of the polygon
  138742. * @param indices indices of the polygon
  138743. * @param bounds bounds of the polygon
  138744. * @param points points of the polygon
  138745. * @param depth depth of the polygon
  138746. * @param flip flip of the polygon
  138747. */
  138748. private addSide;
  138749. }
  138750. }
  138751. declare module BABYLON {
  138752. /**
  138753. * Class containing static functions to help procedurally build meshes
  138754. */
  138755. export class PolygonBuilder {
  138756. /**
  138757. * Creates a polygon mesh
  138758. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  138759. * * 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
  138760. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  138761. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  138762. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  138763. * * Remember you can only change the shape positions, not their number when updating a polygon
  138764. * @param name defines the name of the mesh
  138765. * @param options defines the options used to create the mesh
  138766. * @param scene defines the hosting scene
  138767. * @param earcutInjection can be used to inject your own earcut reference
  138768. * @returns the polygon mesh
  138769. */
  138770. static CreatePolygon(name: string, options: {
  138771. shape: Vector3[];
  138772. holes?: Vector3[][];
  138773. depth?: number;
  138774. faceUV?: Vector4[];
  138775. faceColors?: Color4[];
  138776. updatable?: boolean;
  138777. sideOrientation?: number;
  138778. frontUVs?: Vector4;
  138779. backUVs?: Vector4;
  138780. wrap?: boolean;
  138781. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  138782. /**
  138783. * Creates an extruded polygon mesh, with depth in the Y direction.
  138784. * * 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)
  138785. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  138786. * @param name defines the name of the mesh
  138787. * @param options defines the options used to create the mesh
  138788. * @param scene defines the hosting scene
  138789. * @param earcutInjection can be used to inject your own earcut reference
  138790. * @returns the polygon mesh
  138791. */
  138792. static ExtrudePolygon(name: string, options: {
  138793. shape: Vector3[];
  138794. holes?: Vector3[][];
  138795. depth?: number;
  138796. faceUV?: Vector4[];
  138797. faceColors?: Color4[];
  138798. updatable?: boolean;
  138799. sideOrientation?: number;
  138800. frontUVs?: Vector4;
  138801. backUVs?: Vector4;
  138802. wrap?: boolean;
  138803. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  138804. }
  138805. }
  138806. declare module BABYLON {
  138807. /**
  138808. * Class containing static functions to help procedurally build meshes
  138809. */
  138810. export class LatheBuilder {
  138811. /**
  138812. * Creates lathe mesh.
  138813. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  138814. * * 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
  138815. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  138816. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  138817. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  138818. * * 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
  138819. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  138820. * * 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
  138821. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  138822. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  138823. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  138824. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  138825. * @param name defines the name of the mesh
  138826. * @param options defines the options used to create the mesh
  138827. * @param scene defines the hosting scene
  138828. * @returns the lathe mesh
  138829. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  138830. */
  138831. static CreateLathe(name: string, options: {
  138832. shape: Vector3[];
  138833. radius?: number;
  138834. tessellation?: number;
  138835. clip?: number;
  138836. arc?: number;
  138837. closed?: boolean;
  138838. updatable?: boolean;
  138839. sideOrientation?: number;
  138840. frontUVs?: Vector4;
  138841. backUVs?: Vector4;
  138842. cap?: number;
  138843. invertUV?: boolean;
  138844. }, scene?: Nullable<Scene>): Mesh;
  138845. }
  138846. }
  138847. declare module BABYLON {
  138848. /**
  138849. * Class containing static functions to help procedurally build meshes
  138850. */
  138851. export class TiledPlaneBuilder {
  138852. /**
  138853. * Creates a tiled plane mesh
  138854. * * The parameter `pattern` will, depending on value, do nothing or
  138855. * * * flip (reflect about central vertical) alternate tiles across and up
  138856. * * * flip every tile on alternate rows
  138857. * * * rotate (180 degs) alternate tiles across and up
  138858. * * * rotate every tile on alternate rows
  138859. * * * flip and rotate alternate tiles across and up
  138860. * * * flip and rotate every tile on alternate rows
  138861. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  138862. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  138863. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  138864. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  138865. * * 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)
  138866. * * 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)
  138867. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  138868. * @param name defines the name of the mesh
  138869. * @param options defines the options used to create the mesh
  138870. * @param scene defines the hosting scene
  138871. * @returns the box mesh
  138872. */
  138873. static CreateTiledPlane(name: string, options: {
  138874. pattern?: number;
  138875. tileSize?: number;
  138876. tileWidth?: number;
  138877. tileHeight?: number;
  138878. size?: number;
  138879. width?: number;
  138880. height?: number;
  138881. alignHorizontal?: number;
  138882. alignVertical?: number;
  138883. sideOrientation?: number;
  138884. frontUVs?: Vector4;
  138885. backUVs?: Vector4;
  138886. updatable?: boolean;
  138887. }, scene?: Nullable<Scene>): Mesh;
  138888. }
  138889. }
  138890. declare module BABYLON {
  138891. /**
  138892. * Class containing static functions to help procedurally build meshes
  138893. */
  138894. export class TubeBuilder {
  138895. /**
  138896. * Creates a tube mesh.
  138897. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  138898. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  138899. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  138900. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  138901. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  138902. * * 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)
  138903. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  138904. * * 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
  138905. * * 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
  138906. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  138907. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  138908. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  138909. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  138910. * @param name defines the name of the mesh
  138911. * @param options defines the options used to create the mesh
  138912. * @param scene defines the hosting scene
  138913. * @returns the tube mesh
  138914. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  138915. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  138916. */
  138917. static CreateTube(name: string, options: {
  138918. path: Vector3[];
  138919. radius?: number;
  138920. tessellation?: number;
  138921. radiusFunction?: {
  138922. (i: number, distance: number): number;
  138923. };
  138924. cap?: number;
  138925. arc?: number;
  138926. updatable?: boolean;
  138927. sideOrientation?: number;
  138928. frontUVs?: Vector4;
  138929. backUVs?: Vector4;
  138930. instance?: Mesh;
  138931. invertUV?: boolean;
  138932. }, scene?: Nullable<Scene>): Mesh;
  138933. }
  138934. }
  138935. declare module BABYLON {
  138936. /**
  138937. * Class containing static functions to help procedurally build meshes
  138938. */
  138939. export class IcoSphereBuilder {
  138940. /**
  138941. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  138942. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  138943. * * 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`)
  138944. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  138945. * * 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
  138946. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  138947. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  138948. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  138949. * @param name defines the name of the mesh
  138950. * @param options defines the options used to create the mesh
  138951. * @param scene defines the hosting scene
  138952. * @returns the icosahedron mesh
  138953. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  138954. */
  138955. static CreateIcoSphere(name: string, options: {
  138956. radius?: number;
  138957. radiusX?: number;
  138958. radiusY?: number;
  138959. radiusZ?: number;
  138960. flat?: boolean;
  138961. subdivisions?: number;
  138962. sideOrientation?: number;
  138963. frontUVs?: Vector4;
  138964. backUVs?: Vector4;
  138965. updatable?: boolean;
  138966. }, scene?: Nullable<Scene>): Mesh;
  138967. }
  138968. }
  138969. declare module BABYLON {
  138970. /**
  138971. * Class containing static functions to help procedurally build meshes
  138972. */
  138973. export class DecalBuilder {
  138974. /**
  138975. * Creates a decal mesh.
  138976. * 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
  138977. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  138978. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  138979. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  138980. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  138981. * @param name defines the name of the mesh
  138982. * @param sourceMesh defines the mesh where the decal must be applied
  138983. * @param options defines the options used to create the mesh
  138984. * @param scene defines the hosting scene
  138985. * @returns the decal mesh
  138986. * @see https://doc.babylonjs.com/how_to/decals
  138987. */
  138988. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  138989. position?: Vector3;
  138990. normal?: Vector3;
  138991. size?: Vector3;
  138992. angle?: number;
  138993. }): Mesh;
  138994. }
  138995. }
  138996. declare module BABYLON {
  138997. /**
  138998. * Class containing static functions to help procedurally build meshes
  138999. */
  139000. export class MeshBuilder {
  139001. /**
  139002. * Creates a box mesh
  139003. * * The parameter `size` sets the size (float) of each box side (default 1)
  139004. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  139005. * * 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)
  139006. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  139007. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  139008. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  139009. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  139010. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  139011. * @param name defines the name of the mesh
  139012. * @param options defines the options used to create the mesh
  139013. * @param scene defines the hosting scene
  139014. * @returns the box mesh
  139015. */
  139016. static CreateBox(name: string, options: {
  139017. size?: number;
  139018. width?: number;
  139019. height?: number;
  139020. depth?: number;
  139021. faceUV?: Vector4[];
  139022. faceColors?: Color4[];
  139023. sideOrientation?: number;
  139024. frontUVs?: Vector4;
  139025. backUVs?: Vector4;
  139026. wrap?: boolean;
  139027. topBaseAt?: number;
  139028. bottomBaseAt?: number;
  139029. updatable?: boolean;
  139030. }, scene?: Nullable<Scene>): Mesh;
  139031. /**
  139032. * Creates a tiled box mesh
  139033. * * faceTiles sets the pattern, tile size and number of tiles for a face
  139034. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  139035. * @param name defines the name of the mesh
  139036. * @param options defines the options used to create the mesh
  139037. * @param scene defines the hosting scene
  139038. * @returns the tiled box mesh
  139039. */
  139040. static CreateTiledBox(name: string, options: {
  139041. pattern?: number;
  139042. size?: number;
  139043. width?: number;
  139044. height?: number;
  139045. depth: number;
  139046. tileSize?: number;
  139047. tileWidth?: number;
  139048. tileHeight?: number;
  139049. faceUV?: Vector4[];
  139050. faceColors?: Color4[];
  139051. alignHorizontal?: number;
  139052. alignVertical?: number;
  139053. sideOrientation?: number;
  139054. updatable?: boolean;
  139055. }, scene?: Nullable<Scene>): Mesh;
  139056. /**
  139057. * Creates a sphere mesh
  139058. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  139059. * * 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`)
  139060. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  139061. * * 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
  139062. * * 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)
  139063. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  139064. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  139065. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  139066. * @param name defines the name of the mesh
  139067. * @param options defines the options used to create the mesh
  139068. * @param scene defines the hosting scene
  139069. * @returns the sphere mesh
  139070. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  139071. */
  139072. static CreateSphere(name: string, options: {
  139073. segments?: number;
  139074. diameter?: number;
  139075. diameterX?: number;
  139076. diameterY?: number;
  139077. diameterZ?: number;
  139078. arc?: number;
  139079. slice?: number;
  139080. sideOrientation?: number;
  139081. frontUVs?: Vector4;
  139082. backUVs?: Vector4;
  139083. updatable?: boolean;
  139084. }, scene?: Nullable<Scene>): Mesh;
  139085. /**
  139086. * Creates a plane polygonal mesh. By default, this is a disc
  139087. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  139088. * * 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
  139089. * * 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
  139090. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  139091. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  139092. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  139093. * @param name defines the name of the mesh
  139094. * @param options defines the options used to create the mesh
  139095. * @param scene defines the hosting scene
  139096. * @returns the plane polygonal mesh
  139097. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  139098. */
  139099. static CreateDisc(name: string, options: {
  139100. radius?: number;
  139101. tessellation?: number;
  139102. arc?: number;
  139103. updatable?: boolean;
  139104. sideOrientation?: number;
  139105. frontUVs?: Vector4;
  139106. backUVs?: Vector4;
  139107. }, scene?: Nullable<Scene>): Mesh;
  139108. /**
  139109. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  139110. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  139111. * * 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`)
  139112. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  139113. * * 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
  139114. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  139115. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  139116. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  139117. * @param name defines the name of the mesh
  139118. * @param options defines the options used to create the mesh
  139119. * @param scene defines the hosting scene
  139120. * @returns the icosahedron mesh
  139121. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  139122. */
  139123. static CreateIcoSphere(name: string, options: {
  139124. radius?: number;
  139125. radiusX?: number;
  139126. radiusY?: number;
  139127. radiusZ?: number;
  139128. flat?: boolean;
  139129. subdivisions?: number;
  139130. sideOrientation?: number;
  139131. frontUVs?: Vector4;
  139132. backUVs?: Vector4;
  139133. updatable?: boolean;
  139134. }, scene?: Nullable<Scene>): Mesh;
  139135. /**
  139136. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  139137. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  139138. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  139139. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  139140. * * 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
  139141. * * 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
  139142. * * 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
  139143. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  139144. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  139145. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  139146. * * 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
  139147. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  139148. * * 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
  139149. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  139150. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  139151. * @param name defines the name of the mesh
  139152. * @param options defines the options used to create the mesh
  139153. * @param scene defines the hosting scene
  139154. * @returns the ribbon mesh
  139155. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  139156. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  139157. */
  139158. static CreateRibbon(name: string, options: {
  139159. pathArray: Vector3[][];
  139160. closeArray?: boolean;
  139161. closePath?: boolean;
  139162. offset?: number;
  139163. updatable?: boolean;
  139164. sideOrientation?: number;
  139165. frontUVs?: Vector4;
  139166. backUVs?: Vector4;
  139167. instance?: Mesh;
  139168. invertUV?: boolean;
  139169. uvs?: Vector2[];
  139170. colors?: Color4[];
  139171. }, scene?: Nullable<Scene>): Mesh;
  139172. /**
  139173. * Creates a cylinder or a cone mesh
  139174. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  139175. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  139176. * * 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.
  139177. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  139178. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  139179. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  139180. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  139181. * * 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).
  139182. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  139183. * * 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).
  139184. * * 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
  139185. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  139186. * * 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
  139187. * * 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.
  139188. * * If `enclose` is false, a ring surface is one element.
  139189. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  139190. * * 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
  139191. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  139192. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  139193. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  139194. * @param name defines the name of the mesh
  139195. * @param options defines the options used to create the mesh
  139196. * @param scene defines the hosting scene
  139197. * @returns the cylinder mesh
  139198. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  139199. */
  139200. static CreateCylinder(name: string, options: {
  139201. height?: number;
  139202. diameterTop?: number;
  139203. diameterBottom?: number;
  139204. diameter?: number;
  139205. tessellation?: number;
  139206. subdivisions?: number;
  139207. arc?: number;
  139208. faceColors?: Color4[];
  139209. faceUV?: Vector4[];
  139210. updatable?: boolean;
  139211. hasRings?: boolean;
  139212. enclose?: boolean;
  139213. cap?: number;
  139214. sideOrientation?: number;
  139215. frontUVs?: Vector4;
  139216. backUVs?: Vector4;
  139217. }, scene?: Nullable<Scene>): Mesh;
  139218. /**
  139219. * Creates a torus mesh
  139220. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  139221. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  139222. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  139223. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  139224. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  139225. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  139226. * @param name defines the name of the mesh
  139227. * @param options defines the options used to create the mesh
  139228. * @param scene defines the hosting scene
  139229. * @returns the torus mesh
  139230. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  139231. */
  139232. static CreateTorus(name: string, options: {
  139233. diameter?: number;
  139234. thickness?: number;
  139235. tessellation?: number;
  139236. updatable?: boolean;
  139237. sideOrientation?: number;
  139238. frontUVs?: Vector4;
  139239. backUVs?: Vector4;
  139240. }, scene?: Nullable<Scene>): Mesh;
  139241. /**
  139242. * Creates a torus knot mesh
  139243. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  139244. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  139245. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  139246. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  139247. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  139248. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  139249. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  139250. * @param name defines the name of the mesh
  139251. * @param options defines the options used to create the mesh
  139252. * @param scene defines the hosting scene
  139253. * @returns the torus knot mesh
  139254. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  139255. */
  139256. static CreateTorusKnot(name: string, options: {
  139257. radius?: number;
  139258. tube?: number;
  139259. radialSegments?: number;
  139260. tubularSegments?: number;
  139261. p?: number;
  139262. q?: number;
  139263. updatable?: boolean;
  139264. sideOrientation?: number;
  139265. frontUVs?: Vector4;
  139266. backUVs?: Vector4;
  139267. }, scene?: Nullable<Scene>): Mesh;
  139268. /**
  139269. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  139270. * * 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
  139271. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  139272. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  139273. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  139274. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  139275. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  139276. * * 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
  139277. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  139278. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  139279. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  139280. * @param name defines the name of the new line system
  139281. * @param options defines the options used to create the line system
  139282. * @param scene defines the hosting scene
  139283. * @returns a new line system mesh
  139284. */
  139285. static CreateLineSystem(name: string, options: {
  139286. lines: Vector3[][];
  139287. updatable?: boolean;
  139288. instance?: Nullable<LinesMesh>;
  139289. colors?: Nullable<Color4[][]>;
  139290. useVertexAlpha?: boolean;
  139291. }, scene: Nullable<Scene>): LinesMesh;
  139292. /**
  139293. * Creates a line mesh
  139294. * 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
  139295. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  139296. * * The parameter `points` is an array successive Vector3
  139297. * * 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
  139298. * * The optional parameter `colors` is an array of successive Color4, one per line point
  139299. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  139300. * * When updating an instance, remember that only point positions can change, not the number of points
  139301. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  139302. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  139303. * @param name defines the name of the new line system
  139304. * @param options defines the options used to create the line system
  139305. * @param scene defines the hosting scene
  139306. * @returns a new line mesh
  139307. */
  139308. static CreateLines(name: string, options: {
  139309. points: Vector3[];
  139310. updatable?: boolean;
  139311. instance?: Nullable<LinesMesh>;
  139312. colors?: Color4[];
  139313. useVertexAlpha?: boolean;
  139314. }, scene?: Nullable<Scene>): LinesMesh;
  139315. /**
  139316. * Creates a dashed line mesh
  139317. * * 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
  139318. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  139319. * * The parameter `points` is an array successive Vector3
  139320. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  139321. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  139322. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  139323. * * 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
  139324. * * When updating an instance, remember that only point positions can change, not the number of points
  139325. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  139326. * @param name defines the name of the mesh
  139327. * @param options defines the options used to create the mesh
  139328. * @param scene defines the hosting scene
  139329. * @returns the dashed line mesh
  139330. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  139331. */
  139332. static CreateDashedLines(name: string, options: {
  139333. points: Vector3[];
  139334. dashSize?: number;
  139335. gapSize?: number;
  139336. dashNb?: number;
  139337. updatable?: boolean;
  139338. instance?: LinesMesh;
  139339. }, scene?: Nullable<Scene>): LinesMesh;
  139340. /**
  139341. * 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.
  139342. * * 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.
  139343. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  139344. * * 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.
  139345. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  139346. * * 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
  139347. * * 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
  139348. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  139349. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  139350. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  139351. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  139352. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  139353. * @param name defines the name of the mesh
  139354. * @param options defines the options used to create the mesh
  139355. * @param scene defines the hosting scene
  139356. * @returns the extruded shape mesh
  139357. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  139358. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  139359. */
  139360. static ExtrudeShape(name: string, options: {
  139361. shape: Vector3[];
  139362. path: Vector3[];
  139363. scale?: number;
  139364. rotation?: number;
  139365. cap?: number;
  139366. updatable?: boolean;
  139367. sideOrientation?: number;
  139368. frontUVs?: Vector4;
  139369. backUVs?: Vector4;
  139370. instance?: Mesh;
  139371. invertUV?: boolean;
  139372. }, scene?: Nullable<Scene>): Mesh;
  139373. /**
  139374. * Creates an custom extruded shape mesh.
  139375. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  139376. * * 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.
  139377. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  139378. * * 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
  139379. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  139380. * * 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
  139381. * * It must returns a float value that will be the scale value applied to the shape on each path point
  139382. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  139383. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  139384. * * 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
  139385. * * 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
  139386. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  139387. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  139388. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  139389. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  139390. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  139391. * @param name defines the name of the mesh
  139392. * @param options defines the options used to create the mesh
  139393. * @param scene defines the hosting scene
  139394. * @returns the custom extruded shape mesh
  139395. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  139396. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  139397. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  139398. */
  139399. static ExtrudeShapeCustom(name: string, options: {
  139400. shape: Vector3[];
  139401. path: Vector3[];
  139402. scaleFunction?: any;
  139403. rotationFunction?: any;
  139404. ribbonCloseArray?: boolean;
  139405. ribbonClosePath?: boolean;
  139406. cap?: number;
  139407. updatable?: boolean;
  139408. sideOrientation?: number;
  139409. frontUVs?: Vector4;
  139410. backUVs?: Vector4;
  139411. instance?: Mesh;
  139412. invertUV?: boolean;
  139413. }, scene?: Nullable<Scene>): Mesh;
  139414. /**
  139415. * Creates lathe mesh.
  139416. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  139417. * * 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
  139418. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  139419. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  139420. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  139421. * * 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
  139422. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  139423. * * 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
  139424. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  139425. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  139426. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  139427. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  139428. * @param name defines the name of the mesh
  139429. * @param options defines the options used to create the mesh
  139430. * @param scene defines the hosting scene
  139431. * @returns the lathe mesh
  139432. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  139433. */
  139434. static CreateLathe(name: string, options: {
  139435. shape: Vector3[];
  139436. radius?: number;
  139437. tessellation?: number;
  139438. clip?: number;
  139439. arc?: number;
  139440. closed?: boolean;
  139441. updatable?: boolean;
  139442. sideOrientation?: number;
  139443. frontUVs?: Vector4;
  139444. backUVs?: Vector4;
  139445. cap?: number;
  139446. invertUV?: boolean;
  139447. }, scene?: Nullable<Scene>): Mesh;
  139448. /**
  139449. * Creates a tiled plane mesh
  139450. * * You can set a limited pattern arrangement with the tiles
  139451. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  139452. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  139453. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  139454. * @param name defines the name of the mesh
  139455. * @param options defines the options used to create the mesh
  139456. * @param scene defines the hosting scene
  139457. * @returns the plane mesh
  139458. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  139459. */
  139460. static CreateTiledPlane(name: string, options: {
  139461. pattern?: number;
  139462. tileSize?: number;
  139463. tileWidth?: number;
  139464. tileHeight?: number;
  139465. size?: number;
  139466. width?: number;
  139467. height?: number;
  139468. alignHorizontal?: number;
  139469. alignVertical?: number;
  139470. sideOrientation?: number;
  139471. frontUVs?: Vector4;
  139472. backUVs?: Vector4;
  139473. updatable?: boolean;
  139474. }, scene?: Nullable<Scene>): Mesh;
  139475. /**
  139476. * Creates a plane mesh
  139477. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  139478. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  139479. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  139480. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  139481. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  139482. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  139483. * @param name defines the name of the mesh
  139484. * @param options defines the options used to create the mesh
  139485. * @param scene defines the hosting scene
  139486. * @returns the plane mesh
  139487. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  139488. */
  139489. static CreatePlane(name: string, options: {
  139490. size?: number;
  139491. width?: number;
  139492. height?: number;
  139493. sideOrientation?: number;
  139494. frontUVs?: Vector4;
  139495. backUVs?: Vector4;
  139496. updatable?: boolean;
  139497. sourcePlane?: Plane;
  139498. }, scene?: Nullable<Scene>): Mesh;
  139499. /**
  139500. * Creates a ground mesh
  139501. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  139502. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  139503. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  139504. * @param name defines the name of the mesh
  139505. * @param options defines the options used to create the mesh
  139506. * @param scene defines the hosting scene
  139507. * @returns the ground mesh
  139508. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  139509. */
  139510. static CreateGround(name: string, options: {
  139511. width?: number;
  139512. height?: number;
  139513. subdivisions?: number;
  139514. subdivisionsX?: number;
  139515. subdivisionsY?: number;
  139516. updatable?: boolean;
  139517. }, scene?: Nullable<Scene>): Mesh;
  139518. /**
  139519. * Creates a tiled ground mesh
  139520. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  139521. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  139522. * * 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
  139523. * * 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
  139524. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  139525. * @param name defines the name of the mesh
  139526. * @param options defines the options used to create the mesh
  139527. * @param scene defines the hosting scene
  139528. * @returns the tiled ground mesh
  139529. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  139530. */
  139531. static CreateTiledGround(name: string, options: {
  139532. xmin: number;
  139533. zmin: number;
  139534. xmax: number;
  139535. zmax: number;
  139536. subdivisions?: {
  139537. w: number;
  139538. h: number;
  139539. };
  139540. precision?: {
  139541. w: number;
  139542. h: number;
  139543. };
  139544. updatable?: boolean;
  139545. }, scene?: Nullable<Scene>): Mesh;
  139546. /**
  139547. * Creates a ground mesh from a height map
  139548. * * The parameter `url` sets the URL of the height map image resource.
  139549. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  139550. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  139551. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  139552. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  139553. * * 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.
  139554. * * 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).
  139555. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  139556. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  139557. * @param name defines the name of the mesh
  139558. * @param url defines the url to the height map
  139559. * @param options defines the options used to create the mesh
  139560. * @param scene defines the hosting scene
  139561. * @returns the ground mesh
  139562. * @see https://doc.babylonjs.com/babylon101/height_map
  139563. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  139564. */
  139565. static CreateGroundFromHeightMap(name: string, url: string, options: {
  139566. width?: number;
  139567. height?: number;
  139568. subdivisions?: number;
  139569. minHeight?: number;
  139570. maxHeight?: number;
  139571. colorFilter?: Color3;
  139572. alphaFilter?: number;
  139573. updatable?: boolean;
  139574. onReady?: (mesh: GroundMesh) => void;
  139575. }, scene?: Nullable<Scene>): GroundMesh;
  139576. /**
  139577. * Creates a polygon mesh
  139578. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  139579. * * 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
  139580. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  139581. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  139582. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  139583. * * Remember you can only change the shape positions, not their number when updating a polygon
  139584. * @param name defines the name of the mesh
  139585. * @param options defines the options used to create the mesh
  139586. * @param scene defines the hosting scene
  139587. * @param earcutInjection can be used to inject your own earcut reference
  139588. * @returns the polygon mesh
  139589. */
  139590. static CreatePolygon(name: string, options: {
  139591. shape: Vector3[];
  139592. holes?: Vector3[][];
  139593. depth?: number;
  139594. faceUV?: Vector4[];
  139595. faceColors?: Color4[];
  139596. updatable?: boolean;
  139597. sideOrientation?: number;
  139598. frontUVs?: Vector4;
  139599. backUVs?: Vector4;
  139600. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  139601. /**
  139602. * Creates an extruded polygon mesh, with depth in the Y direction.
  139603. * * 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)
  139604. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  139605. * @param name defines the name of the mesh
  139606. * @param options defines the options used to create the mesh
  139607. * @param scene defines the hosting scene
  139608. * @param earcutInjection can be used to inject your own earcut reference
  139609. * @returns the polygon mesh
  139610. */
  139611. static ExtrudePolygon(name: string, options: {
  139612. shape: Vector3[];
  139613. holes?: Vector3[][];
  139614. depth?: number;
  139615. faceUV?: Vector4[];
  139616. faceColors?: Color4[];
  139617. updatable?: boolean;
  139618. sideOrientation?: number;
  139619. frontUVs?: Vector4;
  139620. backUVs?: Vector4;
  139621. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  139622. /**
  139623. * Creates a tube mesh.
  139624. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  139625. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  139626. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  139627. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  139628. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  139629. * * 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)
  139630. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  139631. * * 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
  139632. * * 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
  139633. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  139634. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  139635. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  139636. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  139637. * @param name defines the name of the mesh
  139638. * @param options defines the options used to create the mesh
  139639. * @param scene defines the hosting scene
  139640. * @returns the tube mesh
  139641. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  139642. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  139643. */
  139644. static CreateTube(name: string, options: {
  139645. path: Vector3[];
  139646. radius?: number;
  139647. tessellation?: number;
  139648. radiusFunction?: {
  139649. (i: number, distance: number): number;
  139650. };
  139651. cap?: number;
  139652. arc?: number;
  139653. updatable?: boolean;
  139654. sideOrientation?: number;
  139655. frontUVs?: Vector4;
  139656. backUVs?: Vector4;
  139657. instance?: Mesh;
  139658. invertUV?: boolean;
  139659. }, scene?: Nullable<Scene>): Mesh;
  139660. /**
  139661. * Creates a polyhedron mesh
  139662. * * 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
  139663. * * The parameter `size` (positive float, default 1) sets the polygon size
  139664. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  139665. * * 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`
  139666. * * 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
  139667. * * 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)`)
  139668. * * 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
  139669. * * 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
  139670. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  139671. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  139672. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  139673. * @param name defines the name of the mesh
  139674. * @param options defines the options used to create the mesh
  139675. * @param scene defines the hosting scene
  139676. * @returns the polyhedron mesh
  139677. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  139678. */
  139679. static CreatePolyhedron(name: string, options: {
  139680. type?: number;
  139681. size?: number;
  139682. sizeX?: number;
  139683. sizeY?: number;
  139684. sizeZ?: number;
  139685. custom?: any;
  139686. faceUV?: Vector4[];
  139687. faceColors?: Color4[];
  139688. flat?: boolean;
  139689. updatable?: boolean;
  139690. sideOrientation?: number;
  139691. frontUVs?: Vector4;
  139692. backUVs?: Vector4;
  139693. }, scene?: Nullable<Scene>): Mesh;
  139694. /**
  139695. * Creates a decal mesh.
  139696. * 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
  139697. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  139698. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  139699. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  139700. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  139701. * @param name defines the name of the mesh
  139702. * @param sourceMesh defines the mesh where the decal must be applied
  139703. * @param options defines the options used to create the mesh
  139704. * @param scene defines the hosting scene
  139705. * @returns the decal mesh
  139706. * @see https://doc.babylonjs.com/how_to/decals
  139707. */
  139708. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  139709. position?: Vector3;
  139710. normal?: Vector3;
  139711. size?: Vector3;
  139712. angle?: number;
  139713. }): Mesh;
  139714. }
  139715. }
  139716. declare module BABYLON {
  139717. /**
  139718. * A simplifier interface for future simplification implementations
  139719. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  139720. */
  139721. export interface ISimplifier {
  139722. /**
  139723. * Simplification of a given mesh according to the given settings.
  139724. * Since this requires computation, it is assumed that the function runs async.
  139725. * @param settings The settings of the simplification, including quality and distance
  139726. * @param successCallback A callback that will be called after the mesh was simplified.
  139727. * @param errorCallback in case of an error, this callback will be called. optional.
  139728. */
  139729. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  139730. }
  139731. /**
  139732. * Expected simplification settings.
  139733. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  139734. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  139735. */
  139736. export interface ISimplificationSettings {
  139737. /**
  139738. * Gets or sets the expected quality
  139739. */
  139740. quality: number;
  139741. /**
  139742. * Gets or sets the distance when this optimized version should be used
  139743. */
  139744. distance: number;
  139745. /**
  139746. * Gets an already optimized mesh
  139747. */
  139748. optimizeMesh?: boolean;
  139749. }
  139750. /**
  139751. * Class used to specify simplification options
  139752. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  139753. */
  139754. export class SimplificationSettings implements ISimplificationSettings {
  139755. /** expected quality */
  139756. quality: number;
  139757. /** distance when this optimized version should be used */
  139758. distance: number;
  139759. /** already optimized mesh */
  139760. optimizeMesh?: boolean | undefined;
  139761. /**
  139762. * Creates a SimplificationSettings
  139763. * @param quality expected quality
  139764. * @param distance distance when this optimized version should be used
  139765. * @param optimizeMesh already optimized mesh
  139766. */
  139767. constructor(
  139768. /** expected quality */
  139769. quality: number,
  139770. /** distance when this optimized version should be used */
  139771. distance: number,
  139772. /** already optimized mesh */
  139773. optimizeMesh?: boolean | undefined);
  139774. }
  139775. /**
  139776. * Interface used to define a simplification task
  139777. */
  139778. export interface ISimplificationTask {
  139779. /**
  139780. * Array of settings
  139781. */
  139782. settings: Array<ISimplificationSettings>;
  139783. /**
  139784. * Simplification type
  139785. */
  139786. simplificationType: SimplificationType;
  139787. /**
  139788. * Mesh to simplify
  139789. */
  139790. mesh: Mesh;
  139791. /**
  139792. * Callback called on success
  139793. */
  139794. successCallback?: () => void;
  139795. /**
  139796. * Defines if parallel processing can be used
  139797. */
  139798. parallelProcessing: boolean;
  139799. }
  139800. /**
  139801. * Queue used to order the simplification tasks
  139802. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  139803. */
  139804. export class SimplificationQueue {
  139805. private _simplificationArray;
  139806. /**
  139807. * Gets a boolean indicating that the process is still running
  139808. */
  139809. running: boolean;
  139810. /**
  139811. * Creates a new queue
  139812. */
  139813. constructor();
  139814. /**
  139815. * Adds a new simplification task
  139816. * @param task defines a task to add
  139817. */
  139818. addTask(task: ISimplificationTask): void;
  139819. /**
  139820. * Execute next task
  139821. */
  139822. executeNext(): void;
  139823. /**
  139824. * Execute a simplification task
  139825. * @param task defines the task to run
  139826. */
  139827. runSimplification(task: ISimplificationTask): void;
  139828. private getSimplifier;
  139829. }
  139830. /**
  139831. * The implemented types of simplification
  139832. * At the moment only Quadratic Error Decimation is implemented
  139833. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  139834. */
  139835. export enum SimplificationType {
  139836. /** Quadratic error decimation */
  139837. QUADRATIC = 0
  139838. }
  139839. /**
  139840. * An implementation of the Quadratic Error simplification algorithm.
  139841. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  139842. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  139843. * @author RaananW
  139844. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  139845. */
  139846. export class QuadraticErrorSimplification implements ISimplifier {
  139847. private _mesh;
  139848. private triangles;
  139849. private vertices;
  139850. private references;
  139851. private _reconstructedMesh;
  139852. /** Gets or sets the number pf sync interations */
  139853. syncIterations: number;
  139854. /** Gets or sets the aggressiveness of the simplifier */
  139855. aggressiveness: number;
  139856. /** Gets or sets the number of allowed iterations for decimation */
  139857. decimationIterations: number;
  139858. /** Gets or sets the espilon to use for bounding box computation */
  139859. boundingBoxEpsilon: number;
  139860. /**
  139861. * Creates a new QuadraticErrorSimplification
  139862. * @param _mesh defines the target mesh
  139863. */
  139864. constructor(_mesh: Mesh);
  139865. /**
  139866. * Simplification of a given mesh according to the given settings.
  139867. * Since this requires computation, it is assumed that the function runs async.
  139868. * @param settings The settings of the simplification, including quality and distance
  139869. * @param successCallback A callback that will be called after the mesh was simplified.
  139870. */
  139871. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  139872. private runDecimation;
  139873. private initWithMesh;
  139874. private init;
  139875. private reconstructMesh;
  139876. private initDecimatedMesh;
  139877. private isFlipped;
  139878. private updateTriangles;
  139879. private identifyBorder;
  139880. private updateMesh;
  139881. private vertexError;
  139882. private calculateError;
  139883. }
  139884. }
  139885. declare module BABYLON {
  139886. interface Scene {
  139887. /** @hidden (Backing field) */
  139888. _simplificationQueue: SimplificationQueue;
  139889. /**
  139890. * Gets or sets the simplification queue attached to the scene
  139891. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  139892. */
  139893. simplificationQueue: SimplificationQueue;
  139894. }
  139895. interface Mesh {
  139896. /**
  139897. * Simplify the mesh according to the given array of settings.
  139898. * Function will return immediately and will simplify async
  139899. * @param settings a collection of simplification settings
  139900. * @param parallelProcessing should all levels calculate parallel or one after the other
  139901. * @param simplificationType the type of simplification to run
  139902. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  139903. * @returns the current mesh
  139904. */
  139905. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  139906. }
  139907. /**
  139908. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  139909. * created in a scene
  139910. */
  139911. export class SimplicationQueueSceneComponent implements ISceneComponent {
  139912. /**
  139913. * The component name helpfull to identify the component in the list of scene components.
  139914. */
  139915. readonly name: string;
  139916. /**
  139917. * The scene the component belongs to.
  139918. */
  139919. scene: Scene;
  139920. /**
  139921. * Creates a new instance of the component for the given scene
  139922. * @param scene Defines the scene to register the component in
  139923. */
  139924. constructor(scene: Scene);
  139925. /**
  139926. * Registers the component in a given scene
  139927. */
  139928. register(): void;
  139929. /**
  139930. * Rebuilds the elements related to this component in case of
  139931. * context lost for instance.
  139932. */
  139933. rebuild(): void;
  139934. /**
  139935. * Disposes the component and the associated ressources
  139936. */
  139937. dispose(): void;
  139938. private _beforeCameraUpdate;
  139939. }
  139940. }
  139941. declare module BABYLON {
  139942. /**
  139943. * Navigation plugin interface to add navigation constrained by a navigation mesh
  139944. */
  139945. export interface INavigationEnginePlugin {
  139946. /**
  139947. * plugin name
  139948. */
  139949. name: string;
  139950. /**
  139951. * Creates a navigation mesh
  139952. * @param meshes array of all the geometry used to compute the navigatio mesh
  139953. * @param parameters bunch of parameters used to filter geometry
  139954. */
  139955. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  139956. /**
  139957. * Create a navigation mesh debug mesh
  139958. * @param scene is where the mesh will be added
  139959. * @returns debug display mesh
  139960. */
  139961. createDebugNavMesh(scene: Scene): Mesh;
  139962. /**
  139963. * Get a navigation mesh constrained position, closest to the parameter position
  139964. * @param position world position
  139965. * @returns the closest point to position constrained by the navigation mesh
  139966. */
  139967. getClosestPoint(position: Vector3): Vector3;
  139968. /**
  139969. * Get a navigation mesh constrained position, closest to the parameter position
  139970. * @param position world position
  139971. * @param result output the closest point to position constrained by the navigation mesh
  139972. */
  139973. getClosestPointToRef(position: Vector3, result: Vector3): void;
  139974. /**
  139975. * Get a navigation mesh constrained position, within a particular radius
  139976. * @param position world position
  139977. * @param maxRadius the maximum distance to the constrained world position
  139978. * @returns the closest point to position constrained by the navigation mesh
  139979. */
  139980. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  139981. /**
  139982. * Get a navigation mesh constrained position, within a particular radius
  139983. * @param position world position
  139984. * @param maxRadius the maximum distance to the constrained world position
  139985. * @param result output the closest point to position constrained by the navigation mesh
  139986. */
  139987. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  139988. /**
  139989. * Compute the final position from a segment made of destination-position
  139990. * @param position world position
  139991. * @param destination world position
  139992. * @returns the resulting point along the navmesh
  139993. */
  139994. moveAlong(position: Vector3, destination: Vector3): Vector3;
  139995. /**
  139996. * Compute the final position from a segment made of destination-position
  139997. * @param position world position
  139998. * @param destination world position
  139999. * @param result output the resulting point along the navmesh
  140000. */
  140001. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  140002. /**
  140003. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  140004. * @param start world position
  140005. * @param end world position
  140006. * @returns array containing world position composing the path
  140007. */
  140008. computePath(start: Vector3, end: Vector3): Vector3[];
  140009. /**
  140010. * If this plugin is supported
  140011. * @returns true if plugin is supported
  140012. */
  140013. isSupported(): boolean;
  140014. /**
  140015. * Create a new Crowd so you can add agents
  140016. * @param maxAgents the maximum agent count in the crowd
  140017. * @param maxAgentRadius the maximum radius an agent can have
  140018. * @param scene to attach the crowd to
  140019. * @returns the crowd you can add agents to
  140020. */
  140021. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  140022. /**
  140023. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  140024. * The queries will try to find a solution within those bounds
  140025. * default is (1,1,1)
  140026. * @param extent x,y,z value that define the extent around the queries point of reference
  140027. */
  140028. setDefaultQueryExtent(extent: Vector3): void;
  140029. /**
  140030. * Get the Bounding box extent specified by setDefaultQueryExtent
  140031. * @returns the box extent values
  140032. */
  140033. getDefaultQueryExtent(): Vector3;
  140034. /**
  140035. * build the navmesh from a previously saved state using getNavmeshData
  140036. * @param data the Uint8Array returned by getNavmeshData
  140037. */
  140038. buildFromNavmeshData(data: Uint8Array): void;
  140039. /**
  140040. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  140041. * @returns data the Uint8Array that can be saved and reused
  140042. */
  140043. getNavmeshData(): Uint8Array;
  140044. /**
  140045. * Get the Bounding box extent result specified by setDefaultQueryExtent
  140046. * @param result output the box extent values
  140047. */
  140048. getDefaultQueryExtentToRef(result: Vector3): void;
  140049. /**
  140050. * Release all resources
  140051. */
  140052. dispose(): void;
  140053. }
  140054. /**
  140055. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  140056. */
  140057. export interface ICrowd {
  140058. /**
  140059. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  140060. * You can attach anything to that node. The node position is updated in the scene update tick.
  140061. * @param pos world position that will be constrained by the navigation mesh
  140062. * @param parameters agent parameters
  140063. * @param transform hooked to the agent that will be update by the scene
  140064. * @returns agent index
  140065. */
  140066. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  140067. /**
  140068. * Returns the agent position in world space
  140069. * @param index agent index returned by addAgent
  140070. * @returns world space position
  140071. */
  140072. getAgentPosition(index: number): Vector3;
  140073. /**
  140074. * Gets the agent position result in world space
  140075. * @param index agent index returned by addAgent
  140076. * @param result output world space position
  140077. */
  140078. getAgentPositionToRef(index: number, result: Vector3): void;
  140079. /**
  140080. * Gets the agent velocity in world space
  140081. * @param index agent index returned by addAgent
  140082. * @returns world space velocity
  140083. */
  140084. getAgentVelocity(index: number): Vector3;
  140085. /**
  140086. * Gets the agent velocity result in world space
  140087. * @param index agent index returned by addAgent
  140088. * @param result output world space velocity
  140089. */
  140090. getAgentVelocityToRef(index: number, result: Vector3): void;
  140091. /**
  140092. * remove a particular agent previously created
  140093. * @param index agent index returned by addAgent
  140094. */
  140095. removeAgent(index: number): void;
  140096. /**
  140097. * get the list of all agents attached to this crowd
  140098. * @returns list of agent indices
  140099. */
  140100. getAgents(): number[];
  140101. /**
  140102. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  140103. * @param deltaTime in seconds
  140104. */
  140105. update(deltaTime: number): void;
  140106. /**
  140107. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  140108. * @param index agent index returned by addAgent
  140109. * @param destination targeted world position
  140110. */
  140111. agentGoto(index: number, destination: Vector3): void;
  140112. /**
  140113. * Teleport the agent to a new position
  140114. * @param index agent index returned by addAgent
  140115. * @param destination targeted world position
  140116. */
  140117. agentTeleport(index: number, destination: Vector3): void;
  140118. /**
  140119. * Update agent parameters
  140120. * @param index agent index returned by addAgent
  140121. * @param parameters agent parameters
  140122. */
  140123. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  140124. /**
  140125. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  140126. * The queries will try to find a solution within those bounds
  140127. * default is (1,1,1)
  140128. * @param extent x,y,z value that define the extent around the queries point of reference
  140129. */
  140130. setDefaultQueryExtent(extent: Vector3): void;
  140131. /**
  140132. * Get the Bounding box extent specified by setDefaultQueryExtent
  140133. * @returns the box extent values
  140134. */
  140135. getDefaultQueryExtent(): Vector3;
  140136. /**
  140137. * Get the Bounding box extent result specified by setDefaultQueryExtent
  140138. * @param result output the box extent values
  140139. */
  140140. getDefaultQueryExtentToRef(result: Vector3): void;
  140141. /**
  140142. * Release all resources
  140143. */
  140144. dispose(): void;
  140145. }
  140146. /**
  140147. * Configures an agent
  140148. */
  140149. export interface IAgentParameters {
  140150. /**
  140151. * Agent radius. [Limit: >= 0]
  140152. */
  140153. radius: number;
  140154. /**
  140155. * Agent height. [Limit: > 0]
  140156. */
  140157. height: number;
  140158. /**
  140159. * Maximum allowed acceleration. [Limit: >= 0]
  140160. */
  140161. maxAcceleration: number;
  140162. /**
  140163. * Maximum allowed speed. [Limit: >= 0]
  140164. */
  140165. maxSpeed: number;
  140166. /**
  140167. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  140168. */
  140169. collisionQueryRange: number;
  140170. /**
  140171. * The path visibility optimization range. [Limit: > 0]
  140172. */
  140173. pathOptimizationRange: number;
  140174. /**
  140175. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  140176. */
  140177. separationWeight: number;
  140178. }
  140179. /**
  140180. * Configures the navigation mesh creation
  140181. */
  140182. export interface INavMeshParameters {
  140183. /**
  140184. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  140185. */
  140186. cs: number;
  140187. /**
  140188. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  140189. */
  140190. ch: number;
  140191. /**
  140192. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  140193. */
  140194. walkableSlopeAngle: number;
  140195. /**
  140196. * Minimum floor to 'ceiling' height that will still allow the floor area to
  140197. * be considered walkable. [Limit: >= 3] [Units: vx]
  140198. */
  140199. walkableHeight: number;
  140200. /**
  140201. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  140202. */
  140203. walkableClimb: number;
  140204. /**
  140205. * The distance to erode/shrink the walkable area of the heightfield away from
  140206. * obstructions. [Limit: >=0] [Units: vx]
  140207. */
  140208. walkableRadius: number;
  140209. /**
  140210. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  140211. */
  140212. maxEdgeLen: number;
  140213. /**
  140214. * The maximum distance a simplfied contour's border edges should deviate
  140215. * the original raw contour. [Limit: >=0] [Units: vx]
  140216. */
  140217. maxSimplificationError: number;
  140218. /**
  140219. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  140220. */
  140221. minRegionArea: number;
  140222. /**
  140223. * Any regions with a span count smaller than this value will, if possible,
  140224. * be merged with larger regions. [Limit: >=0] [Units: vx]
  140225. */
  140226. mergeRegionArea: number;
  140227. /**
  140228. * The maximum number of vertices allowed for polygons generated during the
  140229. * contour to polygon conversion process. [Limit: >= 3]
  140230. */
  140231. maxVertsPerPoly: number;
  140232. /**
  140233. * Sets the sampling distance to use when generating the detail mesh.
  140234. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  140235. */
  140236. detailSampleDist: number;
  140237. /**
  140238. * The maximum distance the detail mesh surface should deviate from heightfield
  140239. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  140240. */
  140241. detailSampleMaxError: number;
  140242. }
  140243. }
  140244. declare module BABYLON {
  140245. /**
  140246. * RecastJS navigation plugin
  140247. */
  140248. export class RecastJSPlugin implements INavigationEnginePlugin {
  140249. /**
  140250. * Reference to the Recast library
  140251. */
  140252. bjsRECAST: any;
  140253. /**
  140254. * plugin name
  140255. */
  140256. name: string;
  140257. /**
  140258. * the first navmesh created. We might extend this to support multiple navmeshes
  140259. */
  140260. navMesh: any;
  140261. /**
  140262. * Initializes the recastJS plugin
  140263. * @param recastInjection can be used to inject your own recast reference
  140264. */
  140265. constructor(recastInjection?: any);
  140266. /**
  140267. * Creates a navigation mesh
  140268. * @param meshes array of all the geometry used to compute the navigatio mesh
  140269. * @param parameters bunch of parameters used to filter geometry
  140270. */
  140271. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  140272. /**
  140273. * Create a navigation mesh debug mesh
  140274. * @param scene is where the mesh will be added
  140275. * @returns debug display mesh
  140276. */
  140277. createDebugNavMesh(scene: Scene): Mesh;
  140278. /**
  140279. * Get a navigation mesh constrained position, closest to the parameter position
  140280. * @param position world position
  140281. * @returns the closest point to position constrained by the navigation mesh
  140282. */
  140283. getClosestPoint(position: Vector3): Vector3;
  140284. /**
  140285. * Get a navigation mesh constrained position, closest to the parameter position
  140286. * @param position world position
  140287. * @param result output the closest point to position constrained by the navigation mesh
  140288. */
  140289. getClosestPointToRef(position: Vector3, result: Vector3): void;
  140290. /**
  140291. * Get a navigation mesh constrained position, within a particular radius
  140292. * @param position world position
  140293. * @param maxRadius the maximum distance to the constrained world position
  140294. * @returns the closest point to position constrained by the navigation mesh
  140295. */
  140296. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  140297. /**
  140298. * Get a navigation mesh constrained position, within a particular radius
  140299. * @param position world position
  140300. * @param maxRadius the maximum distance to the constrained world position
  140301. * @param result output the closest point to position constrained by the navigation mesh
  140302. */
  140303. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  140304. /**
  140305. * Compute the final position from a segment made of destination-position
  140306. * @param position world position
  140307. * @param destination world position
  140308. * @returns the resulting point along the navmesh
  140309. */
  140310. moveAlong(position: Vector3, destination: Vector3): Vector3;
  140311. /**
  140312. * Compute the final position from a segment made of destination-position
  140313. * @param position world position
  140314. * @param destination world position
  140315. * @param result output the resulting point along the navmesh
  140316. */
  140317. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  140318. /**
  140319. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  140320. * @param start world position
  140321. * @param end world position
  140322. * @returns array containing world position composing the path
  140323. */
  140324. computePath(start: Vector3, end: Vector3): Vector3[];
  140325. /**
  140326. * Create a new Crowd so you can add agents
  140327. * @param maxAgents the maximum agent count in the crowd
  140328. * @param maxAgentRadius the maximum radius an agent can have
  140329. * @param scene to attach the crowd to
  140330. * @returns the crowd you can add agents to
  140331. */
  140332. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  140333. /**
  140334. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  140335. * The queries will try to find a solution within those bounds
  140336. * default is (1,1,1)
  140337. * @param extent x,y,z value that define the extent around the queries point of reference
  140338. */
  140339. setDefaultQueryExtent(extent: Vector3): void;
  140340. /**
  140341. * Get the Bounding box extent specified by setDefaultQueryExtent
  140342. * @returns the box extent values
  140343. */
  140344. getDefaultQueryExtent(): Vector3;
  140345. /**
  140346. * build the navmesh from a previously saved state using getNavmeshData
  140347. * @param data the Uint8Array returned by getNavmeshData
  140348. */
  140349. buildFromNavmeshData(data: Uint8Array): void;
  140350. /**
  140351. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  140352. * @returns data the Uint8Array that can be saved and reused
  140353. */
  140354. getNavmeshData(): Uint8Array;
  140355. /**
  140356. * Get the Bounding box extent result specified by setDefaultQueryExtent
  140357. * @param result output the box extent values
  140358. */
  140359. getDefaultQueryExtentToRef(result: Vector3): void;
  140360. /**
  140361. * Disposes
  140362. */
  140363. dispose(): void;
  140364. /**
  140365. * If this plugin is supported
  140366. * @returns true if plugin is supported
  140367. */
  140368. isSupported(): boolean;
  140369. }
  140370. /**
  140371. * Recast detour crowd implementation
  140372. */
  140373. export class RecastJSCrowd implements ICrowd {
  140374. /**
  140375. * Recast/detour plugin
  140376. */
  140377. bjsRECASTPlugin: RecastJSPlugin;
  140378. /**
  140379. * Link to the detour crowd
  140380. */
  140381. recastCrowd: any;
  140382. /**
  140383. * One transform per agent
  140384. */
  140385. transforms: TransformNode[];
  140386. /**
  140387. * All agents created
  140388. */
  140389. agents: number[];
  140390. /**
  140391. * Link to the scene is kept to unregister the crowd from the scene
  140392. */
  140393. private _scene;
  140394. /**
  140395. * Observer for crowd updates
  140396. */
  140397. private _onBeforeAnimationsObserver;
  140398. /**
  140399. * Constructor
  140400. * @param plugin recastJS plugin
  140401. * @param maxAgents the maximum agent count in the crowd
  140402. * @param maxAgentRadius the maximum radius an agent can have
  140403. * @param scene to attach the crowd to
  140404. * @returns the crowd you can add agents to
  140405. */
  140406. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  140407. /**
  140408. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  140409. * You can attach anything to that node. The node position is updated in the scene update tick.
  140410. * @param pos world position that will be constrained by the navigation mesh
  140411. * @param parameters agent parameters
  140412. * @param transform hooked to the agent that will be update by the scene
  140413. * @returns agent index
  140414. */
  140415. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  140416. /**
  140417. * Returns the agent position in world space
  140418. * @param index agent index returned by addAgent
  140419. * @returns world space position
  140420. */
  140421. getAgentPosition(index: number): Vector3;
  140422. /**
  140423. * Returns the agent position result in world space
  140424. * @param index agent index returned by addAgent
  140425. * @param result output world space position
  140426. */
  140427. getAgentPositionToRef(index: number, result: Vector3): void;
  140428. /**
  140429. * Returns the agent velocity in world space
  140430. * @param index agent index returned by addAgent
  140431. * @returns world space velocity
  140432. */
  140433. getAgentVelocity(index: number): Vector3;
  140434. /**
  140435. * Returns the agent velocity result in world space
  140436. * @param index agent index returned by addAgent
  140437. * @param result output world space velocity
  140438. */
  140439. getAgentVelocityToRef(index: number, result: Vector3): void;
  140440. /**
  140441. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  140442. * @param index agent index returned by addAgent
  140443. * @param destination targeted world position
  140444. */
  140445. agentGoto(index: number, destination: Vector3): void;
  140446. /**
  140447. * Teleport the agent to a new position
  140448. * @param index agent index returned by addAgent
  140449. * @param destination targeted world position
  140450. */
  140451. agentTeleport(index: number, destination: Vector3): void;
  140452. /**
  140453. * Update agent parameters
  140454. * @param index agent index returned by addAgent
  140455. * @param parameters agent parameters
  140456. */
  140457. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  140458. /**
  140459. * remove a particular agent previously created
  140460. * @param index agent index returned by addAgent
  140461. */
  140462. removeAgent(index: number): void;
  140463. /**
  140464. * get the list of all agents attached to this crowd
  140465. * @returns list of agent indices
  140466. */
  140467. getAgents(): number[];
  140468. /**
  140469. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  140470. * @param deltaTime in seconds
  140471. */
  140472. update(deltaTime: number): void;
  140473. /**
  140474. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  140475. * The queries will try to find a solution within those bounds
  140476. * default is (1,1,1)
  140477. * @param extent x,y,z value that define the extent around the queries point of reference
  140478. */
  140479. setDefaultQueryExtent(extent: Vector3): void;
  140480. /**
  140481. * Get the Bounding box extent specified by setDefaultQueryExtent
  140482. * @returns the box extent values
  140483. */
  140484. getDefaultQueryExtent(): Vector3;
  140485. /**
  140486. * Get the Bounding box extent result specified by setDefaultQueryExtent
  140487. * @param result output the box extent values
  140488. */
  140489. getDefaultQueryExtentToRef(result: Vector3): void;
  140490. /**
  140491. * Release all resources
  140492. */
  140493. dispose(): void;
  140494. }
  140495. }
  140496. declare module BABYLON {
  140497. /**
  140498. * Class used to enable access to IndexedDB
  140499. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  140500. */
  140501. export class Database implements IOfflineProvider {
  140502. private _callbackManifestChecked;
  140503. private _currentSceneUrl;
  140504. private _db;
  140505. private _enableSceneOffline;
  140506. private _enableTexturesOffline;
  140507. private _manifestVersionFound;
  140508. private _mustUpdateRessources;
  140509. private _hasReachedQuota;
  140510. private _isSupported;
  140511. private _idbFactory;
  140512. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  140513. private static IsUASupportingBlobStorage;
  140514. /**
  140515. * Gets a boolean indicating if Database storate is enabled (off by default)
  140516. */
  140517. static IDBStorageEnabled: boolean;
  140518. /**
  140519. * Gets a boolean indicating if scene must be saved in the database
  140520. */
  140521. get enableSceneOffline(): boolean;
  140522. /**
  140523. * Gets a boolean indicating if textures must be saved in the database
  140524. */
  140525. get enableTexturesOffline(): boolean;
  140526. /**
  140527. * Creates a new Database
  140528. * @param urlToScene defines the url to load the scene
  140529. * @param callbackManifestChecked defines the callback to use when manifest is checked
  140530. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  140531. */
  140532. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  140533. private static _ParseURL;
  140534. private static _ReturnFullUrlLocation;
  140535. private _checkManifestFile;
  140536. /**
  140537. * Open the database and make it available
  140538. * @param successCallback defines the callback to call on success
  140539. * @param errorCallback defines the callback to call on error
  140540. */
  140541. open(successCallback: () => void, errorCallback: () => void): void;
  140542. /**
  140543. * Loads an image from the database
  140544. * @param url defines the url to load from
  140545. * @param image defines the target DOM image
  140546. */
  140547. loadImage(url: string, image: HTMLImageElement): void;
  140548. private _loadImageFromDBAsync;
  140549. private _saveImageIntoDBAsync;
  140550. private _checkVersionFromDB;
  140551. private _loadVersionFromDBAsync;
  140552. private _saveVersionIntoDBAsync;
  140553. /**
  140554. * Loads a file from database
  140555. * @param url defines the URL to load from
  140556. * @param sceneLoaded defines a callback to call on success
  140557. * @param progressCallBack defines a callback to call when progress changed
  140558. * @param errorCallback defines a callback to call on error
  140559. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  140560. */
  140561. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  140562. private _loadFileAsync;
  140563. private _saveFileAsync;
  140564. /**
  140565. * Validates if xhr data is correct
  140566. * @param xhr defines the request to validate
  140567. * @param dataType defines the expected data type
  140568. * @returns true if data is correct
  140569. */
  140570. private static _ValidateXHRData;
  140571. }
  140572. }
  140573. declare module BABYLON {
  140574. /** @hidden */
  140575. export var gpuUpdateParticlesPixelShader: {
  140576. name: string;
  140577. shader: string;
  140578. };
  140579. }
  140580. declare module BABYLON {
  140581. /** @hidden */
  140582. export var gpuUpdateParticlesVertexShader: {
  140583. name: string;
  140584. shader: string;
  140585. };
  140586. }
  140587. declare module BABYLON {
  140588. /** @hidden */
  140589. export var clipPlaneFragmentDeclaration2: {
  140590. name: string;
  140591. shader: string;
  140592. };
  140593. }
  140594. declare module BABYLON {
  140595. /** @hidden */
  140596. export var gpuRenderParticlesPixelShader: {
  140597. name: string;
  140598. shader: string;
  140599. };
  140600. }
  140601. declare module BABYLON {
  140602. /** @hidden */
  140603. export var clipPlaneVertexDeclaration2: {
  140604. name: string;
  140605. shader: string;
  140606. };
  140607. }
  140608. declare module BABYLON {
  140609. /** @hidden */
  140610. export var gpuRenderParticlesVertexShader: {
  140611. name: string;
  140612. shader: string;
  140613. };
  140614. }
  140615. declare module BABYLON {
  140616. /**
  140617. * This represents a GPU particle system in Babylon
  140618. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  140619. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  140620. */
  140621. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  140622. /**
  140623. * The layer mask we are rendering the particles through.
  140624. */
  140625. layerMask: number;
  140626. private _capacity;
  140627. private _activeCount;
  140628. private _currentActiveCount;
  140629. private _accumulatedCount;
  140630. private _renderEffect;
  140631. private _updateEffect;
  140632. private _buffer0;
  140633. private _buffer1;
  140634. private _spriteBuffer;
  140635. private _updateVAO;
  140636. private _renderVAO;
  140637. private _targetIndex;
  140638. private _sourceBuffer;
  140639. private _targetBuffer;
  140640. private _engine;
  140641. private _currentRenderId;
  140642. private _started;
  140643. private _stopped;
  140644. private _timeDelta;
  140645. private _randomTexture;
  140646. private _randomTexture2;
  140647. private _attributesStrideSize;
  140648. private _updateEffectOptions;
  140649. private _randomTextureSize;
  140650. private _actualFrame;
  140651. private readonly _rawTextureWidth;
  140652. /**
  140653. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  140654. */
  140655. static get IsSupported(): boolean;
  140656. /**
  140657. * An event triggered when the system is disposed.
  140658. */
  140659. onDisposeObservable: Observable<GPUParticleSystem>;
  140660. /**
  140661. * Gets the maximum number of particles active at the same time.
  140662. * @returns The max number of active particles.
  140663. */
  140664. getCapacity(): number;
  140665. /**
  140666. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  140667. * to override the particles.
  140668. */
  140669. forceDepthWrite: boolean;
  140670. /**
  140671. * Gets or set the number of active particles
  140672. */
  140673. get activeParticleCount(): number;
  140674. set activeParticleCount(value: number);
  140675. private _preWarmDone;
  140676. /**
  140677. * Specifies if the particles are updated in emitter local space or world space.
  140678. */
  140679. isLocal: boolean;
  140680. /**
  140681. * Is this system ready to be used/rendered
  140682. * @return true if the system is ready
  140683. */
  140684. isReady(): boolean;
  140685. /**
  140686. * Gets if the system has been started. (Note: this will still be true after stop is called)
  140687. * @returns True if it has been started, otherwise false.
  140688. */
  140689. isStarted(): boolean;
  140690. /**
  140691. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  140692. * @returns True if it has been stopped, otherwise false.
  140693. */
  140694. isStopped(): boolean;
  140695. /**
  140696. * Gets a boolean indicating that the system is stopping
  140697. * @returns true if the system is currently stopping
  140698. */
  140699. isStopping(): boolean;
  140700. /**
  140701. * Gets the number of particles active at the same time.
  140702. * @returns The number of active particles.
  140703. */
  140704. getActiveCount(): number;
  140705. /**
  140706. * Starts the particle system and begins to emit
  140707. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  140708. */
  140709. start(delay?: number): void;
  140710. /**
  140711. * Stops the particle system.
  140712. */
  140713. stop(): void;
  140714. /**
  140715. * Remove all active particles
  140716. */
  140717. reset(): void;
  140718. /**
  140719. * Returns the string "GPUParticleSystem"
  140720. * @returns a string containing the class name
  140721. */
  140722. getClassName(): string;
  140723. private _colorGradientsTexture;
  140724. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  140725. /**
  140726. * Adds a new color gradient
  140727. * @param gradient defines the gradient to use (between 0 and 1)
  140728. * @param color1 defines the color to affect to the specified gradient
  140729. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  140730. * @returns the current particle system
  140731. */
  140732. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  140733. private _refreshColorGradient;
  140734. /** Force the system to rebuild all gradients that need to be resync */
  140735. forceRefreshGradients(): void;
  140736. /**
  140737. * Remove a specific color gradient
  140738. * @param gradient defines the gradient to remove
  140739. * @returns the current particle system
  140740. */
  140741. removeColorGradient(gradient: number): GPUParticleSystem;
  140742. private _angularSpeedGradientsTexture;
  140743. private _sizeGradientsTexture;
  140744. private _velocityGradientsTexture;
  140745. private _limitVelocityGradientsTexture;
  140746. private _dragGradientsTexture;
  140747. private _addFactorGradient;
  140748. /**
  140749. * Adds a new size gradient
  140750. * @param gradient defines the gradient to use (between 0 and 1)
  140751. * @param factor defines the size factor to affect to the specified gradient
  140752. * @returns the current particle system
  140753. */
  140754. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  140755. /**
  140756. * Remove a specific size gradient
  140757. * @param gradient defines the gradient to remove
  140758. * @returns the current particle system
  140759. */
  140760. removeSizeGradient(gradient: number): GPUParticleSystem;
  140761. private _refreshFactorGradient;
  140762. /**
  140763. * Adds a new angular speed gradient
  140764. * @param gradient defines the gradient to use (between 0 and 1)
  140765. * @param factor defines the angular speed to affect to the specified gradient
  140766. * @returns the current particle system
  140767. */
  140768. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  140769. /**
  140770. * Remove a specific angular speed gradient
  140771. * @param gradient defines the gradient to remove
  140772. * @returns the current particle system
  140773. */
  140774. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  140775. /**
  140776. * Adds a new velocity gradient
  140777. * @param gradient defines the gradient to use (between 0 and 1)
  140778. * @param factor defines the velocity to affect to the specified gradient
  140779. * @returns the current particle system
  140780. */
  140781. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  140782. /**
  140783. * Remove a specific velocity gradient
  140784. * @param gradient defines the gradient to remove
  140785. * @returns the current particle system
  140786. */
  140787. removeVelocityGradient(gradient: number): GPUParticleSystem;
  140788. /**
  140789. * Adds a new limit velocity gradient
  140790. * @param gradient defines the gradient to use (between 0 and 1)
  140791. * @param factor defines the limit velocity value to affect to the specified gradient
  140792. * @returns the current particle system
  140793. */
  140794. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  140795. /**
  140796. * Remove a specific limit velocity gradient
  140797. * @param gradient defines the gradient to remove
  140798. * @returns the current particle system
  140799. */
  140800. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  140801. /**
  140802. * Adds a new drag gradient
  140803. * @param gradient defines the gradient to use (between 0 and 1)
  140804. * @param factor defines the drag value to affect to the specified gradient
  140805. * @returns the current particle system
  140806. */
  140807. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  140808. /**
  140809. * Remove a specific drag gradient
  140810. * @param gradient defines the gradient to remove
  140811. * @returns the current particle system
  140812. */
  140813. removeDragGradient(gradient: number): GPUParticleSystem;
  140814. /**
  140815. * Not supported by GPUParticleSystem
  140816. * @param gradient defines the gradient to use (between 0 and 1)
  140817. * @param factor defines the emit rate value to affect to the specified gradient
  140818. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  140819. * @returns the current particle system
  140820. */
  140821. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  140822. /**
  140823. * Not supported by GPUParticleSystem
  140824. * @param gradient defines the gradient to remove
  140825. * @returns the current particle system
  140826. */
  140827. removeEmitRateGradient(gradient: number): IParticleSystem;
  140828. /**
  140829. * Not supported by GPUParticleSystem
  140830. * @param gradient defines the gradient to use (between 0 and 1)
  140831. * @param factor defines the start size value to affect to the specified gradient
  140832. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  140833. * @returns the current particle system
  140834. */
  140835. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  140836. /**
  140837. * Not supported by GPUParticleSystem
  140838. * @param gradient defines the gradient to remove
  140839. * @returns the current particle system
  140840. */
  140841. removeStartSizeGradient(gradient: number): IParticleSystem;
  140842. /**
  140843. * Not supported by GPUParticleSystem
  140844. * @param gradient defines the gradient to use (between 0 and 1)
  140845. * @param min defines the color remap minimal range
  140846. * @param max defines the color remap maximal range
  140847. * @returns the current particle system
  140848. */
  140849. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  140850. /**
  140851. * Not supported by GPUParticleSystem
  140852. * @param gradient defines the gradient to remove
  140853. * @returns the current particle system
  140854. */
  140855. removeColorRemapGradient(): IParticleSystem;
  140856. /**
  140857. * Not supported by GPUParticleSystem
  140858. * @param gradient defines the gradient to use (between 0 and 1)
  140859. * @param min defines the alpha remap minimal range
  140860. * @param max defines the alpha remap maximal range
  140861. * @returns the current particle system
  140862. */
  140863. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  140864. /**
  140865. * Not supported by GPUParticleSystem
  140866. * @param gradient defines the gradient to remove
  140867. * @returns the current particle system
  140868. */
  140869. removeAlphaRemapGradient(): IParticleSystem;
  140870. /**
  140871. * Not supported by GPUParticleSystem
  140872. * @param gradient defines the gradient to use (between 0 and 1)
  140873. * @param color defines the color to affect to the specified gradient
  140874. * @returns the current particle system
  140875. */
  140876. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  140877. /**
  140878. * Not supported by GPUParticleSystem
  140879. * @param gradient defines the gradient to remove
  140880. * @returns the current particle system
  140881. */
  140882. removeRampGradient(): IParticleSystem;
  140883. /**
  140884. * Not supported by GPUParticleSystem
  140885. * @returns the list of ramp gradients
  140886. */
  140887. getRampGradients(): Nullable<Array<Color3Gradient>>;
  140888. /**
  140889. * Not supported by GPUParticleSystem
  140890. * Gets or sets a boolean indicating that ramp gradients must be used
  140891. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  140892. */
  140893. get useRampGradients(): boolean;
  140894. set useRampGradients(value: boolean);
  140895. /**
  140896. * Not supported by GPUParticleSystem
  140897. * @param gradient defines the gradient to use (between 0 and 1)
  140898. * @param factor defines the life time factor to affect to the specified gradient
  140899. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  140900. * @returns the current particle system
  140901. */
  140902. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  140903. /**
  140904. * Not supported by GPUParticleSystem
  140905. * @param gradient defines the gradient to remove
  140906. * @returns the current particle system
  140907. */
  140908. removeLifeTimeGradient(gradient: number): IParticleSystem;
  140909. /**
  140910. * Instantiates a GPU particle system.
  140911. * 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.
  140912. * @param name The name of the particle system
  140913. * @param options The options used to create the system
  140914. * @param scene The scene the particle system belongs to
  140915. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  140916. */
  140917. constructor(name: string, options: Partial<{
  140918. capacity: number;
  140919. randomTextureSize: number;
  140920. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  140921. protected _reset(): void;
  140922. private _createUpdateVAO;
  140923. private _createRenderVAO;
  140924. private _initialize;
  140925. /** @hidden */
  140926. _recreateUpdateEffect(): void;
  140927. /** @hidden */
  140928. _recreateRenderEffect(): void;
  140929. /**
  140930. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  140931. * @param preWarm defines if we are in the pre-warmimg phase
  140932. */
  140933. animate(preWarm?: boolean): void;
  140934. private _createFactorGradientTexture;
  140935. private _createSizeGradientTexture;
  140936. private _createAngularSpeedGradientTexture;
  140937. private _createVelocityGradientTexture;
  140938. private _createLimitVelocityGradientTexture;
  140939. private _createDragGradientTexture;
  140940. private _createColorGradientTexture;
  140941. /**
  140942. * Renders the particle system in its current state
  140943. * @param preWarm defines if the system should only update the particles but not render them
  140944. * @returns the current number of particles
  140945. */
  140946. render(preWarm?: boolean): number;
  140947. /**
  140948. * Rebuilds the particle system
  140949. */
  140950. rebuild(): void;
  140951. private _releaseBuffers;
  140952. private _releaseVAOs;
  140953. /**
  140954. * Disposes the particle system and free the associated resources
  140955. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  140956. */
  140957. dispose(disposeTexture?: boolean): void;
  140958. /**
  140959. * Clones the particle system.
  140960. * @param name The name of the cloned object
  140961. * @param newEmitter The new emitter to use
  140962. * @returns the cloned particle system
  140963. */
  140964. clone(name: string, newEmitter: any): GPUParticleSystem;
  140965. /**
  140966. * Serializes the particle system to a JSON object
  140967. * @param serializeTexture defines if the texture must be serialized as well
  140968. * @returns the JSON object
  140969. */
  140970. serialize(serializeTexture?: boolean): any;
  140971. /**
  140972. * Parses a JSON object to create a GPU particle system.
  140973. * @param parsedParticleSystem The JSON object to parse
  140974. * @param scene The scene to create the particle system in
  140975. * @param rootUrl The root url to use to load external dependencies like texture
  140976. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  140977. * @returns the parsed GPU particle system
  140978. */
  140979. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  140980. }
  140981. }
  140982. declare module BABYLON {
  140983. /**
  140984. * Represents a set of particle systems working together to create a specific effect
  140985. */
  140986. export class ParticleSystemSet implements IDisposable {
  140987. /**
  140988. * Gets or sets base Assets URL
  140989. */
  140990. static BaseAssetsUrl: string;
  140991. private _emitterCreationOptions;
  140992. private _emitterNode;
  140993. /**
  140994. * Gets the particle system list
  140995. */
  140996. systems: IParticleSystem[];
  140997. /**
  140998. * Gets the emitter node used with this set
  140999. */
  141000. get emitterNode(): Nullable<TransformNode>;
  141001. /**
  141002. * Creates a new emitter mesh as a sphere
  141003. * @param options defines the options used to create the sphere
  141004. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  141005. * @param scene defines the hosting scene
  141006. */
  141007. setEmitterAsSphere(options: {
  141008. diameter: number;
  141009. segments: number;
  141010. color: Color3;
  141011. }, renderingGroupId: number, scene: Scene): void;
  141012. /**
  141013. * Starts all particle systems of the set
  141014. * @param emitter defines an optional mesh to use as emitter for the particle systems
  141015. */
  141016. start(emitter?: AbstractMesh): void;
  141017. /**
  141018. * Release all associated resources
  141019. */
  141020. dispose(): void;
  141021. /**
  141022. * Serialize the set into a JSON compatible object
  141023. * @param serializeTexture defines if the texture must be serialized as well
  141024. * @returns a JSON compatible representation of the set
  141025. */
  141026. serialize(serializeTexture?: boolean): any;
  141027. /**
  141028. * Parse a new ParticleSystemSet from a serialized source
  141029. * @param data defines a JSON compatible representation of the set
  141030. * @param scene defines the hosting scene
  141031. * @param gpu defines if we want GPU particles or CPU particles
  141032. * @returns a new ParticleSystemSet
  141033. */
  141034. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  141035. }
  141036. }
  141037. declare module BABYLON {
  141038. /**
  141039. * This class is made for on one-liner static method to help creating particle system set.
  141040. */
  141041. export class ParticleHelper {
  141042. /**
  141043. * Gets or sets base Assets URL
  141044. */
  141045. static BaseAssetsUrl: string;
  141046. /** Define the Url to load snippets */
  141047. static SnippetUrl: string;
  141048. /**
  141049. * Create a default particle system that you can tweak
  141050. * @param emitter defines the emitter to use
  141051. * @param capacity defines the system capacity (default is 500 particles)
  141052. * @param scene defines the hosting scene
  141053. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  141054. * @returns the new Particle system
  141055. */
  141056. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  141057. /**
  141058. * This is the main static method (one-liner) of this helper to create different particle systems
  141059. * @param type This string represents the type to the particle system to create
  141060. * @param scene The scene where the particle system should live
  141061. * @param gpu If the system will use gpu
  141062. * @returns the ParticleSystemSet created
  141063. */
  141064. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  141065. /**
  141066. * Static function used to export a particle system to a ParticleSystemSet variable.
  141067. * Please note that the emitter shape is not exported
  141068. * @param systems defines the particle systems to export
  141069. * @returns the created particle system set
  141070. */
  141071. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  141072. /**
  141073. * Creates a particle system from a snippet saved in a remote file
  141074. * @param name defines the name of the particle system to create
  141075. * @param url defines the url to load from
  141076. * @param scene defines the hosting scene
  141077. * @param gpu If the system will use gpu
  141078. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  141079. * @returns a promise that will resolve to the new particle system
  141080. */
  141081. static ParseFromFileAsync(name: string, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  141082. /**
  141083. * Creates a particle system from a snippet saved by the particle system editor
  141084. * @param snippetId defines the snippet to load
  141085. * @param scene defines the hosting scene
  141086. * @param gpu If the system will use gpu
  141087. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  141088. * @returns a promise that will resolve to the new particle system
  141089. */
  141090. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  141091. }
  141092. }
  141093. declare module BABYLON {
  141094. interface Engine {
  141095. /**
  141096. * Create an effect to use with particle systems.
  141097. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  141098. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  141099. * @param uniformsNames defines a list of attribute names
  141100. * @param samplers defines an array of string used to represent textures
  141101. * @param defines defines the string containing the defines to use to compile the shaders
  141102. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  141103. * @param onCompiled defines a function to call when the effect creation is successful
  141104. * @param onError defines a function to call when the effect creation has failed
  141105. * @returns the new Effect
  141106. */
  141107. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  141108. }
  141109. interface Mesh {
  141110. /**
  141111. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  141112. * @returns an array of IParticleSystem
  141113. */
  141114. getEmittedParticleSystems(): IParticleSystem[];
  141115. /**
  141116. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  141117. * @returns an array of IParticleSystem
  141118. */
  141119. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  141120. }
  141121. /**
  141122. * @hidden
  141123. */
  141124. export var _IDoNeedToBeInTheBuild: number;
  141125. }
  141126. declare module BABYLON {
  141127. /** Defines the 4 color options */
  141128. export enum PointColor {
  141129. /** color value */
  141130. Color = 2,
  141131. /** uv value */
  141132. UV = 1,
  141133. /** random value */
  141134. Random = 0,
  141135. /** stated value */
  141136. Stated = 3
  141137. }
  141138. /**
  141139. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  141140. * 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.
  141141. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  141142. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  141143. *
  141144. * Full documentation here : TO BE ENTERED
  141145. */
  141146. export class PointsCloudSystem implements IDisposable {
  141147. /**
  141148. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  141149. * Example : var p = SPS.particles[i];
  141150. */
  141151. particles: CloudPoint[];
  141152. /**
  141153. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  141154. */
  141155. nbParticles: number;
  141156. /**
  141157. * This a counter for your own usage. It's not set by any SPS functions.
  141158. */
  141159. counter: number;
  141160. /**
  141161. * The PCS name. This name is also given to the underlying mesh.
  141162. */
  141163. name: string;
  141164. /**
  141165. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  141166. */
  141167. mesh: Mesh;
  141168. /**
  141169. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  141170. * Please read :
  141171. */
  141172. vars: any;
  141173. /**
  141174. * @hidden
  141175. */
  141176. _size: number;
  141177. private _scene;
  141178. private _promises;
  141179. private _positions;
  141180. private _indices;
  141181. private _normals;
  141182. private _colors;
  141183. private _uvs;
  141184. private _indices32;
  141185. private _positions32;
  141186. private _colors32;
  141187. private _uvs32;
  141188. private _updatable;
  141189. private _isVisibilityBoxLocked;
  141190. private _alwaysVisible;
  141191. private _groups;
  141192. private _groupCounter;
  141193. private _computeParticleColor;
  141194. private _computeParticleTexture;
  141195. private _computeParticleRotation;
  141196. private _computeBoundingBox;
  141197. private _isReady;
  141198. /**
  141199. * Creates a PCS (Points Cloud System) object
  141200. * @param name (String) is the PCS name, this will be the underlying mesh name
  141201. * @param pointSize (number) is the size for each point
  141202. * @param scene (Scene) is the scene in which the PCS is added
  141203. * @param options defines the options of the PCS e.g.
  141204. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  141205. */
  141206. constructor(name: string, pointSize: number, scene: Scene, options?: {
  141207. updatable?: boolean;
  141208. });
  141209. /**
  141210. * Builds the PCS underlying mesh. Returns a standard Mesh.
  141211. * If no points were added to the PCS, the returned mesh is just a single point.
  141212. * @returns a promise for the created mesh
  141213. */
  141214. buildMeshAsync(): Promise<Mesh>;
  141215. /**
  141216. * @hidden
  141217. */
  141218. private _buildMesh;
  141219. private _addParticle;
  141220. private _randomUnitVector;
  141221. private _getColorIndicesForCoord;
  141222. private _setPointsColorOrUV;
  141223. private _colorFromTexture;
  141224. private _calculateDensity;
  141225. /**
  141226. * Adds points to the PCS in random positions within a unit sphere
  141227. * @param nb (positive integer) the number of particles to be created from this model
  141228. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  141229. * @returns the number of groups in the system
  141230. */
  141231. addPoints(nb: number, pointFunction?: any): number;
  141232. /**
  141233. * Adds points to the PCS from the surface of the model shape
  141234. * @param mesh is any Mesh object that will be used as a surface model for the points
  141235. * @param nb (positive integer) the number of particles to be created from this model
  141236. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  141237. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  141238. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  141239. * @returns the number of groups in the system
  141240. */
  141241. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  141242. /**
  141243. * Adds points to the PCS inside the model shape
  141244. * @param mesh is any Mesh object that will be used as a surface model for the points
  141245. * @param nb (positive integer) the number of particles to be created from this model
  141246. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  141247. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  141248. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  141249. * @returns the number of groups in the system
  141250. */
  141251. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  141252. /**
  141253. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  141254. * This method calls `updateParticle()` for each particle of the SPS.
  141255. * For an animated SPS, it is usually called within the render loop.
  141256. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  141257. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  141258. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  141259. * @returns the PCS.
  141260. */
  141261. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  141262. /**
  141263. * Disposes the PCS.
  141264. */
  141265. dispose(): void;
  141266. /**
  141267. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  141268. * doc :
  141269. * @returns the PCS.
  141270. */
  141271. refreshVisibleSize(): PointsCloudSystem;
  141272. /**
  141273. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  141274. * @param size the size (float) of the visibility box
  141275. * note : this doesn't lock the PCS mesh bounding box.
  141276. * doc :
  141277. */
  141278. setVisibilityBox(size: number): void;
  141279. /**
  141280. * Gets whether the PCS is always visible or not
  141281. * doc :
  141282. */
  141283. get isAlwaysVisible(): boolean;
  141284. /**
  141285. * Sets the PCS as always visible or not
  141286. * doc :
  141287. */
  141288. set isAlwaysVisible(val: boolean);
  141289. /**
  141290. * Tells to `setParticles()` to compute the particle rotations or not
  141291. * Default value : false. The PCS is faster when it's set to false
  141292. * Note : particle rotations are only applied to parent particles
  141293. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  141294. */
  141295. set computeParticleRotation(val: boolean);
  141296. /**
  141297. * Tells to `setParticles()` to compute the particle colors or not.
  141298. * Default value : true. The PCS is faster when it's set to false.
  141299. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  141300. */
  141301. set computeParticleColor(val: boolean);
  141302. set computeParticleTexture(val: boolean);
  141303. /**
  141304. * Gets if `setParticles()` computes the particle colors or not.
  141305. * Default value : false. The PCS is faster when it's set to false.
  141306. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  141307. */
  141308. get computeParticleColor(): boolean;
  141309. /**
  141310. * Gets if `setParticles()` computes the particle textures or not.
  141311. * Default value : false. The PCS is faster when it's set to false.
  141312. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  141313. */
  141314. get computeParticleTexture(): boolean;
  141315. /**
  141316. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  141317. */
  141318. set computeBoundingBox(val: boolean);
  141319. /**
  141320. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  141321. */
  141322. get computeBoundingBox(): boolean;
  141323. /**
  141324. * This function does nothing. It may be overwritten to set all the particle first values.
  141325. * The PCS doesn't call this function, you may have to call it by your own.
  141326. * doc :
  141327. */
  141328. initParticles(): void;
  141329. /**
  141330. * This function does nothing. It may be overwritten to recycle a particle
  141331. * The PCS doesn't call this function, you can to call it
  141332. * doc :
  141333. * @param particle The particle to recycle
  141334. * @returns the recycled particle
  141335. */
  141336. recycleParticle(particle: CloudPoint): CloudPoint;
  141337. /**
  141338. * Updates a particle : this function should be overwritten by the user.
  141339. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  141340. * doc :
  141341. * @example : just set a particle position or velocity and recycle conditions
  141342. * @param particle The particle to update
  141343. * @returns the updated particle
  141344. */
  141345. updateParticle(particle: CloudPoint): CloudPoint;
  141346. /**
  141347. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  141348. * This does nothing and may be overwritten by the user.
  141349. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  141350. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  141351. * @param update the boolean update value actually passed to setParticles()
  141352. */
  141353. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  141354. /**
  141355. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  141356. * This will be passed three parameters.
  141357. * This does nothing and may be overwritten by the user.
  141358. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  141359. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  141360. * @param update the boolean update value actually passed to setParticles()
  141361. */
  141362. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  141363. }
  141364. }
  141365. declare module BABYLON {
  141366. /**
  141367. * Represents one particle of a points cloud system.
  141368. */
  141369. export class CloudPoint {
  141370. /**
  141371. * particle global index
  141372. */
  141373. idx: number;
  141374. /**
  141375. * The color of the particle
  141376. */
  141377. color: Nullable<Color4>;
  141378. /**
  141379. * The world space position of the particle.
  141380. */
  141381. position: Vector3;
  141382. /**
  141383. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  141384. */
  141385. rotation: Vector3;
  141386. /**
  141387. * The world space rotation quaternion of the particle.
  141388. */
  141389. rotationQuaternion: Nullable<Quaternion>;
  141390. /**
  141391. * The uv of the particle.
  141392. */
  141393. uv: Nullable<Vector2>;
  141394. /**
  141395. * The current speed of the particle.
  141396. */
  141397. velocity: Vector3;
  141398. /**
  141399. * The pivot point in the particle local space.
  141400. */
  141401. pivot: Vector3;
  141402. /**
  141403. * Must the particle be translated from its pivot point in its local space ?
  141404. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  141405. * Default : false
  141406. */
  141407. translateFromPivot: boolean;
  141408. /**
  141409. * Index of this particle in the global "positions" array (Internal use)
  141410. * @hidden
  141411. */
  141412. _pos: number;
  141413. /**
  141414. * @hidden Index of this particle in the global "indices" array (Internal use)
  141415. */
  141416. _ind: number;
  141417. /**
  141418. * Group this particle belongs to
  141419. */
  141420. _group: PointsGroup;
  141421. /**
  141422. * Group id of this particle
  141423. */
  141424. groupId: number;
  141425. /**
  141426. * Index of the particle in its group id (Internal use)
  141427. */
  141428. idxInGroup: number;
  141429. /**
  141430. * @hidden Particle BoundingInfo object (Internal use)
  141431. */
  141432. _boundingInfo: BoundingInfo;
  141433. /**
  141434. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  141435. */
  141436. _pcs: PointsCloudSystem;
  141437. /**
  141438. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  141439. */
  141440. _stillInvisible: boolean;
  141441. /**
  141442. * @hidden Last computed particle rotation matrix
  141443. */
  141444. _rotationMatrix: number[];
  141445. /**
  141446. * Parent particle Id, if any.
  141447. * Default null.
  141448. */
  141449. parentId: Nullable<number>;
  141450. /**
  141451. * @hidden Internal global position in the PCS.
  141452. */
  141453. _globalPosition: Vector3;
  141454. /**
  141455. * Creates a Point Cloud object.
  141456. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  141457. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  141458. * @param group (PointsGroup) is the group the particle belongs to
  141459. * @param groupId (integer) is the group identifier in the PCS.
  141460. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  141461. * @param pcs defines the PCS it is associated to
  141462. */
  141463. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  141464. /**
  141465. * get point size
  141466. */
  141467. get size(): Vector3;
  141468. /**
  141469. * Set point size
  141470. */
  141471. set size(scale: Vector3);
  141472. /**
  141473. * Legacy support, changed quaternion to rotationQuaternion
  141474. */
  141475. get quaternion(): Nullable<Quaternion>;
  141476. /**
  141477. * Legacy support, changed quaternion to rotationQuaternion
  141478. */
  141479. set quaternion(q: Nullable<Quaternion>);
  141480. /**
  141481. * Returns a boolean. True if the particle intersects a mesh, else false
  141482. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  141483. * @param target is the object (point or mesh) what the intersection is computed against
  141484. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  141485. * @returns true if it intersects
  141486. */
  141487. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  141488. /**
  141489. * get the rotation matrix of the particle
  141490. * @hidden
  141491. */
  141492. getRotationMatrix(m: Matrix): void;
  141493. }
  141494. /**
  141495. * Represents a group of points in a points cloud system
  141496. * * PCS internal tool, don't use it manually.
  141497. */
  141498. export class PointsGroup {
  141499. /**
  141500. * The group id
  141501. * @hidden
  141502. */
  141503. groupID: number;
  141504. /**
  141505. * image data for group (internal use)
  141506. * @hidden
  141507. */
  141508. _groupImageData: Nullable<ArrayBufferView>;
  141509. /**
  141510. * Image Width (internal use)
  141511. * @hidden
  141512. */
  141513. _groupImgWidth: number;
  141514. /**
  141515. * Image Height (internal use)
  141516. * @hidden
  141517. */
  141518. _groupImgHeight: number;
  141519. /**
  141520. * Custom position function (internal use)
  141521. * @hidden
  141522. */
  141523. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  141524. /**
  141525. * density per facet for surface points
  141526. * @hidden
  141527. */
  141528. _groupDensity: number[];
  141529. /**
  141530. * Only when points are colored by texture carries pointer to texture list array
  141531. * @hidden
  141532. */
  141533. _textureNb: number;
  141534. /**
  141535. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  141536. * PCS internal tool, don't use it manually.
  141537. * @hidden
  141538. */
  141539. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  141540. }
  141541. }
  141542. declare module BABYLON {
  141543. interface Scene {
  141544. /** @hidden (Backing field) */
  141545. _physicsEngine: Nullable<IPhysicsEngine>;
  141546. /** @hidden */
  141547. _physicsTimeAccumulator: number;
  141548. /**
  141549. * Gets the current physics engine
  141550. * @returns a IPhysicsEngine or null if none attached
  141551. */
  141552. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  141553. /**
  141554. * Enables physics to the current scene
  141555. * @param gravity defines the scene's gravity for the physics engine
  141556. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  141557. * @return a boolean indicating if the physics engine was initialized
  141558. */
  141559. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  141560. /**
  141561. * Disables and disposes the physics engine associated with the scene
  141562. */
  141563. disablePhysicsEngine(): void;
  141564. /**
  141565. * Gets a boolean indicating if there is an active physics engine
  141566. * @returns a boolean indicating if there is an active physics engine
  141567. */
  141568. isPhysicsEnabled(): boolean;
  141569. /**
  141570. * Deletes a physics compound impostor
  141571. * @param compound defines the compound to delete
  141572. */
  141573. deleteCompoundImpostor(compound: any): void;
  141574. /**
  141575. * An event triggered when physic simulation is about to be run
  141576. */
  141577. onBeforePhysicsObservable: Observable<Scene>;
  141578. /**
  141579. * An event triggered when physic simulation has been done
  141580. */
  141581. onAfterPhysicsObservable: Observable<Scene>;
  141582. }
  141583. interface AbstractMesh {
  141584. /** @hidden */
  141585. _physicsImpostor: Nullable<PhysicsImpostor>;
  141586. /**
  141587. * Gets or sets impostor used for physic simulation
  141588. * @see http://doc.babylonjs.com/features/physics_engine
  141589. */
  141590. physicsImpostor: Nullable<PhysicsImpostor>;
  141591. /**
  141592. * Gets the current physics impostor
  141593. * @see http://doc.babylonjs.com/features/physics_engine
  141594. * @returns a physics impostor or null
  141595. */
  141596. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  141597. /** Apply a physic impulse to the mesh
  141598. * @param force defines the force to apply
  141599. * @param contactPoint defines where to apply the force
  141600. * @returns the current mesh
  141601. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  141602. */
  141603. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  141604. /**
  141605. * Creates a physic joint between two meshes
  141606. * @param otherMesh defines the other mesh to use
  141607. * @param pivot1 defines the pivot to use on this mesh
  141608. * @param pivot2 defines the pivot to use on the other mesh
  141609. * @param options defines additional options (can be plugin dependent)
  141610. * @returns the current mesh
  141611. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  141612. */
  141613. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  141614. /** @hidden */
  141615. _disposePhysicsObserver: Nullable<Observer<Node>>;
  141616. }
  141617. /**
  141618. * Defines the physics engine scene component responsible to manage a physics engine
  141619. */
  141620. export class PhysicsEngineSceneComponent implements ISceneComponent {
  141621. /**
  141622. * The component name helpful to identify the component in the list of scene components.
  141623. */
  141624. readonly name: string;
  141625. /**
  141626. * The scene the component belongs to.
  141627. */
  141628. scene: Scene;
  141629. /**
  141630. * Creates a new instance of the component for the given scene
  141631. * @param scene Defines the scene to register the component in
  141632. */
  141633. constructor(scene: Scene);
  141634. /**
  141635. * Registers the component in a given scene
  141636. */
  141637. register(): void;
  141638. /**
  141639. * Rebuilds the elements related to this component in case of
  141640. * context lost for instance.
  141641. */
  141642. rebuild(): void;
  141643. /**
  141644. * Disposes the component and the associated ressources
  141645. */
  141646. dispose(): void;
  141647. }
  141648. }
  141649. declare module BABYLON {
  141650. /**
  141651. * A helper for physics simulations
  141652. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  141653. */
  141654. export class PhysicsHelper {
  141655. private _scene;
  141656. private _physicsEngine;
  141657. /**
  141658. * Initializes the Physics helper
  141659. * @param scene Babylon.js scene
  141660. */
  141661. constructor(scene: Scene);
  141662. /**
  141663. * Applies a radial explosion impulse
  141664. * @param origin the origin of the explosion
  141665. * @param radiusOrEventOptions the radius or the options of radial explosion
  141666. * @param strength the explosion strength
  141667. * @param falloff possible options: Constant & Linear. Defaults to Constant
  141668. * @returns A physics radial explosion event, or null
  141669. */
  141670. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  141671. /**
  141672. * Applies a radial explosion force
  141673. * @param origin the origin of the explosion
  141674. * @param radiusOrEventOptions the radius or the options of radial explosion
  141675. * @param strength the explosion strength
  141676. * @param falloff possible options: Constant & Linear. Defaults to Constant
  141677. * @returns A physics radial explosion event, or null
  141678. */
  141679. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  141680. /**
  141681. * Creates a gravitational field
  141682. * @param origin the origin of the explosion
  141683. * @param radiusOrEventOptions the radius or the options of radial explosion
  141684. * @param strength the explosion strength
  141685. * @param falloff possible options: Constant & Linear. Defaults to Constant
  141686. * @returns A physics gravitational field event, or null
  141687. */
  141688. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  141689. /**
  141690. * Creates a physics updraft event
  141691. * @param origin the origin of the updraft
  141692. * @param radiusOrEventOptions the radius or the options of the updraft
  141693. * @param strength the strength of the updraft
  141694. * @param height the height of the updraft
  141695. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  141696. * @returns A physics updraft event, or null
  141697. */
  141698. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  141699. /**
  141700. * Creates a physics vortex event
  141701. * @param origin the of the vortex
  141702. * @param radiusOrEventOptions the radius or the options of the vortex
  141703. * @param strength the strength of the vortex
  141704. * @param height the height of the vortex
  141705. * @returns a Physics vortex event, or null
  141706. * A physics vortex event or null
  141707. */
  141708. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  141709. }
  141710. /**
  141711. * Represents a physics radial explosion event
  141712. */
  141713. class PhysicsRadialExplosionEvent {
  141714. private _scene;
  141715. private _options;
  141716. private _sphere;
  141717. private _dataFetched;
  141718. /**
  141719. * Initializes a radial explosioin event
  141720. * @param _scene BabylonJS scene
  141721. * @param _options The options for the vortex event
  141722. */
  141723. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  141724. /**
  141725. * Returns the data related to the radial explosion event (sphere).
  141726. * @returns The radial explosion event data
  141727. */
  141728. getData(): PhysicsRadialExplosionEventData;
  141729. /**
  141730. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  141731. * @param impostor A physics imposter
  141732. * @param origin the origin of the explosion
  141733. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  141734. */
  141735. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  141736. /**
  141737. * Triggers affecterd impostors callbacks
  141738. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  141739. */
  141740. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  141741. /**
  141742. * Disposes the sphere.
  141743. * @param force Specifies if the sphere should be disposed by force
  141744. */
  141745. dispose(force?: boolean): void;
  141746. /*** Helpers ***/
  141747. private _prepareSphere;
  141748. private _intersectsWithSphere;
  141749. }
  141750. /**
  141751. * Represents a gravitational field event
  141752. */
  141753. class PhysicsGravitationalFieldEvent {
  141754. private _physicsHelper;
  141755. private _scene;
  141756. private _origin;
  141757. private _options;
  141758. private _tickCallback;
  141759. private _sphere;
  141760. private _dataFetched;
  141761. /**
  141762. * Initializes the physics gravitational field event
  141763. * @param _physicsHelper A physics helper
  141764. * @param _scene BabylonJS scene
  141765. * @param _origin The origin position of the gravitational field event
  141766. * @param _options The options for the vortex event
  141767. */
  141768. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  141769. /**
  141770. * Returns the data related to the gravitational field event (sphere).
  141771. * @returns A gravitational field event
  141772. */
  141773. getData(): PhysicsGravitationalFieldEventData;
  141774. /**
  141775. * Enables the gravitational field.
  141776. */
  141777. enable(): void;
  141778. /**
  141779. * Disables the gravitational field.
  141780. */
  141781. disable(): void;
  141782. /**
  141783. * Disposes the sphere.
  141784. * @param force The force to dispose from the gravitational field event
  141785. */
  141786. dispose(force?: boolean): void;
  141787. private _tick;
  141788. }
  141789. /**
  141790. * Represents a physics updraft event
  141791. */
  141792. class PhysicsUpdraftEvent {
  141793. private _scene;
  141794. private _origin;
  141795. private _options;
  141796. private _physicsEngine;
  141797. private _originTop;
  141798. private _originDirection;
  141799. private _tickCallback;
  141800. private _cylinder;
  141801. private _cylinderPosition;
  141802. private _dataFetched;
  141803. /**
  141804. * Initializes the physics updraft event
  141805. * @param _scene BabylonJS scene
  141806. * @param _origin The origin position of the updraft
  141807. * @param _options The options for the updraft event
  141808. */
  141809. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  141810. /**
  141811. * Returns the data related to the updraft event (cylinder).
  141812. * @returns A physics updraft event
  141813. */
  141814. getData(): PhysicsUpdraftEventData;
  141815. /**
  141816. * Enables the updraft.
  141817. */
  141818. enable(): void;
  141819. /**
  141820. * Disables the updraft.
  141821. */
  141822. disable(): void;
  141823. /**
  141824. * Disposes the cylinder.
  141825. * @param force Specifies if the updraft should be disposed by force
  141826. */
  141827. dispose(force?: boolean): void;
  141828. private getImpostorHitData;
  141829. private _tick;
  141830. /*** Helpers ***/
  141831. private _prepareCylinder;
  141832. private _intersectsWithCylinder;
  141833. }
  141834. /**
  141835. * Represents a physics vortex event
  141836. */
  141837. class PhysicsVortexEvent {
  141838. private _scene;
  141839. private _origin;
  141840. private _options;
  141841. private _physicsEngine;
  141842. private _originTop;
  141843. private _tickCallback;
  141844. private _cylinder;
  141845. private _cylinderPosition;
  141846. private _dataFetched;
  141847. /**
  141848. * Initializes the physics vortex event
  141849. * @param _scene The BabylonJS scene
  141850. * @param _origin The origin position of the vortex
  141851. * @param _options The options for the vortex event
  141852. */
  141853. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  141854. /**
  141855. * Returns the data related to the vortex event (cylinder).
  141856. * @returns The physics vortex event data
  141857. */
  141858. getData(): PhysicsVortexEventData;
  141859. /**
  141860. * Enables the vortex.
  141861. */
  141862. enable(): void;
  141863. /**
  141864. * Disables the cortex.
  141865. */
  141866. disable(): void;
  141867. /**
  141868. * Disposes the sphere.
  141869. * @param force
  141870. */
  141871. dispose(force?: boolean): void;
  141872. private getImpostorHitData;
  141873. private _tick;
  141874. /*** Helpers ***/
  141875. private _prepareCylinder;
  141876. private _intersectsWithCylinder;
  141877. }
  141878. /**
  141879. * Options fot the radial explosion event
  141880. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  141881. */
  141882. export class PhysicsRadialExplosionEventOptions {
  141883. /**
  141884. * The radius of the sphere for the radial explosion.
  141885. */
  141886. radius: number;
  141887. /**
  141888. * The strenth of the explosion.
  141889. */
  141890. strength: number;
  141891. /**
  141892. * The strenght of the force in correspondence to the distance of the affected object
  141893. */
  141894. falloff: PhysicsRadialImpulseFalloff;
  141895. /**
  141896. * Sphere options for the radial explosion.
  141897. */
  141898. sphere: {
  141899. segments: number;
  141900. diameter: number;
  141901. };
  141902. /**
  141903. * Sphere options for the radial explosion.
  141904. */
  141905. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  141906. }
  141907. /**
  141908. * Options fot the updraft event
  141909. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  141910. */
  141911. export class PhysicsUpdraftEventOptions {
  141912. /**
  141913. * The radius of the cylinder for the vortex
  141914. */
  141915. radius: number;
  141916. /**
  141917. * The strenth of the updraft.
  141918. */
  141919. strength: number;
  141920. /**
  141921. * The height of the cylinder for the updraft.
  141922. */
  141923. height: number;
  141924. /**
  141925. * The mode for the the updraft.
  141926. */
  141927. updraftMode: PhysicsUpdraftMode;
  141928. }
  141929. /**
  141930. * Options fot the vortex event
  141931. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  141932. */
  141933. export class PhysicsVortexEventOptions {
  141934. /**
  141935. * The radius of the cylinder for the vortex
  141936. */
  141937. radius: number;
  141938. /**
  141939. * The strenth of the vortex.
  141940. */
  141941. strength: number;
  141942. /**
  141943. * The height of the cylinder for the vortex.
  141944. */
  141945. height: number;
  141946. /**
  141947. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  141948. */
  141949. centripetalForceThreshold: number;
  141950. /**
  141951. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  141952. */
  141953. centripetalForceMultiplier: number;
  141954. /**
  141955. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  141956. */
  141957. centrifugalForceMultiplier: number;
  141958. /**
  141959. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  141960. */
  141961. updraftForceMultiplier: number;
  141962. }
  141963. /**
  141964. * The strenght of the force in correspondence to the distance of the affected object
  141965. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  141966. */
  141967. export enum PhysicsRadialImpulseFalloff {
  141968. /** Defines that impulse is constant in strength across it's whole radius */
  141969. Constant = 0,
  141970. /** Defines that impulse gets weaker if it's further from the origin */
  141971. Linear = 1
  141972. }
  141973. /**
  141974. * The strength of the force in correspondence to the distance of the affected object
  141975. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  141976. */
  141977. export enum PhysicsUpdraftMode {
  141978. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  141979. Center = 0,
  141980. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  141981. Perpendicular = 1
  141982. }
  141983. /**
  141984. * Interface for a physics hit data
  141985. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  141986. */
  141987. export interface PhysicsHitData {
  141988. /**
  141989. * The force applied at the contact point
  141990. */
  141991. force: Vector3;
  141992. /**
  141993. * The contact point
  141994. */
  141995. contactPoint: Vector3;
  141996. /**
  141997. * The distance from the origin to the contact point
  141998. */
  141999. distanceFromOrigin: number;
  142000. }
  142001. /**
  142002. * Interface for radial explosion event data
  142003. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  142004. */
  142005. export interface PhysicsRadialExplosionEventData {
  142006. /**
  142007. * A sphere used for the radial explosion event
  142008. */
  142009. sphere: Mesh;
  142010. }
  142011. /**
  142012. * Interface for gravitational field event data
  142013. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  142014. */
  142015. export interface PhysicsGravitationalFieldEventData {
  142016. /**
  142017. * A sphere mesh used for the gravitational field event
  142018. */
  142019. sphere: Mesh;
  142020. }
  142021. /**
  142022. * Interface for updraft event data
  142023. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  142024. */
  142025. export interface PhysicsUpdraftEventData {
  142026. /**
  142027. * A cylinder used for the updraft event
  142028. */
  142029. cylinder: Mesh;
  142030. }
  142031. /**
  142032. * Interface for vortex event data
  142033. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  142034. */
  142035. export interface PhysicsVortexEventData {
  142036. /**
  142037. * A cylinder used for the vortex event
  142038. */
  142039. cylinder: Mesh;
  142040. }
  142041. /**
  142042. * Interface for an affected physics impostor
  142043. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  142044. */
  142045. export interface PhysicsAffectedImpostorWithData {
  142046. /**
  142047. * The impostor affected by the effect
  142048. */
  142049. impostor: PhysicsImpostor;
  142050. /**
  142051. * The data about the hit/horce from the explosion
  142052. */
  142053. hitData: PhysicsHitData;
  142054. }
  142055. }
  142056. declare module BABYLON {
  142057. /** @hidden */
  142058. export var blackAndWhitePixelShader: {
  142059. name: string;
  142060. shader: string;
  142061. };
  142062. }
  142063. declare module BABYLON {
  142064. /**
  142065. * Post process used to render in black and white
  142066. */
  142067. export class BlackAndWhitePostProcess extends PostProcess {
  142068. /**
  142069. * Linear about to convert he result to black and white (default: 1)
  142070. */
  142071. degree: number;
  142072. /**
  142073. * Creates a black and white post process
  142074. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  142075. * @param name The name of the effect.
  142076. * @param options The required width/height ratio to downsize to before computing the render pass.
  142077. * @param camera The camera to apply the render pass to.
  142078. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  142079. * @param engine The engine which the post process will be applied. (default: current engine)
  142080. * @param reusable If the post process can be reused on the same frame. (default: false)
  142081. */
  142082. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  142083. }
  142084. }
  142085. declare module BABYLON {
  142086. /**
  142087. * This represents a set of one or more post processes in Babylon.
  142088. * A post process can be used to apply a shader to a texture after it is rendered.
  142089. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  142090. */
  142091. export class PostProcessRenderEffect {
  142092. private _postProcesses;
  142093. private _getPostProcesses;
  142094. private _singleInstance;
  142095. private _cameras;
  142096. private _indicesForCamera;
  142097. /**
  142098. * Name of the effect
  142099. * @hidden
  142100. */
  142101. _name: string;
  142102. /**
  142103. * Instantiates a post process render effect.
  142104. * A post process can be used to apply a shader to a texture after it is rendered.
  142105. * @param engine The engine the effect is tied to
  142106. * @param name The name of the effect
  142107. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  142108. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  142109. */
  142110. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  142111. /**
  142112. * Checks if all the post processes in the effect are supported.
  142113. */
  142114. get isSupported(): boolean;
  142115. /**
  142116. * Updates the current state of the effect
  142117. * @hidden
  142118. */
  142119. _update(): void;
  142120. /**
  142121. * Attaches the effect on cameras
  142122. * @param cameras The camera to attach to.
  142123. * @hidden
  142124. */
  142125. _attachCameras(cameras: Camera): void;
  142126. /**
  142127. * Attaches the effect on cameras
  142128. * @param cameras The camera to attach to.
  142129. * @hidden
  142130. */
  142131. _attachCameras(cameras: Camera[]): void;
  142132. /**
  142133. * Detaches the effect on cameras
  142134. * @param cameras The camera to detatch from.
  142135. * @hidden
  142136. */
  142137. _detachCameras(cameras: Camera): void;
  142138. /**
  142139. * Detatches the effect on cameras
  142140. * @param cameras The camera to detatch from.
  142141. * @hidden
  142142. */
  142143. _detachCameras(cameras: Camera[]): void;
  142144. /**
  142145. * Enables the effect on given cameras
  142146. * @param cameras The camera to enable.
  142147. * @hidden
  142148. */
  142149. _enable(cameras: Camera): void;
  142150. /**
  142151. * Enables the effect on given cameras
  142152. * @param cameras The camera to enable.
  142153. * @hidden
  142154. */
  142155. _enable(cameras: Nullable<Camera[]>): void;
  142156. /**
  142157. * Disables the effect on the given cameras
  142158. * @param cameras The camera to disable.
  142159. * @hidden
  142160. */
  142161. _disable(cameras: Camera): void;
  142162. /**
  142163. * Disables the effect on the given cameras
  142164. * @param cameras The camera to disable.
  142165. * @hidden
  142166. */
  142167. _disable(cameras: Nullable<Camera[]>): void;
  142168. /**
  142169. * Gets a list of the post processes contained in the effect.
  142170. * @param camera The camera to get the post processes on.
  142171. * @returns The list of the post processes in the effect.
  142172. */
  142173. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  142174. }
  142175. }
  142176. declare module BABYLON {
  142177. /** @hidden */
  142178. export var extractHighlightsPixelShader: {
  142179. name: string;
  142180. shader: string;
  142181. };
  142182. }
  142183. declare module BABYLON {
  142184. /**
  142185. * 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.
  142186. */
  142187. export class ExtractHighlightsPostProcess extends PostProcess {
  142188. /**
  142189. * The luminance threshold, pixels below this value will be set to black.
  142190. */
  142191. threshold: number;
  142192. /** @hidden */
  142193. _exposure: number;
  142194. /**
  142195. * Post process which has the input texture to be used when performing highlight extraction
  142196. * @hidden
  142197. */
  142198. _inputPostProcess: Nullable<PostProcess>;
  142199. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  142200. }
  142201. }
  142202. declare module BABYLON {
  142203. /** @hidden */
  142204. export var bloomMergePixelShader: {
  142205. name: string;
  142206. shader: string;
  142207. };
  142208. }
  142209. declare module BABYLON {
  142210. /**
  142211. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  142212. */
  142213. export class BloomMergePostProcess extends PostProcess {
  142214. /** Weight of the bloom to be added to the original input. */
  142215. weight: number;
  142216. /**
  142217. * Creates a new instance of @see BloomMergePostProcess
  142218. * @param name The name of the effect.
  142219. * @param originalFromInput Post process which's input will be used for the merge.
  142220. * @param blurred Blurred highlights post process which's output will be used.
  142221. * @param weight Weight of the bloom to be added to the original input.
  142222. * @param options The required width/height ratio to downsize to before computing the render pass.
  142223. * @param camera The camera to apply the render pass to.
  142224. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  142225. * @param engine The engine which the post process will be applied. (default: current engine)
  142226. * @param reusable If the post process can be reused on the same frame. (default: false)
  142227. * @param textureType Type of textures used when performing the post process. (default: 0)
  142228. * @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)
  142229. */
  142230. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  142231. /** Weight of the bloom to be added to the original input. */
  142232. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  142233. }
  142234. }
  142235. declare module BABYLON {
  142236. /**
  142237. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  142238. */
  142239. export class BloomEffect extends PostProcessRenderEffect {
  142240. private bloomScale;
  142241. /**
  142242. * @hidden Internal
  142243. */
  142244. _effects: Array<PostProcess>;
  142245. /**
  142246. * @hidden Internal
  142247. */
  142248. _downscale: ExtractHighlightsPostProcess;
  142249. private _blurX;
  142250. private _blurY;
  142251. private _merge;
  142252. /**
  142253. * The luminance threshold to find bright areas of the image to bloom.
  142254. */
  142255. get threshold(): number;
  142256. set threshold(value: number);
  142257. /**
  142258. * The strength of the bloom.
  142259. */
  142260. get weight(): number;
  142261. set weight(value: number);
  142262. /**
  142263. * Specifies the size of the bloom blur kernel, relative to the final output size
  142264. */
  142265. get kernel(): number;
  142266. set kernel(value: number);
  142267. /**
  142268. * Creates a new instance of @see BloomEffect
  142269. * @param scene The scene the effect belongs to.
  142270. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  142271. * @param bloomKernel The size of the kernel to be used when applying the blur.
  142272. * @param bloomWeight The the strength of bloom.
  142273. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  142274. * @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)
  142275. */
  142276. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  142277. /**
  142278. * Disposes each of the internal effects for a given camera.
  142279. * @param camera The camera to dispose the effect on.
  142280. */
  142281. disposeEffects(camera: Camera): void;
  142282. /**
  142283. * @hidden Internal
  142284. */
  142285. _updateEffects(): void;
  142286. /**
  142287. * Internal
  142288. * @returns if all the contained post processes are ready.
  142289. * @hidden
  142290. */
  142291. _isReady(): boolean;
  142292. }
  142293. }
  142294. declare module BABYLON {
  142295. /** @hidden */
  142296. export var chromaticAberrationPixelShader: {
  142297. name: string;
  142298. shader: string;
  142299. };
  142300. }
  142301. declare module BABYLON {
  142302. /**
  142303. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  142304. */
  142305. export class ChromaticAberrationPostProcess extends PostProcess {
  142306. /**
  142307. * The amount of seperation of rgb channels (default: 30)
  142308. */
  142309. aberrationAmount: number;
  142310. /**
  142311. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  142312. */
  142313. radialIntensity: number;
  142314. /**
  142315. * 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))
  142316. */
  142317. direction: Vector2;
  142318. /**
  142319. * 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))
  142320. */
  142321. centerPosition: Vector2;
  142322. /**
  142323. * Creates a new instance ChromaticAberrationPostProcess
  142324. * @param name The name of the effect.
  142325. * @param screenWidth The width of the screen to apply the effect on.
  142326. * @param screenHeight The height of the screen to apply the effect on.
  142327. * @param options The required width/height ratio to downsize to before computing the render pass.
  142328. * @param camera The camera to apply the render pass to.
  142329. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  142330. * @param engine The engine which the post process will be applied. (default: current engine)
  142331. * @param reusable If the post process can be reused on the same frame. (default: false)
  142332. * @param textureType Type of textures used when performing the post process. (default: 0)
  142333. * @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)
  142334. */
  142335. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  142336. }
  142337. }
  142338. declare module BABYLON {
  142339. /** @hidden */
  142340. export var circleOfConfusionPixelShader: {
  142341. name: string;
  142342. shader: string;
  142343. };
  142344. }
  142345. declare module BABYLON {
  142346. /**
  142347. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  142348. */
  142349. export class CircleOfConfusionPostProcess extends PostProcess {
  142350. /**
  142351. * 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.
  142352. */
  142353. lensSize: number;
  142354. /**
  142355. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  142356. */
  142357. fStop: number;
  142358. /**
  142359. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  142360. */
  142361. focusDistance: number;
  142362. /**
  142363. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  142364. */
  142365. focalLength: number;
  142366. private _depthTexture;
  142367. /**
  142368. * Creates a new instance CircleOfConfusionPostProcess
  142369. * @param name The name of the effect.
  142370. * @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.
  142371. * @param options The required width/height ratio to downsize to before computing the render pass.
  142372. * @param camera The camera to apply the render pass to.
  142373. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  142374. * @param engine The engine which the post process will be applied. (default: current engine)
  142375. * @param reusable If the post process can be reused on the same frame. (default: false)
  142376. * @param textureType Type of textures used when performing the post process. (default: 0)
  142377. * @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)
  142378. */
  142379. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  142380. /**
  142381. * 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.
  142382. */
  142383. set depthTexture(value: RenderTargetTexture);
  142384. }
  142385. }
  142386. declare module BABYLON {
  142387. /** @hidden */
  142388. export var colorCorrectionPixelShader: {
  142389. name: string;
  142390. shader: string;
  142391. };
  142392. }
  142393. declare module BABYLON {
  142394. /**
  142395. *
  142396. * This post-process allows the modification of rendered colors by using
  142397. * a 'look-up table' (LUT). This effect is also called Color Grading.
  142398. *
  142399. * The object needs to be provided an url to a texture containing the color
  142400. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  142401. * Use an image editing software to tweak the LUT to match your needs.
  142402. *
  142403. * For an example of a color LUT, see here:
  142404. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  142405. * For explanations on color grading, see here:
  142406. * @see http://udn.epicgames.com/Three/ColorGrading.html
  142407. *
  142408. */
  142409. export class ColorCorrectionPostProcess extends PostProcess {
  142410. private _colorTableTexture;
  142411. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  142412. }
  142413. }
  142414. declare module BABYLON {
  142415. /** @hidden */
  142416. export var convolutionPixelShader: {
  142417. name: string;
  142418. shader: string;
  142419. };
  142420. }
  142421. declare module BABYLON {
  142422. /**
  142423. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  142424. * input texture to perform effects such as edge detection or sharpening
  142425. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  142426. */
  142427. export class ConvolutionPostProcess extends PostProcess {
  142428. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  142429. kernel: number[];
  142430. /**
  142431. * Creates a new instance ConvolutionPostProcess
  142432. * @param name The name of the effect.
  142433. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  142434. * @param options The required width/height ratio to downsize to before computing the render pass.
  142435. * @param camera The camera to apply the render pass to.
  142436. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  142437. * @param engine The engine which the post process will be applied. (default: current engine)
  142438. * @param reusable If the post process can be reused on the same frame. (default: false)
  142439. * @param textureType Type of textures used when performing the post process. (default: 0)
  142440. */
  142441. constructor(name: string,
  142442. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  142443. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  142444. /**
  142445. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  142446. */
  142447. static EdgeDetect0Kernel: number[];
  142448. /**
  142449. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  142450. */
  142451. static EdgeDetect1Kernel: number[];
  142452. /**
  142453. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  142454. */
  142455. static EdgeDetect2Kernel: number[];
  142456. /**
  142457. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  142458. */
  142459. static SharpenKernel: number[];
  142460. /**
  142461. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  142462. */
  142463. static EmbossKernel: number[];
  142464. /**
  142465. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  142466. */
  142467. static GaussianKernel: number[];
  142468. }
  142469. }
  142470. declare module BABYLON {
  142471. /**
  142472. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  142473. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  142474. * based on samples that have a large difference in distance than the center pixel.
  142475. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  142476. */
  142477. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  142478. direction: Vector2;
  142479. /**
  142480. * Creates a new instance CircleOfConfusionPostProcess
  142481. * @param name The name of the effect.
  142482. * @param scene The scene the effect belongs to.
  142483. * @param direction The direction the blur should be applied.
  142484. * @param kernel The size of the kernel used to blur.
  142485. * @param options The required width/height ratio to downsize to before computing the render pass.
  142486. * @param camera The camera to apply the render pass to.
  142487. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  142488. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  142489. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  142490. * @param engine The engine which the post process will be applied. (default: current engine)
  142491. * @param reusable If the post process can be reused on the same frame. (default: false)
  142492. * @param textureType Type of textures used when performing the post process. (default: 0)
  142493. * @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)
  142494. */
  142495. 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);
  142496. }
  142497. }
  142498. declare module BABYLON {
  142499. /** @hidden */
  142500. export var depthOfFieldMergePixelShader: {
  142501. name: string;
  142502. shader: string;
  142503. };
  142504. }
  142505. declare module BABYLON {
  142506. /**
  142507. * Options to be set when merging outputs from the default pipeline.
  142508. */
  142509. export class DepthOfFieldMergePostProcessOptions {
  142510. /**
  142511. * The original image to merge on top of
  142512. */
  142513. originalFromInput: PostProcess;
  142514. /**
  142515. * Parameters to perform the merge of the depth of field effect
  142516. */
  142517. depthOfField?: {
  142518. circleOfConfusion: PostProcess;
  142519. blurSteps: Array<PostProcess>;
  142520. };
  142521. /**
  142522. * Parameters to perform the merge of bloom effect
  142523. */
  142524. bloom?: {
  142525. blurred: PostProcess;
  142526. weight: number;
  142527. };
  142528. }
  142529. /**
  142530. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  142531. */
  142532. export class DepthOfFieldMergePostProcess extends PostProcess {
  142533. private blurSteps;
  142534. /**
  142535. * Creates a new instance of DepthOfFieldMergePostProcess
  142536. * @param name The name of the effect.
  142537. * @param originalFromInput Post process which's input will be used for the merge.
  142538. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  142539. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  142540. * @param options The required width/height ratio to downsize to before computing the render pass.
  142541. * @param camera The camera to apply the render pass to.
  142542. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  142543. * @param engine The engine which the post process will be applied. (default: current engine)
  142544. * @param reusable If the post process can be reused on the same frame. (default: false)
  142545. * @param textureType Type of textures used when performing the post process. (default: 0)
  142546. * @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)
  142547. */
  142548. 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);
  142549. /**
  142550. * Updates the effect with the current post process compile time values and recompiles the shader.
  142551. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  142552. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  142553. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  142554. * @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
  142555. * @param onCompiled Called when the shader has been compiled.
  142556. * @param onError Called if there is an error when compiling a shader.
  142557. */
  142558. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  142559. }
  142560. }
  142561. declare module BABYLON {
  142562. /**
  142563. * Specifies the level of max blur that should be applied when using the depth of field effect
  142564. */
  142565. export enum DepthOfFieldEffectBlurLevel {
  142566. /**
  142567. * Subtle blur
  142568. */
  142569. Low = 0,
  142570. /**
  142571. * Medium blur
  142572. */
  142573. Medium = 1,
  142574. /**
  142575. * Large blur
  142576. */
  142577. High = 2
  142578. }
  142579. /**
  142580. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  142581. */
  142582. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  142583. private _circleOfConfusion;
  142584. /**
  142585. * @hidden Internal, blurs from high to low
  142586. */
  142587. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  142588. private _depthOfFieldBlurY;
  142589. private _dofMerge;
  142590. /**
  142591. * @hidden Internal post processes in depth of field effect
  142592. */
  142593. _effects: Array<PostProcess>;
  142594. /**
  142595. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  142596. */
  142597. set focalLength(value: number);
  142598. get focalLength(): number;
  142599. /**
  142600. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  142601. */
  142602. set fStop(value: number);
  142603. get fStop(): number;
  142604. /**
  142605. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  142606. */
  142607. set focusDistance(value: number);
  142608. get focusDistance(): number;
  142609. /**
  142610. * 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.
  142611. */
  142612. set lensSize(value: number);
  142613. get lensSize(): number;
  142614. /**
  142615. * Creates a new instance DepthOfFieldEffect
  142616. * @param scene The scene the effect belongs to.
  142617. * @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.
  142618. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  142619. * @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)
  142620. */
  142621. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  142622. /**
  142623. * Get the current class name of the current effet
  142624. * @returns "DepthOfFieldEffect"
  142625. */
  142626. getClassName(): string;
  142627. /**
  142628. * 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.
  142629. */
  142630. set depthTexture(value: RenderTargetTexture);
  142631. /**
  142632. * Disposes each of the internal effects for a given camera.
  142633. * @param camera The camera to dispose the effect on.
  142634. */
  142635. disposeEffects(camera: Camera): void;
  142636. /**
  142637. * @hidden Internal
  142638. */
  142639. _updateEffects(): void;
  142640. /**
  142641. * Internal
  142642. * @returns if all the contained post processes are ready.
  142643. * @hidden
  142644. */
  142645. _isReady(): boolean;
  142646. }
  142647. }
  142648. declare module BABYLON {
  142649. /** @hidden */
  142650. export var displayPassPixelShader: {
  142651. name: string;
  142652. shader: string;
  142653. };
  142654. }
  142655. declare module BABYLON {
  142656. /**
  142657. * DisplayPassPostProcess which produces an output the same as it's input
  142658. */
  142659. export class DisplayPassPostProcess extends PostProcess {
  142660. /**
  142661. * Creates the DisplayPassPostProcess
  142662. * @param name The name of the effect.
  142663. * @param options The required width/height ratio to downsize to before computing the render pass.
  142664. * @param camera The camera to apply the render pass to.
  142665. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  142666. * @param engine The engine which the post process will be applied. (default: current engine)
  142667. * @param reusable If the post process can be reused on the same frame. (default: false)
  142668. */
  142669. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  142670. }
  142671. }
  142672. declare module BABYLON {
  142673. /** @hidden */
  142674. export var filterPixelShader: {
  142675. name: string;
  142676. shader: string;
  142677. };
  142678. }
  142679. declare module BABYLON {
  142680. /**
  142681. * Applies a kernel filter to the image
  142682. */
  142683. export class FilterPostProcess extends PostProcess {
  142684. /** The matrix to be applied to the image */
  142685. kernelMatrix: Matrix;
  142686. /**
  142687. *
  142688. * @param name The name of the effect.
  142689. * @param kernelMatrix The matrix to be applied to the image
  142690. * @param options The required width/height ratio to downsize to before computing the render pass.
  142691. * @param camera The camera to apply the render pass to.
  142692. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  142693. * @param engine The engine which the post process will be applied. (default: current engine)
  142694. * @param reusable If the post process can be reused on the same frame. (default: false)
  142695. */
  142696. constructor(name: string,
  142697. /** The matrix to be applied to the image */
  142698. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  142699. }
  142700. }
  142701. declare module BABYLON {
  142702. /** @hidden */
  142703. export var fxaaPixelShader: {
  142704. name: string;
  142705. shader: string;
  142706. };
  142707. }
  142708. declare module BABYLON {
  142709. /** @hidden */
  142710. export var fxaaVertexShader: {
  142711. name: string;
  142712. shader: string;
  142713. };
  142714. }
  142715. declare module BABYLON {
  142716. /**
  142717. * Fxaa post process
  142718. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  142719. */
  142720. export class FxaaPostProcess extends PostProcess {
  142721. /** @hidden */
  142722. texelWidth: number;
  142723. /** @hidden */
  142724. texelHeight: number;
  142725. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  142726. private _getDefines;
  142727. }
  142728. }
  142729. declare module BABYLON {
  142730. /** @hidden */
  142731. export var grainPixelShader: {
  142732. name: string;
  142733. shader: string;
  142734. };
  142735. }
  142736. declare module BABYLON {
  142737. /**
  142738. * The GrainPostProcess adds noise to the image at mid luminance levels
  142739. */
  142740. export class GrainPostProcess extends PostProcess {
  142741. /**
  142742. * The intensity of the grain added (default: 30)
  142743. */
  142744. intensity: number;
  142745. /**
  142746. * If the grain should be randomized on every frame
  142747. */
  142748. animated: boolean;
  142749. /**
  142750. * Creates a new instance of @see GrainPostProcess
  142751. * @param name The name of the effect.
  142752. * @param options The required width/height ratio to downsize to before computing the render pass.
  142753. * @param camera The camera to apply the render pass to.
  142754. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  142755. * @param engine The engine which the post process will be applied. (default: current engine)
  142756. * @param reusable If the post process can be reused on the same frame. (default: false)
  142757. * @param textureType Type of textures used when performing the post process. (default: 0)
  142758. * @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)
  142759. */
  142760. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  142761. }
  142762. }
  142763. declare module BABYLON {
  142764. /** @hidden */
  142765. export var highlightsPixelShader: {
  142766. name: string;
  142767. shader: string;
  142768. };
  142769. }
  142770. declare module BABYLON {
  142771. /**
  142772. * Extracts highlights from the image
  142773. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  142774. */
  142775. export class HighlightsPostProcess extends PostProcess {
  142776. /**
  142777. * Extracts highlights from the image
  142778. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  142779. * @param name The name of the effect.
  142780. * @param options The required width/height ratio to downsize to before computing the render pass.
  142781. * @param camera The camera to apply the render pass to.
  142782. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  142783. * @param engine The engine which the post process will be applied. (default: current engine)
  142784. * @param reusable If the post process can be reused on the same frame. (default: false)
  142785. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  142786. */
  142787. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  142788. }
  142789. }
  142790. declare module BABYLON {
  142791. /** @hidden */
  142792. export var mrtFragmentDeclaration: {
  142793. name: string;
  142794. shader: string;
  142795. };
  142796. }
  142797. declare module BABYLON {
  142798. /** @hidden */
  142799. export var geometryPixelShader: {
  142800. name: string;
  142801. shader: string;
  142802. };
  142803. }
  142804. declare module BABYLON {
  142805. /** @hidden */
  142806. export var geometryVertexShader: {
  142807. name: string;
  142808. shader: string;
  142809. };
  142810. }
  142811. declare module BABYLON {
  142812. /** @hidden */
  142813. interface ISavedTransformationMatrix {
  142814. world: Matrix;
  142815. viewProjection: Matrix;
  142816. }
  142817. /**
  142818. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  142819. */
  142820. export class GeometryBufferRenderer {
  142821. /**
  142822. * Constant used to retrieve the position texture index in the G-Buffer textures array
  142823. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  142824. */
  142825. static readonly POSITION_TEXTURE_TYPE: number;
  142826. /**
  142827. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  142828. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  142829. */
  142830. static readonly VELOCITY_TEXTURE_TYPE: number;
  142831. /**
  142832. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  142833. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  142834. */
  142835. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  142836. /**
  142837. * Dictionary used to store the previous transformation matrices of each rendered mesh
  142838. * in order to compute objects velocities when enableVelocity is set to "true"
  142839. * @hidden
  142840. */
  142841. _previousTransformationMatrices: {
  142842. [index: number]: ISavedTransformationMatrix;
  142843. };
  142844. /**
  142845. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  142846. * in order to compute objects velocities when enableVelocity is set to "true"
  142847. * @hidden
  142848. */
  142849. _previousBonesTransformationMatrices: {
  142850. [index: number]: Float32Array;
  142851. };
  142852. /**
  142853. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  142854. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  142855. */
  142856. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  142857. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  142858. renderTransparentMeshes: boolean;
  142859. private _scene;
  142860. private _multiRenderTarget;
  142861. private _ratio;
  142862. private _enablePosition;
  142863. private _enableVelocity;
  142864. private _enableReflectivity;
  142865. private _positionIndex;
  142866. private _velocityIndex;
  142867. private _reflectivityIndex;
  142868. protected _effect: Effect;
  142869. protected _cachedDefines: string;
  142870. /**
  142871. * Set the render list (meshes to be rendered) used in the G buffer.
  142872. */
  142873. set renderList(meshes: Mesh[]);
  142874. /**
  142875. * Gets wether or not G buffer are supported by the running hardware.
  142876. * This requires draw buffer supports
  142877. */
  142878. get isSupported(): boolean;
  142879. /**
  142880. * Returns the index of the given texture type in the G-Buffer textures array
  142881. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  142882. * @returns the index of the given texture type in the G-Buffer textures array
  142883. */
  142884. getTextureIndex(textureType: number): number;
  142885. /**
  142886. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  142887. */
  142888. get enablePosition(): boolean;
  142889. /**
  142890. * Sets whether or not objects positions are enabled for the G buffer.
  142891. */
  142892. set enablePosition(enable: boolean);
  142893. /**
  142894. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  142895. */
  142896. get enableVelocity(): boolean;
  142897. /**
  142898. * Sets wether or not objects velocities are enabled for the G buffer.
  142899. */
  142900. set enableVelocity(enable: boolean);
  142901. /**
  142902. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  142903. */
  142904. get enableReflectivity(): boolean;
  142905. /**
  142906. * Sets wether or not objects roughness are enabled for the G buffer.
  142907. */
  142908. set enableReflectivity(enable: boolean);
  142909. /**
  142910. * Gets the scene associated with the buffer.
  142911. */
  142912. get scene(): Scene;
  142913. /**
  142914. * Gets the ratio used by the buffer during its creation.
  142915. * How big is the buffer related to the main canvas.
  142916. */
  142917. get ratio(): number;
  142918. /** @hidden */
  142919. static _SceneComponentInitialization: (scene: Scene) => void;
  142920. /**
  142921. * Creates a new G Buffer for the scene
  142922. * @param scene The scene the buffer belongs to
  142923. * @param ratio How big is the buffer related to the main canvas.
  142924. */
  142925. constructor(scene: Scene, ratio?: number);
  142926. /**
  142927. * Checks wether everything is ready to render a submesh to the G buffer.
  142928. * @param subMesh the submesh to check readiness for
  142929. * @param useInstances is the mesh drawn using instance or not
  142930. * @returns true if ready otherwise false
  142931. */
  142932. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  142933. /**
  142934. * Gets the current underlying G Buffer.
  142935. * @returns the buffer
  142936. */
  142937. getGBuffer(): MultiRenderTarget;
  142938. /**
  142939. * Gets the number of samples used to render the buffer (anti aliasing).
  142940. */
  142941. get samples(): number;
  142942. /**
  142943. * Sets the number of samples used to render the buffer (anti aliasing).
  142944. */
  142945. set samples(value: number);
  142946. /**
  142947. * Disposes the renderer and frees up associated resources.
  142948. */
  142949. dispose(): void;
  142950. protected _createRenderTargets(): void;
  142951. private _copyBonesTransformationMatrices;
  142952. }
  142953. }
  142954. declare module BABYLON {
  142955. interface Scene {
  142956. /** @hidden (Backing field) */
  142957. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  142958. /**
  142959. * Gets or Sets the current geometry buffer associated to the scene.
  142960. */
  142961. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  142962. /**
  142963. * Enables a GeometryBufferRender and associates it with the scene
  142964. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  142965. * @returns the GeometryBufferRenderer
  142966. */
  142967. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  142968. /**
  142969. * Disables the GeometryBufferRender associated with the scene
  142970. */
  142971. disableGeometryBufferRenderer(): void;
  142972. }
  142973. /**
  142974. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  142975. * in several rendering techniques.
  142976. */
  142977. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  142978. /**
  142979. * The component name helpful to identify the component in the list of scene components.
  142980. */
  142981. readonly name: string;
  142982. /**
  142983. * The scene the component belongs to.
  142984. */
  142985. scene: Scene;
  142986. /**
  142987. * Creates a new instance of the component for the given scene
  142988. * @param scene Defines the scene to register the component in
  142989. */
  142990. constructor(scene: Scene);
  142991. /**
  142992. * Registers the component in a given scene
  142993. */
  142994. register(): void;
  142995. /**
  142996. * Rebuilds the elements related to this component in case of
  142997. * context lost for instance.
  142998. */
  142999. rebuild(): void;
  143000. /**
  143001. * Disposes the component and the associated ressources
  143002. */
  143003. dispose(): void;
  143004. private _gatherRenderTargets;
  143005. }
  143006. }
  143007. declare module BABYLON {
  143008. /** @hidden */
  143009. export var motionBlurPixelShader: {
  143010. name: string;
  143011. shader: string;
  143012. };
  143013. }
  143014. declare module BABYLON {
  143015. /**
  143016. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  143017. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  143018. * As an example, all you have to do is to create the post-process:
  143019. * var mb = new BABYLON.MotionBlurPostProcess(
  143020. * 'mb', // The name of the effect.
  143021. * scene, // The scene containing the objects to blur according to their velocity.
  143022. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  143023. * camera // The camera to apply the render pass to.
  143024. * );
  143025. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  143026. */
  143027. export class MotionBlurPostProcess extends PostProcess {
  143028. /**
  143029. * Defines how much the image is blurred by the movement. Default value is equal to 1
  143030. */
  143031. motionStrength: number;
  143032. /**
  143033. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  143034. */
  143035. get motionBlurSamples(): number;
  143036. /**
  143037. * Sets the number of iterations to be used for motion blur quality
  143038. */
  143039. set motionBlurSamples(samples: number);
  143040. private _motionBlurSamples;
  143041. private _geometryBufferRenderer;
  143042. /**
  143043. * Creates a new instance MotionBlurPostProcess
  143044. * @param name The name of the effect.
  143045. * @param scene The scene containing the objects to blur according to their velocity.
  143046. * @param options The required width/height ratio to downsize to before computing the render pass.
  143047. * @param camera The camera to apply the render pass to.
  143048. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  143049. * @param engine The engine which the post process will be applied. (default: current engine)
  143050. * @param reusable If the post process can be reused on the same frame. (default: false)
  143051. * @param textureType Type of textures used when performing the post process. (default: 0)
  143052. * @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)
  143053. */
  143054. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  143055. /**
  143056. * Excludes the given skinned mesh from computing bones velocities.
  143057. * 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.
  143058. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  143059. */
  143060. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  143061. /**
  143062. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  143063. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  143064. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  143065. */
  143066. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  143067. /**
  143068. * Disposes the post process.
  143069. * @param camera The camera to dispose the post process on.
  143070. */
  143071. dispose(camera?: Camera): void;
  143072. }
  143073. }
  143074. declare module BABYLON {
  143075. /** @hidden */
  143076. export var refractionPixelShader: {
  143077. name: string;
  143078. shader: string;
  143079. };
  143080. }
  143081. declare module BABYLON {
  143082. /**
  143083. * Post process which applies a refractin texture
  143084. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  143085. */
  143086. export class RefractionPostProcess extends PostProcess {
  143087. /** the base color of the refraction (used to taint the rendering) */
  143088. color: Color3;
  143089. /** simulated refraction depth */
  143090. depth: number;
  143091. /** the coefficient of the base color (0 to remove base color tainting) */
  143092. colorLevel: number;
  143093. private _refTexture;
  143094. private _ownRefractionTexture;
  143095. /**
  143096. * Gets or sets the refraction texture
  143097. * Please note that you are responsible for disposing the texture if you set it manually
  143098. */
  143099. get refractionTexture(): Texture;
  143100. set refractionTexture(value: Texture);
  143101. /**
  143102. * Initializes the RefractionPostProcess
  143103. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  143104. * @param name The name of the effect.
  143105. * @param refractionTextureUrl Url of the refraction texture to use
  143106. * @param color the base color of the refraction (used to taint the rendering)
  143107. * @param depth simulated refraction depth
  143108. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  143109. * @param camera The camera to apply the render pass to.
  143110. * @param options The required width/height ratio to downsize to before computing the render pass.
  143111. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  143112. * @param engine The engine which the post process will be applied. (default: current engine)
  143113. * @param reusable If the post process can be reused on the same frame. (default: false)
  143114. */
  143115. constructor(name: string, refractionTextureUrl: string,
  143116. /** the base color of the refraction (used to taint the rendering) */
  143117. color: Color3,
  143118. /** simulated refraction depth */
  143119. depth: number,
  143120. /** the coefficient of the base color (0 to remove base color tainting) */
  143121. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  143122. /**
  143123. * Disposes of the post process
  143124. * @param camera Camera to dispose post process on
  143125. */
  143126. dispose(camera: Camera): void;
  143127. }
  143128. }
  143129. declare module BABYLON {
  143130. /** @hidden */
  143131. export var sharpenPixelShader: {
  143132. name: string;
  143133. shader: string;
  143134. };
  143135. }
  143136. declare module BABYLON {
  143137. /**
  143138. * The SharpenPostProcess applies a sharpen kernel to every pixel
  143139. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  143140. */
  143141. export class SharpenPostProcess extends PostProcess {
  143142. /**
  143143. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  143144. */
  143145. colorAmount: number;
  143146. /**
  143147. * How much sharpness should be applied (default: 0.3)
  143148. */
  143149. edgeAmount: number;
  143150. /**
  143151. * Creates a new instance ConvolutionPostProcess
  143152. * @param name The name of the effect.
  143153. * @param options The required width/height ratio to downsize to before computing the render pass.
  143154. * @param camera The camera to apply the render pass to.
  143155. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  143156. * @param engine The engine which the post process will be applied. (default: current engine)
  143157. * @param reusable If the post process can be reused on the same frame. (default: false)
  143158. * @param textureType Type of textures used when performing the post process. (default: 0)
  143159. * @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)
  143160. */
  143161. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  143162. }
  143163. }
  143164. declare module BABYLON {
  143165. /**
  143166. * PostProcessRenderPipeline
  143167. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  143168. */
  143169. export class PostProcessRenderPipeline {
  143170. private engine;
  143171. private _renderEffects;
  143172. private _renderEffectsForIsolatedPass;
  143173. /**
  143174. * List of inspectable custom properties (used by the Inspector)
  143175. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  143176. */
  143177. inspectableCustomProperties: IInspectable[];
  143178. /**
  143179. * @hidden
  143180. */
  143181. protected _cameras: Camera[];
  143182. /** @hidden */
  143183. _name: string;
  143184. /**
  143185. * Gets pipeline name
  143186. */
  143187. get name(): string;
  143188. /** Gets the list of attached cameras */
  143189. get cameras(): Camera[];
  143190. /**
  143191. * Initializes a PostProcessRenderPipeline
  143192. * @param engine engine to add the pipeline to
  143193. * @param name name of the pipeline
  143194. */
  143195. constructor(engine: Engine, name: string);
  143196. /**
  143197. * Gets the class name
  143198. * @returns "PostProcessRenderPipeline"
  143199. */
  143200. getClassName(): string;
  143201. /**
  143202. * If all the render effects in the pipeline are supported
  143203. */
  143204. get isSupported(): boolean;
  143205. /**
  143206. * Adds an effect to the pipeline
  143207. * @param renderEffect the effect to add
  143208. */
  143209. addEffect(renderEffect: PostProcessRenderEffect): void;
  143210. /** @hidden */
  143211. _rebuild(): void;
  143212. /** @hidden */
  143213. _enableEffect(renderEffectName: string, cameras: Camera): void;
  143214. /** @hidden */
  143215. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  143216. /** @hidden */
  143217. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  143218. /** @hidden */
  143219. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  143220. /** @hidden */
  143221. _attachCameras(cameras: Camera, unique: boolean): void;
  143222. /** @hidden */
  143223. _attachCameras(cameras: Camera[], unique: boolean): void;
  143224. /** @hidden */
  143225. _detachCameras(cameras: Camera): void;
  143226. /** @hidden */
  143227. _detachCameras(cameras: Nullable<Camera[]>): void;
  143228. /** @hidden */
  143229. _update(): void;
  143230. /** @hidden */
  143231. _reset(): void;
  143232. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  143233. /**
  143234. * Disposes of the pipeline
  143235. */
  143236. dispose(): void;
  143237. }
  143238. }
  143239. declare module BABYLON {
  143240. /**
  143241. * PostProcessRenderPipelineManager class
  143242. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  143243. */
  143244. export class PostProcessRenderPipelineManager {
  143245. private _renderPipelines;
  143246. /**
  143247. * Initializes a PostProcessRenderPipelineManager
  143248. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  143249. */
  143250. constructor();
  143251. /**
  143252. * Gets the list of supported render pipelines
  143253. */
  143254. get supportedPipelines(): PostProcessRenderPipeline[];
  143255. /**
  143256. * Adds a pipeline to the manager
  143257. * @param renderPipeline The pipeline to add
  143258. */
  143259. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  143260. /**
  143261. * Attaches a camera to the pipeline
  143262. * @param renderPipelineName The name of the pipeline to attach to
  143263. * @param cameras the camera to attach
  143264. * @param unique if the camera can be attached multiple times to the pipeline
  143265. */
  143266. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  143267. /**
  143268. * Detaches a camera from the pipeline
  143269. * @param renderPipelineName The name of the pipeline to detach from
  143270. * @param cameras the camera to detach
  143271. */
  143272. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  143273. /**
  143274. * Enables an effect by name on a pipeline
  143275. * @param renderPipelineName the name of the pipeline to enable the effect in
  143276. * @param renderEffectName the name of the effect to enable
  143277. * @param cameras the cameras that the effect should be enabled on
  143278. */
  143279. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  143280. /**
  143281. * Disables an effect by name on a pipeline
  143282. * @param renderPipelineName the name of the pipeline to disable the effect in
  143283. * @param renderEffectName the name of the effect to disable
  143284. * @param cameras the cameras that the effect should be disabled on
  143285. */
  143286. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  143287. /**
  143288. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  143289. */
  143290. update(): void;
  143291. /** @hidden */
  143292. _rebuild(): void;
  143293. /**
  143294. * Disposes of the manager and pipelines
  143295. */
  143296. dispose(): void;
  143297. }
  143298. }
  143299. declare module BABYLON {
  143300. interface Scene {
  143301. /** @hidden (Backing field) */
  143302. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  143303. /**
  143304. * Gets the postprocess render pipeline manager
  143305. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  143306. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  143307. */
  143308. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  143309. }
  143310. /**
  143311. * Defines the Render Pipeline scene component responsible to rendering pipelines
  143312. */
  143313. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  143314. /**
  143315. * The component name helpfull to identify the component in the list of scene components.
  143316. */
  143317. readonly name: string;
  143318. /**
  143319. * The scene the component belongs to.
  143320. */
  143321. scene: Scene;
  143322. /**
  143323. * Creates a new instance of the component for the given scene
  143324. * @param scene Defines the scene to register the component in
  143325. */
  143326. constructor(scene: Scene);
  143327. /**
  143328. * Registers the component in a given scene
  143329. */
  143330. register(): void;
  143331. /**
  143332. * Rebuilds the elements related to this component in case of
  143333. * context lost for instance.
  143334. */
  143335. rebuild(): void;
  143336. /**
  143337. * Disposes the component and the associated ressources
  143338. */
  143339. dispose(): void;
  143340. private _gatherRenderTargets;
  143341. }
  143342. }
  143343. declare module BABYLON {
  143344. /**
  143345. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  143346. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  143347. */
  143348. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  143349. private _scene;
  143350. private _camerasToBeAttached;
  143351. /**
  143352. * ID of the sharpen post process,
  143353. */
  143354. private readonly SharpenPostProcessId;
  143355. /**
  143356. * @ignore
  143357. * ID of the image processing post process;
  143358. */
  143359. readonly ImageProcessingPostProcessId: string;
  143360. /**
  143361. * @ignore
  143362. * ID of the Fast Approximate Anti-Aliasing post process;
  143363. */
  143364. readonly FxaaPostProcessId: string;
  143365. /**
  143366. * ID of the chromatic aberration post process,
  143367. */
  143368. private readonly ChromaticAberrationPostProcessId;
  143369. /**
  143370. * ID of the grain post process
  143371. */
  143372. private readonly GrainPostProcessId;
  143373. /**
  143374. * Sharpen post process which will apply a sharpen convolution to enhance edges
  143375. */
  143376. sharpen: SharpenPostProcess;
  143377. private _sharpenEffect;
  143378. private bloom;
  143379. /**
  143380. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  143381. */
  143382. depthOfField: DepthOfFieldEffect;
  143383. /**
  143384. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  143385. */
  143386. fxaa: FxaaPostProcess;
  143387. /**
  143388. * Image post processing pass used to perform operations such as tone mapping or color grading.
  143389. */
  143390. imageProcessing: ImageProcessingPostProcess;
  143391. /**
  143392. * Chromatic aberration post process which will shift rgb colors in the image
  143393. */
  143394. chromaticAberration: ChromaticAberrationPostProcess;
  143395. private _chromaticAberrationEffect;
  143396. /**
  143397. * Grain post process which add noise to the image
  143398. */
  143399. grain: GrainPostProcess;
  143400. private _grainEffect;
  143401. /**
  143402. * Glow post process which adds a glow to emissive areas of the image
  143403. */
  143404. private _glowLayer;
  143405. /**
  143406. * Animations which can be used to tweak settings over a period of time
  143407. */
  143408. animations: Animation[];
  143409. private _imageProcessingConfigurationObserver;
  143410. private _sharpenEnabled;
  143411. private _bloomEnabled;
  143412. private _depthOfFieldEnabled;
  143413. private _depthOfFieldBlurLevel;
  143414. private _fxaaEnabled;
  143415. private _imageProcessingEnabled;
  143416. private _defaultPipelineTextureType;
  143417. private _bloomScale;
  143418. private _chromaticAberrationEnabled;
  143419. private _grainEnabled;
  143420. private _buildAllowed;
  143421. /**
  143422. * Gets active scene
  143423. */
  143424. get scene(): Scene;
  143425. /**
  143426. * Enable or disable the sharpen process from the pipeline
  143427. */
  143428. set sharpenEnabled(enabled: boolean);
  143429. get sharpenEnabled(): boolean;
  143430. private _resizeObserver;
  143431. private _hardwareScaleLevel;
  143432. private _bloomKernel;
  143433. /**
  143434. * Specifies the size of the bloom blur kernel, relative to the final output size
  143435. */
  143436. get bloomKernel(): number;
  143437. set bloomKernel(value: number);
  143438. /**
  143439. * Specifies the weight of the bloom in the final rendering
  143440. */
  143441. private _bloomWeight;
  143442. /**
  143443. * Specifies the luma threshold for the area that will be blurred by the bloom
  143444. */
  143445. private _bloomThreshold;
  143446. private _hdr;
  143447. /**
  143448. * The strength of the bloom.
  143449. */
  143450. set bloomWeight(value: number);
  143451. get bloomWeight(): number;
  143452. /**
  143453. * The strength of the bloom.
  143454. */
  143455. set bloomThreshold(value: number);
  143456. get bloomThreshold(): number;
  143457. /**
  143458. * The scale of the bloom, lower value will provide better performance.
  143459. */
  143460. set bloomScale(value: number);
  143461. get bloomScale(): number;
  143462. /**
  143463. * Enable or disable the bloom from the pipeline
  143464. */
  143465. set bloomEnabled(enabled: boolean);
  143466. get bloomEnabled(): boolean;
  143467. private _rebuildBloom;
  143468. /**
  143469. * If the depth of field is enabled.
  143470. */
  143471. get depthOfFieldEnabled(): boolean;
  143472. set depthOfFieldEnabled(enabled: boolean);
  143473. /**
  143474. * Blur level of the depth of field effect. (Higher blur will effect performance)
  143475. */
  143476. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  143477. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  143478. /**
  143479. * If the anti aliasing is enabled.
  143480. */
  143481. set fxaaEnabled(enabled: boolean);
  143482. get fxaaEnabled(): boolean;
  143483. private _samples;
  143484. /**
  143485. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  143486. */
  143487. set samples(sampleCount: number);
  143488. get samples(): number;
  143489. /**
  143490. * If image processing is enabled.
  143491. */
  143492. set imageProcessingEnabled(enabled: boolean);
  143493. get imageProcessingEnabled(): boolean;
  143494. /**
  143495. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  143496. */
  143497. set glowLayerEnabled(enabled: boolean);
  143498. get glowLayerEnabled(): boolean;
  143499. /**
  143500. * Gets the glow layer (or null if not defined)
  143501. */
  143502. get glowLayer(): Nullable<GlowLayer>;
  143503. /**
  143504. * Enable or disable the chromaticAberration process from the pipeline
  143505. */
  143506. set chromaticAberrationEnabled(enabled: boolean);
  143507. get chromaticAberrationEnabled(): boolean;
  143508. /**
  143509. * Enable or disable the grain process from the pipeline
  143510. */
  143511. set grainEnabled(enabled: boolean);
  143512. get grainEnabled(): boolean;
  143513. /**
  143514. * @constructor
  143515. * @param name - The rendering pipeline name (default: "")
  143516. * @param hdr - If high dynamic range textures should be used (default: true)
  143517. * @param scene - The scene linked to this pipeline (default: the last created scene)
  143518. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  143519. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  143520. */
  143521. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  143522. /**
  143523. * Get the class name
  143524. * @returns "DefaultRenderingPipeline"
  143525. */
  143526. getClassName(): string;
  143527. /**
  143528. * Force the compilation of the entire pipeline.
  143529. */
  143530. prepare(): void;
  143531. private _hasCleared;
  143532. private _prevPostProcess;
  143533. private _prevPrevPostProcess;
  143534. private _setAutoClearAndTextureSharing;
  143535. private _depthOfFieldSceneObserver;
  143536. private _buildPipeline;
  143537. private _disposePostProcesses;
  143538. /**
  143539. * Adds a camera to the pipeline
  143540. * @param camera the camera to be added
  143541. */
  143542. addCamera(camera: Camera): void;
  143543. /**
  143544. * Removes a camera from the pipeline
  143545. * @param camera the camera to remove
  143546. */
  143547. removeCamera(camera: Camera): void;
  143548. /**
  143549. * Dispose of the pipeline and stop all post processes
  143550. */
  143551. dispose(): void;
  143552. /**
  143553. * Serialize the rendering pipeline (Used when exporting)
  143554. * @returns the serialized object
  143555. */
  143556. serialize(): any;
  143557. /**
  143558. * Parse the serialized pipeline
  143559. * @param source Source pipeline.
  143560. * @param scene The scene to load the pipeline to.
  143561. * @param rootUrl The URL of the serialized pipeline.
  143562. * @returns An instantiated pipeline from the serialized object.
  143563. */
  143564. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  143565. }
  143566. }
  143567. declare module BABYLON {
  143568. /** @hidden */
  143569. export var lensHighlightsPixelShader: {
  143570. name: string;
  143571. shader: string;
  143572. };
  143573. }
  143574. declare module BABYLON {
  143575. /** @hidden */
  143576. export var depthOfFieldPixelShader: {
  143577. name: string;
  143578. shader: string;
  143579. };
  143580. }
  143581. declare module BABYLON {
  143582. /**
  143583. * BABYLON.JS Chromatic Aberration GLSL Shader
  143584. * Author: Olivier Guyot
  143585. * Separates very slightly R, G and B colors on the edges of the screen
  143586. * Inspired by Francois Tarlier & Martins Upitis
  143587. */
  143588. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  143589. /**
  143590. * @ignore
  143591. * The chromatic aberration PostProcess id in the pipeline
  143592. */
  143593. LensChromaticAberrationEffect: string;
  143594. /**
  143595. * @ignore
  143596. * The highlights enhancing PostProcess id in the pipeline
  143597. */
  143598. HighlightsEnhancingEffect: string;
  143599. /**
  143600. * @ignore
  143601. * The depth-of-field PostProcess id in the pipeline
  143602. */
  143603. LensDepthOfFieldEffect: string;
  143604. private _scene;
  143605. private _depthTexture;
  143606. private _grainTexture;
  143607. private _chromaticAberrationPostProcess;
  143608. private _highlightsPostProcess;
  143609. private _depthOfFieldPostProcess;
  143610. private _edgeBlur;
  143611. private _grainAmount;
  143612. private _chromaticAberration;
  143613. private _distortion;
  143614. private _highlightsGain;
  143615. private _highlightsThreshold;
  143616. private _dofDistance;
  143617. private _dofAperture;
  143618. private _dofDarken;
  143619. private _dofPentagon;
  143620. private _blurNoise;
  143621. /**
  143622. * @constructor
  143623. *
  143624. * Effect parameters are as follow:
  143625. * {
  143626. * chromatic_aberration: number; // from 0 to x (1 for realism)
  143627. * edge_blur: number; // from 0 to x (1 for realism)
  143628. * distortion: number; // from 0 to x (1 for realism)
  143629. * grain_amount: number; // from 0 to 1
  143630. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  143631. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  143632. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  143633. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  143634. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  143635. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  143636. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  143637. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  143638. * }
  143639. * Note: if an effect parameter is unset, effect is disabled
  143640. *
  143641. * @param name The rendering pipeline name
  143642. * @param parameters - An object containing all parameters (see above)
  143643. * @param scene The scene linked to this pipeline
  143644. * @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)
  143645. * @param cameras The array of cameras that the rendering pipeline will be attached to
  143646. */
  143647. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  143648. /**
  143649. * Get the class name
  143650. * @returns "LensRenderingPipeline"
  143651. */
  143652. getClassName(): string;
  143653. /**
  143654. * Gets associated scene
  143655. */
  143656. get scene(): Scene;
  143657. /**
  143658. * Gets or sets the edge blur
  143659. */
  143660. get edgeBlur(): number;
  143661. set edgeBlur(value: number);
  143662. /**
  143663. * Gets or sets the grain amount
  143664. */
  143665. get grainAmount(): number;
  143666. set grainAmount(value: number);
  143667. /**
  143668. * Gets or sets the chromatic aberration amount
  143669. */
  143670. get chromaticAberration(): number;
  143671. set chromaticAberration(value: number);
  143672. /**
  143673. * Gets or sets the depth of field aperture
  143674. */
  143675. get dofAperture(): number;
  143676. set dofAperture(value: number);
  143677. /**
  143678. * Gets or sets the edge distortion
  143679. */
  143680. get edgeDistortion(): number;
  143681. set edgeDistortion(value: number);
  143682. /**
  143683. * Gets or sets the depth of field distortion
  143684. */
  143685. get dofDistortion(): number;
  143686. set dofDistortion(value: number);
  143687. /**
  143688. * Gets or sets the darken out of focus amount
  143689. */
  143690. get darkenOutOfFocus(): number;
  143691. set darkenOutOfFocus(value: number);
  143692. /**
  143693. * Gets or sets a boolean indicating if blur noise is enabled
  143694. */
  143695. get blurNoise(): boolean;
  143696. set blurNoise(value: boolean);
  143697. /**
  143698. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  143699. */
  143700. get pentagonBokeh(): boolean;
  143701. set pentagonBokeh(value: boolean);
  143702. /**
  143703. * Gets or sets the highlight grain amount
  143704. */
  143705. get highlightsGain(): number;
  143706. set highlightsGain(value: number);
  143707. /**
  143708. * Gets or sets the highlight threshold
  143709. */
  143710. get highlightsThreshold(): number;
  143711. set highlightsThreshold(value: number);
  143712. /**
  143713. * Sets the amount of blur at the edges
  143714. * @param amount blur amount
  143715. */
  143716. setEdgeBlur(amount: number): void;
  143717. /**
  143718. * Sets edge blur to 0
  143719. */
  143720. disableEdgeBlur(): void;
  143721. /**
  143722. * Sets the amout of grain
  143723. * @param amount Amount of grain
  143724. */
  143725. setGrainAmount(amount: number): void;
  143726. /**
  143727. * Set grain amount to 0
  143728. */
  143729. disableGrain(): void;
  143730. /**
  143731. * Sets the chromatic aberration amount
  143732. * @param amount amount of chromatic aberration
  143733. */
  143734. setChromaticAberration(amount: number): void;
  143735. /**
  143736. * Sets chromatic aberration amount to 0
  143737. */
  143738. disableChromaticAberration(): void;
  143739. /**
  143740. * Sets the EdgeDistortion amount
  143741. * @param amount amount of EdgeDistortion
  143742. */
  143743. setEdgeDistortion(amount: number): void;
  143744. /**
  143745. * Sets edge distortion to 0
  143746. */
  143747. disableEdgeDistortion(): void;
  143748. /**
  143749. * Sets the FocusDistance amount
  143750. * @param amount amount of FocusDistance
  143751. */
  143752. setFocusDistance(amount: number): void;
  143753. /**
  143754. * Disables depth of field
  143755. */
  143756. disableDepthOfField(): void;
  143757. /**
  143758. * Sets the Aperture amount
  143759. * @param amount amount of Aperture
  143760. */
  143761. setAperture(amount: number): void;
  143762. /**
  143763. * Sets the DarkenOutOfFocus amount
  143764. * @param amount amount of DarkenOutOfFocus
  143765. */
  143766. setDarkenOutOfFocus(amount: number): void;
  143767. private _pentagonBokehIsEnabled;
  143768. /**
  143769. * Creates a pentagon bokeh effect
  143770. */
  143771. enablePentagonBokeh(): void;
  143772. /**
  143773. * Disables the pentagon bokeh effect
  143774. */
  143775. disablePentagonBokeh(): void;
  143776. /**
  143777. * Enables noise blur
  143778. */
  143779. enableNoiseBlur(): void;
  143780. /**
  143781. * Disables noise blur
  143782. */
  143783. disableNoiseBlur(): void;
  143784. /**
  143785. * Sets the HighlightsGain amount
  143786. * @param amount amount of HighlightsGain
  143787. */
  143788. setHighlightsGain(amount: number): void;
  143789. /**
  143790. * Sets the HighlightsThreshold amount
  143791. * @param amount amount of HighlightsThreshold
  143792. */
  143793. setHighlightsThreshold(amount: number): void;
  143794. /**
  143795. * Disables highlights
  143796. */
  143797. disableHighlights(): void;
  143798. /**
  143799. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  143800. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  143801. */
  143802. dispose(disableDepthRender?: boolean): void;
  143803. private _createChromaticAberrationPostProcess;
  143804. private _createHighlightsPostProcess;
  143805. private _createDepthOfFieldPostProcess;
  143806. private _createGrainTexture;
  143807. }
  143808. }
  143809. declare module BABYLON {
  143810. /** @hidden */
  143811. export var ssao2PixelShader: {
  143812. name: string;
  143813. shader: string;
  143814. };
  143815. }
  143816. declare module BABYLON {
  143817. /** @hidden */
  143818. export var ssaoCombinePixelShader: {
  143819. name: string;
  143820. shader: string;
  143821. };
  143822. }
  143823. declare module BABYLON {
  143824. /**
  143825. * Render pipeline to produce ssao effect
  143826. */
  143827. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  143828. /**
  143829. * @ignore
  143830. * The PassPostProcess id in the pipeline that contains the original scene color
  143831. */
  143832. SSAOOriginalSceneColorEffect: string;
  143833. /**
  143834. * @ignore
  143835. * The SSAO PostProcess id in the pipeline
  143836. */
  143837. SSAORenderEffect: string;
  143838. /**
  143839. * @ignore
  143840. * The horizontal blur PostProcess id in the pipeline
  143841. */
  143842. SSAOBlurHRenderEffect: string;
  143843. /**
  143844. * @ignore
  143845. * The vertical blur PostProcess id in the pipeline
  143846. */
  143847. SSAOBlurVRenderEffect: string;
  143848. /**
  143849. * @ignore
  143850. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  143851. */
  143852. SSAOCombineRenderEffect: string;
  143853. /**
  143854. * The output strength of the SSAO post-process. Default value is 1.0.
  143855. */
  143856. totalStrength: number;
  143857. /**
  143858. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  143859. */
  143860. maxZ: number;
  143861. /**
  143862. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  143863. */
  143864. minZAspect: number;
  143865. private _samples;
  143866. /**
  143867. * Number of samples used for the SSAO calculations. Default value is 8
  143868. */
  143869. set samples(n: number);
  143870. get samples(): number;
  143871. private _textureSamples;
  143872. /**
  143873. * Number of samples to use for antialiasing
  143874. */
  143875. set textureSamples(n: number);
  143876. get textureSamples(): number;
  143877. /**
  143878. * Ratio object used for SSAO ratio and blur ratio
  143879. */
  143880. private _ratio;
  143881. /**
  143882. * Dynamically generated sphere sampler.
  143883. */
  143884. private _sampleSphere;
  143885. /**
  143886. * Blur filter offsets
  143887. */
  143888. private _samplerOffsets;
  143889. private _expensiveBlur;
  143890. /**
  143891. * If bilateral blur should be used
  143892. */
  143893. set expensiveBlur(b: boolean);
  143894. get expensiveBlur(): boolean;
  143895. /**
  143896. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  143897. */
  143898. radius: number;
  143899. /**
  143900. * The base color of the SSAO post-process
  143901. * The final result is "base + ssao" between [0, 1]
  143902. */
  143903. base: number;
  143904. /**
  143905. * Support test.
  143906. */
  143907. static get IsSupported(): boolean;
  143908. private _scene;
  143909. private _depthTexture;
  143910. private _normalTexture;
  143911. private _randomTexture;
  143912. private _originalColorPostProcess;
  143913. private _ssaoPostProcess;
  143914. private _blurHPostProcess;
  143915. private _blurVPostProcess;
  143916. private _ssaoCombinePostProcess;
  143917. /**
  143918. * Gets active scene
  143919. */
  143920. get scene(): Scene;
  143921. /**
  143922. * @constructor
  143923. * @param name The rendering pipeline name
  143924. * @param scene The scene linked to this pipeline
  143925. * @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 }
  143926. * @param cameras The array of cameras that the rendering pipeline will be attached to
  143927. */
  143928. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  143929. /**
  143930. * Get the class name
  143931. * @returns "SSAO2RenderingPipeline"
  143932. */
  143933. getClassName(): string;
  143934. /**
  143935. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  143936. */
  143937. dispose(disableGeometryBufferRenderer?: boolean): void;
  143938. private _createBlurPostProcess;
  143939. /** @hidden */
  143940. _rebuild(): void;
  143941. private _bits;
  143942. private _radicalInverse_VdC;
  143943. private _hammersley;
  143944. private _hemisphereSample_uniform;
  143945. private _generateHemisphere;
  143946. private _createSSAOPostProcess;
  143947. private _createSSAOCombinePostProcess;
  143948. private _createRandomTexture;
  143949. /**
  143950. * Serialize the rendering pipeline (Used when exporting)
  143951. * @returns the serialized object
  143952. */
  143953. serialize(): any;
  143954. /**
  143955. * Parse the serialized pipeline
  143956. * @param source Source pipeline.
  143957. * @param scene The scene to load the pipeline to.
  143958. * @param rootUrl The URL of the serialized pipeline.
  143959. * @returns An instantiated pipeline from the serialized object.
  143960. */
  143961. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  143962. }
  143963. }
  143964. declare module BABYLON {
  143965. /** @hidden */
  143966. export var ssaoPixelShader: {
  143967. name: string;
  143968. shader: string;
  143969. };
  143970. }
  143971. declare module BABYLON {
  143972. /**
  143973. * Render pipeline to produce ssao effect
  143974. */
  143975. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  143976. /**
  143977. * @ignore
  143978. * The PassPostProcess id in the pipeline that contains the original scene color
  143979. */
  143980. SSAOOriginalSceneColorEffect: string;
  143981. /**
  143982. * @ignore
  143983. * The SSAO PostProcess id in the pipeline
  143984. */
  143985. SSAORenderEffect: string;
  143986. /**
  143987. * @ignore
  143988. * The horizontal blur PostProcess id in the pipeline
  143989. */
  143990. SSAOBlurHRenderEffect: string;
  143991. /**
  143992. * @ignore
  143993. * The vertical blur PostProcess id in the pipeline
  143994. */
  143995. SSAOBlurVRenderEffect: string;
  143996. /**
  143997. * @ignore
  143998. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  143999. */
  144000. SSAOCombineRenderEffect: string;
  144001. /**
  144002. * The output strength of the SSAO post-process. Default value is 1.0.
  144003. */
  144004. totalStrength: number;
  144005. /**
  144006. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  144007. */
  144008. radius: number;
  144009. /**
  144010. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  144011. * Must not be equal to fallOff and superior to fallOff.
  144012. * Default value is 0.0075
  144013. */
  144014. area: number;
  144015. /**
  144016. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  144017. * Must not be equal to area and inferior to area.
  144018. * Default value is 0.000001
  144019. */
  144020. fallOff: number;
  144021. /**
  144022. * The base color of the SSAO post-process
  144023. * The final result is "base + ssao" between [0, 1]
  144024. */
  144025. base: number;
  144026. private _scene;
  144027. private _depthTexture;
  144028. private _randomTexture;
  144029. private _originalColorPostProcess;
  144030. private _ssaoPostProcess;
  144031. private _blurHPostProcess;
  144032. private _blurVPostProcess;
  144033. private _ssaoCombinePostProcess;
  144034. private _firstUpdate;
  144035. /**
  144036. * Gets active scene
  144037. */
  144038. get scene(): Scene;
  144039. /**
  144040. * @constructor
  144041. * @param name - The rendering pipeline name
  144042. * @param scene - The scene linked to this pipeline
  144043. * @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 }
  144044. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  144045. */
  144046. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  144047. /**
  144048. * Get the class name
  144049. * @returns "SSAORenderingPipeline"
  144050. */
  144051. getClassName(): string;
  144052. /**
  144053. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  144054. */
  144055. dispose(disableDepthRender?: boolean): void;
  144056. private _createBlurPostProcess;
  144057. /** @hidden */
  144058. _rebuild(): void;
  144059. private _createSSAOPostProcess;
  144060. private _createSSAOCombinePostProcess;
  144061. private _createRandomTexture;
  144062. }
  144063. }
  144064. declare module BABYLON {
  144065. /** @hidden */
  144066. export var screenSpaceReflectionPixelShader: {
  144067. name: string;
  144068. shader: string;
  144069. };
  144070. }
  144071. declare module BABYLON {
  144072. /**
  144073. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  144074. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  144075. */
  144076. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  144077. /**
  144078. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  144079. */
  144080. threshold: number;
  144081. /**
  144082. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  144083. */
  144084. strength: number;
  144085. /**
  144086. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  144087. */
  144088. reflectionSpecularFalloffExponent: number;
  144089. /**
  144090. * 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]
  144091. */
  144092. step: number;
  144093. /**
  144094. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  144095. */
  144096. roughnessFactor: number;
  144097. private _geometryBufferRenderer;
  144098. private _enableSmoothReflections;
  144099. private _reflectionSamples;
  144100. private _smoothSteps;
  144101. /**
  144102. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  144103. * @param name The name of the effect.
  144104. * @param scene The scene containing the objects to calculate reflections.
  144105. * @param options The required width/height ratio to downsize to before computing the render pass.
  144106. * @param camera The camera to apply the render pass to.
  144107. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  144108. * @param engine The engine which the post process will be applied. (default: current engine)
  144109. * @param reusable If the post process can be reused on the same frame. (default: false)
  144110. * @param textureType Type of textures used when performing the post process. (default: 0)
  144111. * @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)
  144112. */
  144113. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  144114. /**
  144115. * Gets wether or not smoothing reflections is enabled.
  144116. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  144117. */
  144118. get enableSmoothReflections(): boolean;
  144119. /**
  144120. * Sets wether or not smoothing reflections is enabled.
  144121. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  144122. */
  144123. set enableSmoothReflections(enabled: boolean);
  144124. /**
  144125. * Gets the number of samples taken while computing reflections. More samples count is high,
  144126. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  144127. */
  144128. get reflectionSamples(): number;
  144129. /**
  144130. * Sets the number of samples taken while computing reflections. More samples count is high,
  144131. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  144132. */
  144133. set reflectionSamples(samples: number);
  144134. /**
  144135. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  144136. * more the post-process will require GPU power and can generate a drop in FPS.
  144137. * Default value (5.0) work pretty well in all cases but can be adjusted.
  144138. */
  144139. get smoothSteps(): number;
  144140. set smoothSteps(steps: number);
  144141. private _updateEffectDefines;
  144142. }
  144143. }
  144144. declare module BABYLON {
  144145. /** @hidden */
  144146. export var standardPixelShader: {
  144147. name: string;
  144148. shader: string;
  144149. };
  144150. }
  144151. declare module BABYLON {
  144152. /**
  144153. * Standard rendering pipeline
  144154. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  144155. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  144156. */
  144157. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  144158. /**
  144159. * Public members
  144160. */
  144161. /**
  144162. * Post-process which contains the original scene color before the pipeline applies all the effects
  144163. */
  144164. originalPostProcess: Nullable<PostProcess>;
  144165. /**
  144166. * Post-process used to down scale an image x4
  144167. */
  144168. downSampleX4PostProcess: Nullable<PostProcess>;
  144169. /**
  144170. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  144171. */
  144172. brightPassPostProcess: Nullable<PostProcess>;
  144173. /**
  144174. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  144175. */
  144176. blurHPostProcesses: PostProcess[];
  144177. /**
  144178. * Post-process array storing all the vertical blur post-processes used by the pipeline
  144179. */
  144180. blurVPostProcesses: PostProcess[];
  144181. /**
  144182. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  144183. */
  144184. textureAdderPostProcess: Nullable<PostProcess>;
  144185. /**
  144186. * Post-process used to create volumetric lighting effect
  144187. */
  144188. volumetricLightPostProcess: Nullable<PostProcess>;
  144189. /**
  144190. * Post-process used to smooth the previous volumetric light post-process on the X axis
  144191. */
  144192. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  144193. /**
  144194. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  144195. */
  144196. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  144197. /**
  144198. * Post-process used to merge the volumetric light effect and the real scene color
  144199. */
  144200. volumetricLightMergePostProces: Nullable<PostProcess>;
  144201. /**
  144202. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  144203. */
  144204. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  144205. /**
  144206. * Base post-process used to calculate the average luminance of the final image for HDR
  144207. */
  144208. luminancePostProcess: Nullable<PostProcess>;
  144209. /**
  144210. * Post-processes used to create down sample post-processes in order to get
  144211. * the average luminance of the final image for HDR
  144212. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  144213. */
  144214. luminanceDownSamplePostProcesses: PostProcess[];
  144215. /**
  144216. * Post-process used to create a HDR effect (light adaptation)
  144217. */
  144218. hdrPostProcess: Nullable<PostProcess>;
  144219. /**
  144220. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  144221. */
  144222. textureAdderFinalPostProcess: Nullable<PostProcess>;
  144223. /**
  144224. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  144225. */
  144226. lensFlareFinalPostProcess: Nullable<PostProcess>;
  144227. /**
  144228. * Post-process used to merge the final HDR post-process and the real scene color
  144229. */
  144230. hdrFinalPostProcess: Nullable<PostProcess>;
  144231. /**
  144232. * Post-process used to create a lens flare effect
  144233. */
  144234. lensFlarePostProcess: Nullable<PostProcess>;
  144235. /**
  144236. * Post-process that merges the result of the lens flare post-process and the real scene color
  144237. */
  144238. lensFlareComposePostProcess: Nullable<PostProcess>;
  144239. /**
  144240. * Post-process used to create a motion blur effect
  144241. */
  144242. motionBlurPostProcess: Nullable<PostProcess>;
  144243. /**
  144244. * Post-process used to create a depth of field effect
  144245. */
  144246. depthOfFieldPostProcess: Nullable<PostProcess>;
  144247. /**
  144248. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  144249. */
  144250. fxaaPostProcess: Nullable<FxaaPostProcess>;
  144251. /**
  144252. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  144253. */
  144254. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  144255. /**
  144256. * Represents the brightness threshold in order to configure the illuminated surfaces
  144257. */
  144258. brightThreshold: number;
  144259. /**
  144260. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  144261. */
  144262. blurWidth: number;
  144263. /**
  144264. * Sets if the blur for highlighted surfaces must be only horizontal
  144265. */
  144266. horizontalBlur: boolean;
  144267. /**
  144268. * Gets the overall exposure used by the pipeline
  144269. */
  144270. get exposure(): number;
  144271. /**
  144272. * Sets the overall exposure used by the pipeline
  144273. */
  144274. set exposure(value: number);
  144275. /**
  144276. * Texture used typically to simulate "dirty" on camera lens
  144277. */
  144278. lensTexture: Nullable<Texture>;
  144279. /**
  144280. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  144281. */
  144282. volumetricLightCoefficient: number;
  144283. /**
  144284. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  144285. */
  144286. volumetricLightPower: number;
  144287. /**
  144288. * Used the set the blur intensity to smooth the volumetric lights
  144289. */
  144290. volumetricLightBlurScale: number;
  144291. /**
  144292. * Light (spot or directional) used to generate the volumetric lights rays
  144293. * The source light must have a shadow generate so the pipeline can get its
  144294. * depth map
  144295. */
  144296. sourceLight: Nullable<SpotLight | DirectionalLight>;
  144297. /**
  144298. * For eye adaptation, represents the minimum luminance the eye can see
  144299. */
  144300. hdrMinimumLuminance: number;
  144301. /**
  144302. * For eye adaptation, represents the decrease luminance speed
  144303. */
  144304. hdrDecreaseRate: number;
  144305. /**
  144306. * For eye adaptation, represents the increase luminance speed
  144307. */
  144308. hdrIncreaseRate: number;
  144309. /**
  144310. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  144311. */
  144312. get hdrAutoExposure(): boolean;
  144313. /**
  144314. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  144315. */
  144316. set hdrAutoExposure(value: boolean);
  144317. /**
  144318. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  144319. */
  144320. lensColorTexture: Nullable<Texture>;
  144321. /**
  144322. * The overall strengh for the lens flare effect
  144323. */
  144324. lensFlareStrength: number;
  144325. /**
  144326. * Dispersion coefficient for lens flare ghosts
  144327. */
  144328. lensFlareGhostDispersal: number;
  144329. /**
  144330. * Main lens flare halo width
  144331. */
  144332. lensFlareHaloWidth: number;
  144333. /**
  144334. * Based on the lens distortion effect, defines how much the lens flare result
  144335. * is distorted
  144336. */
  144337. lensFlareDistortionStrength: number;
  144338. /**
  144339. * Configures the blur intensity used for for lens flare (halo)
  144340. */
  144341. lensFlareBlurWidth: number;
  144342. /**
  144343. * Lens star texture must be used to simulate rays on the flares and is available
  144344. * in the documentation
  144345. */
  144346. lensStarTexture: Nullable<Texture>;
  144347. /**
  144348. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  144349. * flare effect by taking account of the dirt texture
  144350. */
  144351. lensFlareDirtTexture: Nullable<Texture>;
  144352. /**
  144353. * Represents the focal length for the depth of field effect
  144354. */
  144355. depthOfFieldDistance: number;
  144356. /**
  144357. * Represents the blur intensity for the blurred part of the depth of field effect
  144358. */
  144359. depthOfFieldBlurWidth: number;
  144360. /**
  144361. * Gets how much the image is blurred by the movement while using the motion blur post-process
  144362. */
  144363. get motionStrength(): number;
  144364. /**
  144365. * Sets how much the image is blurred by the movement while using the motion blur post-process
  144366. */
  144367. set motionStrength(strength: number);
  144368. /**
  144369. * Gets wether or not the motion blur post-process is object based or screen based.
  144370. */
  144371. get objectBasedMotionBlur(): boolean;
  144372. /**
  144373. * Sets wether or not the motion blur post-process should be object based or screen based
  144374. */
  144375. set objectBasedMotionBlur(value: boolean);
  144376. /**
  144377. * List of animations for the pipeline (IAnimatable implementation)
  144378. */
  144379. animations: Animation[];
  144380. /**
  144381. * Private members
  144382. */
  144383. private _scene;
  144384. private _currentDepthOfFieldSource;
  144385. private _basePostProcess;
  144386. private _fixedExposure;
  144387. private _currentExposure;
  144388. private _hdrAutoExposure;
  144389. private _hdrCurrentLuminance;
  144390. private _motionStrength;
  144391. private _isObjectBasedMotionBlur;
  144392. private _floatTextureType;
  144393. private _camerasToBeAttached;
  144394. private _ratio;
  144395. private _bloomEnabled;
  144396. private _depthOfFieldEnabled;
  144397. private _vlsEnabled;
  144398. private _lensFlareEnabled;
  144399. private _hdrEnabled;
  144400. private _motionBlurEnabled;
  144401. private _fxaaEnabled;
  144402. private _screenSpaceReflectionsEnabled;
  144403. private _motionBlurSamples;
  144404. private _volumetricLightStepsCount;
  144405. private _samples;
  144406. /**
  144407. * @ignore
  144408. * Specifies if the bloom pipeline is enabled
  144409. */
  144410. get BloomEnabled(): boolean;
  144411. set BloomEnabled(enabled: boolean);
  144412. /**
  144413. * @ignore
  144414. * Specifies if the depth of field pipeline is enabed
  144415. */
  144416. get DepthOfFieldEnabled(): boolean;
  144417. set DepthOfFieldEnabled(enabled: boolean);
  144418. /**
  144419. * @ignore
  144420. * Specifies if the lens flare pipeline is enabed
  144421. */
  144422. get LensFlareEnabled(): boolean;
  144423. set LensFlareEnabled(enabled: boolean);
  144424. /**
  144425. * @ignore
  144426. * Specifies if the HDR pipeline is enabled
  144427. */
  144428. get HDREnabled(): boolean;
  144429. set HDREnabled(enabled: boolean);
  144430. /**
  144431. * @ignore
  144432. * Specifies if the volumetric lights scattering effect is enabled
  144433. */
  144434. get VLSEnabled(): boolean;
  144435. set VLSEnabled(enabled: boolean);
  144436. /**
  144437. * @ignore
  144438. * Specifies if the motion blur effect is enabled
  144439. */
  144440. get MotionBlurEnabled(): boolean;
  144441. set MotionBlurEnabled(enabled: boolean);
  144442. /**
  144443. * Specifies if anti-aliasing is enabled
  144444. */
  144445. get fxaaEnabled(): boolean;
  144446. set fxaaEnabled(enabled: boolean);
  144447. /**
  144448. * Specifies if screen space reflections are enabled.
  144449. */
  144450. get screenSpaceReflectionsEnabled(): boolean;
  144451. set screenSpaceReflectionsEnabled(enabled: boolean);
  144452. /**
  144453. * Specifies the number of steps used to calculate the volumetric lights
  144454. * Typically in interval [50, 200]
  144455. */
  144456. get volumetricLightStepsCount(): number;
  144457. set volumetricLightStepsCount(count: number);
  144458. /**
  144459. * Specifies the number of samples used for the motion blur effect
  144460. * Typically in interval [16, 64]
  144461. */
  144462. get motionBlurSamples(): number;
  144463. set motionBlurSamples(samples: number);
  144464. /**
  144465. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  144466. */
  144467. get samples(): number;
  144468. set samples(sampleCount: number);
  144469. /**
  144470. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  144471. * @constructor
  144472. * @param name The rendering pipeline name
  144473. * @param scene The scene linked to this pipeline
  144474. * @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)
  144475. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  144476. * @param cameras The array of cameras that the rendering pipeline will be attached to
  144477. */
  144478. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  144479. private _buildPipeline;
  144480. private _createDownSampleX4PostProcess;
  144481. private _createBrightPassPostProcess;
  144482. private _createBlurPostProcesses;
  144483. private _createTextureAdderPostProcess;
  144484. private _createVolumetricLightPostProcess;
  144485. private _createLuminancePostProcesses;
  144486. private _createHdrPostProcess;
  144487. private _createLensFlarePostProcess;
  144488. private _createDepthOfFieldPostProcess;
  144489. private _createMotionBlurPostProcess;
  144490. private _getDepthTexture;
  144491. private _disposePostProcesses;
  144492. /**
  144493. * Dispose of the pipeline and stop all post processes
  144494. */
  144495. dispose(): void;
  144496. /**
  144497. * Serialize the rendering pipeline (Used when exporting)
  144498. * @returns the serialized object
  144499. */
  144500. serialize(): any;
  144501. /**
  144502. * Parse the serialized pipeline
  144503. * @param source Source pipeline.
  144504. * @param scene The scene to load the pipeline to.
  144505. * @param rootUrl The URL of the serialized pipeline.
  144506. * @returns An instantiated pipeline from the serialized object.
  144507. */
  144508. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  144509. /**
  144510. * Luminance steps
  144511. */
  144512. static LuminanceSteps: number;
  144513. }
  144514. }
  144515. declare module BABYLON {
  144516. /** @hidden */
  144517. export var stereoscopicInterlacePixelShader: {
  144518. name: string;
  144519. shader: string;
  144520. };
  144521. }
  144522. declare module BABYLON {
  144523. /**
  144524. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  144525. */
  144526. export class StereoscopicInterlacePostProcessI extends PostProcess {
  144527. private _stepSize;
  144528. private _passedProcess;
  144529. /**
  144530. * Initializes a StereoscopicInterlacePostProcessI
  144531. * @param name The name of the effect.
  144532. * @param rigCameras The rig cameras to be appled to the post process
  144533. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  144534. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  144535. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  144536. * @param engine The engine which the post process will be applied. (default: current engine)
  144537. * @param reusable If the post process can be reused on the same frame. (default: false)
  144538. */
  144539. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  144540. }
  144541. /**
  144542. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  144543. */
  144544. export class StereoscopicInterlacePostProcess extends PostProcess {
  144545. private _stepSize;
  144546. private _passedProcess;
  144547. /**
  144548. * Initializes a StereoscopicInterlacePostProcess
  144549. * @param name The name of the effect.
  144550. * @param rigCameras The rig cameras to be appled to the post process
  144551. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  144552. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  144553. * @param engine The engine which the post process will be applied. (default: current engine)
  144554. * @param reusable If the post process can be reused on the same frame. (default: false)
  144555. */
  144556. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  144557. }
  144558. }
  144559. declare module BABYLON {
  144560. /** @hidden */
  144561. export var tonemapPixelShader: {
  144562. name: string;
  144563. shader: string;
  144564. };
  144565. }
  144566. declare module BABYLON {
  144567. /** Defines operator used for tonemapping */
  144568. export enum TonemappingOperator {
  144569. /** Hable */
  144570. Hable = 0,
  144571. /** Reinhard */
  144572. Reinhard = 1,
  144573. /** HejiDawson */
  144574. HejiDawson = 2,
  144575. /** Photographic */
  144576. Photographic = 3
  144577. }
  144578. /**
  144579. * Defines a post process to apply tone mapping
  144580. */
  144581. export class TonemapPostProcess extends PostProcess {
  144582. private _operator;
  144583. /** Defines the required exposure adjustement */
  144584. exposureAdjustment: number;
  144585. /**
  144586. * Creates a new TonemapPostProcess
  144587. * @param name defines the name of the postprocess
  144588. * @param _operator defines the operator to use
  144589. * @param exposureAdjustment defines the required exposure adjustement
  144590. * @param camera defines the camera to use (can be null)
  144591. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  144592. * @param engine defines the hosting engine (can be ignore if camera is set)
  144593. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  144594. */
  144595. constructor(name: string, _operator: TonemappingOperator,
  144596. /** Defines the required exposure adjustement */
  144597. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  144598. }
  144599. }
  144600. declare module BABYLON {
  144601. /** @hidden */
  144602. export var volumetricLightScatteringPixelShader: {
  144603. name: string;
  144604. shader: string;
  144605. };
  144606. }
  144607. declare module BABYLON {
  144608. /** @hidden */
  144609. export var volumetricLightScatteringPassVertexShader: {
  144610. name: string;
  144611. shader: string;
  144612. };
  144613. }
  144614. declare module BABYLON {
  144615. /** @hidden */
  144616. export var volumetricLightScatteringPassPixelShader: {
  144617. name: string;
  144618. shader: string;
  144619. };
  144620. }
  144621. declare module BABYLON {
  144622. /**
  144623. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  144624. */
  144625. export class VolumetricLightScatteringPostProcess extends PostProcess {
  144626. private _volumetricLightScatteringPass;
  144627. private _volumetricLightScatteringRTT;
  144628. private _viewPort;
  144629. private _screenCoordinates;
  144630. private _cachedDefines;
  144631. /**
  144632. * If not undefined, the mesh position is computed from the attached node position
  144633. */
  144634. attachedNode: {
  144635. position: Vector3;
  144636. };
  144637. /**
  144638. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  144639. */
  144640. customMeshPosition: Vector3;
  144641. /**
  144642. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  144643. */
  144644. useCustomMeshPosition: boolean;
  144645. /**
  144646. * If the post-process should inverse the light scattering direction
  144647. */
  144648. invert: boolean;
  144649. /**
  144650. * The internal mesh used by the post-process
  144651. */
  144652. mesh: Mesh;
  144653. /**
  144654. * @hidden
  144655. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  144656. */
  144657. get useDiffuseColor(): boolean;
  144658. set useDiffuseColor(useDiffuseColor: boolean);
  144659. /**
  144660. * Array containing the excluded meshes not rendered in the internal pass
  144661. */
  144662. excludedMeshes: AbstractMesh[];
  144663. /**
  144664. * Controls the overall intensity of the post-process
  144665. */
  144666. exposure: number;
  144667. /**
  144668. * Dissipates each sample's contribution in range [0, 1]
  144669. */
  144670. decay: number;
  144671. /**
  144672. * Controls the overall intensity of each sample
  144673. */
  144674. weight: number;
  144675. /**
  144676. * Controls the density of each sample
  144677. */
  144678. density: number;
  144679. /**
  144680. * @constructor
  144681. * @param name The post-process name
  144682. * @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)
  144683. * @param camera The camera that the post-process will be attached to
  144684. * @param mesh The mesh used to create the light scattering
  144685. * @param samples The post-process quality, default 100
  144686. * @param samplingModeThe post-process filtering mode
  144687. * @param engine The babylon engine
  144688. * @param reusable If the post-process is reusable
  144689. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  144690. */
  144691. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  144692. /**
  144693. * Returns the string "VolumetricLightScatteringPostProcess"
  144694. * @returns "VolumetricLightScatteringPostProcess"
  144695. */
  144696. getClassName(): string;
  144697. private _isReady;
  144698. /**
  144699. * Sets the new light position for light scattering effect
  144700. * @param position The new custom light position
  144701. */
  144702. setCustomMeshPosition(position: Vector3): void;
  144703. /**
  144704. * Returns the light position for light scattering effect
  144705. * @return Vector3 The custom light position
  144706. */
  144707. getCustomMeshPosition(): Vector3;
  144708. /**
  144709. * Disposes the internal assets and detaches the post-process from the camera
  144710. */
  144711. dispose(camera: Camera): void;
  144712. /**
  144713. * Returns the render target texture used by the post-process
  144714. * @return the render target texture used by the post-process
  144715. */
  144716. getPass(): RenderTargetTexture;
  144717. private _meshExcluded;
  144718. private _createPass;
  144719. private _updateMeshScreenCoordinates;
  144720. /**
  144721. * Creates a default mesh for the Volumeric Light Scattering post-process
  144722. * @param name The mesh name
  144723. * @param scene The scene where to create the mesh
  144724. * @return the default mesh
  144725. */
  144726. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  144727. }
  144728. }
  144729. declare module BABYLON {
  144730. interface Scene {
  144731. /** @hidden (Backing field) */
  144732. _boundingBoxRenderer: BoundingBoxRenderer;
  144733. /** @hidden (Backing field) */
  144734. _forceShowBoundingBoxes: boolean;
  144735. /**
  144736. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  144737. */
  144738. forceShowBoundingBoxes: boolean;
  144739. /**
  144740. * Gets the bounding box renderer associated with the scene
  144741. * @returns a BoundingBoxRenderer
  144742. */
  144743. getBoundingBoxRenderer(): BoundingBoxRenderer;
  144744. }
  144745. interface AbstractMesh {
  144746. /** @hidden (Backing field) */
  144747. _showBoundingBox: boolean;
  144748. /**
  144749. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  144750. */
  144751. showBoundingBox: boolean;
  144752. }
  144753. /**
  144754. * Component responsible of rendering the bounding box of the meshes in a scene.
  144755. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  144756. */
  144757. export class BoundingBoxRenderer implements ISceneComponent {
  144758. /**
  144759. * The component name helpfull to identify the component in the list of scene components.
  144760. */
  144761. readonly name: string;
  144762. /**
  144763. * The scene the component belongs to.
  144764. */
  144765. scene: Scene;
  144766. /**
  144767. * Color of the bounding box lines placed in front of an object
  144768. */
  144769. frontColor: Color3;
  144770. /**
  144771. * Color of the bounding box lines placed behind an object
  144772. */
  144773. backColor: Color3;
  144774. /**
  144775. * Defines if the renderer should show the back lines or not
  144776. */
  144777. showBackLines: boolean;
  144778. /**
  144779. * @hidden
  144780. */
  144781. renderList: SmartArray<BoundingBox>;
  144782. private _colorShader;
  144783. private _vertexBuffers;
  144784. private _indexBuffer;
  144785. private _fillIndexBuffer;
  144786. private _fillIndexData;
  144787. /**
  144788. * Instantiates a new bounding box renderer in a scene.
  144789. * @param scene the scene the renderer renders in
  144790. */
  144791. constructor(scene: Scene);
  144792. /**
  144793. * Registers the component in a given scene
  144794. */
  144795. register(): void;
  144796. private _evaluateSubMesh;
  144797. private _activeMesh;
  144798. private _prepareRessources;
  144799. private _createIndexBuffer;
  144800. /**
  144801. * Rebuilds the elements related to this component in case of
  144802. * context lost for instance.
  144803. */
  144804. rebuild(): void;
  144805. /**
  144806. * @hidden
  144807. */
  144808. reset(): void;
  144809. /**
  144810. * Render the bounding boxes of a specific rendering group
  144811. * @param renderingGroupId defines the rendering group to render
  144812. */
  144813. render(renderingGroupId: number): void;
  144814. /**
  144815. * In case of occlusion queries, we can render the occlusion bounding box through this method
  144816. * @param mesh Define the mesh to render the occlusion bounding box for
  144817. */
  144818. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  144819. /**
  144820. * Dispose and release the resources attached to this renderer.
  144821. */
  144822. dispose(): void;
  144823. }
  144824. }
  144825. declare module BABYLON {
  144826. interface Scene {
  144827. /** @hidden (Backing field) */
  144828. _depthRenderer: {
  144829. [id: string]: DepthRenderer;
  144830. };
  144831. /**
  144832. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  144833. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  144834. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  144835. * @returns the created depth renderer
  144836. */
  144837. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  144838. /**
  144839. * Disables a depth renderer for a given camera
  144840. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  144841. */
  144842. disableDepthRenderer(camera?: Nullable<Camera>): void;
  144843. }
  144844. /**
  144845. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  144846. * in several rendering techniques.
  144847. */
  144848. export class DepthRendererSceneComponent implements ISceneComponent {
  144849. /**
  144850. * The component name helpfull to identify the component in the list of scene components.
  144851. */
  144852. readonly name: string;
  144853. /**
  144854. * The scene the component belongs to.
  144855. */
  144856. scene: Scene;
  144857. /**
  144858. * Creates a new instance of the component for the given scene
  144859. * @param scene Defines the scene to register the component in
  144860. */
  144861. constructor(scene: Scene);
  144862. /**
  144863. * Registers the component in a given scene
  144864. */
  144865. register(): void;
  144866. /**
  144867. * Rebuilds the elements related to this component in case of
  144868. * context lost for instance.
  144869. */
  144870. rebuild(): void;
  144871. /**
  144872. * Disposes the component and the associated ressources
  144873. */
  144874. dispose(): void;
  144875. private _gatherRenderTargets;
  144876. private _gatherActiveCameraRenderTargets;
  144877. }
  144878. }
  144879. declare module BABYLON {
  144880. /** @hidden */
  144881. export var outlinePixelShader: {
  144882. name: string;
  144883. shader: string;
  144884. };
  144885. }
  144886. declare module BABYLON {
  144887. /** @hidden */
  144888. export var outlineVertexShader: {
  144889. name: string;
  144890. shader: string;
  144891. };
  144892. }
  144893. declare module BABYLON {
  144894. interface Scene {
  144895. /** @hidden */
  144896. _outlineRenderer: OutlineRenderer;
  144897. /**
  144898. * Gets the outline renderer associated with the scene
  144899. * @returns a OutlineRenderer
  144900. */
  144901. getOutlineRenderer(): OutlineRenderer;
  144902. }
  144903. interface AbstractMesh {
  144904. /** @hidden (Backing field) */
  144905. _renderOutline: boolean;
  144906. /**
  144907. * Gets or sets a boolean indicating if the outline must be rendered as well
  144908. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  144909. */
  144910. renderOutline: boolean;
  144911. /** @hidden (Backing field) */
  144912. _renderOverlay: boolean;
  144913. /**
  144914. * Gets or sets a boolean indicating if the overlay must be rendered as well
  144915. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  144916. */
  144917. renderOverlay: boolean;
  144918. }
  144919. /**
  144920. * This class is responsible to draw bothe outline/overlay of meshes.
  144921. * It should not be used directly but through the available method on mesh.
  144922. */
  144923. export class OutlineRenderer implements ISceneComponent {
  144924. /**
  144925. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  144926. */
  144927. private static _StencilReference;
  144928. /**
  144929. * The name of the component. Each component must have a unique name.
  144930. */
  144931. name: string;
  144932. /**
  144933. * The scene the component belongs to.
  144934. */
  144935. scene: Scene;
  144936. /**
  144937. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  144938. */
  144939. zOffset: number;
  144940. private _engine;
  144941. private _effect;
  144942. private _cachedDefines;
  144943. private _savedDepthWrite;
  144944. /**
  144945. * Instantiates a new outline renderer. (There could be only one per scene).
  144946. * @param scene Defines the scene it belongs to
  144947. */
  144948. constructor(scene: Scene);
  144949. /**
  144950. * Register the component to one instance of a scene.
  144951. */
  144952. register(): void;
  144953. /**
  144954. * Rebuilds the elements related to this component in case of
  144955. * context lost for instance.
  144956. */
  144957. rebuild(): void;
  144958. /**
  144959. * Disposes the component and the associated ressources.
  144960. */
  144961. dispose(): void;
  144962. /**
  144963. * Renders the outline in the canvas.
  144964. * @param subMesh Defines the sumesh to render
  144965. * @param batch Defines the batch of meshes in case of instances
  144966. * @param useOverlay Defines if the rendering is for the overlay or the outline
  144967. */
  144968. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  144969. /**
  144970. * Returns whether or not the outline renderer is ready for a given submesh.
  144971. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  144972. * @param subMesh Defines the submesh to check readyness for
  144973. * @param useInstances Defines wheter wee are trying to render instances or not
  144974. * @returns true if ready otherwise false
  144975. */
  144976. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  144977. private _beforeRenderingMesh;
  144978. private _afterRenderingMesh;
  144979. }
  144980. }
  144981. declare module BABYLON {
  144982. /**
  144983. * Defines the basic options interface of a Sprite Frame Source Size.
  144984. */
  144985. export interface ISpriteJSONSpriteSourceSize {
  144986. /**
  144987. * number of the original width of the Frame
  144988. */
  144989. w: number;
  144990. /**
  144991. * number of the original height of the Frame
  144992. */
  144993. h: number;
  144994. }
  144995. /**
  144996. * Defines the basic options interface of a Sprite Frame Data.
  144997. */
  144998. export interface ISpriteJSONSpriteFrameData {
  144999. /**
  145000. * number of the x offset of the Frame
  145001. */
  145002. x: number;
  145003. /**
  145004. * number of the y offset of the Frame
  145005. */
  145006. y: number;
  145007. /**
  145008. * number of the width of the Frame
  145009. */
  145010. w: number;
  145011. /**
  145012. * number of the height of the Frame
  145013. */
  145014. h: number;
  145015. }
  145016. /**
  145017. * Defines the basic options interface of a JSON Sprite.
  145018. */
  145019. export interface ISpriteJSONSprite {
  145020. /**
  145021. * string name of the Frame
  145022. */
  145023. filename: string;
  145024. /**
  145025. * ISpriteJSONSpriteFrame basic object of the frame data
  145026. */
  145027. frame: ISpriteJSONSpriteFrameData;
  145028. /**
  145029. * boolean to flag is the frame was rotated.
  145030. */
  145031. rotated: boolean;
  145032. /**
  145033. * boolean to flag is the frame was trimmed.
  145034. */
  145035. trimmed: boolean;
  145036. /**
  145037. * ISpriteJSONSpriteFrame basic object of the source data
  145038. */
  145039. spriteSourceSize: ISpriteJSONSpriteFrameData;
  145040. /**
  145041. * ISpriteJSONSpriteFrame basic object of the source data
  145042. */
  145043. sourceSize: ISpriteJSONSpriteSourceSize;
  145044. }
  145045. /**
  145046. * Defines the basic options interface of a JSON atlas.
  145047. */
  145048. export interface ISpriteJSONAtlas {
  145049. /**
  145050. * Array of objects that contain the frame data.
  145051. */
  145052. frames: Array<ISpriteJSONSprite>;
  145053. /**
  145054. * object basic object containing the sprite meta data.
  145055. */
  145056. meta?: object;
  145057. }
  145058. }
  145059. declare module BABYLON {
  145060. /** @hidden */
  145061. export var spriteMapPixelShader: {
  145062. name: string;
  145063. shader: string;
  145064. };
  145065. }
  145066. declare module BABYLON {
  145067. /** @hidden */
  145068. export var spriteMapVertexShader: {
  145069. name: string;
  145070. shader: string;
  145071. };
  145072. }
  145073. declare module BABYLON {
  145074. /**
  145075. * Defines the basic options interface of a SpriteMap
  145076. */
  145077. export interface ISpriteMapOptions {
  145078. /**
  145079. * Vector2 of the number of cells in the grid.
  145080. */
  145081. stageSize?: Vector2;
  145082. /**
  145083. * Vector2 of the size of the output plane in World Units.
  145084. */
  145085. outputSize?: Vector2;
  145086. /**
  145087. * Vector3 of the position of the output plane in World Units.
  145088. */
  145089. outputPosition?: Vector3;
  145090. /**
  145091. * Vector3 of the rotation of the output plane.
  145092. */
  145093. outputRotation?: Vector3;
  145094. /**
  145095. * number of layers that the system will reserve in resources.
  145096. */
  145097. layerCount?: number;
  145098. /**
  145099. * number of max animation frames a single cell will reserve in resources.
  145100. */
  145101. maxAnimationFrames?: number;
  145102. /**
  145103. * number cell index of the base tile when the system compiles.
  145104. */
  145105. baseTile?: number;
  145106. /**
  145107. * boolean flip the sprite after its been repositioned by the framing data.
  145108. */
  145109. flipU?: boolean;
  145110. /**
  145111. * Vector3 scalar of the global RGB values of the SpriteMap.
  145112. */
  145113. colorMultiply?: Vector3;
  145114. }
  145115. /**
  145116. * Defines the IDisposable interface in order to be cleanable from resources.
  145117. */
  145118. export interface ISpriteMap extends IDisposable {
  145119. /**
  145120. * String name of the SpriteMap.
  145121. */
  145122. name: string;
  145123. /**
  145124. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  145125. */
  145126. atlasJSON: ISpriteJSONAtlas;
  145127. /**
  145128. * Texture of the SpriteMap.
  145129. */
  145130. spriteSheet: Texture;
  145131. /**
  145132. * The parameters to initialize the SpriteMap with.
  145133. */
  145134. options: ISpriteMapOptions;
  145135. }
  145136. /**
  145137. * Class used to manage a grid restricted sprite deployment on an Output plane.
  145138. */
  145139. export class SpriteMap implements ISpriteMap {
  145140. /** The Name of the spriteMap */
  145141. name: string;
  145142. /** The JSON file with the frame and meta data */
  145143. atlasJSON: ISpriteJSONAtlas;
  145144. /** The systems Sprite Sheet Texture */
  145145. spriteSheet: Texture;
  145146. /** Arguments passed with the Constructor */
  145147. options: ISpriteMapOptions;
  145148. /** Public Sprite Storage array, parsed from atlasJSON */
  145149. sprites: Array<ISpriteJSONSprite>;
  145150. /** Returns the Number of Sprites in the System */
  145151. get spriteCount(): number;
  145152. /** Returns the Position of Output Plane*/
  145153. get position(): Vector3;
  145154. /** Returns the Position of Output Plane*/
  145155. set position(v: Vector3);
  145156. /** Returns the Rotation of Output Plane*/
  145157. get rotation(): Vector3;
  145158. /** Returns the Rotation of Output Plane*/
  145159. set rotation(v: Vector3);
  145160. /** Sets the AnimationMap*/
  145161. get animationMap(): RawTexture;
  145162. /** Sets the AnimationMap*/
  145163. set animationMap(v: RawTexture);
  145164. /** Scene that the SpriteMap was created in */
  145165. private _scene;
  145166. /** Texture Buffer of Float32 that holds tile frame data*/
  145167. private _frameMap;
  145168. /** Texture Buffers of Float32 that holds tileMap data*/
  145169. private _tileMaps;
  145170. /** Texture Buffer of Float32 that holds Animation Data*/
  145171. private _animationMap;
  145172. /** Custom ShaderMaterial Central to the System*/
  145173. private _material;
  145174. /** Custom ShaderMaterial Central to the System*/
  145175. private _output;
  145176. /** Systems Time Ticker*/
  145177. private _time;
  145178. /**
  145179. * Creates a new SpriteMap
  145180. * @param name defines the SpriteMaps Name
  145181. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  145182. * @param spriteSheet is the Texture that the Sprites are on.
  145183. * @param options a basic deployment configuration
  145184. * @param scene The Scene that the map is deployed on
  145185. */
  145186. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  145187. /**
  145188. * Returns tileID location
  145189. * @returns Vector2 the cell position ID
  145190. */
  145191. getTileID(): Vector2;
  145192. /**
  145193. * Gets the UV location of the mouse over the SpriteMap.
  145194. * @returns Vector2 the UV position of the mouse interaction
  145195. */
  145196. getMousePosition(): Vector2;
  145197. /**
  145198. * Creates the "frame" texture Buffer
  145199. * -------------------------------------
  145200. * Structure of frames
  145201. * "filename": "Falling-Water-2.png",
  145202. * "frame": {"x":69,"y":103,"w":24,"h":32},
  145203. * "rotated": true,
  145204. * "trimmed": true,
  145205. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  145206. * "sourceSize": {"w":32,"h":32}
  145207. * @returns RawTexture of the frameMap
  145208. */
  145209. private _createFrameBuffer;
  145210. /**
  145211. * Creates the tileMap texture Buffer
  145212. * @param buffer normally and array of numbers, or a false to generate from scratch
  145213. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  145214. * @returns RawTexture of the tileMap
  145215. */
  145216. private _createTileBuffer;
  145217. /**
  145218. * Modifies the data of the tileMaps
  145219. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  145220. * @param pos is the iVector2 Coordinates of the Tile
  145221. * @param tile The SpriteIndex of the new Tile
  145222. */
  145223. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  145224. /**
  145225. * Creates the animationMap texture Buffer
  145226. * @param buffer normally and array of numbers, or a false to generate from scratch
  145227. * @returns RawTexture of the animationMap
  145228. */
  145229. private _createTileAnimationBuffer;
  145230. /**
  145231. * Modifies the data of the animationMap
  145232. * @param cellID is the Index of the Sprite
  145233. * @param _frame is the target Animation frame
  145234. * @param toCell is the Target Index of the next frame of the animation
  145235. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  145236. * @param speed is a global scalar of the time variable on the map.
  145237. */
  145238. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  145239. /**
  145240. * Exports the .tilemaps file
  145241. */
  145242. saveTileMaps(): void;
  145243. /**
  145244. * Imports the .tilemaps file
  145245. * @param url of the .tilemaps file
  145246. */
  145247. loadTileMaps(url: string): void;
  145248. /**
  145249. * Release associated resources
  145250. */
  145251. dispose(): void;
  145252. }
  145253. }
  145254. declare module BABYLON {
  145255. /**
  145256. * Class used to manage multiple sprites of different sizes on the same spritesheet
  145257. * @see http://doc.babylonjs.com/babylon101/sprites
  145258. */
  145259. export class SpritePackedManager extends SpriteManager {
  145260. /** defines the packed manager's name */
  145261. name: string;
  145262. /**
  145263. * Creates a new sprite manager from a packed sprite sheet
  145264. * @param name defines the manager's name
  145265. * @param imgUrl defines the sprite sheet url
  145266. * @param capacity defines the maximum allowed number of sprites
  145267. * @param scene defines the hosting scene
  145268. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  145269. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  145270. * @param samplingMode defines the smapling mode to use with spritesheet
  145271. * @param fromPacked set to true; do not alter
  145272. */
  145273. constructor(
  145274. /** defines the packed manager's name */
  145275. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  145276. }
  145277. }
  145278. declare module BABYLON {
  145279. /**
  145280. * Defines the list of states available for a task inside a AssetsManager
  145281. */
  145282. export enum AssetTaskState {
  145283. /**
  145284. * Initialization
  145285. */
  145286. INIT = 0,
  145287. /**
  145288. * Running
  145289. */
  145290. RUNNING = 1,
  145291. /**
  145292. * Done
  145293. */
  145294. DONE = 2,
  145295. /**
  145296. * Error
  145297. */
  145298. ERROR = 3
  145299. }
  145300. /**
  145301. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  145302. */
  145303. export abstract class AbstractAssetTask {
  145304. /**
  145305. * Task name
  145306. */ name: string;
  145307. /**
  145308. * Callback called when the task is successful
  145309. */
  145310. onSuccess: (task: any) => void;
  145311. /**
  145312. * Callback called when the task is not successful
  145313. */
  145314. onError: (task: any, message?: string, exception?: any) => void;
  145315. /**
  145316. * Creates a new AssetsManager
  145317. * @param name defines the name of the task
  145318. */
  145319. constructor(
  145320. /**
  145321. * Task name
  145322. */ name: string);
  145323. private _isCompleted;
  145324. private _taskState;
  145325. private _errorObject;
  145326. /**
  145327. * Get if the task is completed
  145328. */
  145329. get isCompleted(): boolean;
  145330. /**
  145331. * Gets the current state of the task
  145332. */
  145333. get taskState(): AssetTaskState;
  145334. /**
  145335. * Gets the current error object (if task is in error)
  145336. */
  145337. get errorObject(): {
  145338. message?: string;
  145339. exception?: any;
  145340. };
  145341. /**
  145342. * Internal only
  145343. * @hidden
  145344. */
  145345. _setErrorObject(message?: string, exception?: any): void;
  145346. /**
  145347. * Execute the current task
  145348. * @param scene defines the scene where you want your assets to be loaded
  145349. * @param onSuccess is a callback called when the task is successfully executed
  145350. * @param onError is a callback called if an error occurs
  145351. */
  145352. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  145353. /**
  145354. * Execute the current task
  145355. * @param scene defines the scene where you want your assets to be loaded
  145356. * @param onSuccess is a callback called when the task is successfully executed
  145357. * @param onError is a callback called if an error occurs
  145358. */
  145359. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  145360. /**
  145361. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  145362. * This can be used with failed tasks that have the reason for failure fixed.
  145363. */
  145364. reset(): void;
  145365. private onErrorCallback;
  145366. private onDoneCallback;
  145367. }
  145368. /**
  145369. * Define the interface used by progress events raised during assets loading
  145370. */
  145371. export interface IAssetsProgressEvent {
  145372. /**
  145373. * Defines the number of remaining tasks to process
  145374. */
  145375. remainingCount: number;
  145376. /**
  145377. * Defines the total number of tasks
  145378. */
  145379. totalCount: number;
  145380. /**
  145381. * Defines the task that was just processed
  145382. */
  145383. task: AbstractAssetTask;
  145384. }
  145385. /**
  145386. * Class used to share progress information about assets loading
  145387. */
  145388. export class AssetsProgressEvent implements IAssetsProgressEvent {
  145389. /**
  145390. * Defines the number of remaining tasks to process
  145391. */
  145392. remainingCount: number;
  145393. /**
  145394. * Defines the total number of tasks
  145395. */
  145396. totalCount: number;
  145397. /**
  145398. * Defines the task that was just processed
  145399. */
  145400. task: AbstractAssetTask;
  145401. /**
  145402. * Creates a AssetsProgressEvent
  145403. * @param remainingCount defines the number of remaining tasks to process
  145404. * @param totalCount defines the total number of tasks
  145405. * @param task defines the task that was just processed
  145406. */
  145407. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  145408. }
  145409. /**
  145410. * Define a task used by AssetsManager to load meshes
  145411. */
  145412. export class MeshAssetTask extends AbstractAssetTask {
  145413. /**
  145414. * Defines the name of the task
  145415. */
  145416. name: string;
  145417. /**
  145418. * Defines the list of mesh's names you want to load
  145419. */
  145420. meshesNames: any;
  145421. /**
  145422. * Defines the root url to use as a base to load your meshes and associated resources
  145423. */
  145424. rootUrl: string;
  145425. /**
  145426. * Defines the filename or File of the scene to load from
  145427. */
  145428. sceneFilename: string | File;
  145429. /**
  145430. * Gets the list of loaded meshes
  145431. */
  145432. loadedMeshes: Array<AbstractMesh>;
  145433. /**
  145434. * Gets the list of loaded particle systems
  145435. */
  145436. loadedParticleSystems: Array<IParticleSystem>;
  145437. /**
  145438. * Gets the list of loaded skeletons
  145439. */
  145440. loadedSkeletons: Array<Skeleton>;
  145441. /**
  145442. * Gets the list of loaded animation groups
  145443. */
  145444. loadedAnimationGroups: Array<AnimationGroup>;
  145445. /**
  145446. * Callback called when the task is successful
  145447. */
  145448. onSuccess: (task: MeshAssetTask) => void;
  145449. /**
  145450. * Callback called when the task is successful
  145451. */
  145452. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  145453. /**
  145454. * Creates a new MeshAssetTask
  145455. * @param name defines the name of the task
  145456. * @param meshesNames defines the list of mesh's names you want to load
  145457. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  145458. * @param sceneFilename defines the filename or File of the scene to load from
  145459. */
  145460. constructor(
  145461. /**
  145462. * Defines the name of the task
  145463. */
  145464. name: string,
  145465. /**
  145466. * Defines the list of mesh's names you want to load
  145467. */
  145468. meshesNames: any,
  145469. /**
  145470. * Defines the root url to use as a base to load your meshes and associated resources
  145471. */
  145472. rootUrl: string,
  145473. /**
  145474. * Defines the filename or File of the scene to load from
  145475. */
  145476. sceneFilename: string | File);
  145477. /**
  145478. * Execute the current task
  145479. * @param scene defines the scene where you want your assets to be loaded
  145480. * @param onSuccess is a callback called when the task is successfully executed
  145481. * @param onError is a callback called if an error occurs
  145482. */
  145483. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  145484. }
  145485. /**
  145486. * Define a task used by AssetsManager to load text content
  145487. */
  145488. export class TextFileAssetTask extends AbstractAssetTask {
  145489. /**
  145490. * Defines the name of the task
  145491. */
  145492. name: string;
  145493. /**
  145494. * Defines the location of the file to load
  145495. */
  145496. url: string;
  145497. /**
  145498. * Gets the loaded text string
  145499. */
  145500. text: string;
  145501. /**
  145502. * Callback called when the task is successful
  145503. */
  145504. onSuccess: (task: TextFileAssetTask) => void;
  145505. /**
  145506. * Callback called when the task is successful
  145507. */
  145508. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  145509. /**
  145510. * Creates a new TextFileAssetTask object
  145511. * @param name defines the name of the task
  145512. * @param url defines the location of the file to load
  145513. */
  145514. constructor(
  145515. /**
  145516. * Defines the name of the task
  145517. */
  145518. name: string,
  145519. /**
  145520. * Defines the location of the file to load
  145521. */
  145522. url: string);
  145523. /**
  145524. * Execute the current task
  145525. * @param scene defines the scene where you want your assets to be loaded
  145526. * @param onSuccess is a callback called when the task is successfully executed
  145527. * @param onError is a callback called if an error occurs
  145528. */
  145529. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  145530. }
  145531. /**
  145532. * Define a task used by AssetsManager to load binary data
  145533. */
  145534. export class BinaryFileAssetTask extends AbstractAssetTask {
  145535. /**
  145536. * Defines the name of the task
  145537. */
  145538. name: string;
  145539. /**
  145540. * Defines the location of the file to load
  145541. */
  145542. url: string;
  145543. /**
  145544. * Gets the lodaded data (as an array buffer)
  145545. */
  145546. data: ArrayBuffer;
  145547. /**
  145548. * Callback called when the task is successful
  145549. */
  145550. onSuccess: (task: BinaryFileAssetTask) => void;
  145551. /**
  145552. * Callback called when the task is successful
  145553. */
  145554. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  145555. /**
  145556. * Creates a new BinaryFileAssetTask object
  145557. * @param name defines the name of the new task
  145558. * @param url defines the location of the file to load
  145559. */
  145560. constructor(
  145561. /**
  145562. * Defines the name of the task
  145563. */
  145564. name: string,
  145565. /**
  145566. * Defines the location of the file to load
  145567. */
  145568. url: string);
  145569. /**
  145570. * Execute the current task
  145571. * @param scene defines the scene where you want your assets to be loaded
  145572. * @param onSuccess is a callback called when the task is successfully executed
  145573. * @param onError is a callback called if an error occurs
  145574. */
  145575. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  145576. }
  145577. /**
  145578. * Define a task used by AssetsManager to load images
  145579. */
  145580. export class ImageAssetTask extends AbstractAssetTask {
  145581. /**
  145582. * Defines the name of the task
  145583. */
  145584. name: string;
  145585. /**
  145586. * Defines the location of the image to load
  145587. */
  145588. url: string;
  145589. /**
  145590. * Gets the loaded images
  145591. */
  145592. image: HTMLImageElement;
  145593. /**
  145594. * Callback called when the task is successful
  145595. */
  145596. onSuccess: (task: ImageAssetTask) => void;
  145597. /**
  145598. * Callback called when the task is successful
  145599. */
  145600. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  145601. /**
  145602. * Creates a new ImageAssetTask
  145603. * @param name defines the name of the task
  145604. * @param url defines the location of the image to load
  145605. */
  145606. constructor(
  145607. /**
  145608. * Defines the name of the task
  145609. */
  145610. name: string,
  145611. /**
  145612. * Defines the location of the image to load
  145613. */
  145614. url: string);
  145615. /**
  145616. * Execute the current task
  145617. * @param scene defines the scene where you want your assets to be loaded
  145618. * @param onSuccess is a callback called when the task is successfully executed
  145619. * @param onError is a callback called if an error occurs
  145620. */
  145621. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  145622. }
  145623. /**
  145624. * Defines the interface used by texture loading tasks
  145625. */
  145626. export interface ITextureAssetTask<TEX extends BaseTexture> {
  145627. /**
  145628. * Gets the loaded texture
  145629. */
  145630. texture: TEX;
  145631. }
  145632. /**
  145633. * Define a task used by AssetsManager to load 2D textures
  145634. */
  145635. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  145636. /**
  145637. * Defines the name of the task
  145638. */
  145639. name: string;
  145640. /**
  145641. * Defines the location of the file to load
  145642. */
  145643. url: string;
  145644. /**
  145645. * Defines if mipmap should not be generated (default is false)
  145646. */
  145647. noMipmap?: boolean | undefined;
  145648. /**
  145649. * Defines if texture must be inverted on Y axis (default is true)
  145650. */
  145651. invertY: boolean;
  145652. /**
  145653. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  145654. */
  145655. samplingMode: number;
  145656. /**
  145657. * Gets the loaded texture
  145658. */
  145659. texture: Texture;
  145660. /**
  145661. * Callback called when the task is successful
  145662. */
  145663. onSuccess: (task: TextureAssetTask) => void;
  145664. /**
  145665. * Callback called when the task is successful
  145666. */
  145667. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  145668. /**
  145669. * Creates a new TextureAssetTask object
  145670. * @param name defines the name of the task
  145671. * @param url defines the location of the file to load
  145672. * @param noMipmap defines if mipmap should not be generated (default is false)
  145673. * @param invertY defines if texture must be inverted on Y axis (default is true)
  145674. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  145675. */
  145676. constructor(
  145677. /**
  145678. * Defines the name of the task
  145679. */
  145680. name: string,
  145681. /**
  145682. * Defines the location of the file to load
  145683. */
  145684. url: string,
  145685. /**
  145686. * Defines if mipmap should not be generated (default is false)
  145687. */
  145688. noMipmap?: boolean | undefined,
  145689. /**
  145690. * Defines if texture must be inverted on Y axis (default is true)
  145691. */
  145692. invertY?: boolean,
  145693. /**
  145694. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  145695. */
  145696. samplingMode?: number);
  145697. /**
  145698. * Execute the current task
  145699. * @param scene defines the scene where you want your assets to be loaded
  145700. * @param onSuccess is a callback called when the task is successfully executed
  145701. * @param onError is a callback called if an error occurs
  145702. */
  145703. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  145704. }
  145705. /**
  145706. * Define a task used by AssetsManager to load cube textures
  145707. */
  145708. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  145709. /**
  145710. * Defines the name of the task
  145711. */
  145712. name: string;
  145713. /**
  145714. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  145715. */
  145716. url: string;
  145717. /**
  145718. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  145719. */
  145720. extensions?: string[] | undefined;
  145721. /**
  145722. * Defines if mipmaps should not be generated (default is false)
  145723. */
  145724. noMipmap?: boolean | undefined;
  145725. /**
  145726. * Defines the explicit list of files (undefined by default)
  145727. */
  145728. files?: string[] | undefined;
  145729. /**
  145730. * Gets the loaded texture
  145731. */
  145732. texture: CubeTexture;
  145733. /**
  145734. * Callback called when the task is successful
  145735. */
  145736. onSuccess: (task: CubeTextureAssetTask) => void;
  145737. /**
  145738. * Callback called when the task is successful
  145739. */
  145740. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  145741. /**
  145742. * Creates a new CubeTextureAssetTask
  145743. * @param name defines the name of the task
  145744. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  145745. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  145746. * @param noMipmap defines if mipmaps should not be generated (default is false)
  145747. * @param files defines the explicit list of files (undefined by default)
  145748. */
  145749. constructor(
  145750. /**
  145751. * Defines the name of the task
  145752. */
  145753. name: string,
  145754. /**
  145755. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  145756. */
  145757. url: string,
  145758. /**
  145759. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  145760. */
  145761. extensions?: string[] | undefined,
  145762. /**
  145763. * Defines if mipmaps should not be generated (default is false)
  145764. */
  145765. noMipmap?: boolean | undefined,
  145766. /**
  145767. * Defines the explicit list of files (undefined by default)
  145768. */
  145769. files?: string[] | undefined);
  145770. /**
  145771. * Execute the current task
  145772. * @param scene defines the scene where you want your assets to be loaded
  145773. * @param onSuccess is a callback called when the task is successfully executed
  145774. * @param onError is a callback called if an error occurs
  145775. */
  145776. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  145777. }
  145778. /**
  145779. * Define a task used by AssetsManager to load HDR cube textures
  145780. */
  145781. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  145782. /**
  145783. * Defines the name of the task
  145784. */
  145785. name: string;
  145786. /**
  145787. * Defines the location of the file to load
  145788. */
  145789. url: string;
  145790. /**
  145791. * Defines the desired size (the more it increases the longer the generation will be)
  145792. */
  145793. size: number;
  145794. /**
  145795. * Defines if mipmaps should not be generated (default is false)
  145796. */
  145797. noMipmap: boolean;
  145798. /**
  145799. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  145800. */
  145801. generateHarmonics: boolean;
  145802. /**
  145803. * 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)
  145804. */
  145805. gammaSpace: boolean;
  145806. /**
  145807. * Internal Use Only
  145808. */
  145809. reserved: boolean;
  145810. /**
  145811. * Gets the loaded texture
  145812. */
  145813. texture: HDRCubeTexture;
  145814. /**
  145815. * Callback called when the task is successful
  145816. */
  145817. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  145818. /**
  145819. * Callback called when the task is successful
  145820. */
  145821. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  145822. /**
  145823. * Creates a new HDRCubeTextureAssetTask object
  145824. * @param name defines the name of the task
  145825. * @param url defines the location of the file to load
  145826. * @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.
  145827. * @param noMipmap defines if mipmaps should not be generated (default is false)
  145828. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  145829. * @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)
  145830. * @param reserved Internal use only
  145831. */
  145832. constructor(
  145833. /**
  145834. * Defines the name of the task
  145835. */
  145836. name: string,
  145837. /**
  145838. * Defines the location of the file to load
  145839. */
  145840. url: string,
  145841. /**
  145842. * Defines the desired size (the more it increases the longer the generation will be)
  145843. */
  145844. size: number,
  145845. /**
  145846. * Defines if mipmaps should not be generated (default is false)
  145847. */
  145848. noMipmap?: boolean,
  145849. /**
  145850. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  145851. */
  145852. generateHarmonics?: boolean,
  145853. /**
  145854. * 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)
  145855. */
  145856. gammaSpace?: boolean,
  145857. /**
  145858. * Internal Use Only
  145859. */
  145860. reserved?: boolean);
  145861. /**
  145862. * Execute the current task
  145863. * @param scene defines the scene where you want your assets to be loaded
  145864. * @param onSuccess is a callback called when the task is successfully executed
  145865. * @param onError is a callback called if an error occurs
  145866. */
  145867. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  145868. }
  145869. /**
  145870. * Define a task used by AssetsManager to load Equirectangular cube textures
  145871. */
  145872. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  145873. /**
  145874. * Defines the name of the task
  145875. */
  145876. name: string;
  145877. /**
  145878. * Defines the location of the file to load
  145879. */
  145880. url: string;
  145881. /**
  145882. * Defines the desired size (the more it increases the longer the generation will be)
  145883. */
  145884. size: number;
  145885. /**
  145886. * Defines if mipmaps should not be generated (default is false)
  145887. */
  145888. noMipmap: boolean;
  145889. /**
  145890. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  145891. * but the standard material would require them in Gamma space) (default is true)
  145892. */
  145893. gammaSpace: boolean;
  145894. /**
  145895. * Gets the loaded texture
  145896. */
  145897. texture: EquiRectangularCubeTexture;
  145898. /**
  145899. * Callback called when the task is successful
  145900. */
  145901. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  145902. /**
  145903. * Callback called when the task is successful
  145904. */
  145905. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  145906. /**
  145907. * Creates a new EquiRectangularCubeTextureAssetTask object
  145908. * @param name defines the name of the task
  145909. * @param url defines the location of the file to load
  145910. * @param size defines the desired size (the more it increases the longer the generation will be)
  145911. * If the size is omitted this implies you are using a preprocessed cubemap.
  145912. * @param noMipmap defines if mipmaps should not be generated (default is false)
  145913. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  145914. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  145915. * (default is true)
  145916. */
  145917. constructor(
  145918. /**
  145919. * Defines the name of the task
  145920. */
  145921. name: string,
  145922. /**
  145923. * Defines the location of the file to load
  145924. */
  145925. url: string,
  145926. /**
  145927. * Defines the desired size (the more it increases the longer the generation will be)
  145928. */
  145929. size: number,
  145930. /**
  145931. * Defines if mipmaps should not be generated (default is false)
  145932. */
  145933. noMipmap?: boolean,
  145934. /**
  145935. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  145936. * but the standard material would require them in Gamma space) (default is true)
  145937. */
  145938. gammaSpace?: boolean);
  145939. /**
  145940. * Execute the current task
  145941. * @param scene defines the scene where you want your assets to be loaded
  145942. * @param onSuccess is a callback called when the task is successfully executed
  145943. * @param onError is a callback called if an error occurs
  145944. */
  145945. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  145946. }
  145947. /**
  145948. * This class can be used to easily import assets into a scene
  145949. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  145950. */
  145951. export class AssetsManager {
  145952. private _scene;
  145953. private _isLoading;
  145954. protected _tasks: AbstractAssetTask[];
  145955. protected _waitingTasksCount: number;
  145956. protected _totalTasksCount: number;
  145957. /**
  145958. * Callback called when all tasks are processed
  145959. */
  145960. onFinish: (tasks: AbstractAssetTask[]) => void;
  145961. /**
  145962. * Callback called when a task is successful
  145963. */
  145964. onTaskSuccess: (task: AbstractAssetTask) => void;
  145965. /**
  145966. * Callback called when a task had an error
  145967. */
  145968. onTaskError: (task: AbstractAssetTask) => void;
  145969. /**
  145970. * Callback called when a task is done (whatever the result is)
  145971. */
  145972. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  145973. /**
  145974. * Observable called when all tasks are processed
  145975. */
  145976. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  145977. /**
  145978. * Observable called when a task had an error
  145979. */
  145980. onTaskErrorObservable: Observable<AbstractAssetTask>;
  145981. /**
  145982. * Observable called when all tasks were executed
  145983. */
  145984. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  145985. /**
  145986. * Observable called when a task is done (whatever the result is)
  145987. */
  145988. onProgressObservable: Observable<IAssetsProgressEvent>;
  145989. /**
  145990. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  145991. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  145992. */
  145993. useDefaultLoadingScreen: boolean;
  145994. /**
  145995. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  145996. * when all assets have been downloaded.
  145997. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  145998. */
  145999. autoHideLoadingUI: boolean;
  146000. /**
  146001. * Creates a new AssetsManager
  146002. * @param scene defines the scene to work on
  146003. */
  146004. constructor(scene: Scene);
  146005. /**
  146006. * Add a MeshAssetTask to the list of active tasks
  146007. * @param taskName defines the name of the new task
  146008. * @param meshesNames defines the name of meshes to load
  146009. * @param rootUrl defines the root url to use to locate files
  146010. * @param sceneFilename defines the filename of the scene file
  146011. * @returns a new MeshAssetTask object
  146012. */
  146013. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  146014. /**
  146015. * Add a TextFileAssetTask to the list of active tasks
  146016. * @param taskName defines the name of the new task
  146017. * @param url defines the url of the file to load
  146018. * @returns a new TextFileAssetTask object
  146019. */
  146020. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  146021. /**
  146022. * Add a BinaryFileAssetTask to the list of active tasks
  146023. * @param taskName defines the name of the new task
  146024. * @param url defines the url of the file to load
  146025. * @returns a new BinaryFileAssetTask object
  146026. */
  146027. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  146028. /**
  146029. * Add a ImageAssetTask to the list of active tasks
  146030. * @param taskName defines the name of the new task
  146031. * @param url defines the url of the file to load
  146032. * @returns a new ImageAssetTask object
  146033. */
  146034. addImageTask(taskName: string, url: string): ImageAssetTask;
  146035. /**
  146036. * Add a TextureAssetTask to the list of active tasks
  146037. * @param taskName defines the name of the new task
  146038. * @param url defines the url of the file to load
  146039. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  146040. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  146041. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  146042. * @returns a new TextureAssetTask object
  146043. */
  146044. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  146045. /**
  146046. * Add a CubeTextureAssetTask to the list of active tasks
  146047. * @param taskName defines the name of the new task
  146048. * @param url defines the url of the file to load
  146049. * @param extensions defines the extension to use to load the cube map (can be null)
  146050. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  146051. * @param files defines the list of files to load (can be null)
  146052. * @returns a new CubeTextureAssetTask object
  146053. */
  146054. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  146055. /**
  146056. *
  146057. * Add a HDRCubeTextureAssetTask to the list of active tasks
  146058. * @param taskName defines the name of the new task
  146059. * @param url defines the url of the file to load
  146060. * @param size defines the size you want for the cubemap (can be null)
  146061. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  146062. * @param generateHarmonics defines if you want to automatically generate (true by default)
  146063. * @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)
  146064. * @param reserved Internal use only
  146065. * @returns a new HDRCubeTextureAssetTask object
  146066. */
  146067. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  146068. /**
  146069. *
  146070. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  146071. * @param taskName defines the name of the new task
  146072. * @param url defines the url of the file to load
  146073. * @param size defines the size you want for the cubemap (can be null)
  146074. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  146075. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  146076. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  146077. * @returns a new EquiRectangularCubeTextureAssetTask object
  146078. */
  146079. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  146080. /**
  146081. * Remove a task from the assets manager.
  146082. * @param task the task to remove
  146083. */
  146084. removeTask(task: AbstractAssetTask): void;
  146085. private _decreaseWaitingTasksCount;
  146086. private _runTask;
  146087. /**
  146088. * Reset the AssetsManager and remove all tasks
  146089. * @return the current instance of the AssetsManager
  146090. */
  146091. reset(): AssetsManager;
  146092. /**
  146093. * Start the loading process
  146094. * @return the current instance of the AssetsManager
  146095. */
  146096. load(): AssetsManager;
  146097. /**
  146098. * Start the loading process as an async operation
  146099. * @return a promise returning the list of failed tasks
  146100. */
  146101. loadAsync(): Promise<void>;
  146102. }
  146103. }
  146104. declare module BABYLON {
  146105. /**
  146106. * Wrapper class for promise with external resolve and reject.
  146107. */
  146108. export class Deferred<T> {
  146109. /**
  146110. * The promise associated with this deferred object.
  146111. */
  146112. readonly promise: Promise<T>;
  146113. private _resolve;
  146114. private _reject;
  146115. /**
  146116. * The resolve method of the promise associated with this deferred object.
  146117. */
  146118. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  146119. /**
  146120. * The reject method of the promise associated with this deferred object.
  146121. */
  146122. get reject(): (reason?: any) => void;
  146123. /**
  146124. * Constructor for this deferred object.
  146125. */
  146126. constructor();
  146127. }
  146128. }
  146129. declare module BABYLON {
  146130. /**
  146131. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  146132. */
  146133. export class MeshExploder {
  146134. private _centerMesh;
  146135. private _meshes;
  146136. private _meshesOrigins;
  146137. private _toCenterVectors;
  146138. private _scaledDirection;
  146139. private _newPosition;
  146140. private _centerPosition;
  146141. /**
  146142. * Explodes meshes from a center mesh.
  146143. * @param meshes The meshes to explode.
  146144. * @param centerMesh The mesh to be center of explosion.
  146145. */
  146146. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  146147. private _setCenterMesh;
  146148. /**
  146149. * Get class name
  146150. * @returns "MeshExploder"
  146151. */
  146152. getClassName(): string;
  146153. /**
  146154. * "Exploded meshes"
  146155. * @returns Array of meshes with the centerMesh at index 0.
  146156. */
  146157. getMeshes(): Array<Mesh>;
  146158. /**
  146159. * Explodes meshes giving a specific direction
  146160. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  146161. */
  146162. explode(direction?: number): void;
  146163. }
  146164. }
  146165. declare module BABYLON {
  146166. /**
  146167. * Class used to help managing file picking and drag'n'drop
  146168. */
  146169. export class FilesInput {
  146170. /**
  146171. * List of files ready to be loaded
  146172. */
  146173. static get FilesToLoad(): {
  146174. [key: string]: File;
  146175. };
  146176. /**
  146177. * Callback called when a file is processed
  146178. */
  146179. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  146180. private _engine;
  146181. private _currentScene;
  146182. private _sceneLoadedCallback;
  146183. private _progressCallback;
  146184. private _additionalRenderLoopLogicCallback;
  146185. private _textureLoadingCallback;
  146186. private _startingProcessingFilesCallback;
  146187. private _onReloadCallback;
  146188. private _errorCallback;
  146189. private _elementToMonitor;
  146190. private _sceneFileToLoad;
  146191. private _filesToLoad;
  146192. /**
  146193. * Creates a new FilesInput
  146194. * @param engine defines the rendering engine
  146195. * @param scene defines the hosting scene
  146196. * @param sceneLoadedCallback callback called when scene is loaded
  146197. * @param progressCallback callback called to track progress
  146198. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  146199. * @param textureLoadingCallback callback called when a texture is loading
  146200. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  146201. * @param onReloadCallback callback called when a reload is requested
  146202. * @param errorCallback callback call if an error occurs
  146203. */
  146204. 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);
  146205. private _dragEnterHandler;
  146206. private _dragOverHandler;
  146207. private _dropHandler;
  146208. /**
  146209. * Calls this function to listen to drag'n'drop events on a specific DOM element
  146210. * @param elementToMonitor defines the DOM element to track
  146211. */
  146212. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  146213. /**
  146214. * Release all associated resources
  146215. */
  146216. dispose(): void;
  146217. private renderFunction;
  146218. private drag;
  146219. private drop;
  146220. private _traverseFolder;
  146221. private _processFiles;
  146222. /**
  146223. * Load files from a drop event
  146224. * @param event defines the drop event to use as source
  146225. */
  146226. loadFiles(event: any): void;
  146227. private _processReload;
  146228. /**
  146229. * Reload the current scene from the loaded files
  146230. */
  146231. reload(): void;
  146232. }
  146233. }
  146234. declare module BABYLON {
  146235. /**
  146236. * Defines the root class used to create scene optimization to use with SceneOptimizer
  146237. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  146238. */
  146239. export class SceneOptimization {
  146240. /**
  146241. * Defines the priority of this optimization (0 by default which means first in the list)
  146242. */
  146243. priority: number;
  146244. /**
  146245. * Gets a string describing the action executed by the current optimization
  146246. * @returns description string
  146247. */
  146248. getDescription(): string;
  146249. /**
  146250. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  146251. * @param scene defines the current scene where to apply this optimization
  146252. * @param optimizer defines the current optimizer
  146253. * @returns true if everything that can be done was applied
  146254. */
  146255. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  146256. /**
  146257. * Creates the SceneOptimization object
  146258. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  146259. * @param desc defines the description associated with the optimization
  146260. */
  146261. constructor(
  146262. /**
  146263. * Defines the priority of this optimization (0 by default which means first in the list)
  146264. */
  146265. priority?: number);
  146266. }
  146267. /**
  146268. * Defines an optimization used to reduce the size of render target textures
  146269. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  146270. */
  146271. export class TextureOptimization extends SceneOptimization {
  146272. /**
  146273. * Defines the priority of this optimization (0 by default which means first in the list)
  146274. */
  146275. priority: number;
  146276. /**
  146277. * 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
  146278. */
  146279. maximumSize: number;
  146280. /**
  146281. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  146282. */
  146283. step: number;
  146284. /**
  146285. * Gets a string describing the action executed by the current optimization
  146286. * @returns description string
  146287. */
  146288. getDescription(): string;
  146289. /**
  146290. * Creates the TextureOptimization object
  146291. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  146292. * @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
  146293. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  146294. */
  146295. constructor(
  146296. /**
  146297. * Defines the priority of this optimization (0 by default which means first in the list)
  146298. */
  146299. priority?: number,
  146300. /**
  146301. * 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
  146302. */
  146303. maximumSize?: number,
  146304. /**
  146305. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  146306. */
  146307. step?: number);
  146308. /**
  146309. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  146310. * @param scene defines the current scene where to apply this optimization
  146311. * @param optimizer defines the current optimizer
  146312. * @returns true if everything that can be done was applied
  146313. */
  146314. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  146315. }
  146316. /**
  146317. * Defines an optimization used to increase or decrease the rendering resolution
  146318. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  146319. */
  146320. export class HardwareScalingOptimization extends SceneOptimization {
  146321. /**
  146322. * Defines the priority of this optimization (0 by default which means first in the list)
  146323. */
  146324. priority: number;
  146325. /**
  146326. * Defines the maximum scale to use (2 by default)
  146327. */
  146328. maximumScale: number;
  146329. /**
  146330. * Defines the step to use between two passes (0.5 by default)
  146331. */
  146332. step: number;
  146333. private _currentScale;
  146334. private _directionOffset;
  146335. /**
  146336. * Gets a string describing the action executed by the current optimization
  146337. * @return description string
  146338. */
  146339. getDescription(): string;
  146340. /**
  146341. * Creates the HardwareScalingOptimization object
  146342. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  146343. * @param maximumScale defines the maximum scale to use (2 by default)
  146344. * @param step defines the step to use between two passes (0.5 by default)
  146345. */
  146346. constructor(
  146347. /**
  146348. * Defines the priority of this optimization (0 by default which means first in the list)
  146349. */
  146350. priority?: number,
  146351. /**
  146352. * Defines the maximum scale to use (2 by default)
  146353. */
  146354. maximumScale?: number,
  146355. /**
  146356. * Defines the step to use between two passes (0.5 by default)
  146357. */
  146358. step?: number);
  146359. /**
  146360. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  146361. * @param scene defines the current scene where to apply this optimization
  146362. * @param optimizer defines the current optimizer
  146363. * @returns true if everything that can be done was applied
  146364. */
  146365. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  146366. }
  146367. /**
  146368. * Defines an optimization used to remove shadows
  146369. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  146370. */
  146371. export class ShadowsOptimization extends SceneOptimization {
  146372. /**
  146373. * Gets a string describing the action executed by the current optimization
  146374. * @return description string
  146375. */
  146376. getDescription(): string;
  146377. /**
  146378. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  146379. * @param scene defines the current scene where to apply this optimization
  146380. * @param optimizer defines the current optimizer
  146381. * @returns true if everything that can be done was applied
  146382. */
  146383. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  146384. }
  146385. /**
  146386. * Defines an optimization used to turn post-processes off
  146387. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  146388. */
  146389. export class PostProcessesOptimization extends SceneOptimization {
  146390. /**
  146391. * Gets a string describing the action executed by the current optimization
  146392. * @return description string
  146393. */
  146394. getDescription(): string;
  146395. /**
  146396. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  146397. * @param scene defines the current scene where to apply this optimization
  146398. * @param optimizer defines the current optimizer
  146399. * @returns true if everything that can be done was applied
  146400. */
  146401. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  146402. }
  146403. /**
  146404. * Defines an optimization used to turn lens flares off
  146405. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  146406. */
  146407. export class LensFlaresOptimization extends SceneOptimization {
  146408. /**
  146409. * Gets a string describing the action executed by the current optimization
  146410. * @return description string
  146411. */
  146412. getDescription(): string;
  146413. /**
  146414. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  146415. * @param scene defines the current scene where to apply this optimization
  146416. * @param optimizer defines the current optimizer
  146417. * @returns true if everything that can be done was applied
  146418. */
  146419. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  146420. }
  146421. /**
  146422. * Defines an optimization based on user defined callback.
  146423. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  146424. */
  146425. export class CustomOptimization extends SceneOptimization {
  146426. /**
  146427. * Callback called to apply the custom optimization.
  146428. */
  146429. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  146430. /**
  146431. * Callback called to get custom description
  146432. */
  146433. onGetDescription: () => string;
  146434. /**
  146435. * Gets a string describing the action executed by the current optimization
  146436. * @returns description string
  146437. */
  146438. getDescription(): string;
  146439. /**
  146440. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  146441. * @param scene defines the current scene where to apply this optimization
  146442. * @param optimizer defines the current optimizer
  146443. * @returns true if everything that can be done was applied
  146444. */
  146445. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  146446. }
  146447. /**
  146448. * Defines an optimization used to turn particles off
  146449. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  146450. */
  146451. export class ParticlesOptimization extends SceneOptimization {
  146452. /**
  146453. * Gets a string describing the action executed by the current optimization
  146454. * @return description string
  146455. */
  146456. getDescription(): string;
  146457. /**
  146458. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  146459. * @param scene defines the current scene where to apply this optimization
  146460. * @param optimizer defines the current optimizer
  146461. * @returns true if everything that can be done was applied
  146462. */
  146463. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  146464. }
  146465. /**
  146466. * Defines an optimization used to turn render targets off
  146467. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  146468. */
  146469. export class RenderTargetsOptimization extends SceneOptimization {
  146470. /**
  146471. * Gets a string describing the action executed by the current optimization
  146472. * @return description string
  146473. */
  146474. getDescription(): string;
  146475. /**
  146476. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  146477. * @param scene defines the current scene where to apply this optimization
  146478. * @param optimizer defines the current optimizer
  146479. * @returns true if everything that can be done was applied
  146480. */
  146481. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  146482. }
  146483. /**
  146484. * Defines an optimization used to merge meshes with compatible materials
  146485. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  146486. */
  146487. export class MergeMeshesOptimization extends SceneOptimization {
  146488. private static _UpdateSelectionTree;
  146489. /**
  146490. * Gets or sets a boolean which defines if optimization octree has to be updated
  146491. */
  146492. static get UpdateSelectionTree(): boolean;
  146493. /**
  146494. * Gets or sets a boolean which defines if optimization octree has to be updated
  146495. */
  146496. static set UpdateSelectionTree(value: boolean);
  146497. /**
  146498. * Gets a string describing the action executed by the current optimization
  146499. * @return description string
  146500. */
  146501. getDescription(): string;
  146502. private _canBeMerged;
  146503. /**
  146504. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  146505. * @param scene defines the current scene where to apply this optimization
  146506. * @param optimizer defines the current optimizer
  146507. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  146508. * @returns true if everything that can be done was applied
  146509. */
  146510. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  146511. }
  146512. /**
  146513. * Defines a list of options used by SceneOptimizer
  146514. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  146515. */
  146516. export class SceneOptimizerOptions {
  146517. /**
  146518. * Defines the target frame rate to reach (60 by default)
  146519. */
  146520. targetFrameRate: number;
  146521. /**
  146522. * Defines the interval between two checkes (2000ms by default)
  146523. */
  146524. trackerDuration: number;
  146525. /**
  146526. * Gets the list of optimizations to apply
  146527. */
  146528. optimizations: SceneOptimization[];
  146529. /**
  146530. * Creates a new list of options used by SceneOptimizer
  146531. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  146532. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  146533. */
  146534. constructor(
  146535. /**
  146536. * Defines the target frame rate to reach (60 by default)
  146537. */
  146538. targetFrameRate?: number,
  146539. /**
  146540. * Defines the interval between two checkes (2000ms by default)
  146541. */
  146542. trackerDuration?: number);
  146543. /**
  146544. * Add a new optimization
  146545. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  146546. * @returns the current SceneOptimizerOptions
  146547. */
  146548. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  146549. /**
  146550. * Add a new custom optimization
  146551. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  146552. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  146553. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  146554. * @returns the current SceneOptimizerOptions
  146555. */
  146556. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  146557. /**
  146558. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  146559. * @param targetFrameRate defines the target frame rate (60 by default)
  146560. * @returns a SceneOptimizerOptions object
  146561. */
  146562. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  146563. /**
  146564. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  146565. * @param targetFrameRate defines the target frame rate (60 by default)
  146566. * @returns a SceneOptimizerOptions object
  146567. */
  146568. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  146569. /**
  146570. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  146571. * @param targetFrameRate defines the target frame rate (60 by default)
  146572. * @returns a SceneOptimizerOptions object
  146573. */
  146574. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  146575. }
  146576. /**
  146577. * Class used to run optimizations in order to reach a target frame rate
  146578. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  146579. */
  146580. export class SceneOptimizer implements IDisposable {
  146581. private _isRunning;
  146582. private _options;
  146583. private _scene;
  146584. private _currentPriorityLevel;
  146585. private _targetFrameRate;
  146586. private _trackerDuration;
  146587. private _currentFrameRate;
  146588. private _sceneDisposeObserver;
  146589. private _improvementMode;
  146590. /**
  146591. * Defines an observable called when the optimizer reaches the target frame rate
  146592. */
  146593. onSuccessObservable: Observable<SceneOptimizer>;
  146594. /**
  146595. * Defines an observable called when the optimizer enables an optimization
  146596. */
  146597. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  146598. /**
  146599. * Defines an observable called when the optimizer is not able to reach the target frame rate
  146600. */
  146601. onFailureObservable: Observable<SceneOptimizer>;
  146602. /**
  146603. * Gets a boolean indicating if the optimizer is in improvement mode
  146604. */
  146605. get isInImprovementMode(): boolean;
  146606. /**
  146607. * Gets the current priority level (0 at start)
  146608. */
  146609. get currentPriorityLevel(): number;
  146610. /**
  146611. * Gets the current frame rate checked by the SceneOptimizer
  146612. */
  146613. get currentFrameRate(): number;
  146614. /**
  146615. * Gets or sets the current target frame rate (60 by default)
  146616. */
  146617. get targetFrameRate(): number;
  146618. /**
  146619. * Gets or sets the current target frame rate (60 by default)
  146620. */
  146621. set targetFrameRate(value: number);
  146622. /**
  146623. * Gets or sets the current interval between two checks (every 2000ms by default)
  146624. */
  146625. get trackerDuration(): number;
  146626. /**
  146627. * Gets or sets the current interval between two checks (every 2000ms by default)
  146628. */
  146629. set trackerDuration(value: number);
  146630. /**
  146631. * Gets the list of active optimizations
  146632. */
  146633. get optimizations(): SceneOptimization[];
  146634. /**
  146635. * Creates a new SceneOptimizer
  146636. * @param scene defines the scene to work on
  146637. * @param options defines the options to use with the SceneOptimizer
  146638. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  146639. * @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)
  146640. */
  146641. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  146642. /**
  146643. * Stops the current optimizer
  146644. */
  146645. stop(): void;
  146646. /**
  146647. * Reset the optimizer to initial step (current priority level = 0)
  146648. */
  146649. reset(): void;
  146650. /**
  146651. * Start the optimizer. By default it will try to reach a specific framerate
  146652. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  146653. */
  146654. start(): void;
  146655. private _checkCurrentState;
  146656. /**
  146657. * Release all resources
  146658. */
  146659. dispose(): void;
  146660. /**
  146661. * Helper function to create a SceneOptimizer with one single line of code
  146662. * @param scene defines the scene to work on
  146663. * @param options defines the options to use with the SceneOptimizer
  146664. * @param onSuccess defines a callback to call on success
  146665. * @param onFailure defines a callback to call on failure
  146666. * @returns the new SceneOptimizer object
  146667. */
  146668. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  146669. }
  146670. }
  146671. declare module BABYLON {
  146672. /**
  146673. * Class used to serialize a scene into a string
  146674. */
  146675. export class SceneSerializer {
  146676. /**
  146677. * Clear cache used by a previous serialization
  146678. */
  146679. static ClearCache(): void;
  146680. /**
  146681. * Serialize a scene into a JSON compatible object
  146682. * @param scene defines the scene to serialize
  146683. * @returns a JSON compatible object
  146684. */
  146685. static Serialize(scene: Scene): any;
  146686. /**
  146687. * Serialize a mesh into a JSON compatible object
  146688. * @param toSerialize defines the mesh to serialize
  146689. * @param withParents defines if parents must be serialized as well
  146690. * @param withChildren defines if children must be serialized as well
  146691. * @returns a JSON compatible object
  146692. */
  146693. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  146694. }
  146695. }
  146696. declare module BABYLON {
  146697. /**
  146698. * Class used to host texture specific utilities
  146699. */
  146700. export class TextureTools {
  146701. /**
  146702. * Uses the GPU to create a copy texture rescaled at a given size
  146703. * @param texture Texture to copy from
  146704. * @param width defines the desired width
  146705. * @param height defines the desired height
  146706. * @param useBilinearMode defines if bilinear mode has to be used
  146707. * @return the generated texture
  146708. */
  146709. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  146710. }
  146711. }
  146712. declare module BABYLON {
  146713. /**
  146714. * This represents the different options available for the video capture.
  146715. */
  146716. export interface VideoRecorderOptions {
  146717. /** Defines the mime type of the video. */
  146718. mimeType: string;
  146719. /** Defines the FPS the video should be recorded at. */
  146720. fps: number;
  146721. /** Defines the chunk size for the recording data. */
  146722. recordChunckSize: number;
  146723. /** The audio tracks to attach to the recording. */
  146724. audioTracks?: MediaStreamTrack[];
  146725. }
  146726. /**
  146727. * This can help with recording videos from BabylonJS.
  146728. * This is based on the available WebRTC functionalities of the browser.
  146729. *
  146730. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  146731. */
  146732. export class VideoRecorder {
  146733. private static readonly _defaultOptions;
  146734. /**
  146735. * Returns whether or not the VideoRecorder is available in your browser.
  146736. * @param engine Defines the Babylon Engine.
  146737. * @returns true if supported otherwise false.
  146738. */
  146739. static IsSupported(engine: Engine): boolean;
  146740. private readonly _options;
  146741. private _canvas;
  146742. private _mediaRecorder;
  146743. private _recordedChunks;
  146744. private _fileName;
  146745. private _resolve;
  146746. private _reject;
  146747. /**
  146748. * True when a recording is already in progress.
  146749. */
  146750. get isRecording(): boolean;
  146751. /**
  146752. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  146753. * @param engine Defines the BabylonJS Engine you wish to record.
  146754. * @param options Defines options that can be used to customize the capture.
  146755. */
  146756. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  146757. /**
  146758. * Stops the current recording before the default capture timeout passed in the startRecording function.
  146759. */
  146760. stopRecording(): void;
  146761. /**
  146762. * Starts recording the canvas for a max duration specified in parameters.
  146763. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  146764. * If null no automatic download will start and you can rely on the promise to get the data back.
  146765. * @param maxDuration Defines the maximum recording time in seconds.
  146766. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  146767. * @return A promise callback at the end of the recording with the video data in Blob.
  146768. */
  146769. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  146770. /**
  146771. * Releases internal resources used during the recording.
  146772. */
  146773. dispose(): void;
  146774. private _handleDataAvailable;
  146775. private _handleError;
  146776. private _handleStop;
  146777. }
  146778. }
  146779. declare module BABYLON {
  146780. /**
  146781. * Class containing a set of static utilities functions for screenshots
  146782. */
  146783. export class ScreenshotTools {
  146784. /**
  146785. * Captures a screenshot of the current rendering
  146786. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  146787. * @param engine defines the rendering engine
  146788. * @param camera defines the source camera
  146789. * @param size This parameter can be set to a single number or to an object with the
  146790. * following (optional) properties: precision, width, height. If a single number is passed,
  146791. * it will be used for both width and height. If an object is passed, the screenshot size
  146792. * will be derived from the parameters. The precision property is a multiplier allowing
  146793. * rendering at a higher or lower resolution
  146794. * @param successCallback defines the callback receives a single parameter which contains the
  146795. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  146796. * src parameter of an <img> to display it
  146797. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  146798. * Check your browser for supported MIME types
  146799. */
  146800. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  146801. /**
  146802. * Captures a screenshot of the current rendering
  146803. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  146804. * @param engine defines the rendering engine
  146805. * @param camera defines the source camera
  146806. * @param size This parameter can be set to a single number or to an object with the
  146807. * following (optional) properties: precision, width, height. If a single number is passed,
  146808. * it will be used for both width and height. If an object is passed, the screenshot size
  146809. * will be derived from the parameters. The precision property is a multiplier allowing
  146810. * rendering at a higher or lower resolution
  146811. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  146812. * Check your browser for supported MIME types
  146813. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  146814. * to the src parameter of an <img> to display it
  146815. */
  146816. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  146817. /**
  146818. * Generates an image screenshot from the specified camera.
  146819. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  146820. * @param engine The engine to use for rendering
  146821. * @param camera The camera to use for rendering
  146822. * @param size This parameter can be set to a single number or to an object with the
  146823. * following (optional) properties: precision, width, height. If a single number is passed,
  146824. * it will be used for both width and height. If an object is passed, the screenshot size
  146825. * will be derived from the parameters. The precision property is a multiplier allowing
  146826. * rendering at a higher or lower resolution
  146827. * @param successCallback The callback receives a single parameter which contains the
  146828. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  146829. * src parameter of an <img> to display it
  146830. * @param mimeType The MIME type of the screenshot image (default: image/png).
  146831. * Check your browser for supported MIME types
  146832. * @param samples Texture samples (default: 1)
  146833. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  146834. * @param fileName A name for for the downloaded file.
  146835. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  146836. */
  146837. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): void;
  146838. /**
  146839. * Generates an image screenshot from the specified camera.
  146840. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  146841. * @param engine The engine to use for rendering
  146842. * @param camera The camera to use for rendering
  146843. * @param size This parameter can be set to a single number or to an object with the
  146844. * following (optional) properties: precision, width, height. If a single number is passed,
  146845. * it will be used for both width and height. If an object is passed, the screenshot size
  146846. * will be derived from the parameters. The precision property is a multiplier allowing
  146847. * rendering at a higher or lower resolution
  146848. * @param mimeType The MIME type of the screenshot image (default: image/png).
  146849. * Check your browser for supported MIME types
  146850. * @param samples Texture samples (default: 1)
  146851. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  146852. * @param fileName A name for for the downloaded file.
  146853. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  146854. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  146855. * to the src parameter of an <img> to display it
  146856. */
  146857. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  146858. /**
  146859. * Gets height and width for screenshot size
  146860. * @private
  146861. */
  146862. private static _getScreenshotSize;
  146863. }
  146864. }
  146865. declare module BABYLON {
  146866. /**
  146867. * Interface for a data buffer
  146868. */
  146869. export interface IDataBuffer {
  146870. /**
  146871. * Reads bytes from the data buffer.
  146872. * @param byteOffset The byte offset to read
  146873. * @param byteLength The byte length to read
  146874. * @returns A promise that resolves when the bytes are read
  146875. */
  146876. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  146877. /**
  146878. * The byte length of the buffer.
  146879. */
  146880. readonly byteLength: number;
  146881. }
  146882. /**
  146883. * Utility class for reading from a data buffer
  146884. */
  146885. export class DataReader {
  146886. /**
  146887. * The data buffer associated with this data reader.
  146888. */
  146889. readonly buffer: IDataBuffer;
  146890. /**
  146891. * The current byte offset from the beginning of the data buffer.
  146892. */
  146893. byteOffset: number;
  146894. private _dataView;
  146895. private _dataByteOffset;
  146896. /**
  146897. * Constructor
  146898. * @param buffer The buffer to read
  146899. */
  146900. constructor(buffer: IDataBuffer);
  146901. /**
  146902. * Loads the given byte length.
  146903. * @param byteLength The byte length to load
  146904. * @returns A promise that resolves when the load is complete
  146905. */
  146906. loadAsync(byteLength: number): Promise<void>;
  146907. /**
  146908. * Read a unsigned 32-bit integer from the currently loaded data range.
  146909. * @returns The 32-bit integer read
  146910. */
  146911. readUint32(): number;
  146912. /**
  146913. * Read a byte array from the currently loaded data range.
  146914. * @param byteLength The byte length to read
  146915. * @returns The byte array read
  146916. */
  146917. readUint8Array(byteLength: number): Uint8Array;
  146918. /**
  146919. * Read a string from the currently loaded data range.
  146920. * @param byteLength The byte length to read
  146921. * @returns The string read
  146922. */
  146923. readString(byteLength: number): string;
  146924. /**
  146925. * Skips the given byte length the currently loaded data range.
  146926. * @param byteLength The byte length to skip
  146927. */
  146928. skipBytes(byteLength: number): void;
  146929. }
  146930. }
  146931. declare module BABYLON {
  146932. /**
  146933. * Class for storing data to local storage if available or in-memory storage otherwise
  146934. */
  146935. export class DataStorage {
  146936. private static _Storage;
  146937. private static _GetStorage;
  146938. /**
  146939. * Reads a string from the data storage
  146940. * @param key The key to read
  146941. * @param defaultValue The value if the key doesn't exist
  146942. * @returns The string value
  146943. */
  146944. static ReadString(key: string, defaultValue: string): string;
  146945. /**
  146946. * Writes a string to the data storage
  146947. * @param key The key to write
  146948. * @param value The value to write
  146949. */
  146950. static WriteString(key: string, value: string): void;
  146951. /**
  146952. * Reads a boolean from the data storage
  146953. * @param key The key to read
  146954. * @param defaultValue The value if the key doesn't exist
  146955. * @returns The boolean value
  146956. */
  146957. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  146958. /**
  146959. * Writes a boolean to the data storage
  146960. * @param key The key to write
  146961. * @param value The value to write
  146962. */
  146963. static WriteBoolean(key: string, value: boolean): void;
  146964. /**
  146965. * Reads a number from the data storage
  146966. * @param key The key to read
  146967. * @param defaultValue The value if the key doesn't exist
  146968. * @returns The number value
  146969. */
  146970. static ReadNumber(key: string, defaultValue: number): number;
  146971. /**
  146972. * Writes a number to the data storage
  146973. * @param key The key to write
  146974. * @param value The value to write
  146975. */
  146976. static WriteNumber(key: string, value: number): void;
  146977. }
  146978. }
  146979. declare module BABYLON {
  146980. /**
  146981. * Options used for hit testing
  146982. */
  146983. export interface IWebXRLegacyHitTestOptions {
  146984. /**
  146985. * Only test when user interacted with the scene. Default - hit test every frame
  146986. */
  146987. testOnPointerDownOnly?: boolean;
  146988. /**
  146989. * The node to use to transform the local results to world coordinates
  146990. */
  146991. worldParentNode?: TransformNode;
  146992. }
  146993. /**
  146994. * Interface defining the babylon result of raycasting/hit-test
  146995. */
  146996. export interface IWebXRLegacyHitResult {
  146997. /**
  146998. * Transformation matrix that can be applied to a node that will put it in the hit point location
  146999. */
  147000. transformationMatrix: Matrix;
  147001. /**
  147002. * The native hit test result
  147003. */
  147004. xrHitResult: XRHitResult | XRHitTestResult;
  147005. }
  147006. /**
  147007. * The currently-working hit-test module.
  147008. * Hit test (or Ray-casting) is used to interact with the real world.
  147009. * For further information read here - https://github.com/immersive-web/hit-test
  147010. */
  147011. export class WebXRHitTestLegacy extends WebXRAbstractFeature {
  147012. /**
  147013. * options to use when constructing this feature
  147014. */
  147015. readonly options: IWebXRLegacyHitTestOptions;
  147016. private _direction;
  147017. private _mat;
  147018. private _onSelectEnabled;
  147019. private _origin;
  147020. /**
  147021. * The module's name
  147022. */
  147023. static readonly Name: string;
  147024. /**
  147025. * The (Babylon) version of this module.
  147026. * This is an integer representing the implementation version.
  147027. * This number does not correspond to the WebXR specs version
  147028. */
  147029. static readonly Version: number;
  147030. /**
  147031. * Populated with the last native XR Hit Results
  147032. */
  147033. lastNativeXRHitResults: XRHitResult[];
  147034. /**
  147035. * Triggered when new babylon (transformed) hit test results are available
  147036. */
  147037. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  147038. /**
  147039. * Creates a new instance of the (legacy version) hit test feature
  147040. * @param _xrSessionManager an instance of WebXRSessionManager
  147041. * @param options options to use when constructing this feature
  147042. */
  147043. constructor(_xrSessionManager: WebXRSessionManager,
  147044. /**
  147045. * options to use when constructing this feature
  147046. */
  147047. options?: IWebXRLegacyHitTestOptions);
  147048. /**
  147049. * execute a hit test with an XR Ray
  147050. *
  147051. * @param xrSession a native xrSession that will execute this hit test
  147052. * @param xrRay the ray (position and direction) to use for ray-casting
  147053. * @param referenceSpace native XR reference space to use for the hit-test
  147054. * @param filter filter function that will filter the results
  147055. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  147056. */
  147057. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  147058. /**
  147059. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  147060. * @param event the (select) event to use to select with
  147061. * @param referenceSpace the reference space to use for this hit test
  147062. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  147063. */
  147064. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  147065. /**
  147066. * attach this feature
  147067. * Will usually be called by the features manager
  147068. *
  147069. * @returns true if successful.
  147070. */
  147071. attach(): boolean;
  147072. /**
  147073. * detach this feature.
  147074. * Will usually be called by the features manager
  147075. *
  147076. * @returns true if successful.
  147077. */
  147078. detach(): boolean;
  147079. /**
  147080. * Dispose this feature and all of the resources attached
  147081. */
  147082. dispose(): void;
  147083. protected _onXRFrame(frame: XRFrame): void;
  147084. private _onHitTestResults;
  147085. private _onSelect;
  147086. }
  147087. }
  147088. declare module BABYLON {
  147089. /**
  147090. * Options used in the plane detector module
  147091. */
  147092. export interface IWebXRPlaneDetectorOptions {
  147093. /**
  147094. * The node to use to transform the local results to world coordinates
  147095. */
  147096. worldParentNode?: TransformNode;
  147097. }
  147098. /**
  147099. * A babylon interface for a WebXR plane.
  147100. * A Plane is actually a polygon, built from N points in space
  147101. *
  147102. * Supported in chrome 79, not supported in canary 81 ATM
  147103. */
  147104. export interface IWebXRPlane {
  147105. /**
  147106. * a babylon-assigned ID for this polygon
  147107. */
  147108. id: number;
  147109. /**
  147110. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  147111. */
  147112. polygonDefinition: Array<Vector3>;
  147113. /**
  147114. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  147115. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  147116. */
  147117. transformationMatrix: Matrix;
  147118. /**
  147119. * the native xr-plane object
  147120. */
  147121. xrPlane: XRPlane;
  147122. }
  147123. /**
  147124. * The plane detector is used to detect planes in the real world when in AR
  147125. * For more information see https://github.com/immersive-web/real-world-geometry/
  147126. */
  147127. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  147128. private _options;
  147129. private _detectedPlanes;
  147130. private _enabled;
  147131. private _lastFrameDetected;
  147132. /**
  147133. * The module's name
  147134. */
  147135. static readonly Name: string;
  147136. /**
  147137. * The (Babylon) version of this module.
  147138. * This is an integer representing the implementation version.
  147139. * This number does not correspond to the WebXR specs version
  147140. */
  147141. static readonly Version: number;
  147142. /**
  147143. * Observers registered here will be executed when a new plane was added to the session
  147144. */
  147145. onPlaneAddedObservable: Observable<IWebXRPlane>;
  147146. /**
  147147. * Observers registered here will be executed when a plane is no longer detected in the session
  147148. */
  147149. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  147150. /**
  147151. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  147152. * This can execute N times every frame
  147153. */
  147154. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  147155. /**
  147156. * construct a new Plane Detector
  147157. * @param _xrSessionManager an instance of xr Session manager
  147158. * @param _options configuration to use when constructing this feature
  147159. */
  147160. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  147161. /**
  147162. * Dispose this feature and all of the resources attached
  147163. */
  147164. dispose(): void;
  147165. protected _onXRFrame(frame: XRFrame): void;
  147166. private _init;
  147167. private _updatePlaneWithXRPlane;
  147168. /**
  147169. * avoiding using Array.find for global support.
  147170. * @param xrPlane the plane to find in the array
  147171. */
  147172. private findIndexInPlaneArray;
  147173. }
  147174. }
  147175. declare module BABYLON {
  147176. /**
  147177. * Configuration options of the anchor system
  147178. */
  147179. export interface IWebXRAnchorSystemOptions {
  147180. /**
  147181. * Should a new anchor be added every time a select event is triggered
  147182. */
  147183. addAnchorOnSelect?: boolean;
  147184. /**
  147185. * should the anchor system use plane detection.
  147186. * If set to true, the plane-detection feature should be set using setPlaneDetector
  147187. */
  147188. usePlaneDetection?: boolean;
  147189. /**
  147190. * a node that will be used to convert local to world coordinates
  147191. */
  147192. worldParentNode?: TransformNode;
  147193. }
  147194. /**
  147195. * A babylon container for an XR Anchor
  147196. */
  147197. export interface IWebXRAnchor {
  147198. /**
  147199. * A babylon-assigned ID for this anchor
  147200. */
  147201. id: number;
  147202. /**
  147203. * Transformation matrix to apply to an object attached to this anchor
  147204. */
  147205. transformationMatrix: Matrix;
  147206. /**
  147207. * The native anchor object
  147208. */
  147209. xrAnchor: XRAnchor;
  147210. }
  147211. /**
  147212. * An implementation of the anchor system of WebXR.
  147213. * Note that the current documented implementation is not available in any browser. Future implementations
  147214. * will use the frame to create an anchor and not the session or a detected plane
  147215. * For further information see https://github.com/immersive-web/anchors/
  147216. */
  147217. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  147218. private _options;
  147219. private _enabled;
  147220. private _hitTestModule;
  147221. private _lastFrameDetected;
  147222. private _onSelect;
  147223. private _planeDetector;
  147224. private _trackedAnchors;
  147225. /**
  147226. * The module's name
  147227. */
  147228. static readonly Name: string;
  147229. /**
  147230. * The (Babylon) version of this module.
  147231. * This is an integer representing the implementation version.
  147232. * This number does not correspond to the WebXR specs version
  147233. */
  147234. static readonly Version: number;
  147235. /**
  147236. * Observers registered here will be executed when a new anchor was added to the session
  147237. */
  147238. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  147239. /**
  147240. * Observers registered here will be executed when an anchor was removed from the session
  147241. */
  147242. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  147243. /**
  147244. * Observers registered here will be executed when an existing anchor updates
  147245. * This can execute N times every frame
  147246. */
  147247. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  147248. /**
  147249. * constructs a new anchor system
  147250. * @param _xrSessionManager an instance of WebXRSessionManager
  147251. * @param _options configuration object for this feature
  147252. */
  147253. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  147254. /**
  147255. * Add anchor at a specific XR point.
  147256. *
  147257. * @param xrRigidTransformation xr-coordinates where a new anchor should be added
  147258. * @param anchorCreator the object o use to create an anchor with. either a session or a plane
  147259. * @returns a promise the fulfills when the anchor was created
  147260. */
  147261. addAnchorAtRigidTransformation(xrRigidTransformation: XRRigidTransform, anchorCreator?: XRAnchorCreator): Promise<XRAnchor>;
  147262. /**
  147263. * attach this feature
  147264. * Will usually be called by the features manager
  147265. *
  147266. * @returns true if successful.
  147267. */
  147268. attach(): boolean;
  147269. /**
  147270. * detach this feature.
  147271. * Will usually be called by the features manager
  147272. *
  147273. * @returns true if successful.
  147274. */
  147275. detach(): boolean;
  147276. /**
  147277. * Dispose this feature and all of the resources attached
  147278. */
  147279. dispose(): void;
  147280. /**
  147281. * If set, it will improve performance by using the current hit-test results instead of executing a new hit-test
  147282. * @param hitTestModule the hit-test module to use.
  147283. */
  147284. setHitTestModule(hitTestModule: WebXRHitTestLegacy): void;
  147285. /**
  147286. * set the plane detector to use in order to create anchors from frames
  147287. * @param planeDetector the plane-detector module to use
  147288. * @param enable enable plane-anchors. default is true
  147289. */
  147290. setPlaneDetector(planeDetector: WebXRPlaneDetector, enable?: boolean): void;
  147291. protected _onXRFrame(frame: XRFrame): void;
  147292. /**
  147293. * avoiding using Array.find for global support.
  147294. * @param xrAnchor the plane to find in the array
  147295. */
  147296. private _findIndexInAnchorArray;
  147297. private _updateAnchorWithXRFrame;
  147298. }
  147299. }
  147300. declare module BABYLON {
  147301. /**
  147302. * Options interface for the background remover plugin
  147303. */
  147304. export interface IWebXRBackgroundRemoverOptions {
  147305. /**
  147306. * Further background meshes to disable when entering AR
  147307. */
  147308. backgroundMeshes?: AbstractMesh[];
  147309. /**
  147310. * flags to configure the removal of the environment helper.
  147311. * If not set, the entire background will be removed. If set, flags should be set as well.
  147312. */
  147313. environmentHelperRemovalFlags?: {
  147314. /**
  147315. * Should the skybox be removed (default false)
  147316. */
  147317. skyBox?: boolean;
  147318. /**
  147319. * Should the ground be removed (default false)
  147320. */
  147321. ground?: boolean;
  147322. };
  147323. /**
  147324. * don't disable the environment helper
  147325. */
  147326. ignoreEnvironmentHelper?: boolean;
  147327. }
  147328. /**
  147329. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  147330. */
  147331. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  147332. /**
  147333. * read-only options to be used in this module
  147334. */
  147335. readonly options: IWebXRBackgroundRemoverOptions;
  147336. /**
  147337. * The module's name
  147338. */
  147339. static readonly Name: string;
  147340. /**
  147341. * The (Babylon) version of this module.
  147342. * This is an integer representing the implementation version.
  147343. * This number does not correspond to the WebXR specs version
  147344. */
  147345. static readonly Version: number;
  147346. /**
  147347. * registered observers will be triggered when the background state changes
  147348. */
  147349. onBackgroundStateChangedObservable: Observable<boolean>;
  147350. /**
  147351. * constructs a new background remover module
  147352. * @param _xrSessionManager the session manager for this module
  147353. * @param options read-only options to be used in this module
  147354. */
  147355. constructor(_xrSessionManager: WebXRSessionManager,
  147356. /**
  147357. * read-only options to be used in this module
  147358. */
  147359. options?: IWebXRBackgroundRemoverOptions);
  147360. /**
  147361. * attach this feature
  147362. * Will usually be called by the features manager
  147363. *
  147364. * @returns true if successful.
  147365. */
  147366. attach(): boolean;
  147367. /**
  147368. * detach this feature.
  147369. * Will usually be called by the features manager
  147370. *
  147371. * @returns true if successful.
  147372. */
  147373. detach(): boolean;
  147374. /**
  147375. * Dispose this feature and all of the resources attached
  147376. */
  147377. dispose(): void;
  147378. protected _onXRFrame(_xrFrame: XRFrame): void;
  147379. private _setBackgroundState;
  147380. }
  147381. }
  147382. declare module BABYLON {
  147383. /**
  147384. * Options for the controller physics feature
  147385. */
  147386. export class IWebXRControllerPhysicsOptions {
  147387. /**
  147388. * Should the headset get its own impostor
  147389. */
  147390. enableHeadsetImpostor?: boolean;
  147391. /**
  147392. * Optional parameters for the headset impostor
  147393. */
  147394. headsetImpostorParams?: {
  147395. /**
  147396. * The type of impostor to create. Default is sphere
  147397. */
  147398. impostorType: number;
  147399. /**
  147400. * the size of the impostor. Defaults to 10cm
  147401. */
  147402. impostorSize?: number | {
  147403. width: number;
  147404. height: number;
  147405. depth: number;
  147406. };
  147407. /**
  147408. * Friction definitions
  147409. */
  147410. friction?: number;
  147411. /**
  147412. * Restitution
  147413. */
  147414. restitution?: number;
  147415. };
  147416. /**
  147417. * The physics properties of the future impostors
  147418. */
  147419. physicsProperties?: {
  147420. /**
  147421. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  147422. * Note that this requires a physics engine that supports mesh impostors!
  147423. */
  147424. useControllerMesh?: boolean;
  147425. /**
  147426. * The type of impostor to create. Default is sphere
  147427. */
  147428. impostorType?: number;
  147429. /**
  147430. * the size of the impostor. Defaults to 10cm
  147431. */
  147432. impostorSize?: number | {
  147433. width: number;
  147434. height: number;
  147435. depth: number;
  147436. };
  147437. /**
  147438. * Friction definitions
  147439. */
  147440. friction?: number;
  147441. /**
  147442. * Restitution
  147443. */
  147444. restitution?: number;
  147445. };
  147446. /**
  147447. * the xr input to use with this pointer selection
  147448. */
  147449. xrInput: WebXRInput;
  147450. }
  147451. /**
  147452. * Add physics impostor to your webxr controllers,
  147453. * including naive calculation of their linear and angular velocity
  147454. */
  147455. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  147456. private readonly _options;
  147457. private _attachController;
  147458. private _controllers;
  147459. private _debugMode;
  147460. private _delta;
  147461. private _headsetImpostor?;
  147462. private _headsetMesh?;
  147463. private _lastTimestamp;
  147464. private _tmpQuaternion;
  147465. private _tmpVector;
  147466. /**
  147467. * The module's name
  147468. */
  147469. static readonly Name: string;
  147470. /**
  147471. * The (Babylon) version of this module.
  147472. * This is an integer representing the implementation version.
  147473. * This number does not correspond to the webxr specs version
  147474. */
  147475. static readonly Version: number;
  147476. /**
  147477. * Construct a new Controller Physics Feature
  147478. * @param _xrSessionManager the corresponding xr session manager
  147479. * @param _options options to create this feature with
  147480. */
  147481. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  147482. /**
  147483. * @hidden
  147484. * enable debugging - will show console outputs and the impostor mesh
  147485. */
  147486. _enablePhysicsDebug(): void;
  147487. /**
  147488. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  147489. * @param xrController the controller to add
  147490. */
  147491. addController(xrController: WebXRInputSource): void;
  147492. /**
  147493. * attach this feature
  147494. * Will usually be called by the features manager
  147495. *
  147496. * @returns true if successful.
  147497. */
  147498. attach(): boolean;
  147499. /**
  147500. * detach this feature.
  147501. * Will usually be called by the features manager
  147502. *
  147503. * @returns true if successful.
  147504. */
  147505. detach(): boolean;
  147506. /**
  147507. * Get the headset impostor, if enabled
  147508. * @returns the impostor
  147509. */
  147510. getHeadsetImpostor(): PhysicsImpostor | undefined;
  147511. /**
  147512. * Get the physics impostor of a specific controller.
  147513. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  147514. * @param controller the controller or the controller id of which to get the impostor
  147515. * @returns the impostor or null
  147516. */
  147517. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  147518. /**
  147519. * Update the physics properties provided in the constructor
  147520. * @param newProperties the new properties object
  147521. */
  147522. setPhysicsProperties(newProperties: {
  147523. impostorType?: number;
  147524. impostorSize?: number | {
  147525. width: number;
  147526. height: number;
  147527. depth: number;
  147528. };
  147529. friction?: number;
  147530. restitution?: number;
  147531. }): void;
  147532. protected _onXRFrame(_xrFrame: any): void;
  147533. private _detachController;
  147534. }
  147535. }
  147536. declare module BABYLON {
  147537. /**
  147538. * Options used for hit testing (version 2)
  147539. */
  147540. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  147541. /**
  147542. * Do not create a permanent hit test. Will usually be used when only
  147543. * transient inputs are needed.
  147544. */
  147545. disablePermanentHitTest?: boolean;
  147546. /**
  147547. * Enable transient (for example touch-based) hit test inspections
  147548. */
  147549. enableTransientHitTest?: boolean;
  147550. /**
  147551. * Offset ray for the permanent hit test
  147552. */
  147553. offsetRay?: Vector3;
  147554. /**
  147555. * Offset ray for the transient hit test
  147556. */
  147557. transientOffsetRay?: Vector3;
  147558. /**
  147559. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  147560. */
  147561. useReferenceSpace?: boolean;
  147562. }
  147563. /**
  147564. * Interface defining the babylon result of hit-test
  147565. */
  147566. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  147567. /**
  147568. * The input source that generated this hit test (if transient)
  147569. */
  147570. inputSource?: XRInputSource;
  147571. /**
  147572. * Is this a transient hit test
  147573. */
  147574. isTransient?: boolean;
  147575. /**
  147576. * Position of the hit test result
  147577. */
  147578. position: Vector3;
  147579. /**
  147580. * Rotation of the hit test result
  147581. */
  147582. rotationQuaternion: Quaternion;
  147583. }
  147584. /**
  147585. * The currently-working hit-test module.
  147586. * Hit test (or Ray-casting) is used to interact with the real world.
  147587. * For further information read here - https://github.com/immersive-web/hit-test
  147588. *
  147589. * Tested on chrome (mobile) 80.
  147590. */
  147591. export class WebXRHitTest extends WebXRAbstractFeature {
  147592. /**
  147593. * options to use when constructing this feature
  147594. */
  147595. readonly options: IWebXRHitTestOptions;
  147596. private _tmpMat;
  147597. private _tmpPos;
  147598. private _tmpQuat;
  147599. private _transientXrHitTestSource;
  147600. private _xrHitTestSource;
  147601. private initHitTestSource;
  147602. /**
  147603. * The module's name
  147604. */
  147605. static readonly Name: string;
  147606. /**
  147607. * The (Babylon) version of this module.
  147608. * This is an integer representing the implementation version.
  147609. * This number does not correspond to the WebXR specs version
  147610. */
  147611. static readonly Version: number;
  147612. /**
  147613. * When set to true, each hit test will have its own position/rotation objects
  147614. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  147615. * the developers will clone them or copy them as they see fit.
  147616. */
  147617. autoCloneTransformation: boolean;
  147618. /**
  147619. * Populated with the last native XR Hit Results
  147620. */
  147621. lastNativeXRHitResults: XRHitResult[];
  147622. /**
  147623. * Triggered when new babylon (transformed) hit test results are available
  147624. */
  147625. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  147626. /**
  147627. * Use this to temporarily pause hit test checks.
  147628. */
  147629. paused: boolean;
  147630. /**
  147631. * Creates a new instance of the hit test feature
  147632. * @param _xrSessionManager an instance of WebXRSessionManager
  147633. * @param options options to use when constructing this feature
  147634. */
  147635. constructor(_xrSessionManager: WebXRSessionManager,
  147636. /**
  147637. * options to use when constructing this feature
  147638. */
  147639. options?: IWebXRHitTestOptions);
  147640. /**
  147641. * attach this feature
  147642. * Will usually be called by the features manager
  147643. *
  147644. * @returns true if successful.
  147645. */
  147646. attach(): boolean;
  147647. /**
  147648. * detach this feature.
  147649. * Will usually be called by the features manager
  147650. *
  147651. * @returns true if successful.
  147652. */
  147653. detach(): boolean;
  147654. /**
  147655. * Dispose this feature and all of the resources attached
  147656. */
  147657. dispose(): void;
  147658. protected _onXRFrame(frame: XRFrame): void;
  147659. private _processWebXRHitTestResult;
  147660. }
  147661. }
  147662. declare module BABYLON {
  147663. /**
  147664. * The motion controller class for all microsoft mixed reality controllers
  147665. */
  147666. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  147667. protected readonly _mapping: {
  147668. defaultButton: {
  147669. valueNodeName: string;
  147670. unpressedNodeName: string;
  147671. pressedNodeName: string;
  147672. };
  147673. defaultAxis: {
  147674. valueNodeName: string;
  147675. minNodeName: string;
  147676. maxNodeName: string;
  147677. };
  147678. buttons: {
  147679. "xr-standard-trigger": {
  147680. rootNodeName: string;
  147681. componentProperty: string;
  147682. states: string[];
  147683. };
  147684. "xr-standard-squeeze": {
  147685. rootNodeName: string;
  147686. componentProperty: string;
  147687. states: string[];
  147688. };
  147689. "xr-standard-touchpad": {
  147690. rootNodeName: string;
  147691. labelAnchorNodeName: string;
  147692. touchPointNodeName: string;
  147693. };
  147694. "xr-standard-thumbstick": {
  147695. rootNodeName: string;
  147696. componentProperty: string;
  147697. states: string[];
  147698. };
  147699. };
  147700. axes: {
  147701. "xr-standard-touchpad": {
  147702. "x-axis": {
  147703. rootNodeName: string;
  147704. };
  147705. "y-axis": {
  147706. rootNodeName: string;
  147707. };
  147708. };
  147709. "xr-standard-thumbstick": {
  147710. "x-axis": {
  147711. rootNodeName: string;
  147712. };
  147713. "y-axis": {
  147714. rootNodeName: string;
  147715. };
  147716. };
  147717. };
  147718. };
  147719. /**
  147720. * The base url used to load the left and right controller models
  147721. */
  147722. static MODEL_BASE_URL: string;
  147723. /**
  147724. * The name of the left controller model file
  147725. */
  147726. static MODEL_LEFT_FILENAME: string;
  147727. /**
  147728. * The name of the right controller model file
  147729. */
  147730. static MODEL_RIGHT_FILENAME: string;
  147731. profileId: string;
  147732. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  147733. protected _getFilenameAndPath(): {
  147734. filename: string;
  147735. path: string;
  147736. };
  147737. protected _getModelLoadingConstraints(): boolean;
  147738. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  147739. protected _setRootMesh(meshes: AbstractMesh[]): void;
  147740. protected _updateModel(): void;
  147741. }
  147742. }
  147743. declare module BABYLON {
  147744. /**
  147745. * The motion controller class for oculus touch (quest, rift).
  147746. * This class supports legacy mapping as well the standard xr mapping
  147747. */
  147748. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  147749. private _forceLegacyControllers;
  147750. private _modelRootNode;
  147751. /**
  147752. * The base url used to load the left and right controller models
  147753. */
  147754. static MODEL_BASE_URL: string;
  147755. /**
  147756. * The name of the left controller model file
  147757. */
  147758. static MODEL_LEFT_FILENAME: string;
  147759. /**
  147760. * The name of the right controller model file
  147761. */
  147762. static MODEL_RIGHT_FILENAME: string;
  147763. /**
  147764. * Base Url for the Quest controller model.
  147765. */
  147766. static QUEST_MODEL_BASE_URL: string;
  147767. profileId: string;
  147768. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  147769. protected _getFilenameAndPath(): {
  147770. filename: string;
  147771. path: string;
  147772. };
  147773. protected _getModelLoadingConstraints(): boolean;
  147774. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  147775. protected _setRootMesh(meshes: AbstractMesh[]): void;
  147776. protected _updateModel(): void;
  147777. /**
  147778. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  147779. * between the touch and touch 2.
  147780. */
  147781. private _isQuest;
  147782. }
  147783. }
  147784. declare module BABYLON {
  147785. /**
  147786. * The motion controller class for the standard HTC-Vive controllers
  147787. */
  147788. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  147789. private _modelRootNode;
  147790. /**
  147791. * The base url used to load the left and right controller models
  147792. */
  147793. static MODEL_BASE_URL: string;
  147794. /**
  147795. * File name for the controller model.
  147796. */
  147797. static MODEL_FILENAME: string;
  147798. profileId: string;
  147799. /**
  147800. * Create a new Vive motion controller object
  147801. * @param scene the scene to use to create this controller
  147802. * @param gamepadObject the corresponding gamepad object
  147803. * @param handedness the handedness of the controller
  147804. */
  147805. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  147806. protected _getFilenameAndPath(): {
  147807. filename: string;
  147808. path: string;
  147809. };
  147810. protected _getModelLoadingConstraints(): boolean;
  147811. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  147812. protected _setRootMesh(meshes: AbstractMesh[]): void;
  147813. protected _updateModel(): void;
  147814. }
  147815. }
  147816. declare module BABYLON {
  147817. /**
  147818. * A cursor which tracks a point on a path
  147819. */
  147820. export class PathCursor {
  147821. private path;
  147822. /**
  147823. * Stores path cursor callbacks for when an onchange event is triggered
  147824. */
  147825. private _onchange;
  147826. /**
  147827. * The value of the path cursor
  147828. */
  147829. value: number;
  147830. /**
  147831. * The animation array of the path cursor
  147832. */
  147833. animations: Animation[];
  147834. /**
  147835. * Initializes the path cursor
  147836. * @param path The path to track
  147837. */
  147838. constructor(path: Path2);
  147839. /**
  147840. * Gets the cursor point on the path
  147841. * @returns A point on the path cursor at the cursor location
  147842. */
  147843. getPoint(): Vector3;
  147844. /**
  147845. * Moves the cursor ahead by the step amount
  147846. * @param step The amount to move the cursor forward
  147847. * @returns This path cursor
  147848. */
  147849. moveAhead(step?: number): PathCursor;
  147850. /**
  147851. * Moves the cursor behind by the step amount
  147852. * @param step The amount to move the cursor back
  147853. * @returns This path cursor
  147854. */
  147855. moveBack(step?: number): PathCursor;
  147856. /**
  147857. * Moves the cursor by the step amount
  147858. * If the step amount is greater than one, an exception is thrown
  147859. * @param step The amount to move the cursor
  147860. * @returns This path cursor
  147861. */
  147862. move(step: number): PathCursor;
  147863. /**
  147864. * Ensures that the value is limited between zero and one
  147865. * @returns This path cursor
  147866. */
  147867. private ensureLimits;
  147868. /**
  147869. * Runs onchange callbacks on change (used by the animation engine)
  147870. * @returns This path cursor
  147871. */
  147872. private raiseOnChange;
  147873. /**
  147874. * Executes a function on change
  147875. * @param f A path cursor onchange callback
  147876. * @returns This path cursor
  147877. */
  147878. onchange(f: (cursor: PathCursor) => void): PathCursor;
  147879. }
  147880. }
  147881. declare module BABYLON {
  147882. /** @hidden */
  147883. export var blurPixelShader: {
  147884. name: string;
  147885. shader: string;
  147886. };
  147887. }
  147888. declare module BABYLON {
  147889. /** @hidden */
  147890. export var pointCloudVertexDeclaration: {
  147891. name: string;
  147892. shader: string;
  147893. };
  147894. }
  147895. // Mixins
  147896. interface Window {
  147897. mozIndexedDB: IDBFactory;
  147898. webkitIndexedDB: IDBFactory;
  147899. msIndexedDB: IDBFactory;
  147900. webkitURL: typeof URL;
  147901. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  147902. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  147903. WebGLRenderingContext: WebGLRenderingContext;
  147904. MSGesture: MSGesture;
  147905. CANNON: any;
  147906. AudioContext: AudioContext;
  147907. webkitAudioContext: AudioContext;
  147908. PointerEvent: any;
  147909. Math: Math;
  147910. Uint8Array: Uint8ArrayConstructor;
  147911. Float32Array: Float32ArrayConstructor;
  147912. mozURL: typeof URL;
  147913. msURL: typeof URL;
  147914. VRFrameData: any; // WebVR, from specs 1.1
  147915. DracoDecoderModule: any;
  147916. setImmediate(handler: (...args: any[]) => void): number;
  147917. }
  147918. interface HTMLCanvasElement {
  147919. requestPointerLock(): void;
  147920. msRequestPointerLock?(): void;
  147921. mozRequestPointerLock?(): void;
  147922. webkitRequestPointerLock?(): void;
  147923. /** Track wether a record is in progress */
  147924. isRecording: boolean;
  147925. /** Capture Stream method defined by some browsers */
  147926. captureStream(fps?: number): MediaStream;
  147927. }
  147928. interface CanvasRenderingContext2D {
  147929. msImageSmoothingEnabled: boolean;
  147930. }
  147931. interface MouseEvent {
  147932. mozMovementX: number;
  147933. mozMovementY: number;
  147934. webkitMovementX: number;
  147935. webkitMovementY: number;
  147936. msMovementX: number;
  147937. msMovementY: number;
  147938. }
  147939. interface Navigator {
  147940. mozGetVRDevices: (any: any) => any;
  147941. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  147942. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  147943. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  147944. webkitGetGamepads(): Gamepad[];
  147945. msGetGamepads(): Gamepad[];
  147946. webkitGamepads(): Gamepad[];
  147947. }
  147948. interface HTMLVideoElement {
  147949. mozSrcObject: any;
  147950. }
  147951. interface Math {
  147952. fround(x: number): number;
  147953. imul(a: number, b: number): number;
  147954. }
  147955. interface WebGLRenderingContext {
  147956. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  147957. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  147958. vertexAttribDivisor(index: number, divisor: number): void;
  147959. createVertexArray(): any;
  147960. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  147961. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  147962. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  147963. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  147964. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  147965. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  147966. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  147967. // Queries
  147968. createQuery(): WebGLQuery;
  147969. deleteQuery(query: WebGLQuery): void;
  147970. beginQuery(target: number, query: WebGLQuery): void;
  147971. endQuery(target: number): void;
  147972. getQueryParameter(query: WebGLQuery, pname: number): any;
  147973. getQuery(target: number, pname: number): any;
  147974. MAX_SAMPLES: number;
  147975. RGBA8: number;
  147976. READ_FRAMEBUFFER: number;
  147977. DRAW_FRAMEBUFFER: number;
  147978. UNIFORM_BUFFER: number;
  147979. HALF_FLOAT_OES: number;
  147980. RGBA16F: number;
  147981. RGBA32F: number;
  147982. R32F: number;
  147983. RG32F: number;
  147984. RGB32F: number;
  147985. R16F: number;
  147986. RG16F: number;
  147987. RGB16F: number;
  147988. RED: number;
  147989. RG: number;
  147990. R8: number;
  147991. RG8: number;
  147992. UNSIGNED_INT_24_8: number;
  147993. DEPTH24_STENCIL8: number;
  147994. MIN: number;
  147995. MAX: number;
  147996. /* Multiple Render Targets */
  147997. drawBuffers(buffers: number[]): void;
  147998. readBuffer(src: number): void;
  147999. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  148000. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  148001. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  148002. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  148003. // Occlusion Query
  148004. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  148005. ANY_SAMPLES_PASSED: number;
  148006. QUERY_RESULT_AVAILABLE: number;
  148007. QUERY_RESULT: number;
  148008. }
  148009. interface WebGLProgram {
  148010. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  148011. }
  148012. interface EXT_disjoint_timer_query {
  148013. QUERY_COUNTER_BITS_EXT: number;
  148014. TIME_ELAPSED_EXT: number;
  148015. TIMESTAMP_EXT: number;
  148016. GPU_DISJOINT_EXT: number;
  148017. QUERY_RESULT_EXT: number;
  148018. QUERY_RESULT_AVAILABLE_EXT: number;
  148019. queryCounterEXT(query: WebGLQuery, target: number): void;
  148020. createQueryEXT(): WebGLQuery;
  148021. beginQueryEXT(target: number, query: WebGLQuery): void;
  148022. endQueryEXT(target: number): void;
  148023. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  148024. deleteQueryEXT(query: WebGLQuery): void;
  148025. }
  148026. interface WebGLUniformLocation {
  148027. _currentState: any;
  148028. }
  148029. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  148030. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  148031. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  148032. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  148033. interface WebGLRenderingContext {
  148034. readonly RASTERIZER_DISCARD: number;
  148035. readonly DEPTH_COMPONENT24: number;
  148036. readonly TEXTURE_3D: number;
  148037. readonly TEXTURE_2D_ARRAY: number;
  148038. readonly TEXTURE_COMPARE_FUNC: number;
  148039. readonly TEXTURE_COMPARE_MODE: number;
  148040. readonly COMPARE_REF_TO_TEXTURE: number;
  148041. readonly TEXTURE_WRAP_R: number;
  148042. readonly HALF_FLOAT: number;
  148043. readonly RGB8: number;
  148044. readonly RED_INTEGER: number;
  148045. readonly RG_INTEGER: number;
  148046. readonly RGB_INTEGER: number;
  148047. readonly RGBA_INTEGER: number;
  148048. readonly R8_SNORM: number;
  148049. readonly RG8_SNORM: number;
  148050. readonly RGB8_SNORM: number;
  148051. readonly RGBA8_SNORM: number;
  148052. readonly R8I: number;
  148053. readonly RG8I: number;
  148054. readonly RGB8I: number;
  148055. readonly RGBA8I: number;
  148056. readonly R8UI: number;
  148057. readonly RG8UI: number;
  148058. readonly RGB8UI: number;
  148059. readonly RGBA8UI: number;
  148060. readonly R16I: number;
  148061. readonly RG16I: number;
  148062. readonly RGB16I: number;
  148063. readonly RGBA16I: number;
  148064. readonly R16UI: number;
  148065. readonly RG16UI: number;
  148066. readonly RGB16UI: number;
  148067. readonly RGBA16UI: number;
  148068. readonly R32I: number;
  148069. readonly RG32I: number;
  148070. readonly RGB32I: number;
  148071. readonly RGBA32I: number;
  148072. readonly R32UI: number;
  148073. readonly RG32UI: number;
  148074. readonly RGB32UI: number;
  148075. readonly RGBA32UI: number;
  148076. readonly RGB10_A2UI: number;
  148077. readonly R11F_G11F_B10F: number;
  148078. readonly RGB9_E5: number;
  148079. readonly RGB10_A2: number;
  148080. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  148081. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  148082. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  148083. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  148084. readonly DEPTH_COMPONENT32F: number;
  148085. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  148086. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  148087. 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;
  148088. framebufferTextureLayer(target: number, attachment: number, texture: WebGLTexture | null, level: number, layer: number): void;
  148089. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  148090. readonly TRANSFORM_FEEDBACK: number;
  148091. readonly INTERLEAVED_ATTRIBS: number;
  148092. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  148093. createTransformFeedback(): WebGLTransformFeedback;
  148094. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  148095. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  148096. beginTransformFeedback(primitiveMode: number): void;
  148097. endTransformFeedback(): void;
  148098. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  148099. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  148100. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  148101. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  148102. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  148103. }
  148104. interface ImageBitmap {
  148105. readonly width: number;
  148106. readonly height: number;
  148107. close(): void;
  148108. }
  148109. interface WebGLQuery extends WebGLObject {
  148110. }
  148111. declare var WebGLQuery: {
  148112. prototype: WebGLQuery;
  148113. new(): WebGLQuery;
  148114. };
  148115. interface WebGLSampler extends WebGLObject {
  148116. }
  148117. declare var WebGLSampler: {
  148118. prototype: WebGLSampler;
  148119. new(): WebGLSampler;
  148120. };
  148121. interface WebGLSync extends WebGLObject {
  148122. }
  148123. declare var WebGLSync: {
  148124. prototype: WebGLSync;
  148125. new(): WebGLSync;
  148126. };
  148127. interface WebGLTransformFeedback extends WebGLObject {
  148128. }
  148129. declare var WebGLTransformFeedback: {
  148130. prototype: WebGLTransformFeedback;
  148131. new(): WebGLTransformFeedback;
  148132. };
  148133. interface WebGLVertexArrayObject extends WebGLObject {
  148134. }
  148135. declare var WebGLVertexArrayObject: {
  148136. prototype: WebGLVertexArrayObject;
  148137. new(): WebGLVertexArrayObject;
  148138. };
  148139. // Type definitions for WebVR API
  148140. // Project: https://w3c.github.io/webvr/
  148141. // Definitions by: six a <https://github.com/lostfictions>
  148142. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  148143. interface VRDisplay extends EventTarget {
  148144. /**
  148145. * Dictionary of capabilities describing the VRDisplay.
  148146. */
  148147. readonly capabilities: VRDisplayCapabilities;
  148148. /**
  148149. * z-depth defining the far plane of the eye view frustum
  148150. * enables mapping of values in the render target depth
  148151. * attachment to scene coordinates. Initially set to 10000.0.
  148152. */
  148153. depthFar: number;
  148154. /**
  148155. * z-depth defining the near plane of the eye view frustum
  148156. * enables mapping of values in the render target depth
  148157. * attachment to scene coordinates. Initially set to 0.01.
  148158. */
  148159. depthNear: number;
  148160. /**
  148161. * An identifier for this distinct VRDisplay. Used as an
  148162. * association point in the Gamepad API.
  148163. */
  148164. readonly displayId: number;
  148165. /**
  148166. * A display name, a user-readable name identifying it.
  148167. */
  148168. readonly displayName: string;
  148169. readonly isConnected: boolean;
  148170. readonly isPresenting: boolean;
  148171. /**
  148172. * If this VRDisplay supports room-scale experiences, the optional
  148173. * stage attribute contains details on the room-scale parameters.
  148174. */
  148175. readonly stageParameters: VRStageParameters | null;
  148176. /**
  148177. * Passing the value returned by `requestAnimationFrame` to
  148178. * `cancelAnimationFrame` will unregister the callback.
  148179. * @param handle Define the hanle of the request to cancel
  148180. */
  148181. cancelAnimationFrame(handle: number): void;
  148182. /**
  148183. * Stops presenting to the VRDisplay.
  148184. * @returns a promise to know when it stopped
  148185. */
  148186. exitPresent(): Promise<void>;
  148187. /**
  148188. * Return the current VREyeParameters for the given eye.
  148189. * @param whichEye Define the eye we want the parameter for
  148190. * @returns the eye parameters
  148191. */
  148192. getEyeParameters(whichEye: string): VREyeParameters;
  148193. /**
  148194. * Populates the passed VRFrameData with the information required to render
  148195. * the current frame.
  148196. * @param frameData Define the data structure to populate
  148197. * @returns true if ok otherwise false
  148198. */
  148199. getFrameData(frameData: VRFrameData): boolean;
  148200. /**
  148201. * Get the layers currently being presented.
  148202. * @returns the list of VR layers
  148203. */
  148204. getLayers(): VRLayer[];
  148205. /**
  148206. * Return a VRPose containing the future predicted pose of the VRDisplay
  148207. * when the current frame will be presented. The value returned will not
  148208. * change until JavaScript has returned control to the browser.
  148209. *
  148210. * The VRPose will contain the position, orientation, velocity,
  148211. * and acceleration of each of these properties.
  148212. * @returns the pose object
  148213. */
  148214. getPose(): VRPose;
  148215. /**
  148216. * Return the current instantaneous pose of the VRDisplay, with no
  148217. * prediction applied.
  148218. * @returns the current instantaneous pose
  148219. */
  148220. getImmediatePose(): VRPose;
  148221. /**
  148222. * The callback passed to `requestAnimationFrame` will be called
  148223. * any time a new frame should be rendered. When the VRDisplay is
  148224. * presenting the callback will be called at the native refresh
  148225. * rate of the HMD. When not presenting this function acts
  148226. * identically to how window.requestAnimationFrame acts. Content should
  148227. * make no assumptions of frame rate or vsync behavior as the HMD runs
  148228. * asynchronously from other displays and at differing refresh rates.
  148229. * @param callback Define the eaction to run next frame
  148230. * @returns the request handle it
  148231. */
  148232. requestAnimationFrame(callback: FrameRequestCallback): number;
  148233. /**
  148234. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  148235. * Repeat calls while already presenting will update the VRLayers being displayed.
  148236. * @param layers Define the list of layer to present
  148237. * @returns a promise to know when the request has been fulfilled
  148238. */
  148239. requestPresent(layers: VRLayer[]): Promise<void>;
  148240. /**
  148241. * Reset the pose for this display, treating its current position and
  148242. * orientation as the "origin/zero" values. VRPose.position,
  148243. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  148244. * updated when calling resetPose(). This should be called in only
  148245. * sitting-space experiences.
  148246. */
  148247. resetPose(): void;
  148248. /**
  148249. * The VRLayer provided to the VRDisplay will be captured and presented
  148250. * in the HMD. Calling this function has the same effect on the source
  148251. * canvas as any other operation that uses its source image, and canvases
  148252. * created without preserveDrawingBuffer set to true will be cleared.
  148253. * @param pose Define the pose to submit
  148254. */
  148255. submitFrame(pose?: VRPose): void;
  148256. }
  148257. declare var VRDisplay: {
  148258. prototype: VRDisplay;
  148259. new(): VRDisplay;
  148260. };
  148261. interface VRLayer {
  148262. leftBounds?: number[] | Float32Array | null;
  148263. rightBounds?: number[] | Float32Array | null;
  148264. source?: HTMLCanvasElement | null;
  148265. }
  148266. interface VRDisplayCapabilities {
  148267. readonly canPresent: boolean;
  148268. readonly hasExternalDisplay: boolean;
  148269. readonly hasOrientation: boolean;
  148270. readonly hasPosition: boolean;
  148271. readonly maxLayers: number;
  148272. }
  148273. interface VREyeParameters {
  148274. /** @deprecated */
  148275. readonly fieldOfView: VRFieldOfView;
  148276. readonly offset: Float32Array;
  148277. readonly renderHeight: number;
  148278. readonly renderWidth: number;
  148279. }
  148280. interface VRFieldOfView {
  148281. readonly downDegrees: number;
  148282. readonly leftDegrees: number;
  148283. readonly rightDegrees: number;
  148284. readonly upDegrees: number;
  148285. }
  148286. interface VRFrameData {
  148287. readonly leftProjectionMatrix: Float32Array;
  148288. readonly leftViewMatrix: Float32Array;
  148289. readonly pose: VRPose;
  148290. readonly rightProjectionMatrix: Float32Array;
  148291. readonly rightViewMatrix: Float32Array;
  148292. readonly timestamp: number;
  148293. }
  148294. interface VRPose {
  148295. readonly angularAcceleration: Float32Array | null;
  148296. readonly angularVelocity: Float32Array | null;
  148297. readonly linearAcceleration: Float32Array | null;
  148298. readonly linearVelocity: Float32Array | null;
  148299. readonly orientation: Float32Array | null;
  148300. readonly position: Float32Array | null;
  148301. readonly timestamp: number;
  148302. }
  148303. interface VRStageParameters {
  148304. sittingToStandingTransform?: Float32Array;
  148305. sizeX?: number;
  148306. sizeY?: number;
  148307. }
  148308. interface Navigator {
  148309. getVRDisplays(): Promise<VRDisplay[]>;
  148310. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  148311. }
  148312. interface Window {
  148313. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  148314. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  148315. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  148316. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  148317. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  148318. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  148319. }
  148320. interface Gamepad {
  148321. readonly displayId: number;
  148322. }
  148323. type XRSessionMode =
  148324. | "inline"
  148325. | "immersive-vr"
  148326. | "immersive-ar";
  148327. type XRReferenceSpaceType =
  148328. | "viewer"
  148329. | "local"
  148330. | "local-floor"
  148331. | "bounded-floor"
  148332. | "unbounded";
  148333. type XREnvironmentBlendMode =
  148334. | "opaque"
  148335. | "additive"
  148336. | "alpha-blend";
  148337. type XRVisibilityState =
  148338. | "visible"
  148339. | "visible-blurred"
  148340. | "hidden";
  148341. type XRHandedness =
  148342. | "none"
  148343. | "left"
  148344. | "right";
  148345. type XRTargetRayMode =
  148346. | "gaze"
  148347. | "tracked-pointer"
  148348. | "screen";
  148349. type XREye =
  148350. | "none"
  148351. | "left"
  148352. | "right";
  148353. type XREventType =
  148354. | "devicechange"
  148355. | "visibilitychange"
  148356. | "end"
  148357. | "inputsourceschange"
  148358. | "select"
  148359. | "selectstart"
  148360. | "selectend"
  148361. | "squeeze"
  148362. | "squeezestart"
  148363. | "squeezeend"
  148364. | "reset";
  148365. interface XRSpace extends EventTarget {
  148366. }
  148367. interface XRRenderState {
  148368. depthNear?: number;
  148369. depthFar?: number;
  148370. inlineVerticalFieldOfView?: number;
  148371. baseLayer?: XRWebGLLayer;
  148372. }
  148373. interface XRInputSource {
  148374. handedness: XRHandedness;
  148375. targetRayMode: XRTargetRayMode;
  148376. targetRaySpace: XRSpace;
  148377. gripSpace: XRSpace | undefined;
  148378. gamepad: Gamepad | undefined;
  148379. profiles: Array<string>;
  148380. }
  148381. interface XRSessionInit {
  148382. optionalFeatures?: string[];
  148383. requiredFeatures?: string[];
  148384. }
  148385. interface XRSession extends XRAnchorCreator {
  148386. addEventListener: Function;
  148387. removeEventListener: Function;
  148388. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  148389. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  148390. requestAnimationFrame: Function;
  148391. end(): Promise<void>;
  148392. renderState: XRRenderState;
  148393. inputSources: Array<XRInputSource>;
  148394. // hit test
  148395. requestHitTestSource(options: XRHitTestOptionsInit): Promise<XRHitTestSource>;
  148396. requestHitTestSourceForTransientInput(options: XRTransientInputHitTestOptionsInit): Promise<XRTransientInputHitTestSource>;
  148397. // legacy AR hit test
  148398. requestHitTest(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  148399. // legacy plane detection
  148400. updateWorldTrackingState(options: {
  148401. planeDetectionState?: { enabled: boolean; }
  148402. }): void;
  148403. }
  148404. interface XRReferenceSpace extends XRSpace {
  148405. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  148406. onreset: any;
  148407. }
  148408. type XRPlaneSet = Set<XRPlane>;
  148409. type XRAnchorSet = Set<XRAnchor>;
  148410. interface XRFrame {
  148411. session: XRSession;
  148412. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  148413. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  148414. // AR
  148415. getHitTestResults(hitTestSource: XRHitTestSource): Array<XRHitTestResult> ;
  148416. getHitTestResultsForTransientInput(hitTestSource: XRTransientInputHitTestSource): Array<XRTransientInputHitTestResult>;
  148417. // Anchors
  148418. trackedAnchors?: XRAnchorSet;
  148419. // Planes
  148420. worldInformation: {
  148421. detectedPlanes?: XRPlaneSet;
  148422. };
  148423. }
  148424. interface XRViewerPose extends XRPose {
  148425. views: Array<XRView>;
  148426. }
  148427. interface XRPose {
  148428. transform: XRRigidTransform;
  148429. emulatedPosition: boolean;
  148430. }
  148431. interface XRWebGLLayerOptions {
  148432. antialias?: boolean;
  148433. depth?: boolean;
  148434. stencil?: boolean;
  148435. alpha?: boolean;
  148436. multiview?: boolean;
  148437. framebufferScaleFactor?: number;
  148438. }
  148439. declare var XRWebGLLayer: {
  148440. prototype: XRWebGLLayer;
  148441. new(session: XRSession, context: WebGLRenderingContext | undefined, options?: XRWebGLLayerOptions): XRWebGLLayer;
  148442. };
  148443. interface XRWebGLLayer {
  148444. framebuffer: WebGLFramebuffer;
  148445. framebufferWidth: number;
  148446. framebufferHeight: number;
  148447. getViewport: Function;
  148448. }
  148449. declare class XRRigidTransform {
  148450. constructor(matrix: Float32Array | DOMPointInit, direction?: DOMPointInit);
  148451. position: DOMPointReadOnly;
  148452. orientation: DOMPointReadOnly;
  148453. matrix: Float32Array;
  148454. inverse: XRRigidTransform;
  148455. }
  148456. interface XRView {
  148457. eye: XREye;
  148458. projectionMatrix: Float32Array;
  148459. transform: XRRigidTransform;
  148460. }
  148461. interface XRInputSourceChangeEvent {
  148462. session: XRSession;
  148463. removed: Array<XRInputSource>;
  148464. added: Array<XRInputSource>;
  148465. }
  148466. interface XRInputSourceEvent extends Event {
  148467. readonly frame: XRFrame;
  148468. readonly inputSource: XRInputSource;
  148469. }
  148470. // Experimental(er) features
  148471. declare class XRRay {
  148472. constructor(transformOrOrigin: XRRigidTransform | DOMPointInit, direction?: DOMPointInit);
  148473. origin: DOMPointReadOnly;
  148474. direction: DOMPointReadOnly;
  148475. matrix: Float32Array;
  148476. }
  148477. declare enum XRHitTestTrackableType {
  148478. "point",
  148479. "plane"
  148480. }
  148481. interface XRHitResult {
  148482. hitMatrix: Float32Array;
  148483. }
  148484. interface XRTransientInputHitTestResult {
  148485. readonly inputSource: XRInputSource;
  148486. readonly results: Array<XRHitTestResult>;
  148487. }
  148488. interface XRHitTestResult {
  148489. getPose(baseSpace: XRSpace): XRPose | undefined;
  148490. }
  148491. interface XRHitTestSource {
  148492. cancel(): void;
  148493. }
  148494. interface XRTransientInputHitTestSource {
  148495. cancel(): void;
  148496. }
  148497. interface XRHitTestOptionsInit {
  148498. space: XRSpace;
  148499. entityTypes?: Array<XRHitTestTrackableType>;
  148500. offsetRay?: XRRay;
  148501. }
  148502. interface XRTransientInputHitTestOptionsInit {
  148503. profile: string;
  148504. entityTypes?: Array<XRHitTestTrackableType>;
  148505. offsetRay?: XRRay;
  148506. }
  148507. interface XRAnchor {
  148508. // remove?
  148509. id?: string;
  148510. anchorSpace: XRSpace;
  148511. lastChangedTime: number;
  148512. detach(): void;
  148513. }
  148514. interface XRPlane extends XRAnchorCreator {
  148515. orientation: "Horizontal" | "Vertical";
  148516. planeSpace: XRSpace;
  148517. polygon: Array<DOMPointReadOnly>;
  148518. lastChangedTime: number;
  148519. }
  148520. interface XRAnchorCreator {
  148521. // AR Anchors
  148522. createAnchor(pose: XRPose | XRRigidTransform, referenceSpace: XRReferenceSpace): Promise<XRAnchor>;
  148523. }